upgrade to typescript@5.6 and cordis@3.18

This commit is contained in:
undefined committed 2024-10-02 08:33:52 +08:00
1 parent c3953a3ce7
commit 30e95b4511
22 files changed
+52 -46

No files matched your search

+3 -3
View File
@@ -5,13 +5,13 @@
"main": "react.yaml",
"dependencies": {
"@stylistic/eslint-plugin": "^2.8.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-github": "^5.0.2",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1"
},
+1 -1
View File
@@ -16,7 +16,7 @@
"koa-router": "^13.0.1",
"lodash": "^4.17.21",
"moment-timezone": "^0.5.45",
"path-to-regexp": "^8.1.0",
"path-to-regexp": "^8.2.0",
"sanitize-filename": "^1.6.3",
"saslprep": "^1.0.3",
"shorty.js": "^1.0.1",
+8 -5
View File
@@ -23,6 +23,8 @@ import serializer from './serializer';
export { WebSocket, WebSocketServer } from 'ws';
const kHandler = Symbol.for('hydro.handler');
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
export function encodeRFC5987ValueChars(str: string) {
return (
@@ -109,6 +111,7 @@ export interface UserModel {
export interface HandlerCommon { }
export class HandlerCommon {
static [kHandler] = true;
session: Record<string, any>;
args: Record<string, any>;
request: HydroRequest;
@@ -316,6 +319,7 @@ interface WebServiceConfig {
cors?: string;
upload?: string;
port: number;
host?: string;
xff?: string;
xhost?: string;
}
@@ -446,7 +450,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
wsServer.close();
});
await new Promise((r) => {
httpServer.listen(this.config.port, () => {
httpServer.listen(this.config.port, this.config.host || '127.0.0.1', () => {
logger.success('Server listening at: %d', this.config.port);
r(true);
});
@@ -596,7 +600,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
private register(type: 'route' | 'conn', routeName: string, path: string, HandlerClass: any, ...permPrivChecker) {
const name = HandlerClass.name;
if (!isClass(HandlerClass)) throw new Error('Invalid registration.');
if (!HandlerClass?.[kHandler] || !isClass(HandlerClass)) throw new Error('Invalid registration.');
if (this.registrationCount[name] && this.registry[name] !== HandlerClass) {
logger.warn('Route with name %s already exists.', name);
}
@@ -625,10 +629,9 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
) {
if (this.registry[name]) callback(this.registry[name]);
// @ts-ignore
this.ctx.on(`handler/register/${name}`, callback);
const dispose = this.ctx.on(`handler/register/${name}`, callback);
this[Context.current]?.on('dispose', () => {
// @ts-ignore
this.ctx.off(`handler/register/${name}`, callback);
dispose();
});
}
+1 -1
View File
@@ -7,7 +7,7 @@
"node": ">=16"
},
"dependencies": {
"esbuild": "0.23.0",
"esbuild": "0.24.0",
"source-map-support": "^0.5.21"
},
"devDependencies": {
+3 -2
View File
@@ -8,7 +8,7 @@ if [ $EUID != 0 ]; then
exit $?
fi
set -e
echo "Executing Hydro install script v3.0.0"
echo "Executing Hydro install script v3.0.1"
echo "Hydro includes system telemetry,
which helps developers figure out the most commonly used operating system and platform.
To disable this feature, checkout our sourcecode."
@@ -22,6 +22,7 @@ echo "// File created by Hydro install script\n" >/tmp/install.js
cat >/tmp/install.b64 << EOF123
%PLACEHOLDER%
EOF123
cat /tmp/install.b64 | base64 -d >>/tmp/install.js
cat /tmp/install.b64 | base64 -d >>/tmp/install.js
rm /tmp/install.b64
node /tmp/install.js "$@"
set +e
+4 -1
View File
@@ -483,7 +483,10 @@ ${nixConfBase}`);
`pm2 start mongod --name mongodb -e /dev/null -- --auth --bind_ip 0.0.0.0 --wiredTigerCacheSizeGB=${wtsize}`,
() => sleep(1000),
async () => {
if (noCaddy) return;
if (noCaddy) {
exec('hydrooj cli system set server.host 0.0.0.0');
return;
}
if (!await isPortFree(80)) log.warn('port.80');
if (migration === 'hustoj') {
exec('systemctl stop nginx || true');
+5 -6
View File
@@ -35,16 +35,16 @@
"devDependencies": {
"@simplewebauthn/types": "9.0.1",
"@types/autocannon": "^7.12.5",
"@types/chai": "^4.3.20",
"@types/chai": "^5.0.0",
"@types/cross-spawn": "^6.0.6",
"@types/node": "20.12.12",
"@types/node": "22.7.4",
"@types/semver": "^7.5.8",
"autocannon": "^7.15.0",
"cac": "^6.7.14",
"chai": "^5.1.1",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"esbuild": "0.23.0",
"esbuild": "0.24.0",
"eslint": "^8.57.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-import-resolver-webpack": "^0.13.9",
@@ -58,11 +58,10 @@
"semver": "^7.6.3",
"simple-git": "^3.27.0",
"supertest": "^7.0.0",
"typescript": "5.3.3",
"typescript": "5.6.2",
"wtfnode": "^0.9.3"
},
"resolutions": {
"@cordisjs/logger": "0.3.2",
"reggol": "1.6.3"
"monaco-editor": "0.50.0"
}
}
+1 -2
View File
@@ -36,6 +36,5 @@ export default class GeoIPService extends Service {
}
export async function apply(ctx: Context) {
ctx.provide('geoip');
ctx.geoip = new GeoIPService(ctx);
ctx.set('geoip', new GeoIPService(ctx));
}
+1 -1
View File
@@ -6,7 +6,7 @@
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0-or-later",
"dependencies": {
"maxmind": "^4.3.21"
"maxmind": "^4.3.22"
},
"preferUnplugged": true
}
+6 -6
View File
@@ -12,10 +12,10 @@
},
"preferUnplugged": true,
"dependencies": {
"@aws-sdk/client-s3": "3.658.1",
"@aws-sdk/lib-storage": "3.658.1",
"@aws-sdk/s3-presigned-post": "3.658.1",
"@aws-sdk/s3-request-presigner": "3.658.1",
"@aws-sdk/client-s3": "3.662.0",
"@aws-sdk/lib-storage": "3.662.0",
"@aws-sdk/s3-presigned-post": "3.662.0",
"@aws-sdk/s3-request-presigner": "3.662.0",
"@graphql-tools/schema": "^10.0.6",
"@hydrooj/framework": "workspace:^",
"@hydrooj/utils": "workspace:^",
@@ -24,7 +24,7 @@
"@yarnpkg/libzip": "^3.1.0",
"adm-zip": "0.5.14",
"cac": "^6.7.14",
"cordis": "3.16.0",
"cordis": "3.18.1",
"detect-browser": "^5.3.0",
"emoji-regex": "^10.4.0",
"emojis-list": "2.1.0",
@@ -66,7 +66,7 @@
"@types/saslprep": "^1.0.3",
"@types/semver": "^7.5.8",
"@types/superagent": "^8.1.9",
"chokidar": "^3.6.0",
"chokidar": "^4.0.1",
"moment": "^2.30.1"
}
}
+1 -1
View File
@@ -506,7 +506,7 @@ export async function apply(ctx: Context) {
ctx.Route('user_lostpass', '/lostpass', UserLostPassHandler);
ctx.Route('user_lostpass_with_code', '/lostpass/:code', UserLostPassWithCodeHandler);
ctx.Route('user_delete', '/user/delete', UserDeleteHandler, PRIV.PRIV_USER_PROFILE);
ctx.Route('user_detail', '/user/:uid(-?\\d+)', UserDetailHandler);
ctx.Route('user_detail', '/user/:uid', UserDetailHandler);
if (system.get('server.contestmode')) {
ctx.Route('contest_mode', '/contestmode', ContestModeHandler, PRIV.PRIV_EDIT_SYSTEM);
}
+1
View File
@@ -28,6 +28,7 @@ export interface SystemKeys {
'server.url': string,
'server.xff': string,
'server.xhost': string,
'server.host': string,
'server.port': number,
'server.language': string,
'limit.problem_files_max': number,
+1 -1
View File
@@ -246,6 +246,7 @@ SystemSetting(
Setting('setting_server', 'server.upload', '256m', 'text', 'server.upload', 'Max upload file size'),
Setting('setting_server', 'server.cdn', '/', 'text', 'server.cdn', 'CDN Prefix'),
Setting('setting_server', 'server.ws', '/', 'text', 'server.ws', 'WebSocket Prefix'),
Setting('setting_server', 'server.host', '127.0.0.1', 'text', 'server.host', 'Listen host'),
Setting('setting_server', 'server.port', 8888, 'number', 'server.port', 'Server Port'),
Setting('setting_server', 'server.xff', null, 'text', 'server.xff', 'IP Header'),
Setting('setting_server', 'server.xhost', null, 'text', 'server.xhost', 'Hostname Header'),
@@ -312,7 +313,6 @@ export class SettingService extends Service {
SystemSetting = T(SystemSetting);
constructor(ctx: Context) {
super(ctx, 'setting', true);
ctx.mixin('setting', ['PreferenceSetting', 'AccountSetting', 'DomainSetting', 'DomainUserSetting', 'SystemSetting']);
}
get(key: string) {
+1
View File
@@ -138,6 +138,7 @@ export async function apply(ctx: Context) {
cors: system.get('server.cors') || '',
upload: system.get('server.upload') || '256m',
port: argv.options.port || system.get('server.port'),
host: argv.options.host || system.get('server.host'),
xff: system.get('server.xff'),
xhost: system.get('server.xhost'),
});
+3 -2
View File
@@ -49,8 +49,9 @@ export default class Watcher extends Service {
if (process.env.WATCH_ROOT) roots.push(process.env.WATCH_ROOT);
this.watcher = watch(roots, {
...this.config,
ignored: ['node_modules', '.git', 'logs', '.cache', '.yarn']
.map((i) => `**/${i}/**`).concat('**/tsconfig.tsbuildinfo'),
ignored: (file) => [
'node_modules', '.git', 'logs', '.cache', '.yarn', 'tsconfig.tsbuildinfo',
].some((rule) => file.startsWith(`${rule}/`) || file.endsWith(`/${rule}`) || file.includes(`/${rule}/`)),
});
logger.info(`Start watching changes in ${this.root}`);
+1 -2
View File
@@ -75,7 +75,6 @@ export function createRegistry(ctx: Context) {
collectDefaultMetrics({ register: registry });
ctx.provide('metrics');
ctx.metrics = registry;
ctx.set('metrics', registry);
return registry;
}
@@ -62,8 +62,7 @@ declare module '../../context' {
export default function ScratchpadContainer() {
const store = useStore();
ctx.provide('scratchpad');
ctx.scratchpad ||= new ScratchpadService(store);
ctx.set('scratchpad', new ScratchpadService(store));
const [, updateState] = React.useState<any>();
const forceUpdate = React.useCallback(() => updateState({}), []);
React.useEffect(() => {
+4 -4
View File
@@ -15,7 +15,7 @@
},
"devDependencies": {
"@blueprintjs/core": "^5.13.0",
"@cordisjs/core": "3.17.3",
"@cordisjs/core": "3.18.1",
"@fontsource/dm-mono": "^5.1.0",
"@fontsource/fira-code": "^5.1.0",
"@fontsource/inconsolata": "^5.1.0",
@@ -37,7 +37,7 @@
"@types/nunjucks": "^3.2.6",
"@types/pickadate": "^3.5.35",
"@types/qrcode": "^1.5.5",
"@types/react": "^18.3.9",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@types/redux-logger": "^3.0.13",
"@types/uuid": "^10.0.0",
@@ -46,7 +46,7 @@
"ajv": "^8.17.1",
"allotment": "^1.20.2",
"autoprefixer": "^10.4.20",
"browser-update": "^3.3.53",
"browser-update": "^3.3.54",
"chalk": "^5.3.0",
"classnames": "^2.5.1",
"clean-webpack-plugin": "^4.0.0",
@@ -124,7 +124,7 @@
"dependencies": {
"ansi_up": "^6.0.2",
"cssfilter": "^0.0.11",
"esbuild": "0.23.0",
"esbuild": "0.24.0",
"fs-extra": "^11.2.0",
"js-yaml": "^4.1.0",
"jsesc": "^3.0.2",
@@ -43,8 +43,7 @@ const page = new NamedPage('home_messages', () => {
reduxStore = store;
(window as any).store = reduxStore;
ctx.provide('messagepad');
ctx.messagepad = new MessagePadService(store, WebSocket);
ctx.set('messagepad', new MessagePadService(store, WebSocket));
const sock = new WebSocket(`${UiContext.ws_prefix}home/messages-conn`);
sock.onmessage = (message) => {
@@ -115,8 +115,8 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
}
async function scratchpadFadeIn() {
// @ts-ignore
await $('#scratchpad')
// @ts-ignore
.transition(
{ opacity: 1 },
{ duration: 200, easing: 'easeOutCubic' },
@@ -125,8 +125,8 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
}
async function scratchpadFadeOut() {
// @ts-ignore
await $('#scratchpad')
// @ts-ignore
.transition(
{ opacity: 0 },
{ duration: 200, easing: 'easeOutCubic' },
+2 -1
View File
@@ -69,7 +69,8 @@ String.prototype.format = function formatStr(...args) {
export function isClass(obj: any, strict = false): obj is new (...args: any) => any {
if (typeof obj !== 'function') return false;
if (obj.prototype === undefined) return false;
if (obj.prototype.constructor !== obj) return false;
// FIXME cordis proxies the object and make this assertion fail
// if (obj.prototype.constructor !== obj) return false;
if (Object.getOwnPropertyNames(obj.prototype).length >= 2) return true;
const str = obj.toString();
if (str.slice(0, 5) === 'class') return true;
+1 -1
View File
@@ -14,7 +14,7 @@
"js-yaml": "^4.1.0",
"moment-timezone": "^0.5.45",
"mongodb": "^5.9.2",
"reggol": "^1.6.3",
"reggol": "^1.7.0",
"search-query-parser": "^1.6.0",
"systeminformation": "^5.23.5"
},