modern-monaco 0.1.6 → 0.1.8
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/dist/core.js +210 -198
- package/dist/shiki.js +62 -62
- package/package.json +1 -1
- package/types/core.d.ts +6 -3
package/dist/core.js
CHANGED
|
@@ -11,7 +11,7 @@ function createWebWorker(url, name) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// src/core.ts
|
|
14
|
-
import { getExtnameFromLanguageId, getLanguageIdFromPath, initShiki, setDefaultWasmLoader,
|
|
14
|
+
import { getExtnameFromLanguageId, getLanguageIdFromPath, grammars, initShiki, setDefaultWasmLoader, themes } from "./shiki.js";
|
|
15
15
|
import { initShikiMonacoTokenizer, registerShikiMonacoTokenizer } from "./shiki.js";
|
|
16
16
|
import { render } from "./shiki.js";
|
|
17
17
|
import { getWasmInstance } from "./shiki-wasm.js";
|
|
@@ -83,75 +83,75 @@ var editorProps = [
|
|
|
83
83
|
var errors = {
|
|
84
84
|
NotFound: ErrorNotFound
|
|
85
85
|
};
|
|
86
|
-
var
|
|
87
|
-
var
|
|
86
|
+
var syntaxes = [];
|
|
87
|
+
var lSPProviders = {};
|
|
88
|
+
var { promise: editorWorkerPromise, resolve: onDidEditorWorkerResolve } = promiseWithResolvers();
|
|
89
|
+
var attr = (el, name) => el.getAttribute(name);
|
|
90
|
+
var style = (el, style2) => Object.assign(el.style, style2);
|
|
88
91
|
async function init(options) {
|
|
89
|
-
const langs = (options?.langs ?? []).concat(
|
|
92
|
+
const langs = (options?.langs ?? []).concat(syntaxes);
|
|
90
93
|
const hightlighter = await initShiki({ ...options, langs });
|
|
91
94
|
return loadMonaco(hightlighter, options?.workspace, options?.lsp);
|
|
92
95
|
}
|
|
93
|
-
async function lazy(options
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
value = void 0;
|
|
96
|
+
async function lazy(options) {
|
|
97
|
+
if (!customElements.get("monaco-editor")) {
|
|
98
|
+
let monacoPromise = null;
|
|
99
|
+
customElements.define(
|
|
100
|
+
"monaco-editor",
|
|
101
|
+
class extends HTMLElement {
|
|
102
|
+
async connectedCallback() {
|
|
103
|
+
const workspace = options?.workspace;
|
|
104
|
+
const renderOptions = {};
|
|
105
|
+
for (const attrName of this.getAttributeNames()) {
|
|
106
|
+
const key = editorProps.find((k) => k.toLowerCase() === attrName);
|
|
107
|
+
if (key) {
|
|
108
|
+
let value = attr(this, attrName);
|
|
109
|
+
if (value === "") {
|
|
110
|
+
value = key === "minimap" || key === "stickyScroll" ? { enabled: true } : true;
|
|
111
|
+
} else {
|
|
112
|
+
value = value.trim();
|
|
113
|
+
if (value === "true") {
|
|
114
|
+
value = true;
|
|
115
|
+
} else if (value === "false") {
|
|
116
|
+
value = false;
|
|
117
|
+
} else if (value === "null") {
|
|
118
|
+
value = null;
|
|
119
|
+
} else if (/^\d+$/.test(value)) {
|
|
120
|
+
value = Number(value);
|
|
121
|
+
} else if (/^\{.+\}$/.test(value)) {
|
|
122
|
+
try {
|
|
123
|
+
value = JSON.parse(value);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
value = void 0;
|
|
126
|
+
}
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
if (key === "padding") {
|
|
130
|
+
if (typeof value === "number") {
|
|
131
|
+
value = { top: value, bottom: value };
|
|
132
|
+
} else if (/^\d+\s+\d+$/.test(value)) {
|
|
133
|
+
const [top, bottom] = value.split(/\s+/);
|
|
134
|
+
if (top && bottom) {
|
|
135
|
+
value = { top: Number(top), bottom: Number(bottom) };
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
value = void 0;
|
|
135
139
|
}
|
|
136
|
-
} else {
|
|
137
|
-
value = void 0;
|
|
138
140
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
if (key === "wordWrap" && (value === "on" || value === true)) {
|
|
142
|
+
value = "on";
|
|
143
|
+
}
|
|
144
|
+
if (value !== void 0) {
|
|
145
|
+
renderOptions[key] = value;
|
|
146
|
+
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const optionsEl = this.children[0];
|
|
152
|
-
if (optionsEl && optionsEl.tagName === "SCRIPT" && optionsEl.className === "monaco-editor-options") {
|
|
149
|
+
let filename;
|
|
150
|
+
let code;
|
|
151
|
+
const firstEl = this.firstElementChild;
|
|
152
|
+
if (firstEl && firstEl.tagName === "SCRIPT" && firstEl.className === "monaco-editor-options") {
|
|
153
153
|
try {
|
|
154
|
-
const v = JSON.parse(
|
|
154
|
+
const v = JSON.parse(firstEl.textContent);
|
|
155
155
|
if (Array.isArray(v) && v.length === 2) {
|
|
156
156
|
const [input, opts] = v;
|
|
157
157
|
Object.assign(renderOptions, opts);
|
|
@@ -167,164 +167,176 @@ async function lazy(options, hydrate2) {
|
|
|
167
167
|
}
|
|
168
168
|
} catch {
|
|
169
169
|
}
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
setStyle(this, { display: "block", position: "relative" });
|
|
174
|
-
let widthAttr = getAttr(this, "width");
|
|
175
|
-
let heightAttr = getAttr(this, "height");
|
|
176
|
-
if (isDigital(widthAttr) && isDigital(heightAttr)) {
|
|
177
|
-
const width = Number(widthAttr);
|
|
178
|
-
const height = Number(heightAttr);
|
|
179
|
-
setStyle(this, { width: width + "px", height: height + "px" });
|
|
180
|
-
renderOptions.dimension = { width, height };
|
|
181
|
-
} else {
|
|
182
|
-
if (isDigital(widthAttr)) {
|
|
183
|
-
widthAttr += "px";
|
|
170
|
+
firstEl.remove();
|
|
184
171
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
setStyle(containerEl, { width: "100%", height: "100%" });
|
|
194
|
-
this.appendChild(containerEl);
|
|
195
|
-
if (!filename && workspace) {
|
|
196
|
-
if (workspace.history.state.current) {
|
|
197
|
-
filename = workspace.history.state.current;
|
|
198
|
-
} else if (workspace.entryFile) {
|
|
199
|
-
filename = workspace.entryFile;
|
|
200
|
-
workspace.history.replace(filename);
|
|
172
|
+
style(this, { display: "block", position: "relative" });
|
|
173
|
+
let widthAttr = attr(this, "width");
|
|
174
|
+
let heightAttr = attr(this, "height");
|
|
175
|
+
if (isDigital(widthAttr) && isDigital(heightAttr)) {
|
|
176
|
+
const width = Number(widthAttr);
|
|
177
|
+
const height = Number(heightAttr);
|
|
178
|
+
style(this, { width: width + "px", height: height + "px" });
|
|
179
|
+
renderOptions.dimension = { width, height };
|
|
201
180
|
} else {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (filename) {
|
|
205
|
-
workspace.history.replace(filename);
|
|
181
|
+
if (isDigital(widthAttr)) {
|
|
182
|
+
widthAttr += "px";
|
|
206
183
|
}
|
|
184
|
+
if (isDigital(heightAttr)) {
|
|
185
|
+
heightAttr += "px";
|
|
186
|
+
}
|
|
187
|
+
this.style.width ||= widthAttr ?? "100%";
|
|
188
|
+
this.style.height ||= heightAttr ?? "100%";
|
|
207
189
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
const highlighter = await initShiki({
|
|
220
|
-
...options,
|
|
221
|
-
theme: renderOptions.theme ?? options?.theme,
|
|
222
|
-
langs
|
|
223
|
-
});
|
|
224
|
-
let prerenderEl = hydrate2 ? this.querySelector(".monaco-editor-prerender") : void 0;
|
|
225
|
-
if (!prerenderEl && filename && workspace) {
|
|
226
|
-
try {
|
|
227
|
-
const code2 = await workspace.fs.readFile(filename);
|
|
228
|
-
const language = getLanguageIdFromPath(filename);
|
|
229
|
-
prerenderEl = containerEl.cloneNode(true);
|
|
230
|
-
prerenderEl.className = "monaco-editor-prerender";
|
|
231
|
-
prerenderEl.innerHTML = render(highlighter, decode(code2), { ...renderOptions, language });
|
|
232
|
-
} catch (error) {
|
|
233
|
-
if (error instanceof ErrorNotFound) {
|
|
190
|
+
const containerEl = document.createElement("div");
|
|
191
|
+
containerEl.className = "monaco-editor-container";
|
|
192
|
+
style(containerEl, { width: "100%", height: "100%" });
|
|
193
|
+
this.appendChild(containerEl);
|
|
194
|
+
if (!filename && workspace) {
|
|
195
|
+
if (workspace.history.state.current) {
|
|
196
|
+
filename = workspace.history.state.current;
|
|
197
|
+
} else if (workspace.entryFile) {
|
|
198
|
+
filename = workspace.entryFile;
|
|
199
|
+
workspace.history.replace(filename);
|
|
234
200
|
} else {
|
|
235
|
-
|
|
201
|
+
const rootFiles = (await workspace.fs.readDirectory("/")).filter(([name, type]) => type === 1).map(([name]) => name);
|
|
202
|
+
filename = rootFiles.includes("index.html") ? "index.html" : rootFiles[0];
|
|
203
|
+
if (filename) {
|
|
204
|
+
workspace.history.replace(filename);
|
|
205
|
+
}
|
|
236
206
|
}
|
|
237
207
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const viewState = await workspace.viewState.get(filename);
|
|
244
|
-
const scrollTop = viewState?.viewState.scrollTop ?? 0;
|
|
245
|
-
if (scrollTop) {
|
|
246
|
-
const mockEl = prerenderEl.querySelector(".mock-monaco-editor");
|
|
247
|
-
if (mockEl) {
|
|
248
|
-
mockEl.scrollTop = scrollTop;
|
|
249
|
-
}
|
|
208
|
+
const langs = (options?.langs ?? []).concat(syntaxes);
|
|
209
|
+
if (renderOptions.language || filename) {
|
|
210
|
+
const lang = renderOptions.language ?? getLanguageIdFromPath(filename) ?? "plaintext";
|
|
211
|
+
if (!syntaxes.find((s) => s.name === lang)) {
|
|
212
|
+
langs.push(lang);
|
|
250
213
|
}
|
|
251
214
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const monaco = await (monacoPromise ?? (monacoPromise = loadMonaco(highlighter, workspace, options?.lsp, onDidEditorWorkerResolve)));
|
|
255
|
-
const editor = monaco.editor.create(containerEl, renderOptions);
|
|
256
|
-
if (workspace) {
|
|
257
|
-
const storeViewState = () => {
|
|
258
|
-
const currentModel = editor.getModel();
|
|
259
|
-
if (currentModel?.uri.scheme === "file") {
|
|
260
|
-
const state = editor.saveViewState();
|
|
261
|
-
if (state) {
|
|
262
|
-
state.viewState.scrollTop ??= editor.getScrollTop();
|
|
263
|
-
workspace.viewState.save(currentModel.uri.toString(), Object.freeze(state));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
editor.onDidChangeCursorSelection(debunce(storeViewState, 500));
|
|
268
|
-
editor.onDidScrollChange(debunce(storeViewState, 500));
|
|
269
|
-
workspace.history.onChange((state) => {
|
|
270
|
-
if (editor.getModel()?.uri.toString() !== state.current) {
|
|
271
|
-
workspace._openTextDocument(state.current, editor);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
215
|
+
if (renderOptions.theme) {
|
|
216
|
+
renderOptions.theme = renderOptions.theme.toLowerCase().replace(/ +/g, "-");
|
|
274
217
|
}
|
|
275
|
-
|
|
218
|
+
const highlighter = await initShiki({
|
|
219
|
+
...options,
|
|
220
|
+
theme: renderOptions.theme ?? options?.theme,
|
|
221
|
+
langs
|
|
222
|
+
});
|
|
223
|
+
let prerenderEl;
|
|
224
|
+
for (const el of this.children) {
|
|
225
|
+
if (el.className === "monaco-editor-prerender") {
|
|
226
|
+
prerenderEl = el;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!prerenderEl && filename && workspace) {
|
|
276
231
|
try {
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
232
|
+
const code2 = await workspace.fs.readFile(filename);
|
|
233
|
+
const language = getLanguageIdFromPath(filename);
|
|
234
|
+
prerenderEl = containerEl.cloneNode(true);
|
|
235
|
+
prerenderEl.className = "monaco-editor-prerender";
|
|
236
|
+
prerenderEl.innerHTML = render(highlighter, decode(code2), { ...renderOptions, language });
|
|
281
237
|
} catch (error) {
|
|
282
238
|
if (error instanceof ErrorNotFound) {
|
|
283
|
-
if (code) {
|
|
284
|
-
const dirname = filename.split("/").slice(0, -1).join("/");
|
|
285
|
-
if (dirname) {
|
|
286
|
-
await workspace.fs.createDirectory(dirname);
|
|
287
|
-
}
|
|
288
|
-
await workspace.fs.writeFile(filename, code);
|
|
289
|
-
workspace._openTextDocument(filename, editor);
|
|
290
|
-
} else {
|
|
291
|
-
editor.setModel(monaco.editor.createModel(""));
|
|
292
|
-
}
|
|
293
239
|
} else {
|
|
294
240
|
throw error;
|
|
295
241
|
}
|
|
296
242
|
}
|
|
297
|
-
} else if (code && (renderOptions.language || filename)) {
|
|
298
|
-
const model = monaco.editor.createModel(code, renderOptions.language, filename);
|
|
299
|
-
editor.setModel(model);
|
|
300
|
-
} else {
|
|
301
|
-
editor.setModel(monaco.editor.createModel(""));
|
|
302
243
|
}
|
|
303
244
|
if (prerenderEl) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
245
|
+
style(prerenderEl, { position: "absolute", top: "0", left: "0" });
|
|
246
|
+
this.appendChild(prerenderEl);
|
|
247
|
+
if (filename && workspace) {
|
|
248
|
+
const viewState = await workspace.viewState.get(filename);
|
|
249
|
+
const scrollTop = viewState?.viewState.scrollTop ?? 0;
|
|
250
|
+
if (scrollTop) {
|
|
251
|
+
const mockEl = prerenderEl.querySelector(".mock-monaco-editor");
|
|
252
|
+
if (mockEl) {
|
|
253
|
+
mockEl.scrollTop = scrollTop;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function createEditor() {
|
|
259
|
+
const monaco = await (monacoPromise ?? (monacoPromise = loadMonaco(highlighter, workspace, options?.lsp, onDidEditorWorkerResolve)));
|
|
260
|
+
const editor = monaco.editor.create(containerEl, renderOptions);
|
|
261
|
+
if (workspace) {
|
|
262
|
+
const storeViewState = () => {
|
|
263
|
+
const currentModel = editor.getModel();
|
|
264
|
+
if (currentModel?.uri.scheme === "file") {
|
|
265
|
+
const state = editor.saveViewState();
|
|
266
|
+
if (state) {
|
|
267
|
+
state.viewState.scrollTop ??= editor.getScrollTop();
|
|
268
|
+
workspace.viewState.save(currentModel.uri.toString(), Object.freeze(state));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
editor.onDidChangeCursorSelection(debunce(storeViewState, 500));
|
|
273
|
+
editor.onDidScrollChange(debunce(storeViewState, 500));
|
|
274
|
+
workspace.history.onChange((state) => {
|
|
275
|
+
if (editor.getModel()?.uri.toString() !== state.current) {
|
|
276
|
+
workspace._openTextDocument(state.current, editor);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (filename && workspace) {
|
|
281
|
+
try {
|
|
282
|
+
const model = await workspace._openTextDocument(filename, editor);
|
|
283
|
+
if (code && code !== model.getValue()) {
|
|
284
|
+
model.setValue(code);
|
|
285
|
+
}
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (error instanceof ErrorNotFound) {
|
|
288
|
+
if (code) {
|
|
289
|
+
const dirname = filename.split("/").slice(0, -1).join("/");
|
|
290
|
+
if (dirname) {
|
|
291
|
+
await workspace.fs.createDirectory(dirname);
|
|
292
|
+
}
|
|
293
|
+
await workspace.fs.writeFile(filename, code);
|
|
294
|
+
workspace._openTextDocument(filename, editor);
|
|
295
|
+
} else {
|
|
296
|
+
editor.setModel(monaco.editor.createModel(""));
|
|
297
|
+
}
|
|
309
298
|
} else {
|
|
310
|
-
|
|
299
|
+
throw error;
|
|
311
300
|
}
|
|
312
|
-
}
|
|
313
|
-
})
|
|
301
|
+
}
|
|
302
|
+
} else if (code && (renderOptions.language || filename)) {
|
|
303
|
+
const modelUri = filename ? monaco.Uri.file(filename) : void 0;
|
|
304
|
+
let model = modelUri ? monaco.editor.getModel(modelUri) : null;
|
|
305
|
+
if (!model) {
|
|
306
|
+
model = monaco.editor.createModel(code, renderOptions.language, modelUri);
|
|
307
|
+
} else if (code !== model.getValue()) {
|
|
308
|
+
model.setValue(code);
|
|
309
|
+
}
|
|
310
|
+
editor.setModel(model);
|
|
311
|
+
} else {
|
|
312
|
+
editor.setModel(monaco.editor.createModel(""));
|
|
313
|
+
}
|
|
314
|
+
if (prerenderEl) {
|
|
315
|
+
editorWorkerPromise.then(() => {
|
|
316
|
+
setTimeout(() => {
|
|
317
|
+
const animate = prerenderEl.animate?.([{ opacity: 1 }, { opacity: 0 }], { duration: 150 });
|
|
318
|
+
if (animate) {
|
|
319
|
+
animate.finished.then(() => prerenderEl.remove());
|
|
320
|
+
} else {
|
|
321
|
+
setTimeout(() => prerenderEl.remove(), 150);
|
|
322
|
+
}
|
|
323
|
+
}, 100);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
314
326
|
}
|
|
327
|
+
await createEditor();
|
|
315
328
|
}
|
|
316
|
-
await createEditor();
|
|
317
329
|
}
|
|
318
|
-
|
|
319
|
-
|
|
330
|
+
);
|
|
331
|
+
}
|
|
320
332
|
await editorWorkerPromise;
|
|
321
333
|
}
|
|
322
334
|
function hydrate(options) {
|
|
323
|
-
return lazy(options
|
|
335
|
+
return lazy(options);
|
|
324
336
|
}
|
|
325
|
-
async function loadMonaco(highlighter, workspace, lsp,
|
|
337
|
+
async function loadMonaco(highlighter, workspace, lsp, onDidEditorWorkerResolve2) {
|
|
326
338
|
const monaco = await import("./editor-core.js");
|
|
327
|
-
const lspProviders = { ...
|
|
339
|
+
const lspProviders = { ...lSPProviders, ...lsp?.providers };
|
|
328
340
|
workspace?.setupMonaco(monaco);
|
|
329
341
|
if (Object.keys(lspProviders).length > 0) {
|
|
330
342
|
initLS(monaco);
|
|
@@ -352,7 +364,7 @@ async function loadMonaco(highlighter, workspace, lsp, onDidEditorWorkerResolve)
|
|
|
352
364
|
const worker = createWebWorker(url, void 0);
|
|
353
365
|
if (!provider) {
|
|
354
366
|
const onMessage = (e) => {
|
|
355
|
-
|
|
367
|
+
onDidEditorWorkerResolve2?.();
|
|
356
368
|
worker.removeEventListener("message", onMessage);
|
|
357
369
|
};
|
|
358
370
|
worker.addEventListener("message", onMessage);
|
|
@@ -416,14 +428,14 @@ async function loadMonaco(highlighter, workspace, lsp, onDidEditorWorkerResolve)
|
|
|
416
428
|
command: "editor.action.quickCommand"
|
|
417
429
|
});
|
|
418
430
|
}
|
|
419
|
-
const allLanguages = new Set(
|
|
431
|
+
const allLanguages = new Set(grammars.filter((g) => !g.injectTo).map((g) => g.name));
|
|
420
432
|
allLanguages.forEach((id) => {
|
|
421
433
|
const languages = monaco.languages;
|
|
422
|
-
languages.register({ id, aliases:
|
|
434
|
+
languages.register({ id, aliases: grammars.find((g) => g.name === id)?.aliases });
|
|
423
435
|
languages.onLanguage(id, async () => {
|
|
424
436
|
const config = monaco.languageConfigurations[monaco.languageConfigurationAliases[id] ?? id];
|
|
425
437
|
const loadedGrammars = new Set(highlighter.getLoadedLanguages());
|
|
426
|
-
const reqiredGrammars = [id].concat(
|
|
438
|
+
const reqiredGrammars = [id].concat(grammars.find((g) => g.name === id)?.embedded ?? []).filter((id2) => !loadedGrammars.has(id2));
|
|
427
439
|
if (config) {
|
|
428
440
|
languages.setLanguageConfiguration(id, monaco.convertVscodeLanguageConfiguration(config));
|
|
429
441
|
}
|
|
@@ -447,17 +459,17 @@ async function loadMonaco(highlighter, workspace, lsp, onDidEditorWorkerResolve)
|
|
|
447
459
|
initShikiMonacoTokenizer(monaco, highlighter);
|
|
448
460
|
return monaco;
|
|
449
461
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
function registerSyntax(...syntaxes) {
|
|
454
|
-
builtinSyntaxes.push(...syntaxes);
|
|
462
|
+
function registerSyntax(...syntaxes2) {
|
|
463
|
+
syntaxes2.push(...syntaxes2);
|
|
455
464
|
}
|
|
456
465
|
function registerTheme(theme) {
|
|
457
466
|
if (theme.name) {
|
|
458
|
-
|
|
467
|
+
themes.set(theme.name, theme);
|
|
459
468
|
}
|
|
460
469
|
}
|
|
470
|
+
function registerLSPProvider(lang, provider) {
|
|
471
|
+
lSPProviders[lang] = provider;
|
|
472
|
+
}
|
|
461
473
|
setDefaultWasmLoader(getWasmInstance);
|
|
462
474
|
export {
|
|
463
475
|
Workspace,
|
package/dist/shiki.js
CHANGED
|
@@ -4,11 +4,11 @@ var __export = (target, all2) => {
|
|
|
4
4
|
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// <define:
|
|
8
|
-
var define_TM_GRAMMARS_default = [{ name: "abap", scopeName: "source.abap" }, { name: "actionscript-3", scopeName: "source.actionscript.3" }, { name: "ada", scopeName: "source.ada" }, { name: "angular-html", scopeName: "text.html.derivative.ng", embedded: ["html", "angular-expression", "angular-let-declaration", "angular-template", "angular-template-blocks"] }, { name: "angular-ts", scopeName: "source.ts.ng", embedded: ["angular-expression", "angular-inline-style", "angular-inline-template", "angular-let-declaration", "angular-template", "angular-template-blocks"] }, { name: "apache", scopeName: "source.apacheconf" }, { name: "apex", scopeName: "source.apex" }, { name: "apl", scopeName: "source.apl", embedded: ["html", "xml", "css", "javascript", "json"] }, { name: "applescript", scopeName: "source.applescript" }, { name: "ara", scopeName: "source.ara" }, { name: "asciidoc", scopeName: "text.asciidoc", aliases: ["adoc"], embedded: ["html", "yaml", "csv", "css", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "regexp", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "markdown", "log", "erlang", "elixir", "latex", "bibtex", "abap", "rst", "haskell", "kotlin"] }, { name: "asm", scopeName: "source.asm.x86_64" }, { name: "astro", scopeName: "source.astro", embedded: ["json", "javascript", "typescript", "stylus", "sass", "css", "scss", "less", "postcss", "tsx"] }, { name: "awk", scopeName: "source.awk" }, { name: "ballerina", scopeName: "source.ballerina" }, { name: "bat", scopeName: "source.batchfile", aliases: ["batch"] }, { name: "beancount", scopeName: "text.beancount" }, { name: "berry", scopeName: "source.berry", aliases: ["be"] }, { name: "bibtex", scopeName: "text.bibtex" }, { name: "bicep", scopeName: "source.bicep" }, { name: "blade", scopeName: "text.html.php.blade", embedded: ["html-derivative", "html", "xml", "sql", "javascript", "json", "css"] }, { name: "bsl", scopeName: "source.bsl", aliases: ["1c"], embedded: ["sdbl"] }, { name: "c", scopeName: "source.c" }, { name: "cadence", scopeName: "source.cadence", aliases: ["cdc"] }, { name: "cairo", scopeName: "source.cairo0", embedded: ["python"] }, { name: "clarity", scopeName: "source.clar" }, { name: "clojure", scopeName: "source.clojure", aliases: ["clj"] }, { name: "cmake", scopeName: "source.cmake" }, { name: "cobol", scopeName: "source.cobol", embedded: ["html", "java"] }, { name: "codeowners", scopeName: "text.codeowners" }, { name: "codeql", scopeName: "source.ql", aliases: ["ql"] }, { name: "coffee", scopeName: "source.coffee", aliases: ["coffeescript"], embedded: ["javascript"] }, { name: "common-lisp", scopeName: "source.commonlisp", aliases: ["lisp"] }, { name: "coq", scopeName: "source.coq" }, { name: "cpp", scopeName: "source.cpp", aliases: ["c++"], embedded: ["cpp-macro", "regexp", "glsl", "sql"] }, { name: "crystal", scopeName: "source.crystal", embedded: ["html", "sql", "css", "c", "javascript", "shellscript"] }, { name: "csharp", scopeName: "source.cs", aliases: ["c#", "cs"] }, { name: "css", scopeName: "source.css" }, { name: "csv", scopeName: "text.csv" }, { name: "cue", scopeName: "source.cue" }, { name: "cypher", scopeName: "source.cypher", aliases: ["cql"] }, { name: "d", scopeName: "source.d" }, { name: "dart", scopeName: "source.dart" }, { name: "dax", scopeName: "source.dax" }, { name: "desktop", scopeName: "source.desktop" }, { name: "diff", scopeName: "source.diff" }, { name: "docker", scopeName: "source.dockerfile", aliases: ["dockerfile"] }, { name: "dotenv", scopeName: "source.dotenv" }, { name: "dream-maker", scopeName: "source.dm" }, { name: "edge", scopeName: "text.html.edge", embedded: ["typescript", "html", "html-derivative"] }, { name: "elixir", scopeName: "source.elixir", embedded: ["html"] }, { name: "elm", scopeName: "source.elm", embedded: ["glsl"] }, { name: "emacs-lisp", scopeName: "source.emacs.lisp", aliases: ["elisp"] }, { name: "erb", scopeName: "text.html.erb", embedded: ["html", "ruby"] }, { name: "erlang", scopeName: "source.erlang", aliases: ["erl"], embedded: ["markdown"] }, { name: "fennel", scopeName: "source.fnl" }, { name: "fish", scopeName: "source.fish" }, { name: "fluent", scopeName: "source.ftl", aliases: ["ftl"] }, { name: "fortran-fixed-form", scopeName: "source.fortran.fixed", aliases: ["f", "for", "f77"], embedded: ["fortran-free-form"] }, { name: "fortran-free-form", scopeName: "source.fortran.free", aliases: ["f90", "f95", "f03", "f08", "f18"] }, { name: "fsharp", scopeName: "source.fsharp", aliases: ["f#", "fs"], embedded: ["markdown"] }, { name: "gdresource", scopeName: "source.gdresource", embedded: ["gdshader", "gdscript"] }, { name: "gdscript", scopeName: "source.gdscript" }, { name: "gdshader", scopeName: "source.gdshader" }, { name: "genie", scopeName: "source.genie" }, { name: "gherkin", scopeName: "text.gherkin.feature" }, { name: "git-commit", scopeName: "text.git-commit", embedded: ["diff"] }, { name: "git-rebase", scopeName: "text.git-rebase", embedded: ["shellscript"] }, { name: "gleam", scopeName: "source.gleam" }, { name: "glimmer-js", scopeName: "source.gjs", aliases: ["gjs"], embedded: ["javascript", "typescript", "css", "html"] }, { name: "glimmer-ts", scopeName: "source.gts", aliases: ["gts"], embedded: ["typescript", "css", "javascript", "html"] }, { name: "glsl", scopeName: "source.glsl", embedded: ["c"] }, { name: "gnuplot", scopeName: "source.gnuplot" }, { name: "go", scopeName: "source.go" }, { name: "graphql", scopeName: "source.graphql", aliases: ["gql"], embedded: ["javascript", "typescript", "jsx", "tsx"] }, { name: "groovy", scopeName: "source.groovy" }, { name: "hack", scopeName: "source.hack", embedded: ["html", "sql"] }, { name: "haml", scopeName: "text.haml", embedded: ["ruby", "javascript", "sass", "coffee", "markdown", "css"] }, { name: "handlebars", scopeName: "text.html.handlebars", aliases: ["hbs"], embedded: ["html", "css", "javascript", "yaml"] }, { name: "haskell", scopeName: "source.haskell", aliases: ["hs"] }, { name: "haxe", scopeName: "source.hx" }, { name: "hcl", scopeName: "source.hcl" }, { name: "hjson", scopeName: "source.hjson" }, { name: "hlsl", scopeName: "source.hlsl" }, { name: "html", scopeName: "text.html.basic", embedded: ["json", "css", "javascript"] }, { name: "html-derivative", scopeName: "text.html.derivative", embedded: ["html"] }, { name: "http", scopeName: "source.http", embedded: ["shellscript", "json", "xml", "graphql"] }, { name: "hxml", scopeName: "source.hxml", embedded: ["haxe"] }, { name: "hy", scopeName: "source.hy" }, { name: "imba", scopeName: "source.imba" }, { name: "ini", scopeName: "source.ini", aliases: ["properties"] }, { name: "java", scopeName: "source.java" }, { name: "javascript", scopeName: "source.js", aliases: ["js", "mjs", "cjs"], embedded: ["html", "css"] }, { name: "jinja", scopeName: "source.jinja", embedded: ["jinja-html"] }, { name: "jison", scopeName: "source.jison", embedded: ["javascript"] }, { name: "json", scopeName: "source.json" }, { name: "json5", scopeName: "source.json5" }, { name: "jsonc", scopeName: "source.json.comments" }, { name: "jsonl", scopeName: "source.json.lines" }, { name: "jsonnet", scopeName: "source.jsonnet" }, { name: "jssm", scopeName: "source.jssm", aliases: ["fsl"] }, { name: "jsx", scopeName: "source.js.jsx", embedded: ["html", "css"] }, { name: "julia", scopeName: "source.julia", aliases: ["jl"], embedded: ["cpp", "python", "javascript", "r", "sql"] }, { name: "kotlin", scopeName: "source.kotlin", aliases: ["kt", "kts"] }, { name: "kusto", scopeName: "source.kusto", aliases: ["kql"] }, { name: "latex", scopeName: "text.tex.latex", embedded: ["tex", "shellscript", "css", "gnuplot", "haskell", "html", "java", "julia", "javascript", "lua", "python", "ruby", "rust", "typescript", "xml", "yaml", "scala"] }, { name: "lean", scopeName: "source.lean4", aliases: ["lean4"] }, { name: "less", scopeName: "source.css.less" }, { name: "liquid", scopeName: "text.html.liquid", embedded: ["html", "css", "json", "javascript"] }, { name: "llvm", scopeName: "source.llvm" }, { name: "log", scopeName: "text.log" }, { name: "logo", scopeName: "source.logo" }, { name: "lua", scopeName: "source.lua", embedded: ["c"] }, { name: "luau", scopeName: "source.luau" }, { name: "make", scopeName: "source.makefile", aliases: ["makefile"] }, { name: "markdown", scopeName: "text.html.markdown", aliases: ["md"], embedded: ["css", "html", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "regexp", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "log", "erlang", "elixir", "latex", "bibtex", "html-derivative"] }, { name: "marko", scopeName: "text.marko", embedded: ["css", "less", "scss", "typescript"] }, { name: "matlab", scopeName: "source.matlab" }, { name: "mdc", scopeName: "text.markdown.mdc.standalone", embedded: ["markdown", "yaml", "html-derivative"] }, { name: "mdx", scopeName: "source.mdx", embedded: ["tsx", "toml", "yaml", "c", "clojure", "coffee", "cpp", "csharp", "css", "diff", "docker", "elixir", "elm", "erlang", "go", "graphql", "haskell", "html", "ini", "java", "javascript", "json", "julia", "kotlin", "less", "lua", "make", "markdown", "objective-c", "perl", "python", "r", "ruby", "rust", "scala", "scss", "shellscript", "shellsession", "sql", "xml", "swift", "typescript"] }, { name: "mermaid", scopeName: "markdown.mermaid.codeblock", aliases: ["mmd"] }, { name: "mipsasm", scopeName: "source.mips", aliases: ["mips"] }, { name: "mojo", scopeName: "source.mojo" }, { name: "move", scopeName: "source.move" }, { name: "narrat", scopeName: "source.narrat", aliases: ["nar"] }, { name: "nextflow", scopeName: "source.nextflow", aliases: ["nf"] }, { name: "nginx", scopeName: "source.nginx", embedded: ["lua"] }, { name: "nim", scopeName: "source.nim", embedded: ["c", "html", "xml", "javascript", "css", "glsl", "markdown"] }, { name: "nix", scopeName: "source.nix" }, { name: "nushell", scopeName: "source.nushell", aliases: ["nu"] }, { name: "objective-c", scopeName: "source.objc", aliases: ["objc"] }, { name: "objective-cpp", scopeName: "source.objcpp" }, { name: "ocaml", scopeName: "source.ocaml" }, { name: "pascal", scopeName: "source.pascal" }, { name: "perl", scopeName: "source.perl", embedded: ["html", "xml", "css", "javascript", "sql"] }, { name: "php", scopeName: "source.php", embedded: ["html", "xml", "sql", "javascript", "json", "css"] }, { name: "plsql", scopeName: "source.plsql.oracle" }, { name: "po", scopeName: "source.po", aliases: ["pot", "potx"] }, { name: "polar", scopeName: "source.polar" }, { name: "postcss", scopeName: "source.css.postcss" }, { name: "powerquery", scopeName: "source.powerquery" }, { name: "powershell", scopeName: "source.powershell", aliases: ["ps", "ps1"] }, { name: "prisma", scopeName: "source.prisma" }, { name: "prolog", scopeName: "source.prolog" }, { name: "proto", scopeName: "source.proto", aliases: ["protobuf"] }, { name: "pug", scopeName: "text.pug", aliases: ["jade"], embedded: ["javascript", "css", "sass", "scss", "stylus", "coffee", "html"] }, { name: "puppet", scopeName: "source.puppet" }, { name: "purescript", scopeName: "source.purescript" }, { name: "python", scopeName: "source.python", aliases: ["py"] }, { name: "qml", scopeName: "source.qml", embedded: ["javascript"] }, { name: "qmldir", scopeName: "source.qmldir" }, { name: "qss", scopeName: "source.qss" }, { name: "r", scopeName: "source.r" }, { name: "racket", scopeName: "source.racket" }, { name: "raku", scopeName: "source.perl.6", aliases: ["perl6"] }, { name: "razor", scopeName: "text.aspnetcorerazor", embedded: ["html", "csharp"] }, { name: "reg", scopeName: "source.reg" }, { name: "regexp", scopeName: "source.regexp.python", aliases: ["regex"] }, { name: "rel", scopeName: "source.rel" }, { name: "riscv", scopeName: "source.riscv" }, { name: "rst", scopeName: "source.rst", embedded: ["html-derivative", "cpp", "python", "javascript", "shellscript", "yaml", "cmake", "ruby"] }, { name: "ruby", scopeName: "source.ruby", aliases: ["rb"], embedded: ["html", "haml", "xml", "sql", "graphql", "css", "cpp", "c", "javascript", "shellscript", "lua", "yaml"] }, { name: "rust", scopeName: "source.rust", aliases: ["rs"] }, { name: "sas", scopeName: "source.sas", embedded: ["sql"] }, { name: "sass", scopeName: "source.sass" }, { name: "scala", scopeName: "source.scala" }, { name: "scheme", scopeName: "source.scheme" }, { name: "scss", scopeName: "source.css.scss", embedded: ["css"] }, { name: "sdbl", scopeName: "source.sdbl", aliases: ["1c-query"] }, { name: "shaderlab", scopeName: "source.shaderlab", aliases: ["shader"], embedded: ["hlsl"] }, { name: "shellscript", scopeName: "source.shell", aliases: ["bash", "sh", "shell", "zsh"] }, { name: "shellsession", scopeName: "text.shell-session", aliases: ["console"], embedded: ["shellscript"] }, { name: "smalltalk", scopeName: "source.smalltalk" }, { name: "solidity", scopeName: "source.solidity" }, { name: "soy", scopeName: "text.html.soy", aliases: ["closure-templates"], embedded: ["html"] }, { name: "sparql", scopeName: "source.sparql", embedded: ["turtle"] }, { name: "splunk", scopeName: "source.splunk_search", aliases: ["spl"] }, { name: "sql", scopeName: "source.sql" }, { name: "ssh-config", scopeName: "source.ssh-config" }, { name: "stata", scopeName: "source.stata", embedded: ["sql"] }, { name: "stylus", scopeName: "source.stylus", aliases: ["styl"] }, { name: "svelte", scopeName: "source.svelte", embedded: ["javascript", "typescript", "coffee", "stylus", "sass", "css", "scss", "less", "postcss", "pug", "markdown"] }, { name: "swift", scopeName: "source.swift" }, { name: "system-verilog", scopeName: "source.systemverilog" }, { name: "systemd", scopeName: "source.systemd" }, { name: "talonscript", scopeName: "source.talon", aliases: ["talon"] }, { name: "tasl", scopeName: "source.tasl" }, { name: "tcl", scopeName: "source.tcl" }, { name: "templ", scopeName: "source.templ", embedded: ["go", "javascript", "css"] }, { name: "terraform", scopeName: "source.hcl.terraform", aliases: ["tf", "tfvars"] }, { name: "tex", scopeName: "text.tex", embedded: ["r"] }, { name: "toml", scopeName: "source.toml" }, { name: "ts-tags", scopeName: "source.ts.tags", aliases: ["lit"], embedded: ["typescript", "es-tag-css", "es-tag-glsl", "es-tag-html", "es-tag-sql", "es-tag-xml"] }, { name: "tsv", scopeName: "text.tsv" }, { name: "tsx", scopeName: "source.tsx", embedded: ["html", "css"] }, { name: "turtle", scopeName: "source.turtle" }, { name: "twig", scopeName: "text.html.twig", embedded: ["css", "javascript", "scss", "php", "python", "ruby"] }, { name: "typescript", scopeName: "source.ts", aliases: ["ts", "mts", "cts"], embedded: ["html", "css"] }, { name: "typespec", scopeName: "source.tsp", aliases: ["tsp"] }, { name: "typst", scopeName: "source.typst", aliases: ["typ"] }, { name: "v", scopeName: "source.v" }, { name: "vala", scopeName: "source.vala" }, { name: "vb", scopeName: "source.asp.vb.net", aliases: ["cmd"] }, { name: "verilog", scopeName: "source.verilog" }, { name: "vhdl", scopeName: "source.vhdl" }, { name: "viml", scopeName: "source.viml", aliases: ["vim", "vimscript"] }, { name: "vue", scopeName: "source.vue", embedded: ["markdown", "pug", "stylus", "sass", "css", "scss", "less", "javascript", "typescript", "jsx", "tsx", "coffee", "json", "jsonc", "json5", "yaml", "toml", "graphql", "html-derivative", "html", "markdown-vue", "vue-directives", "vue-interpolations", "vue-sfc-style-variable-injection"] }, { name: "vue-html", scopeName: "text.html.vue-html", embedded: ["vue", "javascript"] }, { name: "vue-vine", scopeName: "source.vue-vine", embedded: ["css", "scss", "less", "stylus", "postcss", "vue", "javascript"] }, { name: "vyper", scopeName: "source.vyper", aliases: ["vy"] }, { name: "wasm", scopeName: "source.wat" }, { name: "wenyan", scopeName: "source.wenyan", aliases: ["\u6587\u8A00"] }, { name: "wgsl", scopeName: "source.wgsl" }, { name: "wikitext", scopeName: "source.wikitext", aliases: ["mediawiki", "wiki"], embedded: ["html", "css", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "go", "groovy", "pug", "javascript", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "rust", "scala", "shellscript", "typescript", "csharp", "fsharp", "dart", "handlebars", "markdown", "erlang", "elixir", "latex", "bibtex", "json"] }, { name: "wit", scopeName: "source.wit" }, { name: "wolfram", scopeName: "source.wolfram", aliases: ["wl"] }, { name: "xml", scopeName: "text.xml", embedded: ["java"] }, { name: "xsl", scopeName: "text.xml.xsl", embedded: ["xml"] }, { name: "yaml", scopeName: "source.yaml", aliases: ["yml"] }, { name: "zenscript", scopeName: "source.zenscript" }, { name: "zig", scopeName: "source.zig" }];
|
|
7
|
+
// <define:SHIKI_GRAMMARS>
|
|
8
|
+
var define_SHIKI_GRAMMARS_default = [{ name: "abap", scopeName: "source.abap" }, { name: "actionscript-3", scopeName: "source.actionscript.3" }, { name: "ada", scopeName: "source.ada" }, { name: "angular-html", scopeName: "text.html.derivative.ng", embedded: ["html", "angular-expression", "angular-let-declaration", "angular-template", "angular-template-blocks"] }, { name: "angular-ts", scopeName: "source.ts.ng", embedded: ["angular-expression", "angular-inline-style", "angular-inline-template", "angular-let-declaration", "angular-template", "angular-template-blocks"] }, { name: "apache", scopeName: "source.apacheconf" }, { name: "apex", scopeName: "source.apex" }, { name: "apl", scopeName: "source.apl", embedded: ["html", "xml", "css", "javascript", "json"] }, { name: "applescript", scopeName: "source.applescript" }, { name: "ara", scopeName: "source.ara" }, { name: "asciidoc", scopeName: "text.asciidoc", aliases: ["adoc"], embedded: ["html", "yaml", "csv", "css", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "regexp", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "markdown", "log", "erlang", "elixir", "latex", "bibtex", "abap", "rst", "haskell", "kotlin"] }, { name: "asm", scopeName: "source.asm.x86_64" }, { name: "astro", scopeName: "source.astro", embedded: ["json", "javascript", "typescript", "stylus", "sass", "css", "scss", "less", "postcss", "tsx"] }, { name: "awk", scopeName: "source.awk" }, { name: "ballerina", scopeName: "source.ballerina" }, { name: "bat", scopeName: "source.batchfile", aliases: ["batch"] }, { name: "beancount", scopeName: "text.beancount" }, { name: "berry", scopeName: "source.berry", aliases: ["be"] }, { name: "bibtex", scopeName: "text.bibtex" }, { name: "bicep", scopeName: "source.bicep" }, { name: "blade", scopeName: "text.html.php.blade", embedded: ["html-derivative", "html", "xml", "sql", "javascript", "json", "css"] }, { name: "bsl", scopeName: "source.bsl", aliases: ["1c"], embedded: ["sdbl"] }, { name: "c", scopeName: "source.c" }, { name: "cadence", scopeName: "source.cadence", aliases: ["cdc"] }, { name: "cairo", scopeName: "source.cairo0", embedded: ["python"] }, { name: "clarity", scopeName: "source.clar" }, { name: "clojure", scopeName: "source.clojure", aliases: ["clj"] }, { name: "cmake", scopeName: "source.cmake" }, { name: "cobol", scopeName: "source.cobol", embedded: ["html", "java"] }, { name: "codeowners", scopeName: "text.codeowners" }, { name: "codeql", scopeName: "source.ql", aliases: ["ql"] }, { name: "coffee", scopeName: "source.coffee", aliases: ["coffeescript"], embedded: ["javascript"] }, { name: "common-lisp", scopeName: "source.commonlisp", aliases: ["lisp"] }, { name: "coq", scopeName: "source.coq" }, { name: "cpp", scopeName: "source.cpp", aliases: ["c++"], embedded: ["cpp-macro", "regexp", "glsl", "sql"] }, { name: "crystal", scopeName: "source.crystal", embedded: ["html", "sql", "css", "c", "javascript", "shellscript"] }, { name: "csharp", scopeName: "source.cs", aliases: ["c#", "cs"] }, { name: "css", scopeName: "source.css" }, { name: "csv", scopeName: "text.csv" }, { name: "cue", scopeName: "source.cue" }, { name: "cypher", scopeName: "source.cypher", aliases: ["cql"] }, { name: "d", scopeName: "source.d" }, { name: "dart", scopeName: "source.dart" }, { name: "dax", scopeName: "source.dax" }, { name: "desktop", scopeName: "source.desktop" }, { name: "diff", scopeName: "source.diff" }, { name: "docker", scopeName: "source.dockerfile", aliases: ["dockerfile"] }, { name: "dotenv", scopeName: "source.dotenv" }, { name: "dream-maker", scopeName: "source.dm" }, { name: "edge", scopeName: "text.html.edge", embedded: ["typescript", "html", "html-derivative"] }, { name: "elixir", scopeName: "source.elixir", embedded: ["html"] }, { name: "elm", scopeName: "source.elm", embedded: ["glsl"] }, { name: "emacs-lisp", scopeName: "source.emacs.lisp", aliases: ["elisp"] }, { name: "erb", scopeName: "text.html.erb", embedded: ["html", "ruby"] }, { name: "erlang", scopeName: "source.erlang", aliases: ["erl"], embedded: ["markdown"] }, { name: "fennel", scopeName: "source.fnl" }, { name: "fish", scopeName: "source.fish" }, { name: "fluent", scopeName: "source.ftl", aliases: ["ftl"] }, { name: "fortran-fixed-form", scopeName: "source.fortran.fixed", aliases: ["f", "for", "f77"], embedded: ["fortran-free-form"] }, { name: "fortran-free-form", scopeName: "source.fortran.free", aliases: ["f90", "f95", "f03", "f08", "f18"] }, { name: "fsharp", scopeName: "source.fsharp", aliases: ["f#", "fs"], embedded: ["markdown"] }, { name: "gdresource", scopeName: "source.gdresource", embedded: ["gdshader", "gdscript"] }, { name: "gdscript", scopeName: "source.gdscript" }, { name: "gdshader", scopeName: "source.gdshader" }, { name: "genie", scopeName: "source.genie" }, { name: "gherkin", scopeName: "text.gherkin.feature" }, { name: "git-commit", scopeName: "text.git-commit", embedded: ["diff"] }, { name: "git-rebase", scopeName: "text.git-rebase", embedded: ["shellscript"] }, { name: "gleam", scopeName: "source.gleam" }, { name: "glimmer-js", scopeName: "source.gjs", aliases: ["gjs"], embedded: ["javascript", "typescript", "css", "html"] }, { name: "glimmer-ts", scopeName: "source.gts", aliases: ["gts"], embedded: ["typescript", "css", "javascript", "html"] }, { name: "glsl", scopeName: "source.glsl", embedded: ["c"] }, { name: "gnuplot", scopeName: "source.gnuplot" }, { name: "go", scopeName: "source.go" }, { name: "graphql", scopeName: "source.graphql", aliases: ["gql"], embedded: ["javascript", "typescript", "jsx", "tsx"] }, { name: "groovy", scopeName: "source.groovy" }, { name: "hack", scopeName: "source.hack", embedded: ["html", "sql"] }, { name: "haml", scopeName: "text.haml", embedded: ["ruby", "javascript", "sass", "coffee", "markdown", "css"] }, { name: "handlebars", scopeName: "text.html.handlebars", aliases: ["hbs"], embedded: ["html", "css", "javascript", "yaml"] }, { name: "haskell", scopeName: "source.haskell", aliases: ["hs"] }, { name: "haxe", scopeName: "source.hx" }, { name: "hcl", scopeName: "source.hcl" }, { name: "hjson", scopeName: "source.hjson" }, { name: "hlsl", scopeName: "source.hlsl" }, { name: "html", scopeName: "text.html.basic", embedded: ["json", "css", "javascript"] }, { name: "html-derivative", scopeName: "text.html.derivative", embedded: ["html"] }, { name: "http", scopeName: "source.http", embedded: ["shellscript", "json", "xml", "graphql"] }, { name: "hxml", scopeName: "source.hxml", embedded: ["haxe"] }, { name: "hy", scopeName: "source.hy" }, { name: "imba", scopeName: "source.imba" }, { name: "ini", scopeName: "source.ini", aliases: ["properties"] }, { name: "java", scopeName: "source.java" }, { name: "javascript", scopeName: "source.js", aliases: ["js", "mjs", "cjs"], embedded: ["html", "css"] }, { name: "jinja", scopeName: "source.jinja", embedded: ["jinja-html"] }, { name: "jison", scopeName: "source.jison", embedded: ["javascript"] }, { name: "json", scopeName: "source.json" }, { name: "json5", scopeName: "source.json5" }, { name: "jsonc", scopeName: "source.json.comments" }, { name: "jsonl", scopeName: "source.json.lines" }, { name: "jsonnet", scopeName: "source.jsonnet" }, { name: "jssm", scopeName: "source.jssm", aliases: ["fsl"] }, { name: "jsx", scopeName: "source.js.jsx", embedded: ["html", "css"] }, { name: "julia", scopeName: "source.julia", aliases: ["jl"], embedded: ["cpp", "python", "javascript", "r", "sql"] }, { name: "kotlin", scopeName: "source.kotlin", aliases: ["kt", "kts"] }, { name: "kusto", scopeName: "source.kusto", aliases: ["kql"] }, { name: "latex", scopeName: "text.tex.latex", embedded: ["tex", "shellscript", "css", "gnuplot", "haskell", "html", "java", "julia", "javascript", "lua", "python", "ruby", "rust", "typescript", "xml", "yaml", "scala"] }, { name: "lean", scopeName: "source.lean4", aliases: ["lean4"] }, { name: "less", scopeName: "source.css.less" }, { name: "liquid", scopeName: "text.html.liquid", embedded: ["html", "css", "json", "javascript"] }, { name: "llvm", scopeName: "source.llvm" }, { name: "log", scopeName: "text.log" }, { name: "logo", scopeName: "source.logo" }, { name: "lua", scopeName: "source.lua", embedded: ["c"] }, { name: "luau", scopeName: "source.luau" }, { name: "make", scopeName: "source.makefile", aliases: ["makefile"] }, { name: "markdown", scopeName: "text.html.markdown", aliases: ["md"], embedded: ["css", "html", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "regexp", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "log", "erlang", "elixir", "latex", "bibtex", "html-derivative"] }, { name: "marko", scopeName: "text.marko", embedded: ["css", "less", "scss", "typescript"] }, { name: "matlab", scopeName: "source.matlab" }, { name: "mdc", scopeName: "text.markdown.mdc.standalone", embedded: ["markdown", "yaml", "html-derivative"] }, { name: "mdx", scopeName: "source.mdx", embedded: ["tsx", "toml", "yaml", "c", "clojure", "coffee", "cpp", "csharp", "css", "diff", "docker", "elixir", "elm", "erlang", "go", "graphql", "haskell", "html", "ini", "java", "javascript", "json", "julia", "kotlin", "less", "lua", "make", "markdown", "objective-c", "perl", "python", "r", "ruby", "rust", "scala", "scss", "shellscript", "shellsession", "sql", "xml", "swift", "typescript"] }, { name: "mermaid", scopeName: "markdown.mermaid.codeblock", aliases: ["mmd"] }, { name: "mipsasm", scopeName: "source.mips", aliases: ["mips"] }, { name: "mojo", scopeName: "source.mojo" }, { name: "move", scopeName: "source.move" }, { name: "narrat", scopeName: "source.narrat", aliases: ["nar"] }, { name: "nextflow", scopeName: "source.nextflow", aliases: ["nf"] }, { name: "nginx", scopeName: "source.nginx", embedded: ["lua"] }, { name: "nim", scopeName: "source.nim", embedded: ["c", "html", "xml", "javascript", "css", "glsl", "markdown"] }, { name: "nix", scopeName: "source.nix" }, { name: "nushell", scopeName: "source.nushell", aliases: ["nu"] }, { name: "objective-c", scopeName: "source.objc", aliases: ["objc"] }, { name: "objective-cpp", scopeName: "source.objcpp" }, { name: "ocaml", scopeName: "source.ocaml" }, { name: "pascal", scopeName: "source.pascal" }, { name: "perl", scopeName: "source.perl", embedded: ["html", "xml", "css", "javascript", "sql"] }, { name: "php", scopeName: "source.php", embedded: ["html", "xml", "sql", "javascript", "json", "css"] }, { name: "plsql", scopeName: "source.plsql.oracle" }, { name: "po", scopeName: "source.po", aliases: ["pot", "potx"] }, { name: "polar", scopeName: "source.polar" }, { name: "postcss", scopeName: "source.css.postcss" }, { name: "powerquery", scopeName: "source.powerquery" }, { name: "powershell", scopeName: "source.powershell", aliases: ["ps", "ps1"] }, { name: "prisma", scopeName: "source.prisma" }, { name: "prolog", scopeName: "source.prolog" }, { name: "proto", scopeName: "source.proto", aliases: ["protobuf"] }, { name: "pug", scopeName: "text.pug", aliases: ["jade"], embedded: ["javascript", "css", "sass", "scss", "stylus", "coffee", "html"] }, { name: "puppet", scopeName: "source.puppet" }, { name: "purescript", scopeName: "source.purescript" }, { name: "python", scopeName: "source.python", aliases: ["py"] }, { name: "qml", scopeName: "source.qml", embedded: ["javascript"] }, { name: "qmldir", scopeName: "source.qmldir" }, { name: "qss", scopeName: "source.qss" }, { name: "r", scopeName: "source.r" }, { name: "racket", scopeName: "source.racket" }, { name: "raku", scopeName: "source.perl.6", aliases: ["perl6"] }, { name: "razor", scopeName: "text.aspnetcorerazor", embedded: ["html", "csharp"] }, { name: "reg", scopeName: "source.reg" }, { name: "regexp", scopeName: "source.regexp.python", aliases: ["regex"] }, { name: "rel", scopeName: "source.rel" }, { name: "riscv", scopeName: "source.riscv" }, { name: "rst", scopeName: "source.rst", embedded: ["html-derivative", "cpp", "python", "javascript", "shellscript", "yaml", "cmake", "ruby"] }, { name: "ruby", scopeName: "source.ruby", aliases: ["rb"], embedded: ["html", "haml", "xml", "sql", "graphql", "css", "cpp", "c", "javascript", "shellscript", "lua", "yaml"] }, { name: "rust", scopeName: "source.rust", aliases: ["rs"] }, { name: "sas", scopeName: "source.sas", embedded: ["sql"] }, { name: "sass", scopeName: "source.sass" }, { name: "scala", scopeName: "source.scala" }, { name: "scheme", scopeName: "source.scheme" }, { name: "scss", scopeName: "source.css.scss", embedded: ["css"] }, { name: "sdbl", scopeName: "source.sdbl", aliases: ["1c-query"] }, { name: "shaderlab", scopeName: "source.shaderlab", aliases: ["shader"], embedded: ["hlsl"] }, { name: "shellscript", scopeName: "source.shell", aliases: ["bash", "sh", "shell", "zsh"] }, { name: "shellsession", scopeName: "text.shell-session", aliases: ["console"], embedded: ["shellscript"] }, { name: "smalltalk", scopeName: "source.smalltalk" }, { name: "solidity", scopeName: "source.solidity" }, { name: "soy", scopeName: "text.html.soy", aliases: ["closure-templates"], embedded: ["html"] }, { name: "sparql", scopeName: "source.sparql", embedded: ["turtle"] }, { name: "splunk", scopeName: "source.splunk_search", aliases: ["spl"] }, { name: "sql", scopeName: "source.sql" }, { name: "ssh-config", scopeName: "source.ssh-config" }, { name: "stata", scopeName: "source.stata", embedded: ["sql"] }, { name: "stylus", scopeName: "source.stylus", aliases: ["styl"] }, { name: "svelte", scopeName: "source.svelte", embedded: ["javascript", "typescript", "coffee", "stylus", "sass", "css", "scss", "less", "postcss", "pug", "markdown"] }, { name: "swift", scopeName: "source.swift" }, { name: "system-verilog", scopeName: "source.systemverilog" }, { name: "systemd", scopeName: "source.systemd" }, { name: "talonscript", scopeName: "source.talon", aliases: ["talon"] }, { name: "tasl", scopeName: "source.tasl" }, { name: "tcl", scopeName: "source.tcl" }, { name: "templ", scopeName: "source.templ", embedded: ["go", "javascript", "css"] }, { name: "terraform", scopeName: "source.hcl.terraform", aliases: ["tf", "tfvars"] }, { name: "tex", scopeName: "text.tex", embedded: ["r"] }, { name: "toml", scopeName: "source.toml" }, { name: "ts-tags", scopeName: "source.ts.tags", aliases: ["lit"], embedded: ["typescript", "es-tag-css", "es-tag-glsl", "es-tag-html", "es-tag-sql", "es-tag-xml"] }, { name: "tsv", scopeName: "text.tsv" }, { name: "tsx", scopeName: "source.tsx", embedded: ["html", "css"] }, { name: "turtle", scopeName: "source.turtle" }, { name: "twig", scopeName: "text.html.twig", embedded: ["css", "javascript", "scss", "php", "python", "ruby"] }, { name: "typescript", scopeName: "source.ts", aliases: ["ts", "mts", "cts"], embedded: ["html", "css"] }, { name: "typespec", scopeName: "source.tsp", aliases: ["tsp"] }, { name: "typst", scopeName: "source.typst", aliases: ["typ"] }, { name: "v", scopeName: "source.v" }, { name: "vala", scopeName: "source.vala" }, { name: "vb", scopeName: "source.asp.vb.net", aliases: ["cmd"] }, { name: "verilog", scopeName: "source.verilog" }, { name: "vhdl", scopeName: "source.vhdl" }, { name: "viml", scopeName: "source.viml", aliases: ["vim", "vimscript"] }, { name: "vue", scopeName: "source.vue", embedded: ["markdown", "pug", "stylus", "sass", "css", "scss", "less", "javascript", "typescript", "jsx", "tsx", "coffee", "json", "jsonc", "json5", "yaml", "toml", "graphql", "html-derivative", "html", "markdown-vue", "vue-directives", "vue-interpolations", "vue-sfc-style-variable-injection"] }, { name: "vue-html", scopeName: "text.html.vue-html", embedded: ["vue", "javascript"] }, { name: "vue-vine", scopeName: "source.vue-vine", embedded: ["css", "scss", "less", "stylus", "postcss", "vue", "javascript"] }, { name: "vyper", scopeName: "source.vyper", aliases: ["vy"] }, { name: "wasm", scopeName: "source.wat" }, { name: "wenyan", scopeName: "source.wenyan", aliases: ["\u6587\u8A00"] }, { name: "wgsl", scopeName: "source.wgsl" }, { name: "wikitext", scopeName: "source.wikitext", aliases: ["mediawiki", "wiki"], embedded: ["html", "css", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "go", "groovy", "pug", "javascript", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "rust", "scala", "shellscript", "typescript", "csharp", "fsharp", "dart", "handlebars", "markdown", "erlang", "elixir", "latex", "bibtex", "json"] }, { name: "wit", scopeName: "source.wit" }, { name: "wolfram", scopeName: "source.wolfram", aliases: ["wl"] }, { name: "xml", scopeName: "text.xml", embedded: ["java"] }, { name: "xsl", scopeName: "text.xml.xsl", embedded: ["xml"] }, { name: "yaml", scopeName: "source.yaml", aliases: ["yml"] }, { name: "zenscript", scopeName: "source.zenscript" }, { name: "zig", scopeName: "source.zig" }];
|
|
9
9
|
|
|
10
|
-
// <define:
|
|
11
|
-
var
|
|
10
|
+
// <define:SHIKI_THEMES>
|
|
11
|
+
var define_SHIKI_THEMES_default = ["andromeeda", "aurora-x", "ayu-dark", "catppuccin-frappe", "catppuccin-latte", "catppuccin-macchiato", "catppuccin-mocha", "dark-plus", "dracula", "dracula-soft", "everforest-dark", "everforest-light", "github-dark", "github-dark-default", "github-dark-dimmed", "github-dark-high-contrast", "github-light", "github-light-default", "github-light-high-contrast", "gruvbox-dark-hard", "gruvbox-dark-medium", "gruvbox-dark-soft", "gruvbox-light-hard", "gruvbox-light-medium", "gruvbox-light-soft", "houston", "kanagawa-dragon", "kanagawa-lotus", "kanagawa-wave", "laserwave", "light-plus", "material-theme", "material-theme-darker", "material-theme-lighter", "material-theme-ocean", "material-theme-palenight", "min-dark", "min-light", "monokai", "night-owl", "nord", "one-dark-pro", "one-light", "plastic", "poimandres", "red", "rose-pine", "rose-pine-dawn", "rose-pine-moon", "slack-dark", "slack-ochin", "snazzy-light", "solarized-dark", "solarized-light", "synthwave-84", "tokyo-night", "vesper", "vitesse-black", "vitesse-dark", "vitesse-light"];
|
|
12
12
|
|
|
13
13
|
// node_modules/.pnpm/@shikijs+types@3.11.0/node_modules/@shikijs/types/dist/index.mjs
|
|
14
14
|
var ShikiError = class extends Error {
|
|
@@ -5627,9 +5627,9 @@ var GrammarState = class _GrammarState {
|
|
|
5627
5627
|
/**
|
|
5628
5628
|
* Static method to create a initial grammar state.
|
|
5629
5629
|
*/
|
|
5630
|
-
static initial(lang,
|
|
5630
|
+
static initial(lang, themes2) {
|
|
5631
5631
|
return new _GrammarState(
|
|
5632
|
-
Object.fromEntries(toArray(
|
|
5632
|
+
Object.fromEntries(toArray(themes2).map((theme) => [theme, INITIAL])),
|
|
5633
5633
|
lang
|
|
5634
5634
|
);
|
|
5635
5635
|
}
|
|
@@ -6425,8 +6425,8 @@ function explainThemeScope(themeSettingsSelectors, scope, parentScopes) {
|
|
|
6425
6425
|
return result;
|
|
6426
6426
|
}
|
|
6427
6427
|
function codeToTokensWithThemes(internal, code, options) {
|
|
6428
|
-
const
|
|
6429
|
-
const themedTokens =
|
|
6428
|
+
const themes2 = Object.entries(options.themes).filter((i) => i[1]).map((i) => ({ color: i[0], theme: i[1] }));
|
|
6429
|
+
const themedTokens = themes2.map((t) => {
|
|
6430
6430
|
const tokens2 = codeToTokensBase(internal, code, {
|
|
6431
6431
|
...options,
|
|
6432
6432
|
theme: t.theme
|
|
@@ -6459,7 +6459,7 @@ function codeToTokensWithThemes(internal, code, options) {
|
|
|
6459
6459
|
offset: ___,
|
|
6460
6460
|
...styles
|
|
6461
6461
|
} = t[lineIdx][tokenIdx];
|
|
6462
|
-
mergedToken.variants[
|
|
6462
|
+
mergedToken.variants[themes2[themeIdx].color] = styles;
|
|
6463
6463
|
});
|
|
6464
6464
|
return mergedToken;
|
|
6465
6465
|
})
|
|
@@ -6472,11 +6472,11 @@ function codeToTokensWithThemes(internal, code, options) {
|
|
|
6472
6472
|
setLastGrammarStateToMap(mergedTokens, mergedGrammarState);
|
|
6473
6473
|
return mergedTokens;
|
|
6474
6474
|
}
|
|
6475
|
-
function syncThemesTokenization(...
|
|
6476
|
-
const outThemes =
|
|
6477
|
-
const count =
|
|
6478
|
-
for (let i = 0; i <
|
|
6479
|
-
const lines =
|
|
6475
|
+
function syncThemesTokenization(...themes2) {
|
|
6476
|
+
const outThemes = themes2.map(() => []);
|
|
6477
|
+
const count = themes2.length;
|
|
6478
|
+
for (let i = 0; i < themes2[0].length; i++) {
|
|
6479
|
+
const lines = themes2.map((t) => t[i]);
|
|
6480
6480
|
const outLines = outThemes.map(() => []);
|
|
6481
6481
|
outThemes.forEach((t, i2) => t.push(outLines[i2]));
|
|
6482
6482
|
const indexes = lines.map(() => 0);
|
|
@@ -6518,8 +6518,8 @@ function codeToTokens(internal, code, options) {
|
|
|
6518
6518
|
cssVariablePrefix = "--shiki-",
|
|
6519
6519
|
colorsRendering = "css-vars"
|
|
6520
6520
|
} = options;
|
|
6521
|
-
const
|
|
6522
|
-
if (
|
|
6521
|
+
const themes2 = Object.entries(options.themes).filter((i) => i[1]).map((i) => ({ color: i[0], theme: i[1] })).sort((a, b) => a.color === defaultColor ? -1 : b.color === defaultColor ? 1 : 0);
|
|
6522
|
+
if (themes2.length === 0)
|
|
6523
6523
|
throw new ShikiError("`themes` option must not be empty");
|
|
6524
6524
|
const themeTokens = codeToTokensWithThemes(
|
|
6525
6525
|
internal,
|
|
@@ -6527,16 +6527,16 @@ function codeToTokens(internal, code, options) {
|
|
|
6527
6527
|
options
|
|
6528
6528
|
);
|
|
6529
6529
|
grammarState = getLastGrammarStateFromMap(themeTokens);
|
|
6530
|
-
if (defaultColor && DEFAULT_COLOR_LIGHT_DARK !== defaultColor && !
|
|
6530
|
+
if (defaultColor && DEFAULT_COLOR_LIGHT_DARK !== defaultColor && !themes2.find((t) => t.color === defaultColor))
|
|
6531
6531
|
throw new ShikiError(`\`themes\` option must contain the defaultColor key \`${defaultColor}\``);
|
|
6532
|
-
const themeRegs =
|
|
6533
|
-
const themesOrder =
|
|
6532
|
+
const themeRegs = themes2.map((t) => internal.getTheme(t.theme));
|
|
6533
|
+
const themesOrder = themes2.map((t) => t.color);
|
|
6534
6534
|
tokens = themeTokens.map((line) => line.map((token) => flatTokenVariants(token, themesOrder, cssVariablePrefix, defaultColor, colorsRendering)));
|
|
6535
6535
|
if (grammarState)
|
|
6536
6536
|
setLastGrammarStateToMap(tokens, grammarState);
|
|
6537
|
-
const themeColorReplacements =
|
|
6538
|
-
fg = mapThemeColors(
|
|
6539
|
-
bg = mapThemeColors(
|
|
6537
|
+
const themeColorReplacements = themes2.map((t) => resolveColorReplacements(t.theme, options));
|
|
6538
|
+
fg = mapThemeColors(themes2, themeRegs, themeColorReplacements, cssVariablePrefix, defaultColor, "fg", colorsRendering);
|
|
6539
|
+
bg = mapThemeColors(themes2, themeRegs, themeColorReplacements, cssVariablePrefix, defaultColor, "bg", colorsRendering);
|
|
6540
6540
|
themeName = `shiki-themes ${themeRegs.map((t) => t.name).join(" ")}`;
|
|
6541
6541
|
rootStyle = defaultColor ? void 0 : [fg, bg].join(";");
|
|
6542
6542
|
} else if ("theme" in options) {
|
|
@@ -6563,14 +6563,14 @@ function codeToTokens(internal, code, options) {
|
|
|
6563
6563
|
grammarState
|
|
6564
6564
|
};
|
|
6565
6565
|
}
|
|
6566
|
-
function mapThemeColors(
|
|
6567
|
-
return
|
|
6566
|
+
function mapThemeColors(themes2, themeRegs, themeColorReplacements, cssVariablePrefix, defaultColor, property, colorsRendering) {
|
|
6567
|
+
return themes2.map((t, idx) => {
|
|
6568
6568
|
const value = applyColorReplacements(themeRegs[idx][property], themeColorReplacements[idx]) || "inherit";
|
|
6569
6569
|
const cssVar = `${cssVariablePrefix + t.color}${property === "bg" ? "-bg" : ""}:${value}`;
|
|
6570
6570
|
if (idx === 0 && defaultColor) {
|
|
6571
|
-
if (defaultColor === DEFAULT_COLOR_LIGHT_DARK &&
|
|
6572
|
-
const lightIndex =
|
|
6573
|
-
const darkIndex =
|
|
6571
|
+
if (defaultColor === DEFAULT_COLOR_LIGHT_DARK && themes2.length > 1) {
|
|
6572
|
+
const lightIndex = themes2.findIndex((t2) => t2.color === "light");
|
|
6573
|
+
const darkIndex = themes2.findIndex((t2) => t2.color === "dark");
|
|
6574
6574
|
if (lightIndex === -1 || darkIndex === -1)
|
|
6575
6575
|
throw new ShikiError('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');
|
|
6576
6576
|
const lightValue = applyColorReplacements(themeRegs[lightIndex][property], themeColorReplacements[lightIndex]) || "inherit";
|
|
@@ -6955,9 +6955,9 @@ async function resolveLangs(langs) {
|
|
|
6955
6955
|
langs.filter((l) => !isSpecialLang(l)).map(async (lang) => await normalizeGetter(lang).then((r) => Array.isArray(r) ? r : [r]))
|
|
6956
6956
|
)).flat()));
|
|
6957
6957
|
}
|
|
6958
|
-
async function resolveThemes(
|
|
6958
|
+
async function resolveThemes(themes2) {
|
|
6959
6959
|
const resolved = await Promise.all(
|
|
6960
|
-
|
|
6960
|
+
themes2.map(
|
|
6961
6961
|
async (theme) => isSpecialTheme(theme) ? null : normalizeTheme(await normalizeGetter(theme))
|
|
6962
6962
|
)
|
|
6963
6963
|
);
|
|
@@ -7169,9 +7169,9 @@ function createShikiInternalSync(options) {
|
|
|
7169
7169
|
if (!options.engine)
|
|
7170
7170
|
throw new ShikiError2("`engine` option is required for synchronous mode");
|
|
7171
7171
|
const langs = (options.langs || []).flat(1);
|
|
7172
|
-
const
|
|
7172
|
+
const themes2 = (options.themes || []).flat(1).map(normalizeTheme);
|
|
7173
7173
|
const resolver = new Resolver(options.engine, langs);
|
|
7174
|
-
const _registry = new Registry2(resolver,
|
|
7174
|
+
const _registry = new Registry2(resolver, themes2, langs, options.langAlias);
|
|
7175
7175
|
let _lastTheme;
|
|
7176
7176
|
function getLanguage(name) {
|
|
7177
7177
|
ensureNotDisposed();
|
|
@@ -7217,15 +7217,15 @@ function createShikiInternalSync(options) {
|
|
|
7217
7217
|
async function loadLanguage(...langs2) {
|
|
7218
7218
|
return loadLanguageSync(await resolveLangs(langs2));
|
|
7219
7219
|
}
|
|
7220
|
-
function loadThemeSync(...
|
|
7220
|
+
function loadThemeSync(...themes22) {
|
|
7221
7221
|
ensureNotDisposed();
|
|
7222
|
-
for (const theme of
|
|
7222
|
+
for (const theme of themes22.flat(1)) {
|
|
7223
7223
|
_registry.loadTheme(theme);
|
|
7224
7224
|
}
|
|
7225
7225
|
}
|
|
7226
|
-
async function loadTheme(...
|
|
7226
|
+
async function loadTheme(...themes22) {
|
|
7227
7227
|
ensureNotDisposed();
|
|
7228
|
-
return loadThemeSync(await resolveThemes(
|
|
7228
|
+
return loadThemeSync(await resolveThemes(themes22));
|
|
7229
7229
|
}
|
|
7230
7230
|
function ensureNotDisposed() {
|
|
7231
7231
|
if (isDisposed)
|
|
@@ -7257,7 +7257,7 @@ async function createShikiInternal(options) {
|
|
|
7257
7257
|
warnDeprecated("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");
|
|
7258
7258
|
}
|
|
7259
7259
|
const [
|
|
7260
|
-
|
|
7260
|
+
themes2,
|
|
7261
7261
|
langs,
|
|
7262
7262
|
engine
|
|
7263
7263
|
] = await Promise.all([
|
|
@@ -7267,7 +7267,7 @@ async function createShikiInternal(options) {
|
|
|
7267
7267
|
]);
|
|
7268
7268
|
return createShikiInternalSync({
|
|
7269
7269
|
...options,
|
|
7270
|
-
themes,
|
|
7270
|
+
themes: themes2,
|
|
7271
7271
|
langs,
|
|
7272
7272
|
engine
|
|
7273
7273
|
});
|
|
@@ -8057,8 +8057,9 @@ function normalizeColor(bg, fg) {
|
|
|
8057
8057
|
}
|
|
8058
8058
|
|
|
8059
8059
|
// src/shiki.ts
|
|
8060
|
-
var
|
|
8061
|
-
var
|
|
8060
|
+
var grammars = define_SHIKI_GRAMMARS_default;
|
|
8061
|
+
var themes = /* @__PURE__ */ new Map();
|
|
8062
|
+
var shikiThemeIds = new Set(define_SHIKI_THEMES_default);
|
|
8062
8063
|
async function initShiki({
|
|
8063
8064
|
theme = "vitesse-dark",
|
|
8064
8065
|
langs: languages,
|
|
@@ -8066,13 +8067,13 @@ async function initShiki({
|
|
|
8066
8067
|
engine = createOnigurumaEngine(getDefaultWasmLoader())
|
|
8067
8068
|
} = {}) {
|
|
8068
8069
|
const langs = [];
|
|
8069
|
-
const
|
|
8070
|
+
const themes2 = [];
|
|
8070
8071
|
if (languages?.length) {
|
|
8071
8072
|
const set = /* @__PURE__ */ new Set();
|
|
8072
8073
|
languages.forEach((l) => {
|
|
8073
8074
|
if (typeof l === "string" || l instanceof URL) {
|
|
8074
8075
|
if (!set.has(l.toString())) {
|
|
8075
|
-
const g =
|
|
8076
|
+
const g = grammars.find((g2) => g2.name === l);
|
|
8076
8077
|
if (g?.embedded) {
|
|
8077
8078
|
langs.push(...g.embedded.map((id) => loadTMGrammar(id, tmDownloadCDN)));
|
|
8078
8079
|
}
|
|
@@ -8085,11 +8086,11 @@ async function initShiki({
|
|
|
8085
8086
|
});
|
|
8086
8087
|
}
|
|
8087
8088
|
if (typeof theme === "string" || theme instanceof URL) {
|
|
8088
|
-
|
|
8089
|
+
themes2.push(await loadTMTheme(theme, tmDownloadCDN));
|
|
8089
8090
|
} else if (isPlainObject(theme) || typeof theme === "function") {
|
|
8090
|
-
|
|
8091
|
+
themes2.push(theme);
|
|
8091
8092
|
}
|
|
8092
|
-
const highlighterCore = await createHighlighterCore({ langs, themes, engine });
|
|
8093
|
+
const highlighterCore = await createHighlighterCore({ langs, themes: themes2, engine });
|
|
8093
8094
|
Object.assign(highlighterCore, {
|
|
8094
8095
|
loadThemeFromCDN: (themeName) => highlighterCore.loadTheme(loadTMTheme(themeName, tmDownloadCDN)),
|
|
8095
8096
|
loadGrammarFromCDN: (...ids) => highlighterCore.loadLanguage(...ids.map((id) => loadTMGrammar(id, tmDownloadCDN)))
|
|
@@ -8097,23 +8098,22 @@ async function initShiki({
|
|
|
8097
8098
|
return highlighterCore;
|
|
8098
8099
|
}
|
|
8099
8100
|
function loadTMTheme(src, cdn = "https://esm.sh") {
|
|
8101
|
+
if (typeof src === "string" && themes.has(src)) {
|
|
8102
|
+
return themes.get(src);
|
|
8103
|
+
}
|
|
8100
8104
|
if (typeof src === "string" && /^[a-zA-Z]/.test(src)) {
|
|
8101
8105
|
src = src.replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
return theme;
|
|
8106
|
+
if (!shikiThemeIds.has(src)) {
|
|
8107
|
+
throw new Error(
|
|
8108
|
+
`Invalid theme ID: ${src}, please ensure the theme ID is one of the following: ${Array.from(shikiThemeIds.keys()).join(", ")}`
|
|
8109
|
+
);
|
|
8107
8110
|
}
|
|
8111
|
+
}
|
|
8112
|
+
if (typeof src === "string" && shikiThemeIds.has(src)) {
|
|
8108
8113
|
const url2 = new URL(`/tm-themes@${version2}/themes/${src}.json`, cdn);
|
|
8109
|
-
return cache.fetch(url2).then(
|
|
8110
|
-
(res) => res.json().then((theme2) => {
|
|
8111
|
-
tmThemes.set(src, theme2);
|
|
8112
|
-
return theme2;
|
|
8113
|
-
})
|
|
8114
|
-
);
|
|
8114
|
+
return cache.fetch(url2).then((res) => res.json());
|
|
8115
8115
|
}
|
|
8116
|
-
const url = typeof src === "string" ? new URL(src) : src;
|
|
8116
|
+
const url = typeof src === "string" ? new URL(src, globalThis.location?.href) : src;
|
|
8117
8117
|
if (url.protocol === "http" || url.protocol === "https") {
|
|
8118
8118
|
return cache.fetch(url).then((res) => res.json());
|
|
8119
8119
|
}
|
|
@@ -8121,13 +8121,13 @@ function loadTMTheme(src, cdn = "https://esm.sh") {
|
|
|
8121
8121
|
}
|
|
8122
8122
|
function loadTMGrammar(src, cdn = "https://esm.sh") {
|
|
8123
8123
|
if (typeof src === "string") {
|
|
8124
|
-
const g =
|
|
8124
|
+
const g = grammars.find((g2) => g2.name === src);
|
|
8125
8125
|
if (g) {
|
|
8126
8126
|
const url2 = new URL(`/tm-grammars@${version}/grammars/${g.name}.json`, cdn);
|
|
8127
8127
|
return cache.fetch(url2).then((res) => res.json());
|
|
8128
8128
|
}
|
|
8129
8129
|
}
|
|
8130
|
-
const url = typeof src === "string" ? new URL(src) : src;
|
|
8130
|
+
const url = typeof src === "string" ? new URL(src, globalThis.location?.href) : src;
|
|
8131
8131
|
if (url.protocol === "http" || url.protocol === "https") {
|
|
8132
8132
|
return cache.fetch(url).then((res) => res.json());
|
|
8133
8133
|
}
|
|
@@ -8137,14 +8137,14 @@ function getGarmmarInfoFromPath(path) {
|
|
|
8137
8137
|
const idx = path.lastIndexOf(".");
|
|
8138
8138
|
if (idx > 0) {
|
|
8139
8139
|
const ext = path.slice(idx + 1);
|
|
8140
|
-
return
|
|
8140
|
+
return grammars.find((g) => g.name === ext || g.aliases?.includes(ext));
|
|
8141
8141
|
}
|
|
8142
8142
|
}
|
|
8143
8143
|
function getLanguageIdFromPath(path) {
|
|
8144
8144
|
return getGarmmarInfoFromPath(path)?.name;
|
|
8145
8145
|
}
|
|
8146
8146
|
function getExtnameFromLanguageId(language) {
|
|
8147
|
-
const g =
|
|
8147
|
+
const g = grammars.find((g2) => g2.name === language);
|
|
8148
8148
|
if (g) {
|
|
8149
8149
|
return g.aliases?.[0] ?? g.name;
|
|
8150
8150
|
}
|
|
@@ -8154,13 +8154,13 @@ export {
|
|
|
8154
8154
|
getExtnameFromLanguageId,
|
|
8155
8155
|
getGarmmarInfoFromPath,
|
|
8156
8156
|
getLanguageIdFromPath,
|
|
8157
|
+
grammars,
|
|
8157
8158
|
initShiki,
|
|
8158
8159
|
initShikiMonacoTokenizer,
|
|
8159
8160
|
registerShikiMonacoTokenizer,
|
|
8160
8161
|
render,
|
|
8161
8162
|
setDefaultWasmLoader,
|
|
8162
8163
|
textmateThemeToMonacoTheme,
|
|
8163
|
-
|
|
8164
|
-
tmThemes
|
|
8164
|
+
themes
|
|
8165
8165
|
};
|
|
8166
8166
|
/*! based on https://github.com/shikijs/shiki/blob/main/packages/monaco/src/index.ts */
|
package/package.json
CHANGED
package/types/core.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { TextmateGrammar, TextmateTheme } from "./index.d.ts";
|
|
2
|
+
import type { LSPProvider } from "./lsp.d.ts";
|
|
3
|
+
|
|
4
|
+
export function registerSyntax(...syntaxes: TextmateGrammar[]): void;
|
|
5
|
+
export function registerTheme(theme: TextmateTheme): void;
|
|
6
|
+
export function registerLSPProvider(lang: string, provider: LSPProvider): void;
|
|
4
7
|
export * from "./index";
|