mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
next: esbuild loader
This commit is contained in:
1 parent
cca54dc92a
commit
5eaec48002
28 files changed
+171
-113
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import db from 'hydrooj/dist/service/db';
|
import db from 'hydrooj/src/service/db';
|
||||||
import {
|
import {
|
||||||
Handler, post, Route, Types,
|
Handler, post, Route, Types,
|
||||||
} from 'hydrooj/dist/service/server';
|
} from 'hydrooj/src/service/server';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ function decrypt(encrypted: string) {
|
|||||||
return decrypted;
|
return decrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'hydrooj/dist/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface Collections {
|
interface Collections {
|
||||||
dataReport: any;
|
dataReport: any;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import * as bus from 'hydrooj/dist/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
import * as system from 'hydrooj/dist/model/system';
|
import * as system from 'hydrooj/src/model/system';
|
||||||
import i18n from 'hydrooj/dist/lib/i18n';
|
import i18n from 'hydrooj/src/lib/i18n';
|
||||||
|
|
||||||
bus.once('app/started', () => {
|
bus.once('app/started', () => {
|
||||||
const langs = system.get('easy-locale.langs');
|
const langs = system.get('easy-locale.langs');
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import xml2js from 'xml2js';
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { filter } from 'lodash';
|
import { filter } from 'lodash';
|
||||||
import decodeHTML from 'decode-html';
|
import decodeHTML from 'decode-html';
|
||||||
import { Route, Handler } from 'hydrooj/dist/service/server';
|
import { Route, Handler } from 'hydrooj/src/service/server';
|
||||||
import { buildContent } from 'hydrooj/dist/lib/content';
|
import { buildContent } from 'hydrooj/src/lib/content';
|
||||||
import { ProblemAdd } from 'hydrooj/dist/lib/ui';
|
import { ProblemAdd } from 'hydrooj/src/lib/ui';
|
||||||
import solution from 'hydrooj/dist/model/solution';
|
import solution from 'hydrooj/src/model/solution';
|
||||||
import problem from 'hydrooj/dist/model/problem';
|
import problem from 'hydrooj/src/model/problem';
|
||||||
import { PERM } from 'hydrooj/dist/model/builtin';
|
import { PERM } from 'hydrooj/src/model/builtin';
|
||||||
import { FileTooLargeError, ValidationError } from 'hydrooj/dist/error';
|
import { FileTooLargeError, ValidationError } from 'hydrooj/src/error';
|
||||||
import type { ContentNode, ProblemConfigFile } from 'hydrooj';
|
import type { ContentNode, ProblemConfigFile } from 'hydrooj';
|
||||||
|
|
||||||
class FpsProblemImportHandler extends Handler {
|
class FpsProblemImportHandler extends Handler {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import path from 'path';
|
|||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
import { Logger } from 'hydrooj/dist/logger';
|
import { Logger } from 'hydrooj/src/logger';
|
||||||
import * as monitor from 'hydrooj/dist/service/monitor';
|
import * as monitor from 'hydrooj/src/service/monitor';
|
||||||
import * as sysinfo from './sysinfo';
|
import * as sysinfo from './sysinfo';
|
||||||
import * as tmpfs from './tmpfs';
|
import * as tmpfs from './tmpfs';
|
||||||
import { FormatError, CompileError, SystemError } from './error';
|
import { FormatError, CompileError, SystemError } from './error';
|
||||||
@@ -15,7 +15,7 @@ import { compilerText, md5 } from './utils';
|
|||||||
import readCases from './cases';
|
import readCases from './cases';
|
||||||
import { getConfig } from './config';
|
import { getConfig } from './config';
|
||||||
|
|
||||||
declare module 'hydrooj/dist/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface SystemKeys {
|
interface SystemKeys {
|
||||||
'hydrojudge.cache_dir': string,
|
'hydrojudge.cache_dir': string,
|
||||||
'hydrojudge.tmp_dir': string,
|
'hydrojudge.tmp_dir': string,
|
||||||
|
|||||||
@@ -1,11 +1,40 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/* eslint-disable consistent-return */
|
||||||
|
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const argv = require('cac')().parse();
|
const argv = require('cac')().parse();
|
||||||
const child = require('child_process');
|
const child = require('child_process');
|
||||||
|
const esbuild = require('esbuild');
|
||||||
|
|
||||||
|
let transformTimeUsage = 0;
|
||||||
|
let displayTimeout;
|
||||||
|
function transform(type, filename) {
|
||||||
|
const start = new Date();
|
||||||
|
const result = esbuild.buildSync({
|
||||||
|
entryPoints: [filename],
|
||||||
|
sourcemap: 'inline',
|
||||||
|
platform: 'node',
|
||||||
|
format: 'cjs',
|
||||||
|
target: `node${process.version.split('.')[0].split('v')[1]}`,
|
||||||
|
jsx: 'transform',
|
||||||
|
write: false,
|
||||||
|
});
|
||||||
|
if (result.warnings.length) console.warn(result.warnings);
|
||||||
|
transformTimeUsage += new Date().getTime() - start.getTime();
|
||||||
|
if (displayTimeout) clearTimeout(displayTimeout);
|
||||||
|
displayTimeout = setTimeout(() => console.log(`Code transform took ${transformTimeUsage}ms`), 1000);
|
||||||
|
return result.outputFiles[0].text;
|
||||||
|
}
|
||||||
|
require.extensions['.ts'] = function loader(module, filename) {
|
||||||
|
return module._compile(transform('ts', filename), filename);
|
||||||
|
};
|
||||||
|
require.extensions['.tsx'] = function loader(module, filename) {
|
||||||
|
return module._compile(transform('tsx', filename), filename);
|
||||||
|
};
|
||||||
|
|
||||||
function buildUrl(opts) {
|
function buildUrl(opts) {
|
||||||
let mongourl = `${opts.protocol || 'mongodb'}://`;
|
let mongourl = `${opts.protocol || 'mongodb'}://`;
|
||||||
@@ -16,7 +45,7 @@ function buildUrl(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!cluster.isMaster) {
|
if (!cluster.isMaster) {
|
||||||
const hydro = require('../dist/loader');
|
const hydro = require('../src/loader');
|
||||||
// Forked by hydro
|
// Forked by hydro
|
||||||
hydro.load().catch((e) => {
|
hydro.load().catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -78,7 +107,7 @@ if (!cluster.isMaster) {
|
|||||||
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const hydro = require('../dist/loader');
|
const hydro = require('../src/loader');
|
||||||
addons = Array.from(new Set(addons));
|
addons = Array.from(new Set(addons));
|
||||||
for (const addon of addons) hydro.addon(addon);
|
for (const addon of addons) hydro.addon(addon);
|
||||||
(argv.args[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
(argv.args[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.29.46",
|
"version": "2.29.46",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "src/loader",
|
||||||
"typings": "dist/loader.d.ts",
|
"module": "src/loader",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ function getFiles(folder: string, base = ''): string[] {
|
|||||||
|
|
||||||
export async function handler(pending: string[], fail: string[]) {
|
export async function handler(pending: string[], fail: string[]) {
|
||||||
for (const i of pending) {
|
for (const i of pending) {
|
||||||
const p = path.resolve(i, 'handler.js');
|
let p = path.resolve(i, 'handler.ts');
|
||||||
|
if (!fs.existsSync(p)) p = path.resolve(i, 'handler.js');
|
||||||
if (fs.existsSync(p) && !fail.includes(i)) {
|
if (fs.existsSync(p) && !fail.includes(i)) {
|
||||||
try {
|
try {
|
||||||
logger.info('Handler init: %s', i);
|
logger.info('Handler init: %s', i);
|
||||||
@@ -161,7 +162,8 @@ export async function uistatic(pending: string[], fail: string[]) {
|
|||||||
|
|
||||||
export async function model(pending: string[], fail: string[]) {
|
export async function model(pending: string[], fail: string[]) {
|
||||||
for (const i of pending) {
|
for (const i of pending) {
|
||||||
const p = path.resolve(i, 'model.js');
|
let p = path.resolve(i, 'model.ts');
|
||||||
|
if (!fs.existsSync(p)) p = path.resolve(i, 'model.js');
|
||||||
if (fs.existsSync(p) && !fail.includes(i)) {
|
if (fs.existsSync(p) && !fail.includes(i)) {
|
||||||
try {
|
try {
|
||||||
logger.info('Model init: %s', i);
|
logger.info('Model init: %s', i);
|
||||||
@@ -178,7 +180,8 @@ export async function model(pending: string[], fail: string[]) {
|
|||||||
|
|
||||||
export async function lib(pending: string[], fail: string[]) {
|
export async function lib(pending: string[], fail: string[]) {
|
||||||
for (const i of pending) {
|
for (const i of pending) {
|
||||||
const p = path.resolve(i, 'lib.js');
|
let p = path.resolve(i, 'lib.ts');
|
||||||
|
if (!fs.existsSync(p)) p = path.resolve(i, 'lib.js');
|
||||||
if (fs.existsSync(p) && !fail.includes(i)) {
|
if (fs.existsSync(p) && !fail.includes(i)) {
|
||||||
try {
|
try {
|
||||||
logger.info('Lib init: %s', i);
|
logger.info('Lib init: %s', i);
|
||||||
@@ -195,7 +198,8 @@ export async function lib(pending: string[], fail: string[]) {
|
|||||||
|
|
||||||
export async function service(pending: string[], fail: string[]) {
|
export async function service(pending: string[], fail: string[]) {
|
||||||
for (const i of pending) {
|
for (const i of pending) {
|
||||||
const p = path.resolve(i, 'service.js');
|
let p = path.resolve(i, 'service.ts');
|
||||||
|
if (!fs.existsSync(p)) p = path.resolve(i, 'service.js');
|
||||||
if (fs.existsSync(p) && !fail.includes(i)) {
|
if (fs.existsSync(p) && !fail.includes(i)) {
|
||||||
try {
|
try {
|
||||||
logger.info('Service init: %s', i);
|
logger.info('Service init: %s', i);
|
||||||
@@ -216,7 +220,8 @@ export async function service(pending: string[], fail: string[]) {
|
|||||||
|
|
||||||
export async function script(pending: string[], fail: string[], active: string[]) {
|
export async function script(pending: string[], fail: string[], active: string[]) {
|
||||||
for (const i of pending) {
|
for (const i of pending) {
|
||||||
const p = path.resolve(i, 'script.js');
|
let p = path.resolve(i, 'script.ts');
|
||||||
|
if (!fs.existsSync(p)) p = path.resolve(i, 'script.js');
|
||||||
if (await fs.pathExists(p) && !fail.includes(i)) {
|
if (await fs.pathExists(p) && !fail.includes(i)) {
|
||||||
try {
|
try {
|
||||||
logger.info('Script init: %s', i);
|
logger.info('Script init: %s', i);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
|
||||||
|
const versionNum = +process.version.replace(/v/gim, '').split('.')[0];
|
||||||
|
if (versionNum < 14) throw new Error('NodeJS >=v14 required');
|
||||||
|
|
||||||
|
|
||||||
|
if (!global.Hydro) {
|
||||||
|
global.Hydro = {
|
||||||
|
version: {
|
||||||
|
node: process.version,
|
||||||
|
hydrooj: require('hydrooj/package.json').version,
|
||||||
|
},
|
||||||
|
stat: { reqCount: 0 },
|
||||||
|
handler: {},
|
||||||
|
// @ts-ignore
|
||||||
|
service: {},
|
||||||
|
// @ts-ignore
|
||||||
|
model: {},
|
||||||
|
script: {},
|
||||||
|
// @ts-ignore
|
||||||
|
lib: {},
|
||||||
|
// @ts-ignore
|
||||||
|
ui: {
|
||||||
|
manifest: {},
|
||||||
|
nodes: {
|
||||||
|
nav: [],
|
||||||
|
problem_add: [],
|
||||||
|
user_dropdown: [],
|
||||||
|
},
|
||||||
|
template: {},
|
||||||
|
},
|
||||||
|
// @ts-ignore
|
||||||
|
error: {},
|
||||||
|
locales: {},
|
||||||
|
};
|
||||||
|
global.addons = [];
|
||||||
|
}
|
||||||
@@ -1,64 +1,25 @@
|
|||||||
import 'reflect-metadata';
|
|
||||||
/* eslint-disable import/first */
|
|
||||||
/* eslint-disable no-continue */
|
|
||||||
/* eslint-disable import/no-dynamic-require */
|
/* eslint-disable import/no-dynamic-require */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
/* eslint-disable no-eval */
|
/* eslint-disable no-eval */
|
||||||
|
import 'reflect-metadata';
|
||||||
const versionNum = +process.version.replace(/v/gim, '').split('.')[0];
|
import './init';
|
||||||
if (versionNum < 14) throw new Error('NodeJS >=v14 required');
|
|
||||||
|
|
||||||
import cac from 'cac';
|
|
||||||
|
|
||||||
const argv = cac().parse();
|
|
||||||
|
|
||||||
if (argv.options.debug) {
|
|
||||||
process.env.NODE_ENV = 'development';
|
|
||||||
process.env.DEV = 'on';
|
|
||||||
} else process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
||||||
|
|
||||||
if (!global.Hydro) {
|
|
||||||
global.Hydro = {
|
|
||||||
version: {
|
|
||||||
node: process.version,
|
|
||||||
hydrooj: require('hydrooj/package.json').version,
|
|
||||||
},
|
|
||||||
stat: { reqCount: 0 },
|
|
||||||
handler: {},
|
|
||||||
// @ts-ignore
|
|
||||||
service: {},
|
|
||||||
// @ts-ignore
|
|
||||||
model: {},
|
|
||||||
script: {},
|
|
||||||
// @ts-ignore
|
|
||||||
lib: {},
|
|
||||||
// @ts-ignore
|
|
||||||
ui: {
|
|
||||||
manifest: {},
|
|
||||||
nodes: {
|
|
||||||
nav: [],
|
|
||||||
problem_add: [],
|
|
||||||
user_dropdown: [],
|
|
||||||
},
|
|
||||||
template: {},
|
|
||||||
},
|
|
||||||
// @ts-ignore
|
|
||||||
error: {},
|
|
||||||
locales: {},
|
|
||||||
};
|
|
||||||
global.addons = [];
|
|
||||||
}
|
|
||||||
import './interface';
|
import './interface';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import cluster from 'cluster';
|
import cluster from 'cluster';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import './utils';
|
import './utils';
|
||||||
|
import cac from 'cac';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
import './ui';
|
import './ui';
|
||||||
import * as bus from './service/bus';
|
import * as bus from './service/bus';
|
||||||
|
|
||||||
export * from './interface';
|
export * from './interface';
|
||||||
|
const argv = cac().parse();
|
||||||
|
if (argv.options.debug) {
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
process.env.DEV = 'on';
|
||||||
|
} else process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
||||||
const logger = new Logger('loader');
|
const logger = new Logger('loader');
|
||||||
logger.debug('%o', argv);
|
logger.debug('%o', argv);
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ if (cluster.isMaster) {
|
|||||||
});
|
});
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
process.stdin.setEncoding('utf-8');
|
process.stdin.setEncoding('utf-8');
|
||||||
|
process.stdin.setRawMode(false);
|
||||||
process.stdin.on('data', (buf) => {
|
process.stdin.on('data', (buf) => {
|
||||||
const input = buf.toString();
|
const input = buf.toString();
|
||||||
if (input[0] === '@') {
|
if (input[0] === '@') {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import os from 'os';
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { Route, Handler } from 'hydrooj/dist/service/server';
|
import { Route, Handler } from 'hydrooj/src/service/server';
|
||||||
import { BadRequestError, ValidationError } from 'hydrooj/dist/error';
|
import { BadRequestError, ValidationError } from 'hydrooj/src/error';
|
||||||
import { ProblemAdd } from 'hydrooj/dist/lib/ui';
|
import { ProblemAdd } from 'hydrooj/src/lib/ui';
|
||||||
import problem from 'hydrooj/dist/model/problem';
|
import problem from 'hydrooj/src/model/problem';
|
||||||
import { PERM } from 'hydrooj/dist/model/builtin';
|
import { PERM } from 'hydrooj/src/model/builtin';
|
||||||
import { buildContent } from 'hydrooj/dist/lib/content';
|
import { buildContent } from 'hydrooj/src/lib/content';
|
||||||
import type { ContentNode, ProblemConfigFile } from 'hydrooj';
|
import type { ContentNode, ProblemConfigFile } from 'hydrooj';
|
||||||
|
|
||||||
fs.ensureDirSync('/tmp/hydro/import-qduoj');
|
fs.ensureDirSync('/tmp/hydro/import-qduoj');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'hydrooj';
|
import 'hydrooj';
|
||||||
import 'hydrooj/dist/utils';
|
import 'hydrooj/src/utils';
|
||||||
|
|
||||||
declare module 'hydrooj' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface Lib {
|
interface Lib {
|
||||||
oauth_qq: typeof import('./lib'),
|
oauth_qq: typeof import('./lib'),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { } from 'hydrooj';
|
import { } from 'hydrooj';
|
||||||
import * as bus from 'hydrooj/dist/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
|
|
||||||
declare module 'hydrooj' {
|
declare module 'hydrooj' {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import mysql from 'mysql';
|
import mysql from 'mysql';
|
||||||
import 'hydrooj';
|
import 'hydrooj';
|
||||||
import { buildContent } from 'hydrooj/dist/lib/content';
|
import { buildContent } from 'hydrooj/src/lib/content';
|
||||||
|
|
||||||
const { user, problem, system } = global.Hydro.model;
|
const { user, problem, system } = global.Hydro.model;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { UiContextBase } from 'hydrooj/dist/service/server';
|
import { UiContextBase } from 'hydrooj/src/service/server';
|
||||||
import * as system from 'hydrooj/dist/model/system';
|
import * as system from 'hydrooj/src/model/system';
|
||||||
|
|
||||||
declare module 'hydrooj/dist/service/server' {
|
declare module 'hydrooj/src/service/server' {
|
||||||
interface UiContextBase {
|
interface UiContextBase {
|
||||||
onlyofficeApi: string;
|
onlyofficeApi: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
import { ValidationError, ForbiddenError } from 'hydrooj/dist/error';
|
import { ValidationError, ForbiddenError } from 'hydrooj/src/error';
|
||||||
import { PRIV } from 'hydrooj/dist/model/builtin';
|
import { PRIV } from 'hydrooj/src/model/builtin';
|
||||||
import * as system from 'hydrooj/dist/model/system';
|
import * as system from 'hydrooj/src/model/system';
|
||||||
import * as bus from 'hydrooj/dist/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
|
|
||||||
bus.on('handler/before/UserRegister', async (thisArg) => {
|
bus.on('handler/before/UserRegister', async (thisArg) => {
|
||||||
if (!system.get('recaptcha.key')) return;
|
if (!system.get('recaptcha.key')) return;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as bus from 'hydrooj/dist/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
import * as system from 'hydrooj/dist/model/system';
|
import * as system from 'hydrooj/src/model/system';
|
||||||
import sonic from './service';
|
import sonic from './service';
|
||||||
|
|
||||||
bus.on('problem/add', async (doc, docId) => {
|
bus.on('problem/add', async (doc, docId) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { iterateAllProblem, iterateAllProblemInDomain } from 'hydrooj/dist/pipelineUtils';
|
import { iterateAllProblem, iterateAllProblemInDomain } from 'hydrooj/src/pipelineUtils';
|
||||||
import sonic from './service';
|
import sonic from './service';
|
||||||
|
|
||||||
export const description = 'Sonic problem search re-index';
|
export const description = 'Sonic problem search re-index';
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { BaseService } from 'hydrooj';
|
import { BaseService } from 'hydrooj';
|
||||||
import * as system from 'hydrooj/dist/model/system';
|
import * as system from 'hydrooj/src/model/system';
|
||||||
import { Logger } from 'hydrooj/dist/logger';
|
import { Logger } from 'hydrooj/src/logger';
|
||||||
import {
|
import {
|
||||||
Search, Ingest, QueryOptions, SuggestOptions, PushOptions,
|
Search, Ingest, QueryOptions, SuggestOptions, PushOptions,
|
||||||
} from 'sonic-channel';
|
} from 'sonic-channel';
|
||||||
|
|
||||||
const logger = new Logger('sonic');
|
const logger = new Logger('sonic');
|
||||||
|
|
||||||
declare module 'hydrooj/dist/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface SystemKeys {
|
interface SystemKeys {
|
||||||
'sonic.host': string;
|
'sonic.host': string;
|
||||||
'sonic.port': number;
|
'sonic.port': number;
|
||||||
@@ -110,7 +110,7 @@ class SonicService implements BaseService {
|
|||||||
const service = new SonicService();
|
const service = new SonicService();
|
||||||
global.Hydro.service.sonic = service;
|
global.Hydro.service.sonic = service;
|
||||||
export = service;
|
export = service;
|
||||||
declare module 'hydrooj/dist/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface Service {
|
interface Service {
|
||||||
sonic: typeof service
|
sonic: typeof service
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module.exports = {
|
|||||||
webpack: {
|
webpack: {
|
||||||
config: {
|
config: {
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx'],
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
alias: {
|
alias: {
|
||||||
vj: path.resolve(__dirname),
|
vj: path.resolve(__dirname),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const esbuild = require('esbuild');
|
||||||
|
const { renderToString } = require('react-dom/server');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
const serialize = require('serialize-javascript');
|
const serialize = require('serialize-javascript');
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ const { join } = require('path');
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const { tmpdir } = require('os');
|
const { tmpdir } = require('os');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
const bus = require('hydrooj/dist/service/bus');
|
const bus = require('hydrooj/src/service/bus');
|
||||||
const { PERM } = require('hydrooj/dist/model/builtin');
|
const { PERM } = require('hydrooj/src/model/builtin');
|
||||||
const markdown = require('./backendlib/markdown');
|
const markdown = require('./backendlib/markdown');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -113,6 +113,7 @@
|
|||||||
"webpackbar": "^5.0.0-3"
|
"webpackbar": "^5.0.0-3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"esbuild": "^0.12.16",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsesc": "^3.0.2",
|
"jsesc": "^3.0.2",
|
||||||
"katex": "^0.13.13",
|
"katex": "^0.13.13",
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
(() => {
|
||||||
|
const { NamedPage } = window.Hydro;
|
||||||
|
const { $ } = window.node_modules;
|
||||||
|
const { request, i18n, tpl } = window.Hydro.utils;
|
||||||
|
const { ConfirmDialog } = window.Hydro.components;
|
||||||
|
|
||||||
|
const page = new NamedPage('course_detail', async () => {
|
||||||
|
$(document).on('click', '[name="course_buy"]', async (ev) => {
|
||||||
|
const message = '购买课程';
|
||||||
|
const action = await new ConfirmDialog({
|
||||||
|
$body: tpl`
|
||||||
|
<div class="typo">
|
||||||
|
<h3>${i18n(message)}</h3>
|
||||||
|
</div>`,
|
||||||
|
}).open();
|
||||||
|
if (action !== 'yes') return;
|
||||||
|
window.open(`/course/buy/${UiContext.cdoc._id}`, '_blank');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
window.Hydro.extraPages.push(page);
|
||||||
|
})();
|
||||||
@@ -7,7 +7,7 @@ export interface RemoteAccount {
|
|||||||
endpoint?: string;
|
endpoint?: string;
|
||||||
proxy?: string;
|
proxy?: string;
|
||||||
}
|
}
|
||||||
declare module 'hydrooj/dist/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
interface Collections {
|
interface Collections {
|
||||||
vjudge: RemoteAccount;
|
vjudge: RemoteAccount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import { Logger } from 'hydrooj/dist/logger';
|
import { Logger } from 'hydrooj/src/logger';
|
||||||
import db from 'hydrooj/dist/service/db';
|
import db from 'hydrooj/src/service/db';
|
||||||
import * as bus from 'hydrooj/dist/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
import * as Judge from 'hydrooj/dist/handler/judge';
|
import * as Judge from 'hydrooj/src/handler/judge';
|
||||||
import TaskModel from 'hydrooj/dist/model/task';
|
import TaskModel from 'hydrooj/src/model/task';
|
||||||
import DomainModel from 'hydrooj/dist/model/domain';
|
import DomainModel from 'hydrooj/src/model/domain';
|
||||||
import ProblemModel from 'hydrooj/dist/model/problem';
|
import ProblemModel from 'hydrooj/src/model/problem';
|
||||||
import { STATUS } from 'hydrooj/dist/model/builtin';
|
import { STATUS } from 'hydrooj/src/model/builtin';
|
||||||
import { sleep } from '@hydrooj/utils/lib/utils';
|
import { sleep } from '@hydrooj/utils/lib/utils';
|
||||||
import providers from './providers/index';
|
import providers from './providers/index';
|
||||||
import { BasicProvider, IBasicProvider, RemoteAccount } from './interface';
|
import { BasicProvider, IBasicProvider, RemoteAccount } from './interface';
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import proxy from 'superagent-proxy';
|
|||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
import { STATUS } from '@hydrooj/utils/lib/status';
|
import { STATUS } from '@hydrooj/utils/lib/status';
|
||||||
import { sleep } from '@hydrooj/utils/lib/utils';
|
import { sleep } from '@hydrooj/utils/lib/utils';
|
||||||
import { buildContent } from 'hydrooj/dist/lib/content';
|
import { buildContent } from 'hydrooj/src/lib/content';
|
||||||
import * as setting from 'hydrooj/dist/model/setting';
|
import * as setting from 'hydrooj/src/model/setting';
|
||||||
import { Logger } from 'hydrooj/dist/logger';
|
import { Logger } from 'hydrooj/src/logger';
|
||||||
import { PassThrough } from 'stream';
|
import { PassThrough } from 'stream';
|
||||||
import { IBasicProvider, RemoteAccount } from '../interface';
|
import { IBasicProvider, RemoteAccount } from '../interface';
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { JSDOM } from 'jsdom';
|
|||||||
import { PassThrough } from 'stream';
|
import { PassThrough } from 'stream';
|
||||||
import { STATUS } from '@hydrooj/utils/lib/status';
|
import { STATUS } from '@hydrooj/utils/lib/status';
|
||||||
import { parseMemoryMB, sleep } from '@hydrooj/utils/lib/utils';
|
import { parseMemoryMB, sleep } from '@hydrooj/utils/lib/utils';
|
||||||
import * as setting from 'hydrooj/dist/model/setting';
|
import * as setting from 'hydrooj/src/model/setting';
|
||||||
import { Logger } from 'hydrooj/dist/logger';
|
import { Logger } from 'hydrooj/src/logger';
|
||||||
import { IBasicProvider, RemoteAccount } from '../interface';
|
import { IBasicProvider, RemoteAccount } from '../interface';
|
||||||
|
|
||||||
proxy(superagent);
|
proxy(superagent);
|
||||||
|
|||||||
Reference in new issue
Block a user