mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: monaco feature loader: support multi
This commit is contained in:
1 parent
6689604e48
commit
35402e6afc
2 files changed
+9
-3
No files matched your search
@@ -19,9 +19,12 @@ const loaders = {
|
||||
typescript: () => import('./languages/typescript'),
|
||||
yaml: () => import('./languages/yaml'),
|
||||
external: async (monaco, feat) => {
|
||||
let apply = await loadExternalModule(window.externalModules[`monaco-${feat}`]);
|
||||
const items = Object.keys(window.externalModules).filter((i) => i === `monaco-${feat}` || i.startsWith(`monaco-${feat}@`));
|
||||
for (const item of items) {
|
||||
let apply = await loadExternalModule(window.externalModules[`monaco-${item}`]);
|
||||
if (typeof apply !== 'function') apply = apply.default || apply.apply;
|
||||
if (typeof apply === 'function') await apply(monaco);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -38,10 +41,13 @@ export async function load(features = ['markdown']) {
|
||||
}
|
||||
for (const feat of features) {
|
||||
if (loaded.includes(feat)) continue;
|
||||
if (!loaders[feat] && !window.externalModules[`monaco-${feat}`]) {
|
||||
if (!loaders[feat]) {
|
||||
const items = Object.keys(window.externalModules).filter((i) => i === `monaco-${feat}` || i.startsWith(`monaco-${feat}@`));
|
||||
if (!items.length) {
|
||||
console.warn('Unknown monaco feature:', feat);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
s = Date.now();
|
||||
console.log('Loading monaco feature:', feat);
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.38.30",
|
||||
"version": "4.38.31",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user