vde-open 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/THIRD_PARTY_NOTICES.md +159 -235
- package/dist/cli.js +929 -55
- package/dist/daemon.js +3 -4
- package/dist/{heap-C3qHm7SE.js → heap-wO8Issp7.js} +1 -2
- package/dist/{html-static-Ct_9qmNR.js → html-static-FxIbpM5b.js} +1630 -1216
- package/dist/{main-CI9PoWer.js → main-C6WuJzmz.js} +618 -320
- package/dist/{print-Bb6ArlQl.js → print-DNdOXOlQ.js} +281 -346
- package/dist/{render-CY_Mrhyl.js → render-CO37G_5o.js} +4 -7
- package/dist/rolldown-runtime-Bl4WtXjF.js +32 -0
- package/dist/{search-index-B0xpVDwG.js → search-index-CWn1X9n-.js} +160 -79
- package/dist/web/assets/main-cNlDXnWn.js +124 -0
- package/dist/web/assets/markdown.worker-iSTaa6gR.js +13 -0
- package/dist/web/assets/mobile-DlPHtOJc.js +1 -0
- package/dist/web/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
- package/dist/web/assets/src-B8UfTgKw.js +40 -0
- package/dist/web/assets/src-DgGe2wbt.css +2 -0
- package/dist/web/index.html +4 -4
- package/dist/web/mobile.html +4 -4
- package/dist/workers/parse-worker.js +5 -6
- package/dist/workers/search-worker.js +3 -4
- package/docs/agent-usage.md +3 -0
- package/package.json +7 -6
- package/skills/vde-open/SKILL.md +9 -1
- package/dist/web/assets/main-DcvVu7FQ.js +0 -123
- package/dist/web/assets/markdown.worker-BhrAVXtB.js +0 -13
- package/dist/web/assets/mobile-HCpMXT2S.js +0 -1
- package/dist/web/assets/rolldown-runtime-CbXtAM7H.js +0 -1
- package/dist/web/assets/src--PpHwH7V.js +0 -41
- package/dist/web/assets/src-DinzSLDA.css +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as parseMarkdown, D as serialize, E as parseFragment, M as escapeHtml$2, N as footnoteReferenceId, O as defaultTreeAdapter, T as parse, b as dirnameOfLogicalPath, c as renderedLinkOf, g as parseMarkdownDocument, i as transformStaticHtml, j as escapeAttr, k as NS, n as resolveAssetUrl, o as transformCss, s as localImagePath, t as DiagnosticLog, u as MARKDOWN_PARSE_OPTIONS } from "./html-static-
|
|
2
|
-
|
|
1
|
+
import { A as parseMarkdown, D as serialize, E as parseFragment, M as escapeHtml$2, N as footnoteReferenceId, O as defaultTreeAdapter, T as parse, b as dirnameOfLogicalPath, c as renderedLinkOf, g as parseMarkdownDocument, i as transformStaticHtml, j as escapeAttr, k as NS, n as resolveAssetUrl, o as transformCss, s as localImagePath, t as DiagnosticLog, u as MARKDOWN_PARSE_OPTIONS } from "./html-static-FxIbpM5b.js";
|
|
2
|
+
// ../../node_modules/.pnpm/@tanstack+markdown@1.2.0_react@19.3.1/node_modules/@tanstack/markdown/dist/html.js
|
|
3
3
|
function renderHtml(input, options = {}) {
|
|
4
4
|
return (typeof input === "string" ? parseMarkdown(input, options) : input).children.map((node) => renderBlock(node, options)).join("\n");
|
|
5
5
|
}
|
|
@@ -132,8 +132,100 @@ function renderComponentAttrs(node) {
|
|
|
132
132
|
}
|
|
133
133
|
return Object.entries(props).map(([key, value]) => ` ${key}="${escapeAttr(value)}"`).join("");
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/render.js
|
|
136
|
+
function renderTokenOutput(tokens, options, renderer) {
|
|
137
|
+
const rangeDecorations = [];
|
|
138
|
+
const lineDecorations = [];
|
|
139
|
+
for (const decoration of options.decorations || []) {
|
|
140
|
+
if (!decoration.range) {
|
|
141
|
+
lineDecorations.push(decoration);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const [start, end] = decoration.range;
|
|
145
|
+
if (hasIntegerOffsets(start, end) && start < end) rangeDecorations.push(decoration);
|
|
146
|
+
}
|
|
147
|
+
const cursor = {
|
|
148
|
+
index: 0,
|
|
149
|
+
offset: 0,
|
|
150
|
+
boundaries: [0, 0]
|
|
151
|
+
};
|
|
152
|
+
if (!options.lineNumbers && !lineDecorations.length) return renderTokenSlice(tokens, 0, 1e400, rangeDecorations, cursor, renderer);
|
|
153
|
+
const code = tokens.map((token) => token.value).join("");
|
|
154
|
+
const nodes = [];
|
|
155
|
+
let start = 0;
|
|
156
|
+
for (let line = 1;; line++) {
|
|
157
|
+
const newline = code.indexOf("\n", start);
|
|
158
|
+
const end = newline < 0 ? code.length : newline;
|
|
159
|
+
const active = lineDecorations.filter((decoration) => includesLine(decoration.lines, line));
|
|
160
|
+
nodes.push(renderer.element(["th-line", ...active.flatMap((decoration) => splitClassNames(decoration.className))], lineData(active, line), renderTokenSlice(tokens, start, end, rangeDecorations, cursor, renderer)));
|
|
161
|
+
if (newline < 0) break;
|
|
162
|
+
nodes.push(renderer.text("\n"));
|
|
163
|
+
start = end + 1;
|
|
164
|
+
if (start === code.length) break;
|
|
165
|
+
}
|
|
166
|
+
return nodes;
|
|
167
|
+
}
|
|
168
|
+
function renderTokenSlice(tokens, start, end, decorations, cursor, renderer) {
|
|
169
|
+
const nodes = [];
|
|
170
|
+
for (; cursor.index < tokens.length; cursor.index++) {
|
|
171
|
+
const token = tokens[cursor.index];
|
|
172
|
+
const tokenStart = cursor.offset;
|
|
173
|
+
const tokenEnd = tokenStart + token.value.length;
|
|
174
|
+
const sliceStart = Math.max(start, tokenStart);
|
|
175
|
+
const sliceEnd = Math.min(end, tokenEnd);
|
|
176
|
+
if (sliceStart < sliceEnd) {
|
|
177
|
+
let sorted = cursor.boundaries;
|
|
178
|
+
sorted[0] = sliceStart;
|
|
179
|
+
sorted[1] = sliceEnd;
|
|
180
|
+
let boundaries;
|
|
181
|
+
for (const decoration of decorations) {
|
|
182
|
+
const [decorationStart, decorationEnd] = decoration.range;
|
|
183
|
+
if (decorationEnd <= sliceStart || decorationStart >= sliceEnd) continue;
|
|
184
|
+
boundaries ||= new Set(sorted);
|
|
185
|
+
boundaries.add(Math.max(sliceStart, decorationStart)).add(Math.min(sliceEnd, decorationEnd));
|
|
186
|
+
}
|
|
187
|
+
if (boundaries) sorted = [...boundaries].sort((a, b) => a - b);
|
|
188
|
+
for (let index = 0; index < sorted.length - 1; index++) {
|
|
189
|
+
const segmentStart = sorted[index];
|
|
190
|
+
const segmentEnd = sorted[index + 1];
|
|
191
|
+
let node = renderer.text(token.value.slice(segmentStart - tokenStart, segmentEnd - tokenStart));
|
|
192
|
+
if (token.className) node = renderer.token(token.className, node);
|
|
193
|
+
for (const decoration of decorations) {
|
|
194
|
+
if (decoration.range[0] > segmentStart || decoration.range[1] < segmentEnd) continue;
|
|
195
|
+
node = renderer.element(["th-decoration", ...splitClassNames(decoration.className)], stringifyData(decoration.data), [node]);
|
|
196
|
+
}
|
|
197
|
+
nodes.push(node);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (tokenEnd > end) break;
|
|
201
|
+
cursor.offset = tokenEnd;
|
|
202
|
+
}
|
|
203
|
+
return nodes;
|
|
204
|
+
}
|
|
205
|
+
function includesLine(lines, line) {
|
|
206
|
+
return typeof lines === "number" ? lines === line : line >= lines[0] && line <= lines[1];
|
|
207
|
+
}
|
|
208
|
+
function lineData(decorations, line) {
|
|
209
|
+
const data = Object.fromEntries(decorations.flatMap((decoration) => dataEntries(decoration.data)));
|
|
210
|
+
data.line = String(line);
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
213
|
+
function stringifyData(data) {
|
|
214
|
+
if (data) return Object.fromEntries(dataEntries(data));
|
|
215
|
+
}
|
|
216
|
+
function dataEntries(data) {
|
|
217
|
+
return Object.entries(data || {}).map(([key, value]) => [normalizeDataKey(key), String(value)]);
|
|
218
|
+
}
|
|
219
|
+
function normalizeDataKey(value) {
|
|
220
|
+
return value.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`).replace(/[^a-z0-9_.:-]/gi, "-");
|
|
221
|
+
}
|
|
222
|
+
function splitClassNames(className) {
|
|
223
|
+
return className?.match(/\S+/g) || [];
|
|
224
|
+
}
|
|
225
|
+
function hasIntegerOffsets(start, end) {
|
|
226
|
+
return Number.isInteger(start) && Number.isInteger(end);
|
|
227
|
+
}
|
|
228
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/core.js
|
|
137
229
|
function defineLanguage(definition) {
|
|
138
230
|
return definition;
|
|
139
231
|
}
|
|
@@ -153,15 +245,15 @@ function createHighlighter({ fallbackLanguage = "plaintext", languages }) {
|
|
|
153
245
|
function tokenizeRanges(code, lang, depth = 0) {
|
|
154
246
|
const definition = definitions.get(normalizeLanguage(lang));
|
|
155
247
|
if (!definition || depth > 24) return [];
|
|
156
|
-
return
|
|
248
|
+
return definition.tokenize(code, {
|
|
157
249
|
hasLanguage(candidate) {
|
|
158
250
|
const resolved = aliases.get(normalizeName(candidate));
|
|
159
251
|
return Boolean(resolved && definitions.has(resolved));
|
|
160
252
|
},
|
|
161
253
|
tokenize(embeddedCode, embeddedLanguage) {
|
|
162
|
-
return tokenizeRanges(embeddedCode, embeddedLanguage, depth + 1);
|
|
254
|
+
return normalizeTokenRanges(embeddedCode.length, tokenizeRanges(embeddedCode, embeddedLanguage, depth + 1));
|
|
163
255
|
}
|
|
164
|
-
})
|
|
256
|
+
});
|
|
165
257
|
}
|
|
166
258
|
function tokenize(code, options = {}) {
|
|
167
259
|
const lang = normalizeLanguage(options.lang);
|
|
@@ -169,12 +261,17 @@ function createHighlighter({ fallbackLanguage = "plaintext", languages }) {
|
|
|
169
261
|
return {
|
|
170
262
|
code,
|
|
171
263
|
lang,
|
|
172
|
-
tokens:
|
|
264
|
+
tokens: normalizeTokenRanges(code.length, ranges, code)
|
|
173
265
|
};
|
|
174
266
|
}
|
|
175
267
|
function highlight(code, options = {}) {
|
|
176
268
|
const result = tokenize(code, options);
|
|
177
|
-
|
|
269
|
+
let innerHtml = "";
|
|
270
|
+
if (!options.lineNumbers && !options.decorations?.length) for (const token of result.tokens) {
|
|
271
|
+
const value = escapeHtml$1(token.value);
|
|
272
|
+
innerHtml += token.className ? renderHtmlToken(token.className, value) : value;
|
|
273
|
+
}
|
|
274
|
+
else innerHtml = renderTokenOutput(result.tokens, options, htmlRenderer).join("");
|
|
178
275
|
return {
|
|
179
276
|
...result,
|
|
180
277
|
html: `<pre class="th-code th-code--${escapeHtml$1(result.lang)}${options.lineNumbers ? " th-code--line-numbers" : ""}" data-language="${escapeHtml$1(result.lang)}"><code>${innerHtml}</code></pre>`
|
|
@@ -208,42 +305,38 @@ function createHighlighter({ fallbackLanguage = "plaintext", languages }) {
|
|
|
208
305
|
tokenize
|
|
209
306
|
};
|
|
210
307
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
children: renderTokenSlice(tokens, start, end, rangeDecorations, cursor)
|
|
240
|
-
});
|
|
241
|
-
if (hasNewline) nodes.push({
|
|
242
|
-
type: "text",
|
|
243
|
-
value: "\n"
|
|
244
|
-
});
|
|
308
|
+
const nodeRenderer = {
|
|
309
|
+
text: (value) => ({
|
|
310
|
+
type: "text",
|
|
311
|
+
value
|
|
312
|
+
}),
|
|
313
|
+
token: (className, child) => ({
|
|
314
|
+
type: "element",
|
|
315
|
+
classNames: ["th-token", `th-${className}`],
|
|
316
|
+
children: [child]
|
|
317
|
+
}),
|
|
318
|
+
element: (classNames, data, children) => ({
|
|
319
|
+
type: "element",
|
|
320
|
+
classNames,
|
|
321
|
+
data,
|
|
322
|
+
children
|
|
323
|
+
})
|
|
324
|
+
};
|
|
325
|
+
function renderHtmlToken(className, child) {
|
|
326
|
+
return `<span class="th-token th-${escapeHtml$1(className)}">${child}</span>`;
|
|
327
|
+
}
|
|
328
|
+
const htmlRenderer = {
|
|
329
|
+
text: escapeHtml$1,
|
|
330
|
+
token: renderHtmlToken,
|
|
331
|
+
element(classNames, attributes, children) {
|
|
332
|
+
const className = escapeHtml$1(classNames.join(" "));
|
|
333
|
+
let data = "";
|
|
334
|
+
if (attributes) for (const [key, value] of Object.entries(attributes)) data += ` data-${key}="${escapeHtml$1(value)}"`;
|
|
335
|
+
return `<span${className ? ` class="${className}"` : ""}${data}>${children.join("")}</span>`;
|
|
245
336
|
}
|
|
246
|
-
|
|
337
|
+
};
|
|
338
|
+
function renderTokens(tokens, options = {}) {
|
|
339
|
+
return renderTokenOutput(tokens, options, nodeRenderer);
|
|
247
340
|
}
|
|
248
341
|
function renderNodesToHtml(nodes) {
|
|
249
342
|
let html = "";
|
|
@@ -267,19 +360,19 @@ const htmlEscapes = {
|
|
|
267
360
|
"'": "'"
|
|
268
361
|
};
|
|
269
362
|
function escapeHtml$1(value) {
|
|
270
|
-
return value.replace(/[&<>"']/g, (character) => htmlEscapes[character]);
|
|
363
|
+
return /[&<>"']/.test(value) ? value.replace(/[&<>"']/g, (character) => htmlEscapes[character]) : value;
|
|
271
364
|
}
|
|
272
365
|
function normalizeName(value) {
|
|
273
366
|
return value.trim().toLowerCase();
|
|
274
367
|
}
|
|
275
|
-
function normalizeTokenRanges(codeLength, input) {
|
|
368
|
+
function normalizeTokenRanges(codeLength, input, code) {
|
|
276
369
|
const ranges = [];
|
|
277
370
|
let sorted = true;
|
|
278
371
|
let previousStart = 0;
|
|
279
372
|
for (const candidate of input) {
|
|
280
|
-
if (!
|
|
281
|
-
const start = Math.max(0,
|
|
282
|
-
const end = Math.
|
|
373
|
+
if (!hasIntegerOffsets(candidate.start, candidate.end)) continue;
|
|
374
|
+
const start = Math.max(0, candidate.start);
|
|
375
|
+
const end = Math.min(codeLength, candidate.end);
|
|
283
376
|
if (start >= end) continue;
|
|
284
377
|
if (start < previousStart) sorted = false;
|
|
285
378
|
previousStart = start;
|
|
@@ -290,133 +383,55 @@ function normalizeTokenRanges(codeLength, input) {
|
|
|
290
383
|
});
|
|
291
384
|
}
|
|
292
385
|
if (!sorted) ranges.sort((a, b) => a.start - b.start);
|
|
386
|
+
const result = [];
|
|
293
387
|
let end = 0;
|
|
294
|
-
let count = 0;
|
|
295
388
|
for (const candidate of ranges) {
|
|
296
|
-
|
|
297
|
-
|
|
389
|
+
const { start, className } = candidate;
|
|
390
|
+
if (start < end) continue;
|
|
391
|
+
if (code !== void 0 && start > end) result.push({ value: code.slice(end, start) });
|
|
298
392
|
end = candidate.end;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
function rangesToTokens(code, ranges) {
|
|
304
|
-
const tokens = [];
|
|
305
|
-
let index = 0;
|
|
306
|
-
for (const range of ranges) {
|
|
307
|
-
if (range.start > index) tokens.push({ value: code.slice(index, range.start) });
|
|
308
|
-
tokens.push({
|
|
309
|
-
className: range.className,
|
|
310
|
-
value: code.slice(range.start, range.end)
|
|
393
|
+
result.push(code === void 0 ? candidate : {
|
|
394
|
+
className,
|
|
395
|
+
value: code.slice(start, end)
|
|
311
396
|
});
|
|
312
|
-
index = range.end;
|
|
313
|
-
}
|
|
314
|
-
if (index < code.length) tokens.push({ value: code.slice(index) });
|
|
315
|
-
return tokens;
|
|
316
|
-
}
|
|
317
|
-
function renderTokenSlice(tokens, start, end, decorations, cursor) {
|
|
318
|
-
const nodes = [];
|
|
319
|
-
for (; cursor.index < tokens.length; cursor.index++) {
|
|
320
|
-
const token = tokens[cursor.index];
|
|
321
|
-
const tokenStart = cursor.offset;
|
|
322
|
-
const tokenEnd = tokenStart + token.value.length;
|
|
323
|
-
const sliceStart = Math.max(start, tokenStart);
|
|
324
|
-
const sliceEnd = Math.min(end, tokenEnd);
|
|
325
|
-
if (sliceStart < sliceEnd) {
|
|
326
|
-
let sorted = [sliceStart, sliceEnd];
|
|
327
|
-
if (decorations.length) {
|
|
328
|
-
const boundaries = new Set(sorted);
|
|
329
|
-
for (const decoration of decorations) {
|
|
330
|
-
const [decorationStart, decorationEnd] = decoration.range;
|
|
331
|
-
if (decorationEnd <= sliceStart || decorationStart >= sliceEnd) continue;
|
|
332
|
-
boundaries.add(Math.max(sliceStart, decorationStart));
|
|
333
|
-
boundaries.add(Math.min(sliceEnd, decorationEnd));
|
|
334
|
-
}
|
|
335
|
-
sorted = [...boundaries].sort((a, b) => a - b);
|
|
336
|
-
}
|
|
337
|
-
for (let index = 0; index < sorted.length - 1; index++) {
|
|
338
|
-
const segmentStart = sorted[index];
|
|
339
|
-
const segmentEnd = sorted[index + 1];
|
|
340
|
-
let node = {
|
|
341
|
-
type: "text",
|
|
342
|
-
value: token.value.slice(segmentStart - tokenStart, segmentEnd - tokenStart)
|
|
343
|
-
};
|
|
344
|
-
if (token.className) node = {
|
|
345
|
-
type: "element",
|
|
346
|
-
classNames: ["th-token", `th-${token.className}`],
|
|
347
|
-
children: [node]
|
|
348
|
-
};
|
|
349
|
-
for (const decoration of decorations) {
|
|
350
|
-
if (decoration.range[0] > segmentStart || decoration.range[1] < segmentEnd) continue;
|
|
351
|
-
node = {
|
|
352
|
-
type: "element",
|
|
353
|
-
classNames: ["th-decoration", ...splitClassNames(decoration.className)],
|
|
354
|
-
data: stringifyData(decoration.data),
|
|
355
|
-
children: [node]
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
nodes.push(node);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
if (tokenEnd > end) break;
|
|
362
|
-
cursor.offset = tokenEnd;
|
|
363
397
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
function getLineStarts(code) {
|
|
367
|
-
const starts = [0];
|
|
368
|
-
for (let index = 0; index < code.length; index++) if (code[index] === "\n" && index + 1 < code.length) starts.push(index + 1);
|
|
369
|
-
return starts;
|
|
370
|
-
}
|
|
371
|
-
function includesLine(lines, line) {
|
|
372
|
-
return typeof lines === "number" ? lines === line : line >= lines[0] && line <= lines[1];
|
|
373
|
-
}
|
|
374
|
-
function mergeData(decorations) {
|
|
375
|
-
const data = {};
|
|
376
|
-
for (const decoration of decorations) Object.assign(data, stringifyData(decoration.data));
|
|
377
|
-
return data;
|
|
378
|
-
}
|
|
379
|
-
function stringifyData(data) {
|
|
380
|
-
if (!data) return void 0;
|
|
381
|
-
return Object.fromEntries(Object.entries(data).map(([key, value]) => [normalizeDataKey(key), String(value)]));
|
|
382
|
-
}
|
|
383
|
-
function normalizeDataKey(value) {
|
|
384
|
-
return toKebabCase(value).replace(/[^a-z0-9_.:-]/gi, "-");
|
|
385
|
-
}
|
|
386
|
-
function splitClassNames(className) {
|
|
387
|
-
return className?.trim().split(/\s+/).filter(Boolean) || [];
|
|
388
|
-
}
|
|
389
|
-
function toKebabCase(value) {
|
|
390
|
-
return value.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`);
|
|
398
|
+
if (code !== void 0 && (end < codeLength || !result.length)) result.push({ value: code.slice(end) });
|
|
399
|
+
return result;
|
|
391
400
|
}
|
|
392
|
-
|
|
393
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/internal/patterns.js
|
|
401
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/patterns.js
|
|
394
402
|
function patternTokenizer(patterns) {
|
|
395
403
|
return (code) => collectPatternRanges(code, patterns);
|
|
396
404
|
}
|
|
397
|
-
function collectPatternRanges(code, patterns, initial = [], occupied = new Uint8Array(code.length)) {
|
|
398
|
-
const ranges = [...initial];
|
|
405
|
+
function collectPatternRanges(code, patterns, initial = [], occupied = new Uint8Array(code.length), ranges = [...initial]) {
|
|
399
406
|
for (const range of initial) occupied.fill(1, range.start, range.end);
|
|
400
407
|
for (const pattern of patterns) {
|
|
401
|
-
if ("
|
|
402
|
-
for (const range of pattern
|
|
408
|
+
if (typeof pattern === "function") {
|
|
409
|
+
for (const range of pattern(code)) addRange(ranges, occupied, range);
|
|
403
410
|
continue;
|
|
404
411
|
}
|
|
405
|
-
const regex =
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
+
const regex = globalRegex(pattern[0]);
|
|
413
|
+
const className = pattern[1];
|
|
414
|
+
const group = pattern[2] || 0;
|
|
415
|
+
const previousLastIndex = regex.lastIndex;
|
|
416
|
+
regex.lastIndex = 0;
|
|
417
|
+
try {
|
|
418
|
+
let match;
|
|
419
|
+
while (match = regex.exec(code)) {
|
|
420
|
+
const value = match[group];
|
|
421
|
+
if (!value) {
|
|
422
|
+
if (!match[0]) regex.lastIndex++;
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
const offset = group ? match[0].length - value.length : 0;
|
|
426
|
+
const start = match.index + offset;
|
|
427
|
+
addRange(ranges, occupied, {
|
|
428
|
+
start,
|
|
429
|
+
end: start + value.length,
|
|
430
|
+
className: typeof className === "function" ? className(match) : className
|
|
431
|
+
});
|
|
412
432
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
addRange(ranges, occupied, {
|
|
416
|
-
start,
|
|
417
|
-
end: start + value.length,
|
|
418
|
-
className: typeof pattern.className === "function" ? pattern.className(match) : pattern.className
|
|
419
|
-
});
|
|
433
|
+
} finally {
|
|
434
|
+
regex.lastIndex = previousLastIndex;
|
|
420
435
|
}
|
|
421
436
|
}
|
|
422
437
|
return ranges;
|
|
@@ -434,48 +449,34 @@ function addRange(ranges, occupied, range) {
|
|
|
434
449
|
occupied.fill(1, range.start, range.end);
|
|
435
450
|
return true;
|
|
436
451
|
}
|
|
437
|
-
function
|
|
438
|
-
return
|
|
452
|
+
function globalRegex(regex) {
|
|
453
|
+
return regex.global ? regex : new RegExp(regex.source, `${regex.flags}g`);
|
|
439
454
|
}
|
|
440
455
|
function hasOverlap(occupied, start, end) {
|
|
441
456
|
for (let index = start; index < end; index++) if (occupied[index]) return true;
|
|
442
457
|
return false;
|
|
443
458
|
}
|
|
444
|
-
|
|
445
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/css.js
|
|
459
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/css.js
|
|
446
460
|
const css = defineLanguage({
|
|
447
461
|
name: "css",
|
|
448
462
|
tokenize: patternTokenizer([
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
className: "property",
|
|
464
|
-
regex: /(?:^|[;{]\s*)([A-Za-z-]+)(?=\s*:)/gm,
|
|
465
|
-
group: 1
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
className: "function",
|
|
469
|
-
regex: /\b[A-Za-z-]+(?=\()/g
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
className: "number",
|
|
473
|
-
regex: /\b\d+(?:\.\d+)?(?:px|rem|em|%|s|ms|vh|vw|deg)?\b/g
|
|
474
|
-
}
|
|
463
|
+
[/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g, (match) => match[0].startsWith("/*") ? "comment" : "string"],
|
|
464
|
+
[/--[A-Za-z0-9_-]+/g, "variable"],
|
|
465
|
+
[
|
|
466
|
+
/(^|[}\n])\s*([^@{}\n][^{}\n]*)(?=\s*\{)/g,
|
|
467
|
+
"selector",
|
|
468
|
+
2
|
|
469
|
+
],
|
|
470
|
+
[
|
|
471
|
+
/(?:^|[;{]\s*)([A-Za-z-]+)(?=\s*:)/gm,
|
|
472
|
+
"property",
|
|
473
|
+
1
|
|
474
|
+
],
|
|
475
|
+
[/\b[A-Za-z-]+(?=\()/g, "function"],
|
|
476
|
+
[/\b\d+(?:\.\d+)?(?:px|rem|em|%|s|ms|vh|vw|deg)?\b/g, "number"]
|
|
475
477
|
])
|
|
476
478
|
});
|
|
477
|
-
|
|
478
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/internal/markup.js
|
|
479
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/markup.js
|
|
479
480
|
const rawTextClosing = {
|
|
480
481
|
script: /<\/script(?=[\s/>])/gi,
|
|
481
482
|
style: /<\/style(?=[\s/>])/gi
|
|
@@ -484,6 +485,7 @@ function collectMarkupRanges(code, context, mode = "html") {
|
|
|
484
485
|
const ranges = [];
|
|
485
486
|
const regions = [];
|
|
486
487
|
let index = 0;
|
|
488
|
+
let lastTagEnd;
|
|
487
489
|
while ((index = code.indexOf("<", index)) >= 0) {
|
|
488
490
|
if (code.startsWith("<!--", index)) {
|
|
489
491
|
const close = code.indexOf("-->", index + 4);
|
|
@@ -514,7 +516,7 @@ function collectMarkupRanges(code, context, mode = "html") {
|
|
|
514
516
|
index++;
|
|
515
517
|
continue;
|
|
516
518
|
}
|
|
517
|
-
const tagEnd = findTagEnd(code, nameStart + nameMatch[0].length);
|
|
519
|
+
const tagEnd = findTagEnd(code, nameStart + nameMatch[0].length, lastTagEnd ??= code.lastIndexOf(">"));
|
|
518
520
|
if (tagEnd < 0) {
|
|
519
521
|
index++;
|
|
520
522
|
continue;
|
|
@@ -545,7 +547,7 @@ function collectMarkupRanges(code, context, mode = "html") {
|
|
|
545
547
|
if (mode === "svelte") collectBraceRegions(code, regions);
|
|
546
548
|
for (const region of regions) {
|
|
547
549
|
if (region.start >= region.end || !context.hasLanguage(region.lang)) continue;
|
|
548
|
-
|
|
550
|
+
for (const range of offsetRanges(context.tokenize(code.slice(region.start, region.end), region.lang), region.start)) ranges.push(range);
|
|
549
551
|
}
|
|
550
552
|
return ranges;
|
|
551
553
|
}
|
|
@@ -613,7 +615,8 @@ function collectBraceRegions(code, regions) {
|
|
|
613
615
|
index = end + 1;
|
|
614
616
|
}
|
|
615
617
|
}
|
|
616
|
-
function findTagEnd(code, start) {
|
|
618
|
+
function findTagEnd(code, start, lastTagEnd) {
|
|
619
|
+
if (start > lastTagEnd) return -1;
|
|
617
620
|
let index = start;
|
|
618
621
|
while (index < code.length) if (code[index] === "\"" || code[index] === "'") index = findQuoteEnd(code, index, code[index], code.length);
|
|
619
622
|
else if (code[index] === ">") return index;
|
|
@@ -627,8 +630,7 @@ function findQuoteEnd(code, start, quote, limit) {
|
|
|
627
630
|
else index++;
|
|
628
631
|
return limit;
|
|
629
632
|
}
|
|
630
|
-
|
|
631
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/html.js
|
|
633
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/html.js
|
|
632
634
|
const html = defineLanguage({
|
|
633
635
|
name: "html",
|
|
634
636
|
aliases: [
|
|
@@ -638,44 +640,28 @@ const html = defineLanguage({
|
|
|
638
640
|
],
|
|
639
641
|
tokenize: (code, context) => collectMarkupRanges(code, context)
|
|
640
642
|
});
|
|
641
|
-
|
|
642
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/internal/script.js
|
|
643
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/script.js
|
|
643
644
|
const semanticPatterns = [
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
className: "function",
|
|
667
|
-
regex: /\bfunction\s*\*?\s*([A-Za-z_$][\w$]*)/g,
|
|
668
|
-
group: 1
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
className: "function",
|
|
672
|
-
regex: /(^|[^.A-Za-z0-9_$])([A-Za-z_$][\w$]*)(?=\s*\()/g,
|
|
673
|
-
group: 2
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
className: "type",
|
|
677
|
-
regex: /\b(?:Array|Record|Promise|Readonly|Set|Map|WeakMap|WeakSet|string|number|boolean|bigint|symbol|object|unknown|never|void|any|[A-Z][A-Za-z0-9_$]*)\b/g
|
|
678
|
-
}
|
|
645
|
+
[
|
|
646
|
+
/(?<!\.)\.([A-Za-z_$][\w$]*)/g,
|
|
647
|
+
"property",
|
|
648
|
+
1
|
|
649
|
+
],
|
|
650
|
+
[/@[A-Za-z_$][\w$]*/g, "function"],
|
|
651
|
+
[new RegExp(`\\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|new|of|override|package|private|protected|public|readonly|return|satisfies|set|static|super|switch|this|throw|try|type|typeof|using|var|while|with|yield)\\b`, "g"), "keyword"],
|
|
652
|
+
[/\b(?:false|null|true|undefined|NaN|Infinity)\b/g, "literal"],
|
|
653
|
+
[/\b(?:0x[\da-f](?:_?[\da-f])*n?|0b[01](?:_?[01])*n?|0o[0-7](?:_?[0-7])*n?|\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:e[+-]?\d(?:_?\d)*)?n?)\b/gi, "number"],
|
|
654
|
+
[
|
|
655
|
+
/\bfunction\s*\*?\s*([A-Za-z_$][\w$]*)/g,
|
|
656
|
+
"function",
|
|
657
|
+
1
|
|
658
|
+
],
|
|
659
|
+
[
|
|
660
|
+
/(^|[^.A-Za-z0-9_$])([A-Za-z_$][\w$]*)(?=\s*\()/g,
|
|
661
|
+
"function",
|
|
662
|
+
2
|
|
663
|
+
],
|
|
664
|
+
[/\b(?:Array|Record|Promise|Readonly|Set|Map|WeakMap|WeakSet|string|number|boolean|bigint|symbol|object|unknown|never|void|any|[A-Z][A-Za-z0-9_$]*)\b/g, "type"]
|
|
679
665
|
];
|
|
680
666
|
function collectScriptRanges(code, jsx = false, jsxAtLineStart = false) {
|
|
681
667
|
const jsxText = jsx ? new Uint8Array(code.length) : void 0;
|
|
@@ -761,20 +747,18 @@ function collectScriptInitialRanges(code, jsx, jsxAtLineStart, jsxText, ranges,
|
|
|
761
747
|
objectBraces.push("=(:,[".includes(code[before] || "\0") || /^(?:return|yield|const|let|var)$/.test(word));
|
|
762
748
|
} else if (character === "}") objectBraces.pop();
|
|
763
749
|
else if (objectBraces.at(-1) && /[A-Za-z_$]/.test(character)) {
|
|
750
|
+
let end = index + 1;
|
|
751
|
+
while (end < limit && /[\w$]/.test(code[end])) end++;
|
|
764
752
|
const before = previousCodeIndex(code, index, ranges);
|
|
765
753
|
if ("{,;".includes(code[before] || "\0")) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
end,
|
|
772
|
-
className: "property"
|
|
773
|
-
});
|
|
774
|
-
index = end;
|
|
775
|
-
continue;
|
|
776
|
-
}
|
|
754
|
+
if (code[end + (code.slice(end).match(/^(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*(?:\n|$))*/)?.[0].length || 0)] === ":") ranges.push({
|
|
755
|
+
start: index,
|
|
756
|
+
end,
|
|
757
|
+
className: "property"
|
|
758
|
+
});
|
|
777
759
|
}
|
|
760
|
+
index = end;
|
|
761
|
+
continue;
|
|
778
762
|
}
|
|
779
763
|
if (!jsx) {
|
|
780
764
|
index++;
|
|
@@ -859,7 +843,7 @@ function collectTemplateRanges(code, start, ranges, jsx, jsxAtLineStart) {
|
|
|
859
843
|
const end = findInterpolationEnd(code, index + 2);
|
|
860
844
|
const expressionEnd = end < 0 ? code.length : end;
|
|
861
845
|
const expression = code.slice(index + 2, expressionEnd);
|
|
862
|
-
|
|
846
|
+
for (const range of offsetRanges(collectScriptRanges(expression, jsx, jsxAtLineStart), index + 2)) ranges.push(range);
|
|
863
847
|
if (end < 0) return code.length;
|
|
864
848
|
ranges.push({
|
|
865
849
|
start: end,
|
|
@@ -949,7 +933,7 @@ function isTypeParameter(code, start, end, closing) {
|
|
|
949
933
|
return /\s+extends\s+/.test(inside) || after[0] === "(" && !inside.trimEnd().endsWith("/");
|
|
950
934
|
}
|
|
951
935
|
function isRegexStart(code, index) {
|
|
952
|
-
const before = code.slice(0, index).trimEnd();
|
|
936
|
+
const before = code.slice(0, index).trimEnd().slice(-11);
|
|
953
937
|
if (!before) return true;
|
|
954
938
|
if (/\b(?:case|delete|in|instanceof|of|return|throw|typeof|void|yield)$/.test(before)) return true;
|
|
955
939
|
return /[=([{,:;!&|?~+*%^<>-]$/.test(before);
|
|
@@ -1002,8 +986,7 @@ function previousCodeIndex(code, index, ranges) {
|
|
|
1002
986
|
}
|
|
1003
987
|
return before;
|
|
1004
988
|
}
|
|
1005
|
-
|
|
1006
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/js.js
|
|
989
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/js.js
|
|
1007
990
|
const js = defineLanguage({
|
|
1008
991
|
name: "js",
|
|
1009
992
|
aliases: [
|
|
@@ -1014,59 +997,36 @@ const js = defineLanguage({
|
|
|
1014
997
|
],
|
|
1015
998
|
tokenize: (code) => collectScriptRanges(code)
|
|
1016
999
|
});
|
|
1017
|
-
|
|
1018
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/json.js
|
|
1000
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/json.js
|
|
1019
1001
|
const json = defineLanguage({
|
|
1020
1002
|
name: "json",
|
|
1021
|
-
aliases: [
|
|
1003
|
+
aliases: [
|
|
1004
|
+
"jsonc",
|
|
1005
|
+
"json5",
|
|
1006
|
+
"jsonl"
|
|
1007
|
+
],
|
|
1022
1008
|
tokenize: patternTokenizer([
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
className: "literal",
|
|
1029
|
-
regex: /\b(?:false|null|true)\b/g
|
|
1030
|
-
},
|
|
1031
|
-
{
|
|
1032
|
-
className: "number",
|
|
1033
|
-
regex: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/gi
|
|
1034
|
-
}
|
|
1009
|
+
[/\/\/[^\n]*|\/\*[\s\S]*?\*\/|("(?:\\.|[^"\\])*")(?=\s*:)|"(?:\\.|[^"\\])*"/g, (match) => match[0].startsWith("//") || match[0].startsWith("/*") ? "comment" : match[1] ? "property" : "string"],
|
|
1010
|
+
[/\b(?:false|null|true)\b/g, "literal"],
|
|
1011
|
+
[/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/gi, "number"]
|
|
1035
1012
|
])
|
|
1036
1013
|
});
|
|
1037
|
-
|
|
1038
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/jsx.js
|
|
1014
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/jsx.js
|
|
1039
1015
|
const jsx = defineLanguage({
|
|
1040
1016
|
name: "jsx",
|
|
1041
1017
|
tokenize: (code) => collectScriptRanges(code, true)
|
|
1042
1018
|
});
|
|
1043
|
-
|
|
1044
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/markdown.js
|
|
1019
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/markdown.js
|
|
1045
1020
|
const markdown = defineLanguage({
|
|
1046
1021
|
name: "markdown",
|
|
1047
1022
|
aliases: ["md"],
|
|
1048
1023
|
tokenize(code, context) {
|
|
1049
1024
|
return collectPatternRanges(code, [
|
|
1050
|
-
{
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
{
|
|
1055
|
-
className: "heading",
|
|
1056
|
-
regex: /^.+\n(?:=+|-+)\s*$/gm
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
className: "code-inline",
|
|
1060
|
-
regex: /`[^`\n]+`/g
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
className: "link",
|
|
1064
|
-
regex: /!?\[[^\]]+\]\([^)]+\)/g
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
className: "meta",
|
|
1068
|
-
regex: /^\s{0,3}(?:>|[-*+] |\d+\. )/gm
|
|
1069
|
-
}
|
|
1025
|
+
[/^#{1,6}\s.*$/gm, "heading"],
|
|
1026
|
+
[/^.+\n(?:=+|-+)\s*$/gm, "heading"],
|
|
1027
|
+
[/`[^`\n]+`/g, "code-inline"],
|
|
1028
|
+
[/!?\[[^\]]+\]\([^)]+\)/g, "link"],
|
|
1029
|
+
[/^\s{0,3}(?:>|[-*+] |\d+\. )/gm, "meta"]
|
|
1070
1030
|
], collectFencedCode(code, context));
|
|
1071
1031
|
}
|
|
1072
1032
|
});
|
|
@@ -1089,7 +1049,7 @@ function collectFencedCode(code, context) {
|
|
|
1089
1049
|
end: contentStart,
|
|
1090
1050
|
className: "meta"
|
|
1091
1051
|
});
|
|
1092
|
-
|
|
1052
|
+
fillCodeRange(contentStart + 1, contentEnd, embedded, ranges);
|
|
1093
1053
|
if (close) ranges.push({
|
|
1094
1054
|
start: close.index,
|
|
1095
1055
|
end: close.index + close[0].length,
|
|
@@ -1099,8 +1059,7 @@ function collectFencedCode(code, context) {
|
|
|
1099
1059
|
}
|
|
1100
1060
|
return ranges;
|
|
1101
1061
|
}
|
|
1102
|
-
function fillCodeRange(start, end, embedded) {
|
|
1103
|
-
const ranges = [];
|
|
1062
|
+
function fillCodeRange(start, end, embedded, ranges) {
|
|
1104
1063
|
let index = start;
|
|
1105
1064
|
for (const range of embedded) {
|
|
1106
1065
|
if (range.start > index) ranges.push({
|
|
@@ -1116,10 +1075,8 @@ function fillCodeRange(start, end, embedded) {
|
|
|
1116
1075
|
end,
|
|
1117
1076
|
className: "code-inline"
|
|
1118
1077
|
});
|
|
1119
|
-
return ranges;
|
|
1120
1078
|
}
|
|
1121
|
-
|
|
1122
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/plaintext.js
|
|
1079
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/plaintext.js
|
|
1123
1080
|
const plaintext = defineLanguage({
|
|
1124
1081
|
name: "plaintext",
|
|
1125
1082
|
aliases: [
|
|
@@ -1129,8 +1086,7 @@ const plaintext = defineLanguage({
|
|
|
1129
1086
|
],
|
|
1130
1087
|
tokenize: () => []
|
|
1131
1088
|
});
|
|
1132
|
-
|
|
1133
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/shell.js
|
|
1089
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/shell.js
|
|
1134
1090
|
const shell = defineLanguage({
|
|
1135
1091
|
name: "shell",
|
|
1136
1092
|
aliases: [
|
|
@@ -1141,20 +1097,14 @@ const shell = defineLanguage({
|
|
|
1141
1097
|
"console"
|
|
1142
1098
|
],
|
|
1143
1099
|
tokenize: patternTokenizer([
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
className: "command",
|
|
1155
|
-
regex: /(^|[\n;|&])\s*([A-Za-z0-9_./-]+)(?=\s|$)/g,
|
|
1156
|
-
group: 2
|
|
1157
|
-
}
|
|
1100
|
+
collectShellLexicalRanges,
|
|
1101
|
+
[/\$[A-Za-z_][A-Za-z0-9_]*|\b[A-Z_][A-Z0-9_]*(?==)/g, "variable"],
|
|
1102
|
+
[/\b(?:case|do|done|elif|else|esac|export|fi|for|function|if|in|select|then|time|until|while)\b/g, "keyword"],
|
|
1103
|
+
[
|
|
1104
|
+
/(^|[\n;|&])\s*([A-Za-z0-9_./-]+)(?=\s|$)/g,
|
|
1105
|
+
"command",
|
|
1106
|
+
2
|
|
1107
|
+
]
|
|
1158
1108
|
])
|
|
1159
1109
|
});
|
|
1160
1110
|
function collectShellLexicalRanges(code) {
|
|
@@ -1253,41 +1203,32 @@ function isInsideQuote(code, index) {
|
|
|
1253
1203
|
else if (!quote && (code[cursor] === "\"" || code[cursor] === "'")) quote = code[cursor];
|
|
1254
1204
|
return Boolean(quote);
|
|
1255
1205
|
}
|
|
1256
|
-
|
|
1257
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/ts.js
|
|
1206
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/ts.js
|
|
1258
1207
|
const ts = defineLanguage({
|
|
1259
1208
|
name: "ts",
|
|
1260
1209
|
aliases: ["typescript", "angular-ts"],
|
|
1261
1210
|
tokenize: (code) => collectScriptRanges(code)
|
|
1262
1211
|
});
|
|
1263
|
-
|
|
1264
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/tsx.js
|
|
1212
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/tsx.js
|
|
1265
1213
|
const tsx = defineLanguage({
|
|
1266
1214
|
name: "tsx",
|
|
1267
1215
|
tokenize: (code) => collectScriptRanges(code, true)
|
|
1268
1216
|
});
|
|
1269
|
-
|
|
1270
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/languages/yaml.js
|
|
1217
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/yaml.js
|
|
1271
1218
|
const yaml = defineLanguage({
|
|
1272
1219
|
name: "yaml",
|
|
1273
1220
|
aliases: ["yml"],
|
|
1274
1221
|
tokenize(code) {
|
|
1275
1222
|
const lexical = [...collectYamlBlockScalars(code), ...collectYamlLexicalRanges(code)];
|
|
1276
1223
|
return collectPatternRanges(code, [
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
regex: /\b(?:false|null|true|yes|no|on|off|~)\b/gi
|
|
1286
|
-
},
|
|
1287
|
-
{
|
|
1288
|
-
className: "number",
|
|
1289
|
-
regex: /\b\d+(?:\.\d+)?\b/g
|
|
1290
|
-
}
|
|
1224
|
+
[
|
|
1225
|
+
/^[ \t-]*([A-Za-z0-9_.-]+)(?=\s*:)/gm,
|
|
1226
|
+
"property",
|
|
1227
|
+
1
|
|
1228
|
+
],
|
|
1229
|
+
collectYamlValues,
|
|
1230
|
+
[/\b(?:false|null|true|yes|no|on|off|~)\b/gi, "literal"],
|
|
1231
|
+
[/\b\d+(?:\.\d+)?\b/g, "number"]
|
|
1291
1232
|
], lexical);
|
|
1292
1233
|
}
|
|
1293
1234
|
});
|
|
@@ -1304,7 +1245,8 @@ function collectYamlBlockScalars(code) {
|
|
|
1304
1245
|
const lineEnd = code.indexOf("\n", end);
|
|
1305
1246
|
const next = lineEnd < 0 ? code.length : lineEnd;
|
|
1306
1247
|
const line = code.slice(end, next);
|
|
1307
|
-
|
|
1248
|
+
const content = line.trimStart();
|
|
1249
|
+
if (content && line.length - content.length <= indentation) break;
|
|
1308
1250
|
end = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
1309
1251
|
}
|
|
1310
1252
|
if (end > start + 1) ranges.push({
|
|
@@ -1372,8 +1314,7 @@ function collectYamlValues(code) {
|
|
|
1372
1314
|
}
|
|
1373
1315
|
return ranges;
|
|
1374
1316
|
}
|
|
1375
|
-
|
|
1376
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/internal/code-fence.js
|
|
1317
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/code-fence.js
|
|
1377
1318
|
const codeDiffNotation = /(?:(?:\/\/|#)[ \t]*\[!code[ \t]+(\+\+|--)\]|\/\*[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*\*\/|<!--[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*-->)[ \t]*\r?$/;
|
|
1378
1319
|
function parseCodeDiffNotation(code) {
|
|
1379
1320
|
const decorations = [];
|
|
@@ -1398,8 +1339,7 @@ function parseCodeDiffNotation(code) {
|
|
|
1398
1339
|
decorations
|
|
1399
1340
|
};
|
|
1400
1341
|
}
|
|
1401
|
-
|
|
1402
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.0.0/node_modules/@tanstack/highlight/dist/markdown.js
|
|
1342
|
+
// ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/markdown.js
|
|
1403
1343
|
function createTanStackMarkdownHighlighter(highlighter) {
|
|
1404
1344
|
return (code, lang = "plaintext", options = {}) => {
|
|
1405
1345
|
const annotated = parseCodeDiffNotation(code);
|
|
@@ -1414,8 +1354,7 @@ function createTanStackMarkdownHighlighter(highlighter) {
|
|
|
1414
1354
|
}));
|
|
1415
1355
|
};
|
|
1416
1356
|
}
|
|
1417
|
-
|
|
1418
|
-
//#region ../../packages/document/src/highlight.ts
|
|
1357
|
+
// ../../packages/document/src/highlight.ts
|
|
1419
1358
|
const MAX_HIGHLIGHT_CHARS = 262144;
|
|
1420
1359
|
const highlighter = createHighlighter({ languages: [
|
|
1421
1360
|
js,
|
|
@@ -1437,8 +1376,7 @@ const safeHighlighter = (code, lang, options) => {
|
|
|
1437
1376
|
const usable = registered.has(normalized) && code.length <= MAX_HIGHLIGHT_CHARS;
|
|
1438
1377
|
return highlightAdapter(code, usable ? normalized : "plaintext", options);
|
|
1439
1378
|
};
|
|
1440
|
-
|
|
1441
|
-
//#region ../../packages/document/src/print-style.ts
|
|
1379
|
+
// ../../packages/document/src/print-style.ts
|
|
1442
1380
|
const SANS = [
|
|
1443
1381
|
"-apple-system",
|
|
1444
1382
|
"BlinkMacSystemFont",
|
|
@@ -1707,8 +1645,7 @@ figure.tm-code-frame > pre {
|
|
|
1707
1645
|
font-variant-emoji: text;
|
|
1708
1646
|
}
|
|
1709
1647
|
`;
|
|
1710
|
-
|
|
1711
|
-
//#region ../../packages/document/src/html-print.ts
|
|
1648
|
+
// ../../packages/document/src/html-print.ts
|
|
1712
1649
|
const PRINT_CSP$1 = "default-src 'none'; img-src data:; font-src data:; style-src 'unsafe-inline' file:; base-uri 'none'; form-action 'none'";
|
|
1713
1650
|
function renderHtmlPrintDocument(input) {
|
|
1714
1651
|
if (!/^[0-9a-f]{32,}$/.test(input.assetSlot)) throw new Error("The asset slot must be random hexadecimal.");
|
|
@@ -1751,8 +1688,7 @@ function renderHtmlPrintDocument(input) {
|
|
|
1751
1688
|
stylesheets
|
|
1752
1689
|
};
|
|
1753
1690
|
}
|
|
1754
|
-
|
|
1755
|
-
//#region ../../packages/document/src/print.ts
|
|
1691
|
+
// ../../packages/document/src/print.ts
|
|
1756
1692
|
const PRINT_CSP = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'";
|
|
1757
1693
|
const KANA = /[\u3041-\u3096\u30a1-\u30fa]/;
|
|
1758
1694
|
const HANGUL = /[\uac00-\ud7af]/;
|
|
@@ -1819,5 +1755,4 @@ function renderPrintDocument(input) {
|
|
|
1819
1755
|
""
|
|
1820
1756
|
].join("\n");
|
|
1821
1757
|
}
|
|
1822
|
-
//#endregion
|
|
1823
1758
|
export { cssString, headerTitle, renderHtmlPrintDocument, renderPrintDocument };
|