mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add node typings
This commit is contained in:
1 parent
fcfc93a40a
commit
aadc8cdde1
4 files changed
+17
-4
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.2.13",
|
"version": "3.2.14",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ export { size, formatSeconds } from '@hydrooj/utils/lib/utils';
|
|||||||
|
|
||||||
const AU = new AnsiUp();
|
const AU = new AnsiUp();
|
||||||
|
|
||||||
export function ansiToHtml(str: string) {
|
export function ansiToHtml(str: string, whiteToBlack = true) {
|
||||||
return AU.ansi_to_html(str);
|
const res = AU.ansi_to_html(str);
|
||||||
|
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function datetimeSpan(dt: Date | ObjectID, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
export function datetimeSpan(dt: Date | ObjectID, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||||
|
|
||||||
|
const types = require.context('!!raw-loader!@types/node/', true, /\.d\.ts$/);
|
||||||
|
|
||||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||||
noSemanticValidation: false,
|
noSemanticValidation: false,
|
||||||
noSyntaxValidation: false,
|
noSyntaxValidation: false,
|
||||||
@@ -12,6 +14,15 @@ const libSource = [
|
|||||||
'declare function readline(): string;',
|
'declare function readline(): string;',
|
||||||
'declare function print(content: string): void;',
|
'declare function print(content: string): void;',
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
const libUri = 'ts:filename/basic.d.ts';
|
const libUri = 'ts:filename/basic.d.ts';
|
||||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||||
|
for (const key of types.keys()) {
|
||||||
|
const val = types(key).default;
|
||||||
|
const uri = `ts:node/${key.split('./')[1]}`;
|
||||||
|
console.log(val, uri);
|
||||||
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(val, uri);
|
||||||
|
monaco.editor.createModel(val, 'typescript', monaco.Uri.parse(uri));
|
||||||
|
}
|
||||||
|
console.log(types);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.27.2",
|
"version": "4.27.3",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
"prismjs": "^1.25.0",
|
"prismjs": "^1.25.0",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"qrcode": "^1.5.0",
|
"qrcode": "^1.5.0",
|
||||||
|
"raw-loader": "^4.0.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-redux": "^7.2.6",
|
"react-redux": "^7.2.6",
|
||||||
|
|||||||
Reference in new issue
Block a user