workspace: add ui-next

This commit is contained in:
undefined committed 2025-03-07 17:26:27 +08:00
1 parent 209cee98b5
commit d009eb4147
14 files changed
+1087 -903

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
"@aws-sdk/lib-storage": "3.726.1",
"@aws-sdk/s3-presigned-post": "3.726.1",
"@aws-sdk/s3-request-presigner": "3.726.1",
"@cordisjs/core": "4.0.0-alpha.1",
"@cordisjs/core": "4.0.0-alpha.2",
"@cordisjs/logger": "1.0.0-alpha.1",
"@cordisjs/plugin-timer": "1.0.0-alpha.0",
"@graphql-tools/schema": "^10.0.21",
@@ -111,7 +111,7 @@ function block(state, start, end, silent) {
}
export default function plugin(md) {
const options = { throwOnError: false, strict: 'ignore', displayMode: false };
const options = { throwOnError: false, strict: 'ignore' as 'ignore', displayMode: false };
const render = (latex: string, displayMode = false) => {
options.displayMode = displayMode;
try {
+2 -2
View File
@@ -15,7 +15,7 @@
},
"devDependencies": {
"@blueprintjs/core": "^5.17.5",
"@cordisjs/core": "4.0.0-alpha.1",
"@cordisjs/core": "4.0.0-alpha.2",
"@fontsource/dm-mono": "^5.2.5",
"@fontsource/fira-code": "^5.2.5",
"@fontsource/inconsolata": "^5.2.5",
@@ -25,7 +25,7 @@
"@fontsource/source-code-pro": "^5.2.5",
"@fontsource/ubuntu-mono": "^5.2.5",
"@hydrooj/utils": "workspace:^",
"@sentry/browser": "^9.3.0",
"@sentry/browser": "^9.5.0",
"@sentry/webpack-plugin": "^3.2.2",
"@simplewebauthn/browser": "13.1.0",
"@svgr/webpack": "^8.1.0",
+13
View File
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hydro</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
import path from 'path';
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin';
import react from '@vitejs/plugin-react-swc';
import c2k from 'koa2-connect';
import _ from 'lodash';
import { createServer } from 'vite';
import { } from '@hydrooj/framework';
import {
BadRequestError, Context, db, DocumentModel, Handler, ObjectId, param, ProblemModel, RecordModel, SettingModel,
StorageModel,
} from 'hydrooj';
export async function apply(ctx: Context) {
if (process.env.HYDRO_CLI) return;
const vite = await createServer({
server: {
middlewareMode: true,
hmr: {
port: 3010,
},
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
allowedHosts: ['beta.hydro.ac'],
},
appType: 'custom',
root: __dirname,
base: '/',
plugins: [react()],
optimizeDeps: {
esbuildOptions: {
plugins: [
// @ts-ignore
importMetaUrlPlugin,
],
},
},
worker: {
format: 'es',
},
});
const middleware = c2k(vite.middlewares);
const capture = ['/@vite/', '/src/', '/node_modules/', '/@react-refresh', '/@fs'];
for (const route of capture) {
ctx.server.addCaptureRoute(route, middleware);
}
const html = require('fs').readFileSync(path.join(__dirname, 'index.html'), 'utf-8');
console.log(html);
ctx.server.registerRenderer('next', {
name: 'next',
accept: ['main.html'],
output: 'html',
asFallback: false,
priority: 100,
render: async (name, args, context) => await vite.transformIndexHtml(context.handler.context.req.url, html),
});
ctx.on('dispose', async () => {
await vite.close().catch((e) => console.error(e));
});
}
+29
View File
@@ -0,0 +1,29 @@
{
"name": "@hydrooj/ui-next",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@vitejs/plugin-react": "^4.3.4",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@vitejs/plugin-react-swc": "^3.8.0",
"eslint": "^9.21.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"typescript": "~5.8.2",
"typescript-eslint": "^8.26.0",
"vite": "^6.2.1"
}
}
+5
View File
@@ -0,0 +1,5 @@
function App() {
return <div></div>;
}
export default App;
+7
View File
@@ -0,0 +1,7 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
createRoot(document.getElementById('root')!).render(<StrictMode>
<App />
</StrictMode>);
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />