ui: allow custom esbuild plugins

This commit is contained in:
undefined committed 2022-07-05 10:15:39 +08:00
1 parent ef0582d63c
commit 8428581860
4 files changed
+18 -8

No files matched your search

+1 -1
View File
@@ -175,7 +175,7 @@ async function render(name, state) {
perm: global.Hydro.model.builtin.PERM, perm: global.Hydro.model.builtin.PERM,
PRIV: global.Hydro.model.builtin.PRIV, PRIV: global.Hydro.model.builtin.PRIV,
STATUS: global.Hydro.model.builtin.STATUS, STATUS: global.Hydro.model.builtin.STATUS,
UiContext: state.handler.UiContext, UiContext: state.handler?.UiContext || {},
}, (err, res) => { }, (err, res) => {
if (err) reject(err); if (err) reject(err);
else resolve(res); else resolve(res);
+16 -5
View File
@@ -6,16 +6,26 @@ import { ObjectID } from 'mongodb';
import * as bus from 'hydrooj/src/service/bus'; import * as bus from 'hydrooj/src/service/bus';
import { Route, Handler } from 'hydrooj/src/service/server'; import { Route, Handler } from 'hydrooj/src/service/server';
import { PERM, PRIV } from 'hydrooj/src/model/builtin'; import { PERM, PRIV } from 'hydrooj/src/model/builtin';
import * as system from 'hydrooj/src/model/system';
import user from 'hydrooj/src/model/user';
import * as contest from 'hydrooj/src/model/contest';
import problem from 'hydrooj/src/model/problem';
import * as setting from 'hydrooj/src/model/setting';
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import { tmpdir } from 'os'; import { tmpdir } from 'os';
import markdown from './backendlib/markdown'; import markdown from './backendlib/markdown';
const { declare module 'hydrooj/src/interface' {
system, user, setting, problem, contest, interface UI {
} = global.Hydro.model; esbuildPlugins?: esbuild.Plugin[]
}
interface SystemKeys {
'ui-default.nav_logo_dark': string;
'ui-default.nav_logo_dark_2x': string;
}
}
const pageFiles = Object.keys(global.Hydro.ui.manifest) const pageFiles = Object.keys(global.Hydro.ui.manifest).filter(/\.page\.[jt]sx?$/.test);
.filter((file) => file.endsWith('.page.js') || file.endsWith('.page.ts'));
const build = esbuild.buildSync({ const build = esbuild.buildSync({
format: 'iife', format: 'iife',
entryPoints: pageFiles.map((i) => join(global.Hydro.ui.manifest[i], i)), entryPoints: pageFiles.map((i) => join(global.Hydro.ui.manifest[i], i)),
@@ -26,6 +36,7 @@ const build = esbuild.buildSync({
target: [ target: [
'chrome60', 'chrome60',
], ],
plugins: global.Hydro.ui.esbuildPlugins || [],
minify: !process.env.DEV, minify: !process.env.DEV,
}); });
if (build.errors.length) console.error(build.errors); if (build.errors.length) console.error(build.errors);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.38.3", "version": "4.38.4",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",
-1
View File
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
declare let UserContext: any; declare let UserContext: any;
declare let UiContext: any; declare let UiContext: any;
declare let Hydro: any;
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
declare let node_modules: any; declare let node_modules: any;
declare let LANGS: Record<string, import('@hydrooj/utils/lib/lang').LangConfig>; declare let LANGS: Record<string, import('@hydrooj/utils/lib/lang').LangConfig>;