From 8c26c42e0cba5d1f4237770eb15e22185fd77f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD?= <3401797899@qq.com> Date: Mon, 27 Jul 2026 21:02:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(filelib-web):=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=A2=9E=E5=8A=A0=20Typst=20=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E9=AB=98=E4=BA=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hub/filelib-web/package-lock.json | 74 ++++++++--------------- hub/filelib-web/package.json | 4 +- hub/filelib-web/src/lib/CodeEditor.svelte | 4 ++ hub/filelib-web/vite.config.ts | 3 +- 4 files changed, 35 insertions(+), 50 deletions(-) diff --git a/hub/filelib-web/package-lock.json b/hub/filelib-web/package-lock.json index 0e71f79..d027ac2 100644 --- a/hub/filelib-web/package-lock.json +++ b/hub/filelib-web/package-lock.json @@ -14,7 +14,9 @@ "@codemirror/lang-json": "^6.0.2", "@codemirror/lang-markdown": "^6.5.1", "@codemirror/language": "^6.12.4", - "codemirror": "^6.0.2" + "codemirror": "^6.0.2", + "codemirror-lang-typst": "^0.4.0", + "vite-plugin-wasm": "^3.6.0" }, "devDependencies": { "@sveltejs/adapter-static": "^3.0.10", @@ -183,7 +185,6 @@ "version": "1.11.1", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz", "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -195,7 +196,6 @@ "version": "1.11.1", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz", "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -206,7 +206,6 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz", "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -351,7 +350,6 @@ "version": "1.1.6", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz", "integrity": "sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -370,7 +368,6 @@ "version": "0.139.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.139.0.tgz", "integrity": "sha512-r9gHphtCs+1M7J0pw6Sn/hh/Wpa/iQrOOkrNAlVLF/gHq+/CJmHIWKKUUhdWjcD6CIa8idarspCsASiXCXvFUw==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/Boshen" @@ -390,7 +387,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -407,7 +403,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -424,7 +419,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -441,7 +435,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -458,7 +451,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -475,7 +467,6 @@ "cpu": [ "arm64" ], - "dev": true, "libc": [ "glibc" ], @@ -495,7 +486,6 @@ "cpu": [ "arm64" ], - "dev": true, "libc": [ "musl" ], @@ -515,7 +505,6 @@ "cpu": [ "ppc64" ], - "dev": true, "libc": [ "glibc" ], @@ -535,7 +524,6 @@ "cpu": [ "s390x" ], - "dev": true, "libc": [ "glibc" ], @@ -555,7 +543,6 @@ "cpu": [ "x64" ], - "dev": true, "libc": [ "glibc" ], @@ -575,7 +562,6 @@ "cpu": [ "x64" ], - "dev": true, "libc": [ "musl" ], @@ -595,7 +581,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -612,7 +597,6 @@ "cpu": [ "wasm32" ], - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -631,7 +615,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -648,7 +631,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -662,7 +644,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", - "dev": true, "license": "MIT" }, "node_modules/@standard-schema/spec": { @@ -1052,7 +1033,6 @@ "version": "0.10.3", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -1154,6 +1134,19 @@ "@codemirror/view": "^6.0.0" } }, + "node_modules/codemirror-lang-typst": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/codemirror-lang-typst/-/codemirror-lang-typst-0.4.0.tgz", + "integrity": "sha512-jpHz5qQRC3LE48JH+C24qZJAEAhjqRzWA4MFodPaxriz7UwLVuTLCQ672rdDx9ziObBQ2BvHaRIm5/Upz4KoBQ==", + "license": "Apache-2.0", + "dependencies": { + "@codemirror/language": "^6.11.2", + "@codemirror/state": "^6.5.2", + "@codemirror/view": "^6.38.1", + "@lezer/common": "^1.2.3", + "@lezer/highlight": "^1.2.1" + } + }, "node_modules/cookie": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", @@ -1184,7 +1177,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -1240,7 +1232,6 @@ "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12.0.0" @@ -1258,7 +1249,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -1290,7 +1280,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", - "dev": true, + "devOptional": true, "license": "MIT", "bin": { "jiti": "lib/jiti-cli.mjs" @@ -1310,7 +1300,6 @@ "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", - "dev": true, "license": "MPL-2.0", "dependencies": { "detect-libc": "^2.0.3" @@ -1343,7 +1332,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1364,7 +1352,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1385,7 +1372,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1406,7 +1392,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1427,7 +1412,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1448,7 +1432,6 @@ "cpu": [ "arm64" ], - "dev": true, "libc": [ "glibc" ], @@ -1472,7 +1455,6 @@ "cpu": [ "arm64" ], - "dev": true, "libc": [ "musl" ], @@ -1496,7 +1478,6 @@ "cpu": [ "x64" ], - "dev": true, "libc": [ "glibc" ], @@ -1520,7 +1501,6 @@ "cpu": [ "x64" ], - "dev": true, "libc": [ "musl" ], @@ -1544,7 +1524,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1565,7 +1544,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -1620,7 +1598,6 @@ "version": "3.3.16", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz", "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==", - "dev": true, "funding": [ { "type": "github", @@ -1653,14 +1630,12 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, "license": "ISC" }, "node_modules/picomatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1673,7 +1648,6 @@ "version": "8.5.22", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.22.tgz", "integrity": "sha512-KBDEIpLrvpv16pp3K0Fw+UCoZfopFjjgeB+0tA/aaThfEE74kKDLrgg603YvOWJyg3+WYtyq3xYsQWsIyZlPqQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -1716,7 +1690,6 @@ "version": "1.1.5", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz", "integrity": "sha512-t9z29cJjXf/vxQ8dyhCSpt6H6aSwHTk8cT5I3iy6SMXuFpk5mB6PL6XfC8PCwrPTx93udwKUm9HRteAlTGBLiA==", - "dev": true, "license": "MIT", "dependencies": { "@oxc-project/types": "=0.139.0", @@ -1785,7 +1758,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -1875,7 +1847,6 @@ "version": "0.2.17", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", - "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", @@ -1902,7 +1873,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, "license": "0BSD", "optional": true }, @@ -1924,7 +1894,6 @@ "version": "8.1.5", "resolved": "https://registry.npmjs.org/vite/-/vite-8.1.5.tgz", "integrity": "sha512-7ULLwsCdYx/nRyrpiEwvqb5TFHrMVZyBt+rg/OAXT7rgj/z+DtTDyKFeLAdDkubDVDKD8jOsndmy7m55XcfUsw==", - "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.32.0", @@ -1998,6 +1967,15 @@ } } }, + "node_modules/vite-plugin-wasm": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/vite-plugin-wasm/-/vite-plugin-wasm-3.6.0.tgz", + "integrity": "sha512-mL/QPziiIA4RAA6DkaZZzOstdwbW5jO4Vz7Zenj0wieKWBlNvIvX5L5ljum9lcUX0ShNfBgCNLKTjNkRVVqcsw==", + "license": "MIT", + "peerDependencies": { + "vite": "^2 || ^3 || ^4 || ^5 || ^6 || ^7 || ^8" + } + }, "node_modules/vitefu": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz", diff --git a/hub/filelib-web/package.json b/hub/filelib-web/package.json index 351a869..502ad06 100644 --- a/hub/filelib-web/package.json +++ b/hub/filelib-web/package.json @@ -28,6 +28,8 @@ "@codemirror/lang-json": "^6.0.2", "@codemirror/lang-markdown": "^6.5.1", "@codemirror/language": "^6.12.4", - "codemirror": "^6.0.2" + "codemirror": "^6.0.2", + "codemirror-lang-typst": "^0.4.0", + "vite-plugin-wasm": "^3.6.0" } } diff --git a/hub/filelib-web/src/lib/CodeEditor.svelte b/hub/filelib-web/src/lib/CodeEditor.svelte index f07f553..2616c87 100644 --- a/hub/filelib-web/src/lib/CodeEditor.svelte +++ b/hub/filelib-web/src/lib/CodeEditor.svelte @@ -11,6 +11,7 @@ import { json } from "@codemirror/lang-json"; import { html } from "@codemirror/lang-html"; import { css } from "@codemirror/lang-css"; + import { typst } from "codemirror-lang-typst"; import type { Extension } from "@codemirror/state"; let { value = "", readonly = false, filename = "", onchange }: { @@ -53,6 +54,9 @@ case "css": case "scss": return [css()]; + case "typ": + case "typst": + return [typst()]; default: return []; } diff --git a/hub/filelib-web/vite.config.ts b/hub/filelib-web/vite.config.ts index ef7e8d4..21e67aa 100644 --- a/hub/filelib-web/vite.config.ts +++ b/hub/filelib-web/vite.config.ts @@ -1,5 +1,6 @@ import { sveltekit } from "@sveltejs/kit/vite"; import tailwindcss from "@tailwindcss/vite"; +import wasm from "vite-plugin-wasm"; import { defineConfig } from "vite"; // 老师端 /app + 管理后台 /database/* 的唯一前端工程;构建产物由 hub 后端静态托管。 @@ -8,7 +9,7 @@ import { defineConfig } from "vite"; const backend = "http://127.0.0.1:8788"; export default defineConfig({ - plugins: [tailwindcss(), sveltekit()], + plugins: [wasm(), tailwindcss(), sveltekit()], server: { port: 5173, proxy: {