stream-monaco 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -1
- package/README.zh-CN.md +67 -1
- package/dist/{index.base-D0jPJkA_.d.cts → index.base-9QTN8hPV.d.cts} +38 -4
- package/dist/{index.base-BaAqAXUs.d.ts → index.base-D0lzInae.d.ts} +39 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.legacy.cjs +142 -3
- package/dist/index.legacy.d.cts +5 -5
- package/dist/index.legacy.d.ts +15 -5
- package/dist/index.legacy.js +142 -3
- package/dist/{preloadMonacoWorkers.shared-gUKedCzF.cjs → preloadMonacoWorkers.shared-DMvZ1HUs.cjs} +1261 -31
- package/dist/{preloadMonacoWorkers.shared-C62vOlc9.js → preloadMonacoWorkers.shared-DQ17-Bwz.js} +1245 -33
- package/package.json +7 -2
package/dist/index.legacy.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import { RevealStrategy, clearHighlighterCache, defaultRevealDebounceMs, detectLanguage, getOrCreateHighlighter, registerMonacoThemes, useMonaco, workerPathByLabel } from "./preloadMonacoWorkers.shared-
|
|
1
|
+
import { RevealStrategy, clearHighlighterCache, defaultRevealDebounceMs, detectLanguage, getOrCreateHighlighter, monaco_shim_exports, processedLanguage, registerMonacoThemes, useMonaco, workerPathByLabel } from "./preloadMonacoWorkers.shared-DQ17-Bwz.js";
|
|
2
|
+
import { conf, language } from "monaco-editor/esm/vs/basic-languages/cpp/cpp";
|
|
3
|
+
import { conf as conf$1, language as language$1 } from "monaco-editor/esm/vs/basic-languages/javascript/javascript";
|
|
4
|
+
import { conf as conf$2, language as language$2 } from "monaco-editor/esm/vs/basic-languages/powershell/powershell";
|
|
5
|
+
import { conf as conf$3, language as language$3 } from "monaco-editor/esm/vs/basic-languages/python/python";
|
|
6
|
+
import { conf as conf$4, language as language$4 } from "monaco-editor/esm/vs/basic-languages/shell/shell";
|
|
7
|
+
import { conf as conf$5, language as language$5 } from "monaco-editor/esm/vs/basic-languages/typescript/typescript";
|
|
8
|
+
import "monaco-editor/esm/vs/editor/contrib/documentSymbols/browser/outlineModel";
|
|
9
|
+
import "monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestMemory";
|
|
10
|
+
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution";
|
|
11
|
+
import "monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution";
|
|
12
|
+
import "monaco-editor/esm/vs/basic-languages/python/python.contribution";
|
|
13
|
+
import "monaco-editor/esm/vs/basic-languages/cpp/cpp.contribution";
|
|
14
|
+
import "monaco-editor/esm/vs/basic-languages/shell/shell.contribution";
|
|
15
|
+
import "monaco-editor/esm/vs/basic-languages/powershell/powershell.contribution";
|
|
16
|
+
import "monaco-editor/esm/vs/language/json/monaco.contribution";
|
|
17
|
+
import "monaco-editor/esm/vs/language/typescript/monaco.contribution";
|
|
18
|
+
import "monaco-editor/esm/vs/language/html/monaco.contribution";
|
|
19
|
+
import "monaco-editor/esm/vs/language/css/monaco.contribution";
|
|
2
20
|
|
|
3
21
|
//#region src/ensureMonacoWorkers.legacy.ts
|
|
4
22
|
function normalizeBaseUrl(baseUrl) {
|
|
@@ -18,7 +36,7 @@ function detectMonacoBaseUrlFromScripts() {
|
|
|
18
36
|
for (const script of scripts) {
|
|
19
37
|
const src = script.getAttribute("src") || "";
|
|
20
38
|
if (!src) continue;
|
|
21
|
-
const loaderMatch = src.match(/^(.*)\/vs\/loader\.js
|
|
39
|
+
const loaderMatch = src.match(/^(.*)\/vs\/loader\.js.*$/);
|
|
22
40
|
if (loaderMatch) return normalizeBaseUrl(loaderMatch[1]);
|
|
23
41
|
const vsIndex = src.indexOf("/vs/");
|
|
24
42
|
if (vsIndex > 0) return normalizeBaseUrl(src.slice(0, vsIndex));
|
|
@@ -85,7 +103,7 @@ function ensureMonacoWorkersLegacy(options) {
|
|
|
85
103
|
if (!baseUrl) return;
|
|
86
104
|
const workerUrl = makeWorkerUrl(baseUrl);
|
|
87
105
|
if (!workerUrl) return;
|
|
88
|
-
|
|
106
|
+
globalThis.MonacoEnvironment = { getWorkerUrl() {
|
|
89
107
|
return workerUrl;
|
|
90
108
|
} };
|
|
91
109
|
} catch {}
|
|
@@ -118,6 +136,127 @@ async function preloadMonacoWorkers() {
|
|
|
118
136
|
|
|
119
137
|
//#endregion
|
|
120
138
|
//#region src/index.legacy.ts
|
|
139
|
+
const LEGACY_ONIG_INIT_KEY = "__streamMonacoLegacyOnigurumaInit__";
|
|
140
|
+
const LEGACY_ENGINE_KEY = "__streamMonacoLegacyShikiEngine__";
|
|
141
|
+
const LEGACY_ERROR_FILTER_KEY = "__streamMonacoLegacyMonacoErrorFilterInstalled__";
|
|
142
|
+
const LEGACY_FLAG_KEY = "__streamMonacoLegacy__";
|
|
143
|
+
const LEGACY_MONACO_LANGS_INIT_KEY = "__streamMonacoLegacyMonacoLangsInit__";
|
|
144
|
+
const LEGACY_TOKENS_PROVIDER_GUARD_KEY = "__streamMonacoLegacyTokensProviderGuardInstalled__";
|
|
145
|
+
function ensureLegacyOnigurumaInit() {
|
|
146
|
+
if (typeof globalThis === "undefined") return;
|
|
147
|
+
const g = globalThis;
|
|
148
|
+
if (g[LEGACY_ONIG_INIT_KEY]) return;
|
|
149
|
+
const init = (async () => {
|
|
150
|
+
try {
|
|
151
|
+
const shiki = await import("shiki");
|
|
152
|
+
if (typeof shiki.createJavaScriptRegexEngine === "function") return shiki.createJavaScriptRegexEngine();
|
|
153
|
+
return null;
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
g[LEGACY_ONIG_INIT_KEY] = init.then(() => true, () => false);
|
|
159
|
+
g[LEGACY_ENGINE_KEY] = init;
|
|
160
|
+
}
|
|
161
|
+
function ensureLegacyMonacoLanguageContributions() {
|
|
162
|
+
if (typeof globalThis === "undefined") return;
|
|
163
|
+
const g = globalThis;
|
|
164
|
+
if (g[LEGACY_MONACO_LANGS_INIT_KEY]) return;
|
|
165
|
+
const init = Promise.resolve().then(() => {
|
|
166
|
+
try {
|
|
167
|
+
const langs = monaco_shim_exports.languages;
|
|
168
|
+
if (typeof (langs === null || langs === void 0 ? void 0 : langs.setMonarchTokensProvider) === "function") {
|
|
169
|
+
var _langs$setLanguageCon, _langs$setLanguageCon2, _langs$setLanguageCon3, _langs$setLanguageCon4, _langs$setLanguageCon5, _langs$setLanguageCon6;
|
|
170
|
+
langs.setMonarchTokensProvider("javascript", language$1);
|
|
171
|
+
(_langs$setLanguageCon = langs.setLanguageConfiguration) === null || _langs$setLanguageCon === void 0 || _langs$setLanguageCon.call(langs, "javascript", conf$1);
|
|
172
|
+
langs.setMonarchTokensProvider("typescript", language$5);
|
|
173
|
+
(_langs$setLanguageCon2 = langs.setLanguageConfiguration) === null || _langs$setLanguageCon2 === void 0 || _langs$setLanguageCon2.call(langs, "typescript", conf$5);
|
|
174
|
+
langs.setMonarchTokensProvider("python", language$3);
|
|
175
|
+
(_langs$setLanguageCon3 = langs.setLanguageConfiguration) === null || _langs$setLanguageCon3 === void 0 || _langs$setLanguageCon3.call(langs, "python", conf$3);
|
|
176
|
+
langs.setMonarchTokensProvider("cpp", language);
|
|
177
|
+
(_langs$setLanguageCon4 = langs.setLanguageConfiguration) === null || _langs$setLanguageCon4 === void 0 || _langs$setLanguageCon4.call(langs, "cpp", conf);
|
|
178
|
+
langs.setMonarchTokensProvider("shell", language$4);
|
|
179
|
+
(_langs$setLanguageCon5 = langs.setLanguageConfiguration) === null || _langs$setLanguageCon5 === void 0 || _langs$setLanguageCon5.call(langs, "shell", conf$4);
|
|
180
|
+
langs.setMonarchTokensProvider("powershell", language$2);
|
|
181
|
+
(_langs$setLanguageCon6 = langs.setLanguageConfiguration) === null || _langs$setLanguageCon6 === void 0 || _langs$setLanguageCon6.call(langs, "powershell", conf$2);
|
|
182
|
+
}
|
|
183
|
+
} catch {}
|
|
184
|
+
try {
|
|
185
|
+
for (const model of monaco_shim_exports.editor.getModels()) {
|
|
186
|
+
const current = model.getLanguageId();
|
|
187
|
+
const next = processedLanguage(current) || current;
|
|
188
|
+
if (next !== current) monaco_shim_exports.editor.setModelLanguage(model, next);
|
|
189
|
+
else monaco_shim_exports.editor.setModelLanguage(model, current);
|
|
190
|
+
}
|
|
191
|
+
} catch {}
|
|
192
|
+
});
|
|
193
|
+
g[LEGACY_MONACO_LANGS_INIT_KEY] = init;
|
|
194
|
+
}
|
|
195
|
+
function ensureLegacyTokensProviderGuard() {
|
|
196
|
+
if (typeof globalThis === "undefined") return;
|
|
197
|
+
const g = globalThis;
|
|
198
|
+
if (g[LEGACY_TOKENS_PROVIDER_GUARD_KEY]) return;
|
|
199
|
+
g[LEGACY_TOKENS_PROVIDER_GUARD_KEY] = true;
|
|
200
|
+
try {
|
|
201
|
+
const langs = monaco_shim_exports.languages;
|
|
202
|
+
const setTokensProvider = typeof (langs === null || langs === void 0 ? void 0 : langs.setTokensProvider) === "function" ? langs.setTokensProvider.bind(langs) : null;
|
|
203
|
+
if (!setTokensProvider) return;
|
|
204
|
+
langs.setTokensProvider = (lang, provider) => {
|
|
205
|
+
if (provider && typeof provider.tokenize === "function") {
|
|
206
|
+
const originalTokenize = provider.tokenize.bind(provider);
|
|
207
|
+
const getInitialState = typeof provider.getInitialState === "function" ? provider.getInitialState.bind(provider) : null;
|
|
208
|
+
const wrappedProvider = {
|
|
209
|
+
...provider,
|
|
210
|
+
tokenize(line, state) {
|
|
211
|
+
try {
|
|
212
|
+
return originalTokenize(line, state);
|
|
213
|
+
} catch {
|
|
214
|
+
return {
|
|
215
|
+
endState: state,
|
|
216
|
+
tokens: [{
|
|
217
|
+
startIndex: 0,
|
|
218
|
+
scopes: ""
|
|
219
|
+
}]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
try {
|
|
225
|
+
const st = getInitialState ? getInitialState() : null;
|
|
226
|
+
wrappedProvider.tokenize("const a = 1", st);
|
|
227
|
+
} catch {
|
|
228
|
+
return { dispose() {} };
|
|
229
|
+
}
|
|
230
|
+
return setTokensProvider(lang, wrappedProvider);
|
|
231
|
+
}
|
|
232
|
+
return setTokensProvider(lang, provider);
|
|
233
|
+
};
|
|
234
|
+
} catch {}
|
|
235
|
+
}
|
|
236
|
+
function ensureLegacyMonacoErrorFilter() {
|
|
237
|
+
if (typeof globalThis === "undefined") return;
|
|
238
|
+
const g = globalThis;
|
|
239
|
+
if (g[LEGACY_ERROR_FILTER_KEY]) return;
|
|
240
|
+
g[LEGACY_ERROR_FILTER_KEY] = true;
|
|
241
|
+
(async () => {
|
|
242
|
+
try {
|
|
243
|
+
const mod = await import("monaco-editor/esm/vs/base/common/errors.js");
|
|
244
|
+
const handler = mod === null || mod === void 0 ? void 0 : mod.errorHandler;
|
|
245
|
+
if (!handler || typeof handler.unexpectedErrorHandler !== "function") return;
|
|
246
|
+
const prev = handler.unexpectedErrorHandler.bind(handler);
|
|
247
|
+
handler.unexpectedErrorHandler = (err) => {
|
|
248
|
+
const msg = (err === null || err === void 0 ? void 0 : err.message) ? String(err.message) : String(err);
|
|
249
|
+
if (msg.includes("compileAG") || msg.includes("Cannot read properties of null (reading")) return;
|
|
250
|
+
return prev(err);
|
|
251
|
+
};
|
|
252
|
+
} catch {}
|
|
253
|
+
})();
|
|
254
|
+
}
|
|
255
|
+
ensureLegacyOnigurumaInit();
|
|
256
|
+
globalThis[LEGACY_FLAG_KEY] = true;
|
|
257
|
+
ensureLegacyMonacoLanguageContributions();
|
|
258
|
+
ensureLegacyTokensProviderGuard();
|
|
259
|
+
ensureLegacyMonacoErrorFilter();
|
|
121
260
|
ensureMonacoWorkersLegacy();
|
|
122
261
|
|
|
123
262
|
//#endregion
|