modern-monaco 0.0.0-beta.0 → 0.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +129 -87
- package/dist/cache.js +1 -1
- package/dist/core.js +479 -0
- package/dist/editor-core.js +128 -21
- package/dist/index.js +29166 -449
- package/dist/lsp/css/setup.js +6 -7
- package/dist/lsp/css/worker.js +8961 -1355
- package/dist/lsp/html/setup.js +7 -8
- package/dist/lsp/html/worker.js +6506 -672
- package/dist/lsp/json/setup.js +5 -6
- package/dist/lsp/json/worker.js +395 -393
- package/dist/lsp/language-service.js +21 -21
- package/dist/lsp/typescript/libs.js +11 -9
- package/dist/lsp/typescript/setup.js +6 -7
- package/dist/shiki-wasm.js +1 -1
- package/dist/shiki.js +129 -751
- package/dist/ssr/index.js +13 -18
- package/dist/ssr/workerd.js +13 -18
- package/dist/util.js +7 -3
- package/dist/workspace.js +16 -16
- package/package.json +31 -13
- package/types/core.d.ts +4 -0
- package/types/index.d.ts +31 -8
- package/types/jsonSchema.d.ts +2 -0
- package/types/lsp.d.ts +7 -1
- package/types/ssr.d.ts +5 -5
- package/types/textmate.d.ts +1 -1
- package/types/cache.d.ts +0 -7
package/dist/core.js
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
// src/lsp/index.ts
|
|
2
|
+
function createWebWorker(url, name) {
|
|
3
|
+
let workerUrl = url;
|
|
4
|
+
if (url.origin !== location.origin) {
|
|
5
|
+
workerUrl = URL.createObjectURL(new Blob([`import "${url.href}"`], { type: "application/javascript" }));
|
|
6
|
+
}
|
|
7
|
+
return new Worker(workerUrl, {
|
|
8
|
+
type: "module",
|
|
9
|
+
name: name ?? url.pathname.slice(1).split("/").slice(-2).join("/")
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/core.ts
|
|
14
|
+
import { getLanguageIdFromPath, initShiki, setDefaultWasmLoader, tmGrammars, tmThemes } from "./shiki.js";
|
|
15
|
+
import { initShikiMonacoTokenizer, registerShikiMonacoTokenizer } from "./shiki.js";
|
|
16
|
+
import { render } from "./shiki.js";
|
|
17
|
+
import { getWasmInstance } from "./shiki-wasm.js";
|
|
18
|
+
import { ErrorNotFound, Workspace } from "./workspace.js";
|
|
19
|
+
|
|
20
|
+
// src/util.ts
|
|
21
|
+
var dec = /* @__PURE__ */ new TextDecoder();
|
|
22
|
+
function decode(data) {
|
|
23
|
+
return data instanceof Uint8Array ? dec.decode(data) : data;
|
|
24
|
+
}
|
|
25
|
+
function isDigital(v) {
|
|
26
|
+
return typeof v === "number" || typeof v === "string" && /^\d+$/.test(v);
|
|
27
|
+
}
|
|
28
|
+
function debunce(fn, delay) {
|
|
29
|
+
let timer = null;
|
|
30
|
+
return () => {
|
|
31
|
+
if (timer !== null) {
|
|
32
|
+
clearTimeout(timer);
|
|
33
|
+
}
|
|
34
|
+
timer = setTimeout(() => {
|
|
35
|
+
timer = null;
|
|
36
|
+
fn();
|
|
37
|
+
}, delay);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function promiseWithResolvers() {
|
|
41
|
+
let resolve;
|
|
42
|
+
let reject;
|
|
43
|
+
const promise = new Promise((res, rej) => {
|
|
44
|
+
resolve = res;
|
|
45
|
+
reject = rej;
|
|
46
|
+
});
|
|
47
|
+
return { promise, resolve, reject };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/core.ts
|
|
51
|
+
import { init as initLS } from "./lsp/language-service.js";
|
|
52
|
+
var editorProps = [
|
|
53
|
+
"autoDetectHighContrast",
|
|
54
|
+
"automaticLayout",
|
|
55
|
+
"contextmenu",
|
|
56
|
+
"cursorBlinking",
|
|
57
|
+
"cursorSmoothCaretAnimation",
|
|
58
|
+
"cursorStyle",
|
|
59
|
+
"cursorWidth",
|
|
60
|
+
"fontFamily",
|
|
61
|
+
"fontLigatures",
|
|
62
|
+
"fontSize",
|
|
63
|
+
"fontVariations",
|
|
64
|
+
"fontWeight",
|
|
65
|
+
"letterSpacing",
|
|
66
|
+
"lineHeight",
|
|
67
|
+
"lineNumbers",
|
|
68
|
+
"lineNumbersMinChars",
|
|
69
|
+
"matchBrackets",
|
|
70
|
+
"minimap",
|
|
71
|
+
"mouseStyle",
|
|
72
|
+
"multiCursorModifier",
|
|
73
|
+
"padding",
|
|
74
|
+
"readOnly",
|
|
75
|
+
"readOnlyMessage",
|
|
76
|
+
"rulers",
|
|
77
|
+
"scrollbar",
|
|
78
|
+
"stickyScroll",
|
|
79
|
+
"tabSize",
|
|
80
|
+
"theme",
|
|
81
|
+
"wordWrap"
|
|
82
|
+
];
|
|
83
|
+
var errors = {
|
|
84
|
+
NotFound: ErrorNotFound
|
|
85
|
+
};
|
|
86
|
+
var builtinLSPProviders = {};
|
|
87
|
+
var builtinSyntaxes = [];
|
|
88
|
+
async function init(options) {
|
|
89
|
+
const langs = (options?.langs ?? []).concat(builtinSyntaxes);
|
|
90
|
+
const hightlighter = await initShiki({ ...options, langs });
|
|
91
|
+
return loadMonaco(hightlighter, options?.workspace, options?.lsp);
|
|
92
|
+
}
|
|
93
|
+
async function lazy(options, hydrate2) {
|
|
94
|
+
const workspace = options?.workspace;
|
|
95
|
+
const { promise: editorWorkerPromise, resolve: onDidEditorWorkerResolve } = promiseWithResolvers();
|
|
96
|
+
let monacoCore = null;
|
|
97
|
+
function load(highlighter) {
|
|
98
|
+
if (monacoCore) {
|
|
99
|
+
return monacoCore;
|
|
100
|
+
}
|
|
101
|
+
return monacoCore = loadMonaco(highlighter, workspace, options?.lsp, onDidEditorWorkerResolve).then((m) => monacoCore = m);
|
|
102
|
+
}
|
|
103
|
+
function setStyle(el, style) {
|
|
104
|
+
Object.assign(el.style, style);
|
|
105
|
+
}
|
|
106
|
+
function getAttr(el, name) {
|
|
107
|
+
return el.getAttribute(name);
|
|
108
|
+
}
|
|
109
|
+
customElements.define(
|
|
110
|
+
"monaco-editor",
|
|
111
|
+
class extends HTMLElement {
|
|
112
|
+
async connectedCallback() {
|
|
113
|
+
const renderOptions = {};
|
|
114
|
+
for (const attrName of this.getAttributeNames()) {
|
|
115
|
+
const key = editorProps.find((k) => k.toLowerCase() === attrName);
|
|
116
|
+
if (key) {
|
|
117
|
+
let value = getAttr(this, attrName);
|
|
118
|
+
if (value === "") {
|
|
119
|
+
value = key === "minimap" || key === "stickyScroll" ? { enabled: true } : true;
|
|
120
|
+
} else {
|
|
121
|
+
value = value.trim();
|
|
122
|
+
if (value === "true") {
|
|
123
|
+
value = true;
|
|
124
|
+
} else if (value === "false") {
|
|
125
|
+
value = false;
|
|
126
|
+
} else if (value === "null") {
|
|
127
|
+
value = null;
|
|
128
|
+
} else if (/^\d+$/.test(value)) {
|
|
129
|
+
value = Number(value);
|
|
130
|
+
} else if (/^\{.+\}$/.test(value)) {
|
|
131
|
+
try {
|
|
132
|
+
value = JSON.parse(value);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
value = void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (key === "padding") {
|
|
139
|
+
if (typeof value === "number") {
|
|
140
|
+
value = { top: value, bottom: value };
|
|
141
|
+
} else if (/^\d+\s+\d+$/.test(value)) {
|
|
142
|
+
const [top, bottom] = value.split(/\s+/);
|
|
143
|
+
if (top && bottom) {
|
|
144
|
+
value = { top: Number(top), bottom: Number(bottom) };
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
value = void 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (key === "wordWrap" && (value === "on" || value === true)) {
|
|
151
|
+
value = "on";
|
|
152
|
+
}
|
|
153
|
+
if (value !== void 0) {
|
|
154
|
+
renderOptions[key] = value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let filename;
|
|
159
|
+
let code;
|
|
160
|
+
if (hydrate2) {
|
|
161
|
+
const optionsEl = this.children[0];
|
|
162
|
+
if (optionsEl && optionsEl.tagName === "SCRIPT" && optionsEl.className === "monaco-editor-options") {
|
|
163
|
+
try {
|
|
164
|
+
const v = JSON.parse(optionsEl.textContent);
|
|
165
|
+
if (Array.isArray(v) && v.length === 2) {
|
|
166
|
+
const [input, opts] = v;
|
|
167
|
+
Object.assign(renderOptions, opts);
|
|
168
|
+
if (opts.fontDigitWidth) {
|
|
169
|
+
Reflect.set(globalThis, "__monaco_maxDigitWidth", opts.fontDigitWidth);
|
|
170
|
+
}
|
|
171
|
+
if (typeof input === "string") {
|
|
172
|
+
code = input;
|
|
173
|
+
} else {
|
|
174
|
+
filename = input.filename;
|
|
175
|
+
code = input.code;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
optionsEl.remove();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
setStyle(this, { display: "block", position: "relative" });
|
|
184
|
+
let widthAttr = getAttr(this, "width");
|
|
185
|
+
let heightAttr = getAttr(this, "height");
|
|
186
|
+
if (isDigital(widthAttr) && isDigital(heightAttr)) {
|
|
187
|
+
const width = Number(widthAttr);
|
|
188
|
+
const height = Number(heightAttr);
|
|
189
|
+
setStyle(this, { width: width + "px", height: height + "px" });
|
|
190
|
+
renderOptions.dimension = { width, height };
|
|
191
|
+
} else {
|
|
192
|
+
if (isDigital(widthAttr)) {
|
|
193
|
+
widthAttr += "px";
|
|
194
|
+
}
|
|
195
|
+
if (isDigital(heightAttr)) {
|
|
196
|
+
heightAttr += "px";
|
|
197
|
+
}
|
|
198
|
+
this.style.width ||= widthAttr ?? "100%";
|
|
199
|
+
this.style.height ||= heightAttr ?? "100%";
|
|
200
|
+
}
|
|
201
|
+
const containerEl = document.createElement("div");
|
|
202
|
+
containerEl.className = "monaco-editor-container";
|
|
203
|
+
setStyle(containerEl, { width: "100%", height: "100%" });
|
|
204
|
+
this.appendChild(containerEl);
|
|
205
|
+
if (!filename && workspace) {
|
|
206
|
+
if (workspace.history.state.current) {
|
|
207
|
+
filename = workspace.history.state.current;
|
|
208
|
+
} else if (workspace.entryFile) {
|
|
209
|
+
filename = workspace.entryFile;
|
|
210
|
+
workspace.history.replace(filename);
|
|
211
|
+
} else {
|
|
212
|
+
const rootFiles = (await workspace.fs.readDirectory("/")).filter(([name, type]) => type === 1).map(([name]) => name);
|
|
213
|
+
filename = rootFiles.includes("index.html") ? "index.html" : rootFiles[0];
|
|
214
|
+
if (filename) {
|
|
215
|
+
workspace.history.replace(filename);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const langs = (options?.langs ?? []).concat(builtinSyntaxes);
|
|
220
|
+
if (renderOptions.language || filename) {
|
|
221
|
+
const lang = renderOptions.language ?? getLanguageIdFromPath(filename) ?? "plaintext";
|
|
222
|
+
if (!builtinSyntaxes.find((s) => s.name === lang)) {
|
|
223
|
+
langs.push(lang);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (renderOptions.theme) {
|
|
227
|
+
renderOptions.theme = renderOptions.theme.toLowerCase().replace(/ +/g, "-");
|
|
228
|
+
}
|
|
229
|
+
const highlighter = await initShiki({
|
|
230
|
+
...options,
|
|
231
|
+
theme: renderOptions.theme ?? options?.theme,
|
|
232
|
+
langs
|
|
233
|
+
});
|
|
234
|
+
let prerenderEl = hydrate2 ? this.querySelector(".monaco-editor-prerender") : void 0;
|
|
235
|
+
if (!prerenderEl && filename && workspace) {
|
|
236
|
+
try {
|
|
237
|
+
const code2 = await workspace.fs.readFile(filename);
|
|
238
|
+
const language = getLanguageIdFromPath(filename);
|
|
239
|
+
prerenderEl = containerEl.cloneNode(true);
|
|
240
|
+
prerenderEl.className = "monaco-editor-prerender";
|
|
241
|
+
prerenderEl.innerHTML = render(highlighter, decode(code2), { ...renderOptions, language });
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (error instanceof ErrorNotFound) {
|
|
244
|
+
} else {
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (prerenderEl) {
|
|
250
|
+
setStyle(prerenderEl, { position: "absolute", top: "0", left: "0" });
|
|
251
|
+
this.appendChild(prerenderEl);
|
|
252
|
+
if (filename && workspace) {
|
|
253
|
+
const viewState = await workspace.viewState.get(filename);
|
|
254
|
+
const scrollTop = viewState?.viewState.scrollTop ?? 0;
|
|
255
|
+
if (scrollTop) {
|
|
256
|
+
const mockEl = prerenderEl.querySelector(".mock-monaco-editor");
|
|
257
|
+
if (mockEl) {
|
|
258
|
+
mockEl.scrollTop = scrollTop;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async function createEditor() {
|
|
264
|
+
const monaco = await load(highlighter);
|
|
265
|
+
const editor = monaco.editor.create(containerEl, renderOptions);
|
|
266
|
+
if (workspace) {
|
|
267
|
+
const storeViewState = () => {
|
|
268
|
+
const currentModel = editor.getModel();
|
|
269
|
+
if (currentModel?.uri.scheme === "file") {
|
|
270
|
+
const state = editor.saveViewState();
|
|
271
|
+
if (state) {
|
|
272
|
+
state.viewState.scrollTop ??= editor.getScrollTop();
|
|
273
|
+
workspace.viewState.save(currentModel.uri.toString(), Object.freeze(state));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
editor.onDidChangeCursorSelection(debunce(storeViewState, 500));
|
|
278
|
+
editor.onDidScrollChange(debunce(storeViewState, 500));
|
|
279
|
+
workspace.history.onChange((state) => {
|
|
280
|
+
if (editor.getModel()?.uri.toString() !== state.current) {
|
|
281
|
+
workspace._openTextDocument(state.current, editor);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
if (filename && workspace) {
|
|
286
|
+
try {
|
|
287
|
+
const model = await workspace._openTextDocument(filename, editor);
|
|
288
|
+
if (code && code !== model.getValue()) {
|
|
289
|
+
model.setValue(code);
|
|
290
|
+
}
|
|
291
|
+
} catch (error) {
|
|
292
|
+
if (error instanceof ErrorNotFound) {
|
|
293
|
+
if (code) {
|
|
294
|
+
await workspace.fs.writeFile(filename, code);
|
|
295
|
+
workspace._openTextDocument(filename, editor);
|
|
296
|
+
} else {
|
|
297
|
+
editor.setModel(monaco.editor.createModel(""));
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
} else if (code && (renderOptions.language || filename)) {
|
|
304
|
+
const model = monaco.editor.createModel(code, renderOptions.language, filename);
|
|
305
|
+
editor.setModel(model);
|
|
306
|
+
} else {
|
|
307
|
+
editor.setModel(monaco.editor.createModel(""));
|
|
308
|
+
}
|
|
309
|
+
if (prerenderEl) {
|
|
310
|
+
editorWorkerPromise.then(() => {
|
|
311
|
+
setTimeout(() => {
|
|
312
|
+
const animate = prerenderEl.animate?.([{ opacity: 1 }, { opacity: 0 }], { duration: 150 });
|
|
313
|
+
if (animate) {
|
|
314
|
+
animate.finished.then(() => prerenderEl.remove());
|
|
315
|
+
} else {
|
|
316
|
+
setTimeout(() => prerenderEl.remove(), 150);
|
|
317
|
+
}
|
|
318
|
+
}, 100);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
await createEditor();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
await editorWorkerPromise;
|
|
327
|
+
return {
|
|
328
|
+
workspace
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function hydrate(options) {
|
|
332
|
+
return lazy(options, true);
|
|
333
|
+
}
|
|
334
|
+
async function loadMonaco(highlighter, workspace, lsp, onDidEditorWorkerResolve) {
|
|
335
|
+
const monaco = await import("./editor-core.js");
|
|
336
|
+
const lspProviders = { ...builtinLSPProviders, ...lsp?.providers };
|
|
337
|
+
workspace?.setupMonaco(monaco);
|
|
338
|
+
if (Object.keys(lspProviders).length > 0) {
|
|
339
|
+
initLS(monaco);
|
|
340
|
+
}
|
|
341
|
+
if (!document.getElementById("monaco-editor-core-css")) {
|
|
342
|
+
const styleEl = document.createElement("style");
|
|
343
|
+
styleEl.id = "monaco-editor-core-css";
|
|
344
|
+
styleEl.media = "screen";
|
|
345
|
+
styleEl.textContent = monaco.CSS;
|
|
346
|
+
document.head.appendChild(styleEl);
|
|
347
|
+
}
|
|
348
|
+
Reflect.set(globalThis, "MonacoEnvironment", {
|
|
349
|
+
getWorker: async (_workerId, label) => {
|
|
350
|
+
let provider = lspProviders[label];
|
|
351
|
+
if (!provider) {
|
|
352
|
+
provider = Object.values(lspProviders).find((p) => p.aliases?.includes(label));
|
|
353
|
+
}
|
|
354
|
+
const url = provider ? (await provider.import()).getWorkerUrl() : monaco.getWorkerUrl();
|
|
355
|
+
if (label === "typescript") {
|
|
356
|
+
const tsVersion = lsp?.typescript?.tsVersion;
|
|
357
|
+
if (tsVersion && (url.hostname === "esm.sh" || url.hostname.endsWith(".esm.sh"))) {
|
|
358
|
+
url.searchParams.set("deps", `typescript@${tsVersion}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const worker = createWebWorker(url, void 0);
|
|
362
|
+
if (!provider) {
|
|
363
|
+
const onMessage = (e) => {
|
|
364
|
+
onDidEditorWorkerResolve?.();
|
|
365
|
+
worker.removeEventListener("message", onMessage);
|
|
366
|
+
};
|
|
367
|
+
worker.addEventListener("message", onMessage);
|
|
368
|
+
}
|
|
369
|
+
return worker;
|
|
370
|
+
},
|
|
371
|
+
getLanguageIdFromUri: (uri) => getLanguageIdFromPath(uri.path)
|
|
372
|
+
});
|
|
373
|
+
monaco.editor.registerLinkOpener({
|
|
374
|
+
async open(link) {
|
|
375
|
+
if ((link.scheme === "https" || link.scheme === "http") && monaco.editor.getModel(link)) {
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
monaco.editor.registerEditorOpener({
|
|
382
|
+
openCodeEditor: async (editor, resource, selectionOrPosition) => {
|
|
383
|
+
if (workspace && resource.scheme === "file") {
|
|
384
|
+
try {
|
|
385
|
+
await workspace._openTextDocument(resource.toString(), editor, selectionOrPosition);
|
|
386
|
+
return true;
|
|
387
|
+
} catch (err) {
|
|
388
|
+
if (err instanceof ErrorNotFound) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
throw err;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
const model = monaco.editor.getModel(resource);
|
|
396
|
+
if (model) {
|
|
397
|
+
editor.setModel(model);
|
|
398
|
+
if (selectionOrPosition) {
|
|
399
|
+
if ("startLineNumber" in selectionOrPosition) {
|
|
400
|
+
editor.setSelection(selectionOrPosition);
|
|
401
|
+
} else {
|
|
402
|
+
editor.setPosition(selectionOrPosition);
|
|
403
|
+
}
|
|
404
|
+
const pos = editor.getPosition();
|
|
405
|
+
if (pos) {
|
|
406
|
+
const svp = editor.getScrolledVisiblePosition(new monaco.Position(pos.lineNumber - 7, pos.column));
|
|
407
|
+
if (svp) {
|
|
408
|
+
editor.setScrollTop(svp.top);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const isHttpUrl = resource.scheme === "https" || resource.scheme === "http";
|
|
413
|
+
editor.updateOptions({ readOnly: isHttpUrl });
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
} catch (error) {
|
|
417
|
+
}
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
if (globalThis.navigator?.userAgent?.includes("Macintosh")) {
|
|
422
|
+
monaco.editor.addKeybindingRule({
|
|
423
|
+
keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK,
|
|
424
|
+
command: "editor.action.quickCommand"
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
const allLanguages = new Set(tmGrammars.filter((g) => !g.injectTo).map((g) => g.name));
|
|
428
|
+
allLanguages.forEach((id) => {
|
|
429
|
+
const languages = monaco.languages;
|
|
430
|
+
languages.register({ id, aliases: tmGrammars.find((g) => g.name === id)?.aliases });
|
|
431
|
+
languages.onLanguage(id, async () => {
|
|
432
|
+
const config = monaco.languageConfigurations[monaco.languageConfigurationAliases[id] ?? id];
|
|
433
|
+
const loadedGrammars = new Set(highlighter.getLoadedLanguages());
|
|
434
|
+
const reqiredGrammars = [id].concat(tmGrammars.find((g) => g.name === id)?.embedded ?? []).filter((id2) => !loadedGrammars.has(id2));
|
|
435
|
+
if (config) {
|
|
436
|
+
languages.setLanguageConfiguration(id, monaco.convertVscodeLanguageConfiguration(config));
|
|
437
|
+
}
|
|
438
|
+
if (reqiredGrammars.length > 0) {
|
|
439
|
+
await highlighter.loadGrammarFromCDN(...reqiredGrammars);
|
|
440
|
+
}
|
|
441
|
+
registerShikiMonacoTokenizer(monaco, highlighter, id);
|
|
442
|
+
let lspLabel = id;
|
|
443
|
+
let lspProvider = lspProviders[lspLabel];
|
|
444
|
+
if (!lspProvider) {
|
|
445
|
+
const alias = Object.entries(lspProviders).find(([, lsp2]) => lsp2.aliases?.includes(id));
|
|
446
|
+
if (alias) {
|
|
447
|
+
[lspLabel, lspProvider] = alias;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (lspProvider) {
|
|
451
|
+
lspProvider.import().then(({ setup }) => setup(monaco, id, workspace, lsp?.[lspLabel], lsp?.formatting));
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
initShikiMonacoTokenizer(monaco, highlighter);
|
|
456
|
+
return monaco;
|
|
457
|
+
}
|
|
458
|
+
function registerLSPProvider(lang, provider) {
|
|
459
|
+
builtinLSPProviders[lang] = provider;
|
|
460
|
+
}
|
|
461
|
+
function registerSyntax(...syntaxes) {
|
|
462
|
+
builtinSyntaxes.push(...syntaxes);
|
|
463
|
+
}
|
|
464
|
+
function registerTheme(theme) {
|
|
465
|
+
if (theme.name) {
|
|
466
|
+
tmThemes.set(theme.name, theme);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
setDefaultWasmLoader(getWasmInstance);
|
|
470
|
+
export {
|
|
471
|
+
Workspace,
|
|
472
|
+
errors,
|
|
473
|
+
hydrate,
|
|
474
|
+
init,
|
|
475
|
+
lazy,
|
|
476
|
+
registerLSPProvider,
|
|
477
|
+
registerSyntax,
|
|
478
|
+
registerTheme
|
|
479
|
+
};
|
package/dist/editor-core.js
CHANGED
|
@@ -166674,10 +166674,6 @@ if (isMacintosh) {
|
|
|
166674
166674
|
registerQuickPickCommandAndKeybindingRule({ id: "quickInput.Next", primary: 256 + 44, handler: focusHandler(QuickPickFocus.Next) });
|
|
166675
166675
|
registerQuickPickCommandAndKeybindingRule({ id: "quickInput.Previous", primary: 256 + 46, handler: focusHandler(QuickPickFocus.Previous) });
|
|
166676
166676
|
}
|
|
166677
|
-
if (isMacintosh) {
|
|
166678
|
-
registerQuickPickCommandAndKeybindingRule({ id: "quickInput.Next", primary: 256 + 44, handler: focusHandler(QuickPickFocus.Next) });
|
|
166679
|
-
registerQuickPickCommandAndKeybindingRule({ id: "quickInput.Previous", primary: 256 + 46, handler: focusHandler(QuickPickFocus.Previous) });
|
|
166680
|
-
}
|
|
166681
166677
|
|
|
166682
166678
|
// node_modules/.pnpm/monaco-editor-core@0.52.2/node_modules/monaco-editor-core/esm/vs/platform/quickinput/browser/quickInputController.js
|
|
166683
166679
|
var __decorate152 = function(decorators, target, key, desc) {
|
|
@@ -173132,6 +173128,107 @@ if (typeof globalThis.require !== "undefined" && typeof globalThis.require.confi
|
|
|
173132
173128
|
|
|
173133
173129
|
// language-configurations.json
|
|
173134
173130
|
var language_configurations_default = {
|
|
173131
|
+
prompt: {
|
|
173132
|
+
comments: {
|
|
173133
|
+
blockComment: [
|
|
173134
|
+
"<!--",
|
|
173135
|
+
"-->"
|
|
173136
|
+
]
|
|
173137
|
+
},
|
|
173138
|
+
brackets: [
|
|
173139
|
+
[
|
|
173140
|
+
"{",
|
|
173141
|
+
"}"
|
|
173142
|
+
],
|
|
173143
|
+
[
|
|
173144
|
+
"[",
|
|
173145
|
+
"]"
|
|
173146
|
+
],
|
|
173147
|
+
[
|
|
173148
|
+
"(",
|
|
173149
|
+
")"
|
|
173150
|
+
]
|
|
173151
|
+
],
|
|
173152
|
+
colorizedBracketPairs: [],
|
|
173153
|
+
autoClosingPairs: [
|
|
173154
|
+
{
|
|
173155
|
+
open: "{",
|
|
173156
|
+
close: "}"
|
|
173157
|
+
},
|
|
173158
|
+
{
|
|
173159
|
+
open: "[",
|
|
173160
|
+
close: "]"
|
|
173161
|
+
},
|
|
173162
|
+
{
|
|
173163
|
+
open: "(",
|
|
173164
|
+
close: ")"
|
|
173165
|
+
},
|
|
173166
|
+
{
|
|
173167
|
+
open: "<",
|
|
173168
|
+
close: ">",
|
|
173169
|
+
notIn: [
|
|
173170
|
+
"string"
|
|
173171
|
+
]
|
|
173172
|
+
}
|
|
173173
|
+
],
|
|
173174
|
+
surroundingPairs: [
|
|
173175
|
+
[
|
|
173176
|
+
"(",
|
|
173177
|
+
")"
|
|
173178
|
+
],
|
|
173179
|
+
[
|
|
173180
|
+
"[",
|
|
173181
|
+
"]"
|
|
173182
|
+
],
|
|
173183
|
+
[
|
|
173184
|
+
"`",
|
|
173185
|
+
"`"
|
|
173186
|
+
],
|
|
173187
|
+
[
|
|
173188
|
+
"_",
|
|
173189
|
+
"_"
|
|
173190
|
+
],
|
|
173191
|
+
[
|
|
173192
|
+
"*",
|
|
173193
|
+
"*"
|
|
173194
|
+
],
|
|
173195
|
+
[
|
|
173196
|
+
"{",
|
|
173197
|
+
"}"
|
|
173198
|
+
],
|
|
173199
|
+
[
|
|
173200
|
+
"'",
|
|
173201
|
+
"'"
|
|
173202
|
+
],
|
|
173203
|
+
[
|
|
173204
|
+
'"',
|
|
173205
|
+
'"'
|
|
173206
|
+
],
|
|
173207
|
+
[
|
|
173208
|
+
"<",
|
|
173209
|
+
">"
|
|
173210
|
+
],
|
|
173211
|
+
[
|
|
173212
|
+
"~",
|
|
173213
|
+
"~"
|
|
173214
|
+
],
|
|
173215
|
+
[
|
|
173216
|
+
"$",
|
|
173217
|
+
"$"
|
|
173218
|
+
]
|
|
173219
|
+
],
|
|
173220
|
+
folding: {
|
|
173221
|
+
offSide: true,
|
|
173222
|
+
markers: {
|
|
173223
|
+
start: "^\\s*<!--\\s*#?region\\b.*-->",
|
|
173224
|
+
end: "^\\s*<!--\\s*#?endregion\\b.*-->"
|
|
173225
|
+
}
|
|
173226
|
+
},
|
|
173227
|
+
wordPattern: {
|
|
173228
|
+
pattern: "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*",
|
|
173229
|
+
flags: "ug"
|
|
173230
|
+
}
|
|
173231
|
+
},
|
|
173135
173232
|
razor: {
|
|
173136
173233
|
comments: {
|
|
173137
173234
|
blockComment: [
|
|
@@ -175252,7 +175349,13 @@ var language_configurations_default = {
|
|
|
175252
175349
|
],
|
|
175253
175350
|
indentationRules: {
|
|
175254
175351
|
increaseIndentPattern: "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)",
|
|
175255
|
-
decreaseIndentPattern: "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\]\\)*[;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch));))"
|
|
175352
|
+
decreaseIndentPattern: "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\]\\)*[;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch));))",
|
|
175353
|
+
unIndentedLinePattern: {
|
|
175354
|
+
pattern: "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*\\*([ ]([^\\*]|\\*(?!/))*)?$"
|
|
175355
|
+
},
|
|
175356
|
+
indentNextLinePattern: {
|
|
175357
|
+
pattern: "^\\s*(((if|else ?if|while|for|foreach)\\s*\\(.*\\)\\s*)|else\\s*)$"
|
|
175358
|
+
}
|
|
175256
175359
|
},
|
|
175257
175360
|
folding: {
|
|
175258
175361
|
markers: {
|
|
@@ -175703,7 +175806,7 @@ var language_configurations_default = {
|
|
|
175703
175806
|
pattern: "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*\\*([ ]([^\\*]|\\*(?!/))*)?$"
|
|
175704
175807
|
},
|
|
175705
175808
|
indentNextLinePattern: {
|
|
175706
|
-
pattern: "^((.*=>\\s*)|((.*[^\\w]+|\\s*)(if|while|for)\\s*\\(.*\\)\\s*))$"
|
|
175809
|
+
pattern: "^((.*=>\\s*)|((.*[^\\w]+|\\s*)((if|while|for)\\s*\\(.*\\)\\s*|else\\s*)))$"
|
|
175707
175810
|
}
|
|
175708
175811
|
},
|
|
175709
175812
|
onEnterRules: [
|
|
@@ -175801,12 +175904,8 @@ var language_configurations_default = {
|
|
|
175801
175904
|
}
|
|
175802
175905
|
},
|
|
175803
175906
|
{
|
|
175804
|
-
beforeText:
|
|
175805
|
-
|
|
175806
|
-
},
|
|
175807
|
-
afterText: {
|
|
175808
|
-
pattern: "^(?!\\s*$).+"
|
|
175809
|
-
},
|
|
175907
|
+
beforeText: "(?<!\\\\|\\w:)//\\s*\\S",
|
|
175908
|
+
afterText: "^(?!\\s*$).+",
|
|
175810
175909
|
action: {
|
|
175811
175910
|
indent: "none",
|
|
175812
175911
|
appendText: "// "
|
|
@@ -176225,7 +176324,10 @@ var language_configurations_default = {
|
|
|
176225
176324
|
},
|
|
176226
176325
|
make: {
|
|
176227
176326
|
comments: {
|
|
176228
|
-
lineComment:
|
|
176327
|
+
lineComment: {
|
|
176328
|
+
comment: "#",
|
|
176329
|
+
noIndent: true
|
|
176330
|
+
}
|
|
176229
176331
|
},
|
|
176230
176332
|
brackets: [
|
|
176231
176333
|
[
|
|
@@ -176620,7 +176722,7 @@ var language_configurations_default = {
|
|
|
176620
176722
|
onEnterRules: [
|
|
176621
176723
|
{
|
|
176622
176724
|
beforeText: {
|
|
176623
|
-
pattern: "
|
|
176725
|
+
pattern: "[^/]//[^/].*"
|
|
176624
176726
|
},
|
|
176625
176727
|
afterText: {
|
|
176626
176728
|
pattern: "^(?!\\s*$).+"
|
|
@@ -176629,6 +176731,15 @@ var language_configurations_default = {
|
|
|
176629
176731
|
indent: "none",
|
|
176630
176732
|
appendText: "// "
|
|
176631
176733
|
}
|
|
176734
|
+
},
|
|
176735
|
+
{
|
|
176736
|
+
beforeText: {
|
|
176737
|
+
pattern: "^\\s*///"
|
|
176738
|
+
},
|
|
176739
|
+
action: {
|
|
176740
|
+
indent: "none",
|
|
176741
|
+
appendText: "/// "
|
|
176742
|
+
}
|
|
176632
176743
|
}
|
|
176633
176744
|
]
|
|
176634
176745
|
},
|
|
@@ -177073,7 +177184,7 @@ var language_configurations_default = {
|
|
|
177073
177184
|
pattern: "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$"
|
|
177074
177185
|
},
|
|
177075
177186
|
indentNextLinePattern: {
|
|
177076
|
-
pattern: "^((.*=>\\s*)|((.*[^\\w]+|\\s*)(if|while|for)\\s*\\(.*\\)\\s*))$"
|
|
177187
|
+
pattern: "^((.*=>\\s*)|((.*[^\\w]+|\\s*)((if|while|for)\\s*\\(.*\\)\\s*|else\\s*)))$"
|
|
177077
177188
|
}
|
|
177078
177189
|
},
|
|
177079
177190
|
onEnterRules: [
|
|
@@ -177171,12 +177282,8 @@ var language_configurations_default = {
|
|
|
177171
177282
|
}
|
|
177172
177283
|
},
|
|
177173
177284
|
{
|
|
177174
|
-
beforeText:
|
|
177175
|
-
|
|
177176
|
-
},
|
|
177177
|
-
afterText: {
|
|
177178
|
-
pattern: "^(?!\\s*$).+"
|
|
177179
|
-
},
|
|
177285
|
+
beforeText: "(?<!\\\\|\\w:)//\\s*\\S",
|
|
177286
|
+
afterText: "^(?!\\s*$).+",
|
|
177180
177287
|
action: {
|
|
177181
177288
|
indent: "none",
|
|
177182
177289
|
appendText: "// "
|