From 7dafab834439647dd1eca299fb1aeadf74c0af75 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 7 Aug 2022 05:05:45 +0800 Subject: [PATCH] utils: module loader register --- build/publish.js | 41 +--------- package.json | 10 +-- packages/center/package.json | 2 +- packages/hydrojudge/bin/hydrojudge.js | 40 +-------- packages/hydrojudge/package.json | 10 +-- packages/hydrojudge/vendor/testlib | 2 +- packages/hydrooj/bin/hydrooj.js | 82 +------------------ packages/hydrooj/package.json | 21 ++--- packages/hydrooj/src/loader.ts | 5 -- packages/login-with-github/package.json | 2 +- packages/login-with-google/package.json | 2 +- packages/recaptcha/package.json | 2 +- packages/ui-default/build/index.js | 27 +----- .../ui-default/components/languageselect.tsx | 2 +- packages/ui-default/misc/icons/book.svg | 2 +- packages/ui-default/misc/icons/check.svg | 2 +- .../ui-default/misc/icons/chevron_left.svg | 2 +- .../ui-default/misc/icons/chevron_right.svg | 2 +- packages/ui-default/misc/icons/close.svg | 2 +- packages/ui-default/misc/icons/code.svg | 2 +- packages/ui-default/misc/icons/comparison.svg | 2 +- packages/ui-default/misc/icons/crown.svg | 2 +- packages/ui-default/misc/icons/edit.svg | 2 +- packages/ui-default/misc/icons/emoji.svg | 2 +- packages/ui-default/misc/icons/erase.svg | 2 +- .../ui-default/misc/icons/expand_less.svg | 2 +- .../ui-default/misc/icons/expand_more.svg | 2 +- .../ui-default/misc/icons/heart--outline.svg | 2 +- packages/ui-default/misc/icons/heart.svg | 2 +- packages/ui-default/misc/icons/homework.svg | 2 +- .../ui-default/misc/icons/insert--image.svg | 2 +- packages/ui-default/misc/icons/lab.svg | 2 +- .../ui-default/misc/icons/link--external.svg | 2 +- .../misc/icons/platform--chromeos.svg | 2 +- .../misc/icons/platform--unknown.svg | 2 +- packages/ui-default/misc/icons/quote.svg | 2 +- packages/ui-default/misc/icons/search.svg | 2 +- packages/ui-default/misc/icons/security.svg | 2 +- packages/ui-default/misc/icons/send.svg | 2 +- packages/ui-default/misc/icons/stack.svg | 2 +- .../ui-default/misc/icons/star--outline.svg | 2 +- packages/ui-default/misc/icons/star.svg | 2 +- packages/ui-default/misc/icons/warning.svg | 2 +- packages/ui-default/misc/icons/wrench.svg | 2 +- packages/ui-default/package.json | 18 ++-- .../ui-default/pages/problem_main.page.js | 6 +- packages/ui-default/pages/record_main.page.ts | 6 +- .../ui-default/templates/record_detail.html | 6 +- packages/utils/package.json | 10 ++- packages/vjudge/package.json | 4 +- 50 files changed, 83 insertions(+), 275 deletions(-) diff --git a/build/publish.js b/build/publish.js index bd55abd52..fd863d201 100644 --- a/build/publish.js +++ b/build/publish.js @@ -3,48 +3,13 @@ /* eslint-disable consistent-return */ /* eslint-disable no-await-in-loop */ /* eslint-disable import/no-dynamic-require */ -const esbuild = require('esbuild'); -const { readFileSync, writeFileSync } = require('fs'); -const major = +process.version.split('.')[0].split('v')[1]; -const minor = +process.version.split('.')[1]; - -let transformTimeUsage = 0; -let transformCount = 0; -let displayTimeout; -function transform(filename) { - const start = new Date(); - const result = esbuild.buildSync({ - entryPoints: [filename], - sourcemap: 'inline', - platform: 'node', - format: 'cjs', - target: `node${major}.${minor}`, - jsx: 'transform', - write: false, - }); - if (result.warnings.length) console.warn(result.warnings); - transformTimeUsage += new Date().getTime() - start.getTime(); - transformCount++; - if (displayTimeout) clearTimeout(displayTimeout); - displayTimeout = setTimeout(() => console.log(`Transformed ${transformCount} files. (${transformTimeUsage}ms)`), 1000); - return result.outputFiles[0].text; -} -const ESM = ['p-queue', 'p-timeout', 'latest-version']; -require.extensions['.js'] = function loader(module, filename) { - if (ESM.filter((i) => filename.includes(i)).length || major < 14) { - return module._compile(transform(filename), filename); - } - const content = readFileSync(filename, 'utf-8'); - return module._compile(content, filename); -}; -require.extensions['.ts'] = require.extensions['.tsx'] = function loader(module, filename) { - return module._compile(transform(filename), filename); -}; +require('@hydrooj/utils/lib/register'); const { gt } = require('semver'); const { default: latest } = require('latest-version'); const path = require('path'); -const ora = require('ora'); +const { default: ora } = require('ora'); +const { writeFileSync } = require('fs'); const { getWorkspaces, spawnAsync } = require('./utils'); const { diff --git a/package.json b/package.json index f562b5030..db87b8c56 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@types/autocannon": "^7.6.1", "@types/cross-spawn": "^6.0.2", "@types/mocha": "^9.1.1", - "@types/node": "^18.0.3", + "@types/node": "^18.6.4", "@types/semver": "^7.3.10", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^5.29.0", @@ -54,14 +54,14 @@ "eslint-plugin-simple-import-sort": "7.0.0", "fs-extra": "^10.1.0", "globby": "11.1.0", - "latest-version": "6.0.0", + "latest-version": "7.0.0", "mocha": "^10.0.0", "mongodb": "^3.7.3", - "mongodb-memory-server": "^8.7.2", - "ora": "5.4.1", + "mongodb-memory-server": "^8.8.0", + "ora": "^6.1.2", "semver": "^7.3.7", "supertest": "^6.2.4", - "typedoc": "^0.23.7", + "typedoc": "^0.23.10", "typescript": "4.6.4" }, "resolutions": { diff --git a/packages/center/package.json b/packages/center/package.json index 1ca3adce4..88be34cc2 100644 --- a/packages/center/package.json +++ b/packages/center/package.json @@ -8,7 +8,7 @@ "preferUnplugged": true, "dependencies": { "js-yaml": "^4.1.0", - "superagent": "^7.1.5" + "superagent": "^8.0.0" }, "devDependencies": { "@types/js-yaml": "^4.0.5" diff --git a/packages/hydrojudge/bin/hydrojudge.js b/packages/hydrojudge/bin/hydrojudge.js index 6db3875e7..39a9c04c4 100755 --- a/packages/hydrojudge/bin/hydrojudge.js +++ b/packages/hydrojudge/bin/hydrojudge.js @@ -1,45 +1,7 @@ #!/usr/bin/env node const argv = require('cac')().parse(); -const esbuild = require('esbuild'); -const fs = require('fs-extra'); +require('@hydrooj/utils/lib/register'); -const major = +process.version.split('.')[0].split('v')[1]; -const minor = +process.version.split('.')[1]; - -let transformTimeUsage = 0; -let transformCount = 0; -let displayTimeout; -function transform(filename) { - const start = new Date(); - const result = esbuild.buildSync({ - entryPoints: [filename], - sourcemap: 'inline', - platform: 'node', - format: 'cjs', - target: `node${major}.${minor}`, - jsx: 'transform', - write: false, - }); - if (result.warnings.length) console.warn(result.warnings); - transformTimeUsage += new Date().getTime() - start.getTime(); - transformCount++; - if (displayTimeout) clearTimeout(displayTimeout); - displayTimeout = setTimeout(() => console.log(`Transformed ${transformCount} files. (${transformTimeUsage}ms)`), 1000); - return result.outputFiles[0].text; -} -const ESM = ['p-queue', 'p-timeout']; -require.extensions['.js'] = function loader(module, filename) { - if (ESM.filter((i) => filename.includes(i)).length || major < 14) { - return module._compile(transform(filename), filename); - } - const content = fs.readFileSync(filename, 'utf-8'); - return module._compile(content, filename); -}; -require.extensions['.ts'] = require.extensions['.tsx'] = function loader(module, filename) { - return module._compile(transform(filename), filename); -}; - -if (argv.options.debug) process.env.DEV = 'on'; if (argv.args[0] === 'cache') require('../src/cache')(); else require('../src/daemon')(); diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 6c56a19c1..ad539315a 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.22.4", + "version": "2.22.5", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", @@ -9,14 +9,13 @@ "@hydrooj/utils": "workspace:*", "axios": "^0.27.2", "cac": "^6.7.12", - "esbuild": "0.14.3", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "mongodb": "^3.7.3", - "p-queue": "^7.2.0", + "p-queue": "^7.3.0", "shell-quote": "^1.7.3", - "ws": "^8.8.0" + "ws": "^8.8.1" }, "preferUnplugged": true, "license": "AGPL-3.0-or-later", @@ -26,8 +25,5 @@ "@types/lodash": "^4.14.182", "@types/shell-quote": "^1.7.1", "@types/ws": "^8.5.3" - }, - "peerDependencies": { - "hydrooj": "*" } } diff --git a/packages/hydrojudge/vendor/testlib b/packages/hydrojudge/vendor/testlib index f5b55f138..4cc5a417c 160000 --- a/packages/hydrojudge/vendor/testlib +++ b/packages/hydrojudge/vendor/testlib @@ -1 +1 @@ -Subproject commit f5b55f138709e97916f51bdb7a23baed941b5751 +Subproject commit 4cc5a417ca80d6b15e55e9c31f63685cebe61cba diff --git a/packages/hydrooj/bin/hydrooj.js b/packages/hydrooj/bin/hydrooj.js index 278102c73..34cf3bcc3 100755 --- a/packages/hydrooj/bin/hydrooj.js +++ b/packages/hydrooj/bin/hydrooj.js @@ -1,87 +1,7 @@ #!/usr/bin/env node +require('@hydrooj/utils/lib/register'); -/* eslint-disable consistent-return */ - -const map = {}; -require('source-map-support').install({ - handleUncaughtExceptions: false, - environment: 'node', - retrieveSourceMap(file) { - if (map[file]) { - return { - url: file, - map: map[file], - }; - } - return null; - }, -}); -const path = require('path'); -const vm = require('vm'); -const fs = require('fs-extra'); -const esbuild = require('esbuild'); const { default: hook } = require('require-resolve-hook'); const { bypass } = hook(/^(hydrooj|@hydrooj\/utils)/, (id) => bypass(() => require.resolve(id))); -if (!process.env.NODE_APP_INSTANCE) process.env.NODE_APP_INSTANCE = '0'; -const major = +process.version.split('.')[0].split('v')[1]; -const minor = +process.version.split('.')[1]; - -function transform(filename) { - const code = fs.readFileSync(filename, 'utf-8'); - const result = esbuild.transformSync(code, { - sourcefile: filename, - sourcemap: 'both', - format: 'cjs', - loader: 'tsx', - target: `node${major}.${minor}`, - jsx: 'transform', - }); - if (result.warnings.length) console.warn(result.warnings); - map[filename] = result.map; - return result.code; -} -const ESM = ['p-queue', 'p-timeout']; -const _script = new vm.Script('"Hydro"', { produceCachedData: true }); -const bytecode = (_script.createCachedData && _script.createCachedData.call) - ? _script.createCachedData() - : _script.cachedData; -require.extensions['.js'] = function loader(module, filename) { - if (ESM.filter((i) => filename.includes(i)).length || major < 14) { - return module._compile(transform(filename), filename); - } - const content = fs.readFileSync(filename, 'utf-8'); - return module._compile(content, filename); -}; -require.extensions['.ts'] = require.extensions['.tsx'] = function loader(module, filename) { - return module._compile(transform(filename), filename); -}; -require.extensions['.jsc'] = function loader(module, filename) { - const buf = fs.readFileSync(filename); - bytecode.slice(12, 16).copy(buf, 12); - if (![12, 13, 14, 15, 16, 17].filter((i) => process.version.startsWith(`v${i}`)).length) { - bytecode.slice(16, 20).copy(buf, 16); - } - // eslint-disable-next-line no-return-assign - const length = buf.slice(8, 12).reduce((sum, number, power) => sum += number * (256 ** power), 0); - let dummyCode = ''; - if (length > 1) dummyCode = `"${'\u200b'.repeat(length - 2)}"`; - const script = new vm.Script(dummyCode, { - filename, - lineOffset: 0, - displayErrors: true, - cachedData: buf, - }); - if (script.cachedDataRejected) throw new Error(`cacheDataRejected on ${filename}`); - const compiledWrapper = script.runInThisContext({ - filename, - lineOffset: 0, - columnOffset: 0, - displayErrors: true, - }); - const dirname = path.dirname(filename); - const args = [module.exports, require, module, filename, dirname, process, global]; - return compiledWrapper.apply(module.exports, args); -}; - require('./commands'); diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 597266490..aaad4fb75 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.15.5", + "version": "3.15.6", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", @@ -12,7 +12,7 @@ }, "preferUnplugged": true, "dependencies": { - "@graphql-tools/schema": "^8.5.0", + "@graphql-tools/schema": "^8.5.1", "@hydrooj/utils": "workspace:*", "adm-zip": "0.5.5", "ajv": "^8.11.0", @@ -21,7 +21,6 @@ "detect-browser": "^5.3.0", "emoji-regex": "^10.1.0", "emojis-list": "2.1.0", - "esbuild": "0.14.3", "fs-extra": "^10.1.0", "graphql": "^16.5.0", "graphql-scalars": "1.17.0", @@ -31,7 +30,7 @@ "koa-body": "^5.0.0", "koa-compress": "^5.1.0", "koa-proxies": "^0.12.2", - "koa-router": "^10.1.1", + "koa-router": "^12.0.0", "koa-static-cache": "^5.1.4", "lodash": "^4.17.21", "lru-cache": "7.12.0", @@ -39,17 +38,16 @@ "minio": "7.0.25", "moment-timezone": "^0.5.34", "mongodb": "^3.7.3", - "nanoid": "^3.3.4", + "nanoid": "^4.0.0", "nodemailer": "^6.7.7", "notp": "^2.0.3", - "p-queue": "^7.2.0", + "p-queue": "^7.3.0", "path-to-regexp": "^6.2.1", "require-resolve-hook": "^1.1.0", - "schemastery": "^3.5.0", + "schemastery": "^3.5.1", "semver": "^7.3.7", "serialize-javascript": "^6.0.0", - "source-map-support": "^0.5.21", - "superagent": "^7.1.5", + "superagent": "^8.0.0", "thirty-two": "^1.0.2", "tx2": "^1.0.5" }, @@ -57,7 +55,7 @@ "@types/adm-zip": "^0.4.34", "@types/fs-extra": "^9.0.13", "@types/js-yaml": "^4.0.5", - "@types/koa": "^2.13.4", + "@types/koa": "^2.13.5", "@types/koa-compress": "^4.0.3", "@types/koa-router": "^7.4.4", "@types/koa-static-cache": "^5.1.1", @@ -66,11 +64,10 @@ "@types/mime-types": "^2.1.1", "@types/minio": "^7.0.13", "@types/mongodb": "^3.6.20", - "@types/nodemailer": "^6.4.4", + "@types/nodemailer": "^6.4.5", "@types/notp": "^2.0.2", "@types/semver": "^7.3.10", "@types/serialize-javascript": "^5.0.2", - "@types/source-map-support": "^0.5.4", "@types/superagent": "^4.1.15", "moment": "^2.29.4", "pm2": "^5.2.0" diff --git a/packages/hydrooj/src/loader.ts b/packages/hydrooj/src/loader.ts index c65d94a82..c83a41101 100644 --- a/packages/hydrooj/src/loader.ts +++ b/packages/hydrooj/src/loader.ts @@ -16,11 +16,6 @@ export * from './interface'; export { Schema, Logger }; const argv = cac().parse(); -if (argv.options.debug) { - console.log('Debug mode enabled'); - process.env.NODE_ENV = 'development'; - process.env.DEV = 'on'; -} else process.env.NODE_ENV = process.env.NODE_ENV || 'production'; const logger = new Logger('loader'); logger.debug('%o', argv); diff --git a/packages/login-with-github/package.json b/packages/login-with-github/package.json index 685e48571..515c1470d 100644 --- a/packages/login-with-github/package.json +++ b/packages/login-with-github/package.json @@ -13,6 +13,6 @@ "hydrooj": "*" }, "dependencies": { - "superagent": "^7.1.5" + "superagent": "^8.0.0" } } diff --git a/packages/login-with-google/package.json b/packages/login-with-google/package.json index 6d762843b..a83129dd3 100644 --- a/packages/login-with-google/package.json +++ b/packages/login-with-google/package.json @@ -13,6 +13,6 @@ "hydrooj": "*" }, "dependencies": { - "superagent": "^7.1.5" + "superagent": "^8.0.0" } } diff --git a/packages/recaptcha/package.json b/packages/recaptcha/package.json index 30dfa0151..568e61187 100644 --- a/packages/recaptcha/package.json +++ b/packages/recaptcha/package.json @@ -8,6 +8,6 @@ "license": "AGPL-3.0-or-later", "preferUnplugged": true, "dependencies": { - "superagent": "^7.1.5" + "superagent": "^8.0.0" } } diff --git a/packages/ui-default/build/index.js b/packages/ui-default/build/index.js index 45fc5a398..403a4b177 100644 --- a/packages/ui-default/build/index.js +++ b/packages/ui-default/build/index.js @@ -1,29 +1,4 @@ -const esbuild = require('esbuild'); -const fs = require('fs'); - -function transform(filename) { - const result = esbuild.buildSync({ - entryPoints: [filename], - sourcemap: 'inline', - platform: 'node', - format: 'cjs', - target: 'node12', - jsx: 'transform', - write: false, - }); - if (result.warnings.length) console.warn(result.warnings); - return result.outputFiles[0].text; -} -require.extensions['.js'] = function loader(module, filename) { - if (filename.includes('chalk') || (!filename.includes('node_modules') && !filename.includes('postcss.config.js'))) { - return module._compile(transform(filename), filename); - } - const content = fs.readFileSync(filename, 'utf-8'); - return module._compile(content, filename); -}; -require.extensions['.ts'] = function loader(module, filename) { - return module._compile(transform(filename), filename); -}; +require('@hydrooj/utils/lib/register'); const main = require('./main'); if (!module.parent) main(); diff --git a/packages/ui-default/components/languageselect.tsx b/packages/ui-default/components/languageselect.tsx index 1721bb1c4..8282881bc 100644 --- a/packages/ui-default/components/languageselect.tsx +++ b/packages/ui-default/components/languageselect.tsx @@ -20,7 +20,7 @@ export default function LanguageSelect({ const subselections = Object.keys(options).length; if (options[sub]) return; if (!subselections) setSub(''); - if (subselections === 1) setSub(Object.keys(options)[0]); + setSub(Object.keys(options)[0]); }, [main]); return ( diff --git a/packages/ui-default/misc/icons/book.svg b/packages/ui-default/misc/icons/book.svg index ed043fe94..9c918754b 100644 --- a/packages/ui-default/misc/icons/book.svg +++ b/packages/ui-default/misc/icons/book.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/check.svg b/packages/ui-default/misc/icons/check.svg index 92a76cb02..7ea62fb88 100644 --- a/packages/ui-default/misc/icons/check.svg +++ b/packages/ui-default/misc/icons/check.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/chevron_left.svg b/packages/ui-default/misc/icons/chevron_left.svg index 22ed1c18b..e85f33e8b 100644 --- a/packages/ui-default/misc/icons/chevron_left.svg +++ b/packages/ui-default/misc/icons/chevron_left.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/chevron_right.svg b/packages/ui-default/misc/icons/chevron_right.svg index dcce53dd5..1fd787961 100644 --- a/packages/ui-default/misc/icons/chevron_right.svg +++ b/packages/ui-default/misc/icons/chevron_right.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/close.svg b/packages/ui-default/misc/icons/close.svg index eca8a8af7..aed9c44ee 100644 --- a/packages/ui-default/misc/icons/close.svg +++ b/packages/ui-default/misc/icons/close.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/code.svg b/packages/ui-default/misc/icons/code.svg index d80d13726..e06baf59a 100644 --- a/packages/ui-default/misc/icons/code.svg +++ b/packages/ui-default/misc/icons/code.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/comparison.svg b/packages/ui-default/misc/icons/comparison.svg index 013e3613f..3eb05d045 100644 --- a/packages/ui-default/misc/icons/comparison.svg +++ b/packages/ui-default/misc/icons/comparison.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/crown.svg b/packages/ui-default/misc/icons/crown.svg index 5b9b99208..555d027a9 100644 --- a/packages/ui-default/misc/icons/crown.svg +++ b/packages/ui-default/misc/icons/crown.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/edit.svg b/packages/ui-default/misc/icons/edit.svg index fd7468076..16483f9eb 100644 --- a/packages/ui-default/misc/icons/edit.svg +++ b/packages/ui-default/misc/icons/edit.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/emoji.svg b/packages/ui-default/misc/icons/emoji.svg index 50ffbc9e7..1a0d798ec 100644 --- a/packages/ui-default/misc/icons/emoji.svg +++ b/packages/ui-default/misc/icons/emoji.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/erase.svg b/packages/ui-default/misc/icons/erase.svg index a7726b4a5..db167978f 100644 --- a/packages/ui-default/misc/icons/erase.svg +++ b/packages/ui-default/misc/icons/erase.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/expand_less.svg b/packages/ui-default/misc/icons/expand_less.svg index 31cd7edcc..6c86caea5 100644 --- a/packages/ui-default/misc/icons/expand_less.svg +++ b/packages/ui-default/misc/icons/expand_less.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/expand_more.svg b/packages/ui-default/misc/icons/expand_more.svg index 42592d282..9b8d6c124 100644 --- a/packages/ui-default/misc/icons/expand_more.svg +++ b/packages/ui-default/misc/icons/expand_more.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/heart--outline.svg b/packages/ui-default/misc/icons/heart--outline.svg index 09e83f59f..c3e0a27f9 100644 --- a/packages/ui-default/misc/icons/heart--outline.svg +++ b/packages/ui-default/misc/icons/heart--outline.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/heart.svg b/packages/ui-default/misc/icons/heart.svg index b9d01abcc..db68f26d6 100644 --- a/packages/ui-default/misc/icons/heart.svg +++ b/packages/ui-default/misc/icons/heart.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/homework.svg b/packages/ui-default/misc/icons/homework.svg index 53844c5ae..89893be37 100644 --- a/packages/ui-default/misc/icons/homework.svg +++ b/packages/ui-default/misc/icons/homework.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/insert--image.svg b/packages/ui-default/misc/icons/insert--image.svg index c16c78005..e65a9b3a7 100644 --- a/packages/ui-default/misc/icons/insert--image.svg +++ b/packages/ui-default/misc/icons/insert--image.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/lab.svg b/packages/ui-default/misc/icons/lab.svg index 860a7671a..84cb1fb84 100644 --- a/packages/ui-default/misc/icons/lab.svg +++ b/packages/ui-default/misc/icons/lab.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/link--external.svg b/packages/ui-default/misc/icons/link--external.svg index 2984b82f6..64ac47926 100644 --- a/packages/ui-default/misc/icons/link--external.svg +++ b/packages/ui-default/misc/icons/link--external.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/platform--chromeos.svg b/packages/ui-default/misc/icons/platform--chromeos.svg index 35230f6b4..7cd895653 100644 --- a/packages/ui-default/misc/icons/platform--chromeos.svg +++ b/packages/ui-default/misc/icons/platform--chromeos.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/platform--unknown.svg b/packages/ui-default/misc/icons/platform--unknown.svg index cff40ce82..131bd9f94 100644 --- a/packages/ui-default/misc/icons/platform--unknown.svg +++ b/packages/ui-default/misc/icons/platform--unknown.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/quote.svg b/packages/ui-default/misc/icons/quote.svg index 0b2d36da0..1eaa22ff6 100644 --- a/packages/ui-default/misc/icons/quote.svg +++ b/packages/ui-default/misc/icons/quote.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/search.svg b/packages/ui-default/misc/icons/search.svg index aa556747d..d77e6be0f 100644 --- a/packages/ui-default/misc/icons/search.svg +++ b/packages/ui-default/misc/icons/search.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/security.svg b/packages/ui-default/misc/icons/security.svg index 9fd87b7f5..7aa59be28 100644 --- a/packages/ui-default/misc/icons/security.svg +++ b/packages/ui-default/misc/icons/security.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/send.svg b/packages/ui-default/misc/icons/send.svg index ef4632002..6e0585f6b 100644 --- a/packages/ui-default/misc/icons/send.svg +++ b/packages/ui-default/misc/icons/send.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/stack.svg b/packages/ui-default/misc/icons/stack.svg index 98fa193e7..43eaced9e 100644 --- a/packages/ui-default/misc/icons/stack.svg +++ b/packages/ui-default/misc/icons/stack.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/star--outline.svg b/packages/ui-default/misc/icons/star--outline.svg index 5d7e408a5..a5ebdd963 100644 --- a/packages/ui-default/misc/icons/star--outline.svg +++ b/packages/ui-default/misc/icons/star--outline.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/star.svg b/packages/ui-default/misc/icons/star.svg index 3c0310074..fa80a5331 100644 --- a/packages/ui-default/misc/icons/star.svg +++ b/packages/ui-default/misc/icons/star.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/warning.svg b/packages/ui-default/misc/icons/warning.svg index 999ff90c6..8f144bdcc 100644 --- a/packages/ui-default/misc/icons/warning.svg +++ b/packages/ui-default/misc/icons/warning.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/misc/icons/wrench.svg b/packages/ui-default/misc/icons/wrench.svg index 9e4f7f332..22b927d82 100644 --- a/packages/ui-default/misc/icons/wrench.svg +++ b/packages/ui-default/misc/icons/wrench.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index cdc151933..3c819b592 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.39.0", + "version": "4.39.2", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", @@ -30,8 +30,9 @@ "@types/qrcode": "^1.4.2", "@types/react-dom": "^18.0.6", "@types/redux-logger": "^3.0.9", + "@vscode/codicons": "^0.0.32", "autoprefixer": "^10.4.8", - "browser-update": "^3.3.38", + "browser-update": "^3.3.40", "chalk": "^5.0.1", "chunk-progress-webpack-plugin": "^2.0.1", "classnames": "^2.3.1", @@ -40,7 +41,7 @@ "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.7.1", "diff": "^5.1.0", - "diff-dom": "^4.2.3", + "diff-dom": "^4.2.5", "echarts": "^5.3.3", "emojis-keywords": "2.0.0", "emojis-list": "2.1.0", @@ -53,20 +54,20 @@ "gulp-iconfont": "^11.0.1", "gulp-if": "^3.0.0", "gulp-plumber": "^1.2.1", - "gulp-svgmin": "^3.0.0", + "gulp-svgmin": "^4.1.0", "jquery": "^3.6.0", "jquery-scroll-lock": "^3.1.3", "jquery.easing": "^1.4.1", "jquery.transit": "^0.9.12", "matchmedia-polyfill": "^0.3.2", - "mini-css-extract-plugin": "^1.6.2", + "mini-css-extract-plugin": "^2.6.1", "moment": "^2.29.4", "monaco-editor": "^0.33.0", "monaco-editor-nls": "^2.0.0", "monaco-editor-webpack-plugin": "^7.0.1", "monaco-themes": "^0.4.2", "monaco-yaml": "^4.0.0", - "nanoid": "^3.3.4", + "nanoid": "^4.0.0", "normalize.css": "^8.0.1", "nprogress": "^0.2.0", "pickadate": "^3.6.4", @@ -101,7 +102,7 @@ "through2": "^4.0.2", "timeago-react": "^3.0.5", "timeago.js": "^4.0.2", - "vditor": "^3.8.15", + "vditor": "^3.8.17", "vinyl-buffer": "^1.0.1", "web-streams-polyfill": "^3.2.1", "webpack": "^5.74.0", @@ -110,7 +111,6 @@ "webpackbar": "^5.0.2" }, "dependencies": { - "@vscode/codicons": "^0.0.31", "ansi_up": "^5.1.0", "esbuild": "0.14.3", "fs-extra": "^10.1.0", @@ -128,7 +128,7 @@ "markdown-it-table-of-contents": "^0.6.0", "mongodb": "^3.7.3", "nunjucks": "^3.2.3", - "p-queue": "^7.2.0", + "p-queue": "^7.3.0", "streamsaver": "^2.0.6", "xss": "^1.0.13" } diff --git a/packages/ui-default/pages/problem_main.page.js b/packages/ui-default/pages/problem_main.page.js index 446bce2fa..27bf0bbba 100644 --- a/packages/ui-default/pages/problem_main.page.js +++ b/packages/ui-default/pages/problem_main.page.js @@ -249,11 +249,7 @@ const page = new NamedPage(['problem_main'], () => { updateSelection(); }); $('#searchForm').on('submit', updateSelection); - let update; - $('#searchForm').find('input').on('input', () => { - if (update) clearTimeout(update); - update = setTimeout(updateSelection, 500); - }); + $('#searchForm').find('input').on('input', _.debounce(updateSelection, 500)); $(document).on('click', 'a.pager__item', (ev) => { ev.preventDefault(); pjax.request(ev.currentTarget.getAttribute('href')).then(() => window.scrollTo(0, 0)); diff --git a/packages/ui-default/pages/record_main.page.ts b/packages/ui-default/pages/record_main.page.ts index 160f3b156..ffdd8b4de 100644 --- a/packages/ui-default/pages/record_main.page.ts +++ b/packages/ui-default/pages/record_main.page.ts @@ -14,11 +14,7 @@ const page = new NamedPage('record_main', async () => { const sock = new WebSocket(UiContext.socketUrl); const dd = new DiffDOM(); - let firstLoad = true; - sock.onopen = () => { - if (firstLoad) sock.send(JSON.stringify({ rids: UiContext.rids })); - firstLoad = false; - }; + sock.onopen = () => sock.send(JSON.stringify({ rids: UiContext.rids })); sock.onmessage = (message) => { const msg = JSON.parse(message.data); const $newTr = $(msg.html); diff --git a/packages/ui-default/templates/record_detail.html b/packages/ui-default/templates/record_detail.html index d494d8421..62c7786f2 100644 --- a/packages/ui-default/templates/record_detail.html +++ b/packages/ui-default/templates/record_detail.html @@ -66,8 +66,10 @@ {{ tdoc.title }} {% endif %} -
{{ _('Language') }}
-
{{ model.setting.langs[rdoc.lang].display }}
+ {% if pdoc.config.type != 'objective' %} +
{{ _('Language') }}
+
{{ model.setting.langs[rdoc.lang].display }}
+ {% endif %}
{{ _('Submit At') }}
{{ datetimeSpan(rdoc._id)|safe }}
{% if rdoc.judgeAt %} diff --git a/packages/utils/package.json b/packages/utils/package.json index f4fe3e047..ef0f75608 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/utils", - "version": "1.3.4", + "version": "1.3.5", "description": "hydrooj utils", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git", @@ -8,13 +8,17 @@ "license": "AGPL-3.0-or-later", "preferUnplugged": true, "dependencies": { + "cac": "^6.7.12", + "esbuild": "0.14.3", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0", "moment-timezone": "^0.5.34", "mongodb": "^3.7.3", - "systeminformation": "^5.11.24" + "source-map-support": "^0.5.21", + "systeminformation": "^5.12.3" }, "devDependencies": { - "@types/fs-extra": "^9.0.13" + "@types/fs-extra": "^9.0.13", + "@types/source-map-support": "^0.5.4" } } diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index 23229ed40..b1c683fe2 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -16,11 +16,11 @@ "puppeteer-extra": "3.3.0", "puppeteer-extra-plugin-portal": "3.1.0", "puppeteer-extra-plugin-stealth": "2.10.1", - "superagent": "^7.1.5", + "superagent": "^8.0.0", "superagent-proxy": "^3.0.0" }, "devDependencies": { - "@types/jsdom": "^16.2.14", + "@types/jsdom": "^16.2.15", "@types/lodash": "^4.14.182", "@types/superagent": "^4.1.15", "@types/superagent-proxy": "^3.0.0"