mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
chore(deps): update npm dependencies (#5561)
* chore(deps): update npm dependencies * fix: types * chore: replace vite-plugin-monaco-editor-esm with utils/monaco --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Slinetrac <realakayuki@gmail.com>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Slinetrac
parent
a271ba6ce5
commit
51760a5b95
@@ -0,0 +1,39 @@
|
||||
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
||||
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
|
||||
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
|
||||
import yamlWorker from "monaco-yaml/yaml.worker?worker";
|
||||
|
||||
type WorkerConstructor = new () => Worker;
|
||||
|
||||
// Align with the former plugin mapping so Monaco can resolve its background workers.
|
||||
const workerConstructors: Record<string, WorkerConstructor> = {
|
||||
editorWorkerService: editorWorker,
|
||||
typescript: tsWorker,
|
||||
javascript: tsWorker,
|
||||
"languages.typescript": tsWorker,
|
||||
css: cssWorker,
|
||||
less: cssWorker,
|
||||
scss: cssWorker,
|
||||
"languages.css": cssWorker,
|
||||
yaml: yamlWorker,
|
||||
};
|
||||
|
||||
const defaultWorker = workerConstructors.editorWorkerService;
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const globalScope = self as typeof self & {
|
||||
MonacoEnvironment?: {
|
||||
getWorker: (moduleId: string, label: string) => Worker;
|
||||
};
|
||||
};
|
||||
|
||||
const getWorker = (_moduleId: string, label: string) => {
|
||||
const WorkerCtor = workerConstructors[label] ?? defaultWorker;
|
||||
return new WorkerCtor();
|
||||
};
|
||||
|
||||
globalScope.MonacoEnvironment = {
|
||||
...globalScope.MonacoEnvironment,
|
||||
getWorker,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user