@fldr/ui 0.3.8 → 0.3.10
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 +67 -448
- package/ai/component-registry.json +27 -14
- package/ai/component-registry.md +3 -3
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/auth-card/auth-card.test.tsx +20 -14
- package/dist/blocks-source/auth-card/auth-card.tsx +73 -55
- package/dist/blocks-source/file-table/file-table.tsx +197 -150
- package/dist/blocks-source/login-page/login-page.tsx +3 -1
- package/dist/blocks-source/share-dialog/share-dialog.test.tsx +9 -3
- package/dist/blocks-source/share-dialog/share-dialog.tsx +50 -35
- package/dist/blocks.d.ts +24 -5
- package/dist/blocks.js +250 -197
- package/dist/brands.d.ts +143 -0
- package/dist/brands.js +92 -0
- package/dist/{button-DzavLWXm.d.ts → button-CS82eT0x.d.ts} +1 -1
- package/dist/chunks/{checkbox-eifiwbw34xwsikvf.js → checkbox-d5epe4dl78bzy4f8.js} +8 -8
- package/dist/chunks/{dropdown-e5zk0ez21busnt0b.js → dropdown-oec4g1w9kbsjsg15.js} +1 -1
- package/dist/chunks/highlighter-kb7huz24pcziin6d.js +57 -0
- package/dist/chunks/{layer-dialog-m8qb0wzfg3k7406a.js → layer-dialog-ioa3r4ayemppsspx.js} +4 -3
- package/dist/chunks/{table-ngl1b5yc8mcur662.js → table-bdye068ekayq3u1n.js} +1 -1
- package/dist/chunks/table-n5yarooiknhc18ln.js +448 -0
- package/dist/chunks/{table-of-contents-gkjv9ck8etbz64ej.js → table-of-contents-d3pmkrk223umdz9h.js} +1 -1
- package/dist/code/server.js +1 -1
- package/dist/code.js +4 -131
- package/dist/components/banner.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/dropdown.js +1 -1
- package/dist/components/input-group.d.ts +2 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/layer-dialog.js +1 -1
- package/dist/components/link.d.ts +2 -67
- package/dist/components/sidebar.d.ts +2 -1
- package/dist/components/table-of-contents.js +1 -1
- package/dist/components/table.d.ts +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/form.d.ts +207 -0
- package/dist/form.js +317 -0
- package/dist/hotkeys.d.ts +135 -0
- package/dist/hotkeys.js +203 -0
- package/dist/index-9LwQy84o.d.ts +1 -0
- package/dist/index-B7iG0qDU.d.ts +1 -0
- package/dist/{index-B6JNUfG9.d.ts → index-BMXHK-3k.d.ts} +2 -2
- package/dist/{index-B6Wo_iiN.d.ts → index-B_ug9XY7.d.ts} +1 -1
- package/dist/{index-RP_rt8vB.d.ts → index-Bh9kuAvN.d.ts} +1 -1
- package/dist/{index-DjSGDESy.d.ts → index-CAUjUp2G.d.ts} +1 -1
- package/dist/{index-NnHba-T1.d.ts → index-DK28YxxP.d.ts} +2 -2
- package/dist/{index-aahL-0Zw.d.ts → index-DOVlARA6.d.ts} +2 -2
- package/dist/index-DTj6M6kA.d.ts +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.js +5 -6
- package/dist/{input-group-8gEtPiKw.d.ts → input-group-Swzit45o.d.ts} +1 -1
- package/dist/link-CoVXE5W2.d.ts +68 -0
- package/dist/query.d.ts +156 -0
- package/dist/query.js +204 -0
- package/dist/router.d.ts +95 -0
- package/dist/router.js +146 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +4 -0
- package/dist/styles/kumo-binding.css +36 -0
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-fldr.css +18 -18
- package/dist/table.d.ts +245 -0
- package/dist/table.js +3 -0
- package/dist/theming.d.ts +4 -4
- package/dist/theming.js +2 -2
- package/package.json +46 -1
- package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +0 -1364
- package/dist/index-DL1-uSuH.d.ts +0 -1
- /package/dist/{index-BkTAB4wj.d.ts → sidebar-BkTAB4wj.d.ts} +0 -0
|
@@ -1,1364 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/render.js
|
|
3
|
-
function renderTokenOutput(tokens, options, renderer) {
|
|
4
|
-
const rangeDecorations = [];
|
|
5
|
-
const lineDecorations = [];
|
|
6
|
-
for (const decoration of options.decorations || []) {
|
|
7
|
-
if (!decoration.range) {
|
|
8
|
-
lineDecorations.push(decoration);
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
const [start, end] = decoration.range;
|
|
12
|
-
if (hasIntegerOffsets(start, end) && start < end) rangeDecorations.push(decoration);
|
|
13
|
-
}
|
|
14
|
-
const cursor = {
|
|
15
|
-
index: 0,
|
|
16
|
-
offset: 0,
|
|
17
|
-
boundaries: [0, 0]
|
|
18
|
-
};
|
|
19
|
-
if (!options.lineNumbers && !lineDecorations.length) return renderTokenSlice(tokens, 0, Infinity, rangeDecorations, cursor, renderer);
|
|
20
|
-
const code = tokens.map((token) => token.value).join("");
|
|
21
|
-
const nodes = [];
|
|
22
|
-
let start = 0;
|
|
23
|
-
for (let line = 1;; line++) {
|
|
24
|
-
const newline = code.indexOf("\n", start);
|
|
25
|
-
const end = newline < 0 ? code.length : newline;
|
|
26
|
-
const active = lineDecorations.filter((decoration) => includesLine(decoration.lines, line));
|
|
27
|
-
nodes.push(renderer.element(["th-line", ...active.flatMap((decoration) => splitClassNames(decoration.className))], lineData(active, line), renderTokenSlice(tokens, start, end, rangeDecorations, cursor, renderer)));
|
|
28
|
-
if (newline < 0) break;
|
|
29
|
-
nodes.push(renderer.text("\n"));
|
|
30
|
-
start = end + 1;
|
|
31
|
-
if (start === code.length) break;
|
|
32
|
-
}
|
|
33
|
-
return nodes;
|
|
34
|
-
}
|
|
35
|
-
function renderTokenSlice(tokens, start, end, decorations, cursor, renderer) {
|
|
36
|
-
const nodes = [];
|
|
37
|
-
for (; cursor.index < tokens.length; cursor.index++) {
|
|
38
|
-
const token = tokens[cursor.index];
|
|
39
|
-
const tokenStart = cursor.offset;
|
|
40
|
-
const tokenEnd = tokenStart + token.value.length;
|
|
41
|
-
const sliceStart = Math.max(start, tokenStart);
|
|
42
|
-
const sliceEnd = Math.min(end, tokenEnd);
|
|
43
|
-
if (sliceStart < sliceEnd) {
|
|
44
|
-
let sorted = cursor.boundaries;
|
|
45
|
-
sorted[0] = sliceStart;
|
|
46
|
-
sorted[1] = sliceEnd;
|
|
47
|
-
let boundaries;
|
|
48
|
-
for (const decoration of decorations) {
|
|
49
|
-
const [decorationStart, decorationEnd] = decoration.range;
|
|
50
|
-
if (decorationEnd <= sliceStart || decorationStart >= sliceEnd) continue;
|
|
51
|
-
boundaries ||= new Set(sorted);
|
|
52
|
-
boundaries.add(Math.max(sliceStart, decorationStart)).add(Math.min(sliceEnd, decorationEnd));
|
|
53
|
-
}
|
|
54
|
-
if (boundaries) sorted = [...boundaries].sort((a, b) => a - b);
|
|
55
|
-
for (let index = 0; index < sorted.length - 1; index++) {
|
|
56
|
-
const segmentStart = sorted[index];
|
|
57
|
-
const segmentEnd = sorted[index + 1];
|
|
58
|
-
let node = renderer.text(token.value.slice(segmentStart - tokenStart, segmentEnd - tokenStart));
|
|
59
|
-
if (token.className) node = renderer.token(token.className, node);
|
|
60
|
-
for (const decoration of decorations) {
|
|
61
|
-
if (decoration.range[0] > segmentStart || decoration.range[1] < segmentEnd) continue;
|
|
62
|
-
node = renderer.element(["th-decoration", ...splitClassNames(decoration.className)], stringifyData(decoration.data), [node]);
|
|
63
|
-
}
|
|
64
|
-
nodes.push(node);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (tokenEnd > end) break;
|
|
68
|
-
cursor.offset = tokenEnd;
|
|
69
|
-
}
|
|
70
|
-
return nodes;
|
|
71
|
-
}
|
|
72
|
-
function includesLine(lines, line) {
|
|
73
|
-
return typeof lines === "number" ? lines === line : line >= lines[0] && line <= lines[1];
|
|
74
|
-
}
|
|
75
|
-
function lineData(decorations, line) {
|
|
76
|
-
const data = Object.fromEntries(decorations.flatMap((decoration) => dataEntries(decoration.data)));
|
|
77
|
-
data.line = String(line);
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
function stringifyData(data) {
|
|
81
|
-
if (data) return Object.fromEntries(dataEntries(data));
|
|
82
|
-
}
|
|
83
|
-
function dataEntries(data) {
|
|
84
|
-
return Object.entries(data || {}).map(([key, value]) => [normalizeDataKey(key), String(value)]);
|
|
85
|
-
}
|
|
86
|
-
function normalizeDataKey(value) {
|
|
87
|
-
return value.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`).replace(/[^a-z0-9_.:-]/gi, "-");
|
|
88
|
-
}
|
|
89
|
-
function splitClassNames(className) {
|
|
90
|
-
return className?.match(/\S+/g) || [];
|
|
91
|
-
}
|
|
92
|
-
function hasIntegerOffsets(start, end) {
|
|
93
|
-
return Number.isInteger(start) && Number.isInteger(end);
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/core.js
|
|
97
|
-
function defineLanguage(definition) {
|
|
98
|
-
return definition;
|
|
99
|
-
}
|
|
100
|
-
function createHighlighter({ fallbackLanguage = "plaintext", languages }) {
|
|
101
|
-
const definitions = /* @__PURE__ */ new Map();
|
|
102
|
-
const aliases = /* @__PURE__ */ new Map();
|
|
103
|
-
for (const definition of languages) {
|
|
104
|
-
const name = normalizeName(definition.name);
|
|
105
|
-
definitions.set(name, definition);
|
|
106
|
-
aliases.set(name, name);
|
|
107
|
-
for (const alias of definition.aliases || []) aliases.set(normalizeName(alias), name);
|
|
108
|
-
}
|
|
109
|
-
const fallback = normalizeName(fallbackLanguage);
|
|
110
|
-
function normalizeLanguage(lang) {
|
|
111
|
-
return aliases.get(normalizeName(lang || fallback)) || fallback;
|
|
112
|
-
}
|
|
113
|
-
function tokenizeRanges(code, lang, depth = 0) {
|
|
114
|
-
const definition = definitions.get(normalizeLanguage(lang));
|
|
115
|
-
if (!definition || depth > 24) return [];
|
|
116
|
-
return definition.tokenize(code, {
|
|
117
|
-
hasLanguage(candidate) {
|
|
118
|
-
const resolved = aliases.get(normalizeName(candidate));
|
|
119
|
-
return Boolean(resolved && definitions.has(resolved));
|
|
120
|
-
},
|
|
121
|
-
tokenize(embeddedCode, embeddedLanguage) {
|
|
122
|
-
return normalizeTokenRanges(embeddedCode.length, tokenizeRanges(embeddedCode, embeddedLanguage, depth + 1));
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function tokenize(code, options = {}) {
|
|
127
|
-
const lang = normalizeLanguage(options.lang);
|
|
128
|
-
const ranges = tokenizeRanges(code, lang);
|
|
129
|
-
return {
|
|
130
|
-
code,
|
|
131
|
-
lang,
|
|
132
|
-
tokens: normalizeTokenRanges(code.length, ranges, code)
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function highlight(code, options = {}) {
|
|
136
|
-
const result = tokenize(code, options);
|
|
137
|
-
let innerHtml = "";
|
|
138
|
-
if (!options.lineNumbers && !options.decorations?.length) for (const token of result.tokens) {
|
|
139
|
-
const value = escapeHtml(token.value);
|
|
140
|
-
innerHtml += token.className ? renderHtmlToken(token.className, value) : value;
|
|
141
|
-
}
|
|
142
|
-
else innerHtml = renderTokenOutput(result.tokens, options, htmlRenderer).join("");
|
|
143
|
-
return {
|
|
144
|
-
...result,
|
|
145
|
-
html: `<pre class="th-code th-code--${escapeHtml(result.lang)}${options.lineNumbers ? " th-code--line-numbers" : ""}" data-language="${escapeHtml(result.lang)}"><code>${innerHtml}</code></pre>`
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function renderCodeBlockData({ code, decorations, lang, lineNumbers, title }) {
|
|
149
|
-
const copyText = code.trimEnd();
|
|
150
|
-
const result = highlight(copyText, {
|
|
151
|
-
decorations,
|
|
152
|
-
lang,
|
|
153
|
-
lineNumbers
|
|
154
|
-
});
|
|
155
|
-
return {
|
|
156
|
-
copyText,
|
|
157
|
-
htmlMarkup: result.html,
|
|
158
|
-
lang: result.lang,
|
|
159
|
-
title,
|
|
160
|
-
tokens: result.tokens
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
highlight,
|
|
165
|
-
highlightToHtml(code, options = {}) {
|
|
166
|
-
return highlight(code, options).html;
|
|
167
|
-
},
|
|
168
|
-
listLanguages() {
|
|
169
|
-
return [...definitions.keys()];
|
|
170
|
-
},
|
|
171
|
-
normalizeLanguage,
|
|
172
|
-
renderCodeBlockData,
|
|
173
|
-
tokenize
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function renderHtmlToken(className, child) {
|
|
177
|
-
return `<span class="th-token th-${escapeHtml(className)}">${child}</span>`;
|
|
178
|
-
}
|
|
179
|
-
const htmlRenderer = {
|
|
180
|
-
text: escapeHtml,
|
|
181
|
-
token: renderHtmlToken,
|
|
182
|
-
element(classNames, attributes, children) {
|
|
183
|
-
const className = escapeHtml(classNames.join(" "));
|
|
184
|
-
let data = "";
|
|
185
|
-
if (attributes) for (const [key, value] of Object.entries(attributes)) data += ` data-${key}="${escapeHtml(value)}"`;
|
|
186
|
-
return `<span${className ? ` class="${className}"` : ""}${data}>${children.join("")}</span>`;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const htmlEscapes = {
|
|
190
|
-
"&": "&",
|
|
191
|
-
"<": "<",
|
|
192
|
-
">": ">",
|
|
193
|
-
"\"": """,
|
|
194
|
-
"'": "'"
|
|
195
|
-
};
|
|
196
|
-
function escapeHtml(value) {
|
|
197
|
-
return /[&<>"']/.test(value) ? value.replace(/[&<>"']/g, (character) => htmlEscapes[character]) : value;
|
|
198
|
-
}
|
|
199
|
-
function normalizeName(value) {
|
|
200
|
-
return value.trim().toLowerCase();
|
|
201
|
-
}
|
|
202
|
-
function normalizeTokenRanges(codeLength, input, code) {
|
|
203
|
-
const ranges = [];
|
|
204
|
-
let sorted = true;
|
|
205
|
-
let previousStart = 0;
|
|
206
|
-
for (const candidate of input) {
|
|
207
|
-
if (!hasIntegerOffsets(candidate.start, candidate.end)) continue;
|
|
208
|
-
const start = Math.max(0, candidate.start);
|
|
209
|
-
const end = Math.min(codeLength, candidate.end);
|
|
210
|
-
if (start >= end) continue;
|
|
211
|
-
if (start < previousStart) sorted = false;
|
|
212
|
-
previousStart = start;
|
|
213
|
-
ranges.push({
|
|
214
|
-
className: candidate.className,
|
|
215
|
-
start,
|
|
216
|
-
end
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
if (!sorted) ranges.sort((a, b) => a.start - b.start);
|
|
220
|
-
const result = [];
|
|
221
|
-
let end = 0;
|
|
222
|
-
for (const candidate of ranges) {
|
|
223
|
-
const { start, className } = candidate;
|
|
224
|
-
if (start < end) continue;
|
|
225
|
-
if (code !== void 0 && start > end) result.push({ value: code.slice(end, start) });
|
|
226
|
-
end = candidate.end;
|
|
227
|
-
result.push(code === void 0 ? candidate : {
|
|
228
|
-
className,
|
|
229
|
-
value: code.slice(start, end)
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if (code !== void 0 && (end < codeLength || !result.length)) result.push({ value: code.slice(end) });
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/patterns.js
|
|
237
|
-
function patternTokenizer(patterns) {
|
|
238
|
-
return (code) => collectPatternRanges(code, patterns);
|
|
239
|
-
}
|
|
240
|
-
function collectPatternRanges(code, patterns, initial = [], occupied = new Uint8Array(code.length), ranges = [...initial]) {
|
|
241
|
-
for (const range of initial) occupied.fill(1, range.start, range.end);
|
|
242
|
-
for (const pattern of patterns) {
|
|
243
|
-
if (typeof pattern === "function") {
|
|
244
|
-
for (const range of pattern(code)) addRange(ranges, occupied, range);
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
const regex = globalRegex(pattern[0]);
|
|
248
|
-
const className = pattern[1];
|
|
249
|
-
const group = pattern[2] || 0;
|
|
250
|
-
const previousLastIndex = regex.lastIndex;
|
|
251
|
-
regex.lastIndex = 0;
|
|
252
|
-
try {
|
|
253
|
-
let match;
|
|
254
|
-
while (match = regex.exec(code)) {
|
|
255
|
-
const value = match[group];
|
|
256
|
-
if (!value) {
|
|
257
|
-
if (!match[0]) regex.lastIndex++;
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
const offset = group ? match[0].length - value.length : 0;
|
|
261
|
-
const start = match.index + offset;
|
|
262
|
-
addRange(ranges, occupied, {
|
|
263
|
-
start,
|
|
264
|
-
end: start + value.length,
|
|
265
|
-
className: typeof className === "function" ? className(match) : className
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
} finally {
|
|
269
|
-
regex.lastIndex = previousLastIndex;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return ranges;
|
|
273
|
-
}
|
|
274
|
-
function offsetRanges(ranges, offset) {
|
|
275
|
-
return ranges.map((range) => ({
|
|
276
|
-
...range,
|
|
277
|
-
start: range.start + offset,
|
|
278
|
-
end: range.end + offset
|
|
279
|
-
}));
|
|
280
|
-
}
|
|
281
|
-
function addRange(ranges, occupied, range) {
|
|
282
|
-
if (range.start >= range.end || range.start < 0 || range.end > occupied.length || hasOverlap(occupied, range.start, range.end)) return false;
|
|
283
|
-
ranges.push(range);
|
|
284
|
-
occupied.fill(1, range.start, range.end);
|
|
285
|
-
return true;
|
|
286
|
-
}
|
|
287
|
-
function globalRegex(regex) {
|
|
288
|
-
return regex.global ? regex : new RegExp(regex.source, `${regex.flags}g`);
|
|
289
|
-
}
|
|
290
|
-
function hasOverlap(occupied, start, end) {
|
|
291
|
-
for (let index = start; index < end; index++) if (occupied[index]) return true;
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/css.js
|
|
296
|
-
const css = defineLanguage({
|
|
297
|
-
name: "css",
|
|
298
|
-
tokenize: patternTokenizer([
|
|
299
|
-
[/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g, (match) => match[0].startsWith("/*") ? "comment" : "string"],
|
|
300
|
-
[/--[A-Za-z0-9_-]+/g, "variable"],
|
|
301
|
-
[
|
|
302
|
-
/(^|[}\n])\s*([^@{}\n][^{}\n]*)(?=\s*\{)/g,
|
|
303
|
-
"selector",
|
|
304
|
-
2
|
|
305
|
-
],
|
|
306
|
-
[
|
|
307
|
-
/(?:^|[;{]\s*)([A-Za-z-]+)(?=\s*:)/gm,
|
|
308
|
-
"property",
|
|
309
|
-
1
|
|
310
|
-
],
|
|
311
|
-
[/\b[A-Za-z-]+(?=\()/g, "function"],
|
|
312
|
-
[/\b\d+(?:\.\d+)?(?:px|rem|em|%|s|ms|vh|vw|deg)?\b/g, "number"]
|
|
313
|
-
])
|
|
314
|
-
});
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/diff.js
|
|
317
|
-
const diff = defineLanguage({
|
|
318
|
-
name: "diff",
|
|
319
|
-
aliases: ["patch"],
|
|
320
|
-
tokenize: patternTokenizer([
|
|
321
|
-
[/^(?:@@|diff |index |--- |\+\+\+ ).*$/gm, "meta"],
|
|
322
|
-
[/^-.*$/gm, "deleted"],
|
|
323
|
-
[/^\+.*$/gm, "inserted"]
|
|
324
|
-
])
|
|
325
|
-
});
|
|
326
|
-
//#endregion
|
|
327
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/simple-language.js
|
|
328
|
-
function simpleLanguage(options, wordPatterns = regexWordPatterns, owned = false) {
|
|
329
|
-
let pending = options;
|
|
330
|
-
let tokenize;
|
|
331
|
-
return defineLanguage({
|
|
332
|
-
name: options.name,
|
|
333
|
-
aliases: options.aliases,
|
|
334
|
-
tokenize(code) {
|
|
335
|
-
if (!tokenize) {
|
|
336
|
-
tokenize = createSimpleTokenizer(pending, wordPatterns, owned);
|
|
337
|
-
pending = void 0;
|
|
338
|
-
}
|
|
339
|
-
return tokenize(code);
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
function createSimpleTokenizer(options, wordPatterns = regexWordPatterns, owned = false) {
|
|
344
|
-
const flags = options.insensitive ? "gmi" : "gm";
|
|
345
|
-
const lexical = new RegExp(`(${options.comments.source})|(?:${options.strings.source})`, flags);
|
|
346
|
-
const runtime = owned ? { nestedComments: options.nestedComments } : options;
|
|
347
|
-
const collectLexicalRanges = function(code) {
|
|
348
|
-
const ranges = [];
|
|
349
|
-
const previousLastIndex = lexical.lastIndex;
|
|
350
|
-
try {
|
|
351
|
-
lexical.lastIndex = 0;
|
|
352
|
-
let match;
|
|
353
|
-
while (match = lexical.exec(code)) {
|
|
354
|
-
if (!match[0].length) {
|
|
355
|
-
lexical.lastIndex = match.index + 1;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
let end = match.index + match[0].length;
|
|
359
|
-
if (match[1] !== void 0) for (const [open, close] of runtime.nestedComments || []) {
|
|
360
|
-
if (!code.startsWith(open, match.index)) continue;
|
|
361
|
-
let cursor = match.index + open.length;
|
|
362
|
-
let depth = 1;
|
|
363
|
-
while (depth && cursor < code.length) if (code.startsWith(open, cursor)) {
|
|
364
|
-
depth++;
|
|
365
|
-
cursor += open.length;
|
|
366
|
-
} else if (code.startsWith(close, cursor)) {
|
|
367
|
-
depth--;
|
|
368
|
-
cursor += close.length;
|
|
369
|
-
} else cursor++;
|
|
370
|
-
end = cursor;
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
lexical.lastIndex = end;
|
|
374
|
-
ranges.push({
|
|
375
|
-
start: match.index,
|
|
376
|
-
end,
|
|
377
|
-
className: match[1] !== void 0 ? "comment" : "string"
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
} finally {
|
|
381
|
-
lexical.lastIndex = previousLastIndex;
|
|
382
|
-
}
|
|
383
|
-
return ranges;
|
|
384
|
-
};
|
|
385
|
-
const patterns = [];
|
|
386
|
-
patterns.push(...options.beforeWords || []);
|
|
387
|
-
const wordCharacters = options.wordCharacters || "\\w$";
|
|
388
|
-
patterns.push(...wordPatterns(options, flags, wordCharacters));
|
|
389
|
-
patterns.push(...options.rules || []);
|
|
390
|
-
if (options.numbers !== false) patterns.push([options.numbers || new RegExp(String.raw`(?<![\w.])(?:0[xX][\da-fA-F]+|0[bB][01]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)${options.numberSuffix || ""}(?![\w.])`, "g"), "number"]);
|
|
391
|
-
return (code) => {
|
|
392
|
-
const ranges = collectLexicalRanges(code);
|
|
393
|
-
return collectPatternRanges(code, patterns, ranges, void 0, ranges);
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
function wordCategories(options) {
|
|
397
|
-
return [
|
|
398
|
-
["keyword", options.keywords],
|
|
399
|
-
["literal", options.literals],
|
|
400
|
-
["type", options.types]
|
|
401
|
-
];
|
|
402
|
-
}
|
|
403
|
-
function regexWordPatterns(options, flags, wordCharacters) {
|
|
404
|
-
const patterns = [];
|
|
405
|
-
for (const [className, words] of [
|
|
406
|
-
["keyword", options.keywords],
|
|
407
|
-
["literal", options.literals],
|
|
408
|
-
["type", options.types]
|
|
409
|
-
]) if (words) patterns.push([new RegExp(`(?<![${wordCharacters}])(?:${words.split(/\s+/).map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})(?![${wordCharacters}])`, flags), className]);
|
|
410
|
-
return patterns;
|
|
411
|
-
}
|
|
412
|
-
//#endregion
|
|
413
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/word-language.js
|
|
414
|
-
function compiledWordLanguage(options) {
|
|
415
|
-
return simpleLanguage(options, options.insensitive ? void 0 : mapWordPatterns, true);
|
|
416
|
-
}
|
|
417
|
-
function mapWordPatterns(options, flags, wordCharacters) {
|
|
418
|
-
const known = /* @__PURE__ */ new Set();
|
|
419
|
-
const classes = /* @__PURE__ */ new Map();
|
|
420
|
-
for (const [className, words] of wordCategories(options)) if (words) for (const word of words.split(/\s+/)) {
|
|
421
|
-
if (known.has(word)) continue;
|
|
422
|
-
known.add(word);
|
|
423
|
-
if (className !== "keyword") classes.set(word, className);
|
|
424
|
-
}
|
|
425
|
-
return [[new RegExp(`(?<![${wordCharacters}])(?:${[...known].map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})(?![${wordCharacters}])`, flags), (match) => classes.get(match[0]) || "keyword"]];
|
|
426
|
-
}
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/graphql.js
|
|
429
|
-
const graphql = /* @__PURE__ */ compiledWordLanguage({
|
|
430
|
-
name: "graphql",
|
|
431
|
-
aliases: ["gql"],
|
|
432
|
-
comments: /#[^\r\n]*/,
|
|
433
|
-
strings: /"""[\s\S]*?(?:"""|(?![\s\S]))|"(?:\\[\s\S]|[^"\\])*(?:"|(?![\s\S]))/,
|
|
434
|
-
keywords: "directive enum fragment input interface mutation on query scalar schema subscription type union",
|
|
435
|
-
literals: "false null true",
|
|
436
|
-
beforeWords: [[/\$[A-Za-z_]\w*/g, "variable"], [/@[A-Za-z_]\w*/g, "attr"]]
|
|
437
|
-
});
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/markup.js
|
|
440
|
-
const rawTextClosing = {
|
|
441
|
-
script: /<\/script(?=[\s/>])/gi,
|
|
442
|
-
style: /<\/style(?=[\s/>])/gi
|
|
443
|
-
};
|
|
444
|
-
function collectMarkupRanges(code, context, mode = "html") {
|
|
445
|
-
const ranges = [];
|
|
446
|
-
const regions = [];
|
|
447
|
-
let index = 0;
|
|
448
|
-
let lastTagEnd;
|
|
449
|
-
while ((index = code.indexOf("<", index)) >= 0) {
|
|
450
|
-
if (code.startsWith("<!--", index)) {
|
|
451
|
-
const close = code.indexOf("-->", index + 4);
|
|
452
|
-
const end = close < 0 ? code.length : close + 3;
|
|
453
|
-
ranges.push({
|
|
454
|
-
start: index,
|
|
455
|
-
end,
|
|
456
|
-
className: "comment"
|
|
457
|
-
});
|
|
458
|
-
index = end;
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
if (mode === "ejs" && code.startsWith("<%", index)) {
|
|
462
|
-
const close = code.indexOf("%>", index + 2);
|
|
463
|
-
const end = close < 0 ? code.length : close;
|
|
464
|
-
regions.push({
|
|
465
|
-
start: index + 2,
|
|
466
|
-
end,
|
|
467
|
-
lang: "js"
|
|
468
|
-
});
|
|
469
|
-
index = close < 0 ? code.length : close + 2;
|
|
470
|
-
continue;
|
|
471
|
-
}
|
|
472
|
-
const closing = code[index + 1] === "/";
|
|
473
|
-
const nameStart = index + (closing ? 2 : 1);
|
|
474
|
-
const nameMatch = /^[A-Za-z][\w:.-]*/.exec(code.slice(nameStart));
|
|
475
|
-
if (!nameMatch) {
|
|
476
|
-
index++;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
const tagEnd = findTagEnd(code, nameStart + nameMatch[0].length, lastTagEnd ??= code.lastIndexOf(">"));
|
|
480
|
-
if (tagEnd < 0) {
|
|
481
|
-
index++;
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
const tagName = nameMatch[0].toLowerCase();
|
|
485
|
-
ranges.push({
|
|
486
|
-
start: nameStart,
|
|
487
|
-
end: nameStart + nameMatch[0].length,
|
|
488
|
-
className: "tag"
|
|
489
|
-
});
|
|
490
|
-
if (!closing) collectAttributes(code, nameStart + nameMatch[0].length, tagEnd, ranges);
|
|
491
|
-
if (!closing && (tagName === "script" || tagName === "style")) {
|
|
492
|
-
const rawTextClose = rawTextClosing[tagName];
|
|
493
|
-
rawTextClose.lastIndex = tagEnd + 1;
|
|
494
|
-
const contentEnd = rawTextClose.exec(code)?.index ?? code.length;
|
|
495
|
-
const lang = getEmbeddedLanguage(tagName, code.slice(index, tagEnd + 1));
|
|
496
|
-
regions.push({
|
|
497
|
-
start: tagEnd + 1,
|
|
498
|
-
end: contentEnd,
|
|
499
|
-
lang
|
|
500
|
-
});
|
|
501
|
-
index = contentEnd;
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
index = tagEnd + 1;
|
|
505
|
-
}
|
|
506
|
-
if (mode === "vue") collectDelimitedRegions(code, "{{", "}}", "js", regions);
|
|
507
|
-
if (mode === "svelte") collectBraceRegions(code, regions);
|
|
508
|
-
for (const region of regions) {
|
|
509
|
-
if (region.start >= region.end || !context.hasLanguage(region.lang)) continue;
|
|
510
|
-
for (const range of offsetRanges(context.tokenize(code.slice(region.start, region.end), region.lang), region.start)) ranges.push(range);
|
|
511
|
-
}
|
|
512
|
-
return ranges;
|
|
513
|
-
}
|
|
514
|
-
function collectAttributes(code, start, end, ranges) {
|
|
515
|
-
const source = code.slice(start, end);
|
|
516
|
-
const attributes = /\s([:@A-Za-z_][\w:.-]*)(?=\s*(?:=|\/?>))/g;
|
|
517
|
-
let match;
|
|
518
|
-
while (match = attributes.exec(source)) {
|
|
519
|
-
const offset = match[0].indexOf(match[1]);
|
|
520
|
-
const attributeStart = start + match.index + offset;
|
|
521
|
-
ranges.push({
|
|
522
|
-
start: attributeStart,
|
|
523
|
-
end: attributeStart + match[1].length,
|
|
524
|
-
className: "attr"
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
let index = start;
|
|
528
|
-
while (index < end) {
|
|
529
|
-
const quote = code[index];
|
|
530
|
-
if (quote !== "\"" && quote !== "'") {
|
|
531
|
-
index++;
|
|
532
|
-
continue;
|
|
533
|
-
}
|
|
534
|
-
const close = findQuoteEnd(code, index, quote, end);
|
|
535
|
-
ranges.push({
|
|
536
|
-
start: index,
|
|
537
|
-
end: close,
|
|
538
|
-
className: "string"
|
|
539
|
-
});
|
|
540
|
-
index = close;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
function getEmbeddedLanguage(tag, openingTag) {
|
|
544
|
-
if (tag === "style") return "css";
|
|
545
|
-
const lang = /\blang\s*=\s*["']?([\w-]+)/i.exec(openingTag)?.[1];
|
|
546
|
-
return lang === "ts" || lang === "typescript" ? "ts" : "js";
|
|
547
|
-
}
|
|
548
|
-
function collectDelimitedRegions(code, open, close, lang, regions) {
|
|
549
|
-
let index = 0;
|
|
550
|
-
while ((index = code.indexOf(open, index)) >= 0) {
|
|
551
|
-
const end = code.indexOf(close, index + open.length);
|
|
552
|
-
if (end < 0) return;
|
|
553
|
-
regions.push({
|
|
554
|
-
start: index + open.length,
|
|
555
|
-
end,
|
|
556
|
-
lang
|
|
557
|
-
});
|
|
558
|
-
index = end + close.length;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function collectBraceRegions(code, regions) {
|
|
562
|
-
let index = 0;
|
|
563
|
-
while (index < code.length) {
|
|
564
|
-
if (code[index] !== "{" || code[index + 1] === "#") {
|
|
565
|
-
index++;
|
|
566
|
-
continue;
|
|
567
|
-
}
|
|
568
|
-
const end = code.indexOf("}", index + 1);
|
|
569
|
-
if (end < 0) return;
|
|
570
|
-
regions.push({
|
|
571
|
-
start: index + 1,
|
|
572
|
-
end,
|
|
573
|
-
lang: "js"
|
|
574
|
-
});
|
|
575
|
-
index = end + 1;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
function findTagEnd(code, start, lastTagEnd) {
|
|
579
|
-
if (start > lastTagEnd) return -1;
|
|
580
|
-
let index = start;
|
|
581
|
-
while (index < code.length) if (code[index] === "\"" || code[index] === "'") index = findQuoteEnd(code, index, code[index], code.length);
|
|
582
|
-
else if (code[index] === ">") return index;
|
|
583
|
-
else index++;
|
|
584
|
-
return -1;
|
|
585
|
-
}
|
|
586
|
-
function findQuoteEnd(code, start, quote, limit) {
|
|
587
|
-
let index = start + 1;
|
|
588
|
-
while (index < limit) if (code[index] === "\\") index += 2;
|
|
589
|
-
else if (code[index] === quote) return index + 1;
|
|
590
|
-
else index++;
|
|
591
|
-
return limit;
|
|
592
|
-
}
|
|
593
|
-
//#endregion
|
|
594
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/html.js
|
|
595
|
-
const html = defineLanguage({
|
|
596
|
-
name: "html",
|
|
597
|
-
aliases: [
|
|
598
|
-
"htm",
|
|
599
|
-
"xml",
|
|
600
|
-
"angular-html"
|
|
601
|
-
],
|
|
602
|
-
tokenize: (code, context) => collectMarkupRanges(code, context)
|
|
603
|
-
});
|
|
604
|
-
//#endregion
|
|
605
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/internal/script.js
|
|
606
|
-
const semanticPatterns = [
|
|
607
|
-
[
|
|
608
|
-
/(?<!\.)\.([A-Za-z_$][\w$]*)/g,
|
|
609
|
-
"property",
|
|
610
|
-
1
|
|
611
|
-
],
|
|
612
|
-
[/@[A-Za-z_$][\w$]*/g, "function"],
|
|
613
|
-
[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"],
|
|
614
|
-
[/\b(?:false|null|true|undefined|NaN|Infinity)\b/g, "literal"],
|
|
615
|
-
[/\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"],
|
|
616
|
-
[
|
|
617
|
-
/\bfunction\s*\*?\s*([A-Za-z_$][\w$]*)/g,
|
|
618
|
-
"function",
|
|
619
|
-
1
|
|
620
|
-
],
|
|
621
|
-
[
|
|
622
|
-
/(^|[^.A-Za-z0-9_$])([A-Za-z_$][\w$]*)(?=\s*\()/g,
|
|
623
|
-
"function",
|
|
624
|
-
2
|
|
625
|
-
],
|
|
626
|
-
[/\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"]
|
|
627
|
-
];
|
|
628
|
-
function collectScriptRanges(code, jsx = false, jsxAtLineStart = false) {
|
|
629
|
-
const jsxText = jsx ? new Uint8Array(code.length) : void 0;
|
|
630
|
-
const initial = [];
|
|
631
|
-
collectScriptInitialRanges(code, jsx, jsxAtLineStart, jsxText, initial);
|
|
632
|
-
return collectPatternRanges(code, semanticPatterns, initial, jsxText);
|
|
633
|
-
}
|
|
634
|
-
function collectScriptInitialRanges(code, jsx, jsxAtLineStart, jsxText, ranges, index = 0, limit = code.length, tagBody = false) {
|
|
635
|
-
const objectBraces = [];
|
|
636
|
-
const expressions = [];
|
|
637
|
-
let jsxDepth = 0;
|
|
638
|
-
while (index < limit) {
|
|
639
|
-
const expression = expressions.at(-1);
|
|
640
|
-
const inJsxText = jsxDepth > (expression || 0);
|
|
641
|
-
const character = code[index];
|
|
642
|
-
const next = code[index + 1];
|
|
643
|
-
if (inJsxText) {
|
|
644
|
-
if (character === "{") {
|
|
645
|
-
expressions.push(jsxDepth);
|
|
646
|
-
index++;
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
if (character !== "<") {
|
|
650
|
-
const start = index;
|
|
651
|
-
while (index < code.length && code[index] !== "<" && code[index] !== "{") index++;
|
|
652
|
-
jsxText.fill(1, start, index);
|
|
653
|
-
continue;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
if (tagBody && !expressions.length && !jsxDepth && character === ">") return index;
|
|
657
|
-
if (character === "/" && next === "/") {
|
|
658
|
-
const end = findLineEnd(code, index + 2);
|
|
659
|
-
ranges.push({
|
|
660
|
-
start: index,
|
|
661
|
-
end,
|
|
662
|
-
className: "comment"
|
|
663
|
-
});
|
|
664
|
-
index = end;
|
|
665
|
-
continue;
|
|
666
|
-
}
|
|
667
|
-
if (character === "/" && next === "*") {
|
|
668
|
-
const close = code.indexOf("*/", index + 2);
|
|
669
|
-
const end = close < 0 ? code.length : close + 2;
|
|
670
|
-
ranges.push({
|
|
671
|
-
start: index,
|
|
672
|
-
end,
|
|
673
|
-
className: "comment"
|
|
674
|
-
});
|
|
675
|
-
index = end;
|
|
676
|
-
continue;
|
|
677
|
-
}
|
|
678
|
-
if (character === "'" || character === "\"") {
|
|
679
|
-
const end = findQuotedEnd(code, index, character, tagBody && !expressions.length);
|
|
680
|
-
ranges.push({
|
|
681
|
-
start: index,
|
|
682
|
-
end,
|
|
683
|
-
className: "string"
|
|
684
|
-
});
|
|
685
|
-
index = end;
|
|
686
|
-
continue;
|
|
687
|
-
}
|
|
688
|
-
if (character === "`") {
|
|
689
|
-
index = collectTemplateRanges(code, index, ranges, jsx, jsxAtLineStart);
|
|
690
|
-
continue;
|
|
691
|
-
}
|
|
692
|
-
if (character === "/" && !(jsx && code[index - 1] === "<") && isRegexStart(code, index)) {
|
|
693
|
-
const end = findRegexEnd(code, index);
|
|
694
|
-
if (end > index + 1) {
|
|
695
|
-
ranges.push({
|
|
696
|
-
start: index,
|
|
697
|
-
end,
|
|
698
|
-
className: "literal"
|
|
699
|
-
});
|
|
700
|
-
index = end;
|
|
701
|
-
continue;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (character === "{") {
|
|
705
|
-
const before = previousCodeIndex(code, index, ranges);
|
|
706
|
-
let wordStart = before;
|
|
707
|
-
while (wordStart >= 0 && /[\w$]/.test(code[wordStart])) wordStart--;
|
|
708
|
-
const word = code.slice(wordStart + 1, before + 1);
|
|
709
|
-
objectBraces.push("=(:,[".includes(code[before] || "\0") || /^(?:return|yield|const|let|var)$/.test(word));
|
|
710
|
-
} else if (character === "}") objectBraces.pop();
|
|
711
|
-
else if (objectBraces.at(-1) && /[A-Za-z_$]/.test(character)) {
|
|
712
|
-
let end = index + 1;
|
|
713
|
-
while (end < limit && /[\w$]/.test(code[end])) end++;
|
|
714
|
-
const before = previousCodeIndex(code, index, ranges);
|
|
715
|
-
if ("{,;".includes(code[before] || "\0")) {
|
|
716
|
-
if (code[end + (code.slice(end).match(/^(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*(?:\n|$))*/)?.[0].length || 0)] === ":") ranges.push({
|
|
717
|
-
start: index,
|
|
718
|
-
end,
|
|
719
|
-
className: "property"
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
index = end;
|
|
723
|
-
continue;
|
|
724
|
-
}
|
|
725
|
-
if (!jsx) {
|
|
726
|
-
index++;
|
|
727
|
-
continue;
|
|
728
|
-
}
|
|
729
|
-
if (!inJsxText && character === "{" && (expressions.length || tagBody)) {
|
|
730
|
-
expressions.push(expressions.length ? expression : jsxDepth);
|
|
731
|
-
index++;
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
if (!inJsxText && expressions.length && character === "}") {
|
|
735
|
-
expressions.pop();
|
|
736
|
-
index++;
|
|
737
|
-
continue;
|
|
738
|
-
}
|
|
739
|
-
if (character !== "<") {
|
|
740
|
-
index++;
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
743
|
-
if (code.startsWith("</>", index)) {
|
|
744
|
-
jsxDepth--;
|
|
745
|
-
index += 3;
|
|
746
|
-
continue;
|
|
747
|
-
}
|
|
748
|
-
if (code.startsWith("<>", index) && (inJsxText || isJsxStart(code, index, jsxAtLineStart))) {
|
|
749
|
-
jsxDepth++;
|
|
750
|
-
index += 2;
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
|
-
const closing = code[index + 1] === "/";
|
|
754
|
-
const nameStart = index + (closing ? 2 : 1);
|
|
755
|
-
const nameMatch = /^[A-Za-z][\w:.-]*/.exec(code.slice(nameStart));
|
|
756
|
-
if (!nameMatch || !closing && !inJsxText && !isJsxStart(code, index, jsxAtLineStart)) {
|
|
757
|
-
index++;
|
|
758
|
-
continue;
|
|
759
|
-
}
|
|
760
|
-
const end = collectScriptInitialRanges(code, true, jsxAtLineStart, jsxText, ranges, nameStart + nameMatch[0].length, limit, true);
|
|
761
|
-
if (end < 0 || isTypeParameter(code, index, end, closing)) {
|
|
762
|
-
index++;
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
ranges.push({
|
|
766
|
-
start: nameStart,
|
|
767
|
-
end: nameStart + nameMatch[0].length,
|
|
768
|
-
className: "tag"
|
|
769
|
-
});
|
|
770
|
-
if (!closing) collectJsxAttributes(code, nameStart + nameMatch[0].length, end, ranges);
|
|
771
|
-
const selfClosing = /\/\s*$/.test(code.slice(nameStart, end));
|
|
772
|
-
if (closing) jsxDepth--;
|
|
773
|
-
else if (!selfClosing) jsxDepth++;
|
|
774
|
-
index = end + 1;
|
|
775
|
-
}
|
|
776
|
-
return -1;
|
|
777
|
-
}
|
|
778
|
-
function collectTemplateRanges(code, start, ranges, jsx, jsxAtLineStart) {
|
|
779
|
-
let segmentStart = start;
|
|
780
|
-
let index = start + 1;
|
|
781
|
-
while (index < code.length) {
|
|
782
|
-
if (code[index] === "\\") {
|
|
783
|
-
index += 2;
|
|
784
|
-
continue;
|
|
785
|
-
}
|
|
786
|
-
if (code[index] === "`") {
|
|
787
|
-
ranges.push({
|
|
788
|
-
start: segmentStart,
|
|
789
|
-
end: index + 1,
|
|
790
|
-
className: "string"
|
|
791
|
-
});
|
|
792
|
-
return index + 1;
|
|
793
|
-
}
|
|
794
|
-
if (code[index] === "$" && code[index + 1] === "{") {
|
|
795
|
-
if (segmentStart < index) ranges.push({
|
|
796
|
-
start: segmentStart,
|
|
797
|
-
end: index,
|
|
798
|
-
className: "string"
|
|
799
|
-
});
|
|
800
|
-
ranges.push({
|
|
801
|
-
start: index,
|
|
802
|
-
end: index + 2,
|
|
803
|
-
className: "operator"
|
|
804
|
-
});
|
|
805
|
-
const end = findInterpolationEnd(code, index + 2);
|
|
806
|
-
const expressionEnd = end < 0 ? code.length : end;
|
|
807
|
-
const expression = code.slice(index + 2, expressionEnd);
|
|
808
|
-
for (const range of offsetRanges(collectScriptRanges(expression, jsx, jsxAtLineStart), index + 2)) ranges.push(range);
|
|
809
|
-
if (end < 0) return code.length;
|
|
810
|
-
ranges.push({
|
|
811
|
-
start: end,
|
|
812
|
-
end: end + 1,
|
|
813
|
-
className: "operator"
|
|
814
|
-
});
|
|
815
|
-
index = end + 1;
|
|
816
|
-
segmentStart = index;
|
|
817
|
-
continue;
|
|
818
|
-
}
|
|
819
|
-
index++;
|
|
820
|
-
}
|
|
821
|
-
if (segmentStart < code.length) ranges.push({
|
|
822
|
-
start: segmentStart,
|
|
823
|
-
end: code.length,
|
|
824
|
-
className: "string"
|
|
825
|
-
});
|
|
826
|
-
return code.length;
|
|
827
|
-
}
|
|
828
|
-
function findInterpolationEnd(code, start) {
|
|
829
|
-
let depth = 1;
|
|
830
|
-
let index = start;
|
|
831
|
-
while (index < code.length) {
|
|
832
|
-
const character = code[index];
|
|
833
|
-
const next = code[index + 1];
|
|
834
|
-
if (character === "'" || character === "\"") {
|
|
835
|
-
index = findQuotedEnd(code, index, character);
|
|
836
|
-
continue;
|
|
837
|
-
}
|
|
838
|
-
if (character === "`") {
|
|
839
|
-
index = skipTemplate(code, index);
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
if (character === "/" && next === "/") {
|
|
843
|
-
index = findLineEnd(code, index + 2);
|
|
844
|
-
continue;
|
|
845
|
-
}
|
|
846
|
-
if (character === "/" && next === "*") {
|
|
847
|
-
const close = code.indexOf("*/", index + 2);
|
|
848
|
-
index = close < 0 ? code.length : close + 2;
|
|
849
|
-
continue;
|
|
850
|
-
}
|
|
851
|
-
if (character === "/" && isRegexStart(code, index)) {
|
|
852
|
-
index = findRegexEnd(code, index);
|
|
853
|
-
continue;
|
|
854
|
-
}
|
|
855
|
-
if (character === "{") depth++;
|
|
856
|
-
if (character === "}" && --depth === 0) return index;
|
|
857
|
-
index++;
|
|
858
|
-
}
|
|
859
|
-
return -1;
|
|
860
|
-
}
|
|
861
|
-
function skipTemplate(code, start) {
|
|
862
|
-
let index = start + 1;
|
|
863
|
-
while (index < code.length) if (code[index] === "\\") index += 2;
|
|
864
|
-
else if (code[index] === "`") return index + 1;
|
|
865
|
-
else if (code[index] === "$" && code[index + 1] === "{") {
|
|
866
|
-
const end = findInterpolationEnd(code, index + 2);
|
|
867
|
-
index = end < 0 ? code.length : end + 1;
|
|
868
|
-
} else index++;
|
|
869
|
-
return code.length;
|
|
870
|
-
}
|
|
871
|
-
function collectJsxAttributes(code, start, end, ranges) {
|
|
872
|
-
const source = code.slice(start, end);
|
|
873
|
-
const regex = /\s([:@A-Za-z_$][\w$:.-]*)(?=\s*(?:=|\/?>))/g;
|
|
874
|
-
let match;
|
|
875
|
-
while (match = regex.exec(source)) {
|
|
876
|
-
const attributeStart = start + match.index + 1;
|
|
877
|
-
ranges.push({
|
|
878
|
-
start: attributeStart,
|
|
879
|
-
end: attributeStart + match[1].length,
|
|
880
|
-
className: "attr"
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
function isJsxStart(code, index, jsxAtLineStart) {
|
|
885
|
-
if (jsxAtLineStart && /^\s*$/.test(code.slice(code.lastIndexOf("\n", index - 1) + 1, index))) return true;
|
|
886
|
-
const before = code.slice(0, index).trimEnd();
|
|
887
|
-
if (!before) return true;
|
|
888
|
-
if (/\b(?:return|case|yield)$/.test(before)) return true;
|
|
889
|
-
return /(?:[=([{,:;!&|?]|>)$/.test(before);
|
|
890
|
-
}
|
|
891
|
-
function isTypeParameter(code, start, end, closing) {
|
|
892
|
-
if (closing) return false;
|
|
893
|
-
const inside = code.slice(start + 1, end);
|
|
894
|
-
const after = code.slice(end + 1).trimStart();
|
|
895
|
-
return /\s+extends\s+/.test(inside) || after[0] === "(" && !inside.trimEnd().endsWith("/");
|
|
896
|
-
}
|
|
897
|
-
function isRegexStart(code, index) {
|
|
898
|
-
const before = code.slice(0, index).trimEnd().slice(-11);
|
|
899
|
-
if (!before) return true;
|
|
900
|
-
if (/\b(?:case|delete|in|instanceof|of|return|throw|typeof|void|yield)$/.test(before)) return true;
|
|
901
|
-
return /[=([{,:;!&|?~+*%^<>-]$/.test(before);
|
|
902
|
-
}
|
|
903
|
-
function findRegexEnd(code, start) {
|
|
904
|
-
let inClass = false;
|
|
905
|
-
let index = start + 1;
|
|
906
|
-
while (index < code.length && code[index] !== "\n") if (code[index] === "\\") index += 2;
|
|
907
|
-
else if (code[index] === "[") {
|
|
908
|
-
inClass = true;
|
|
909
|
-
index++;
|
|
910
|
-
} else if (code[index] === "]") {
|
|
911
|
-
inClass = false;
|
|
912
|
-
index++;
|
|
913
|
-
} else if (code[index] === "/" && !inClass) {
|
|
914
|
-
index++;
|
|
915
|
-
while (/[a-z]/i.test(code[index] || "")) index++;
|
|
916
|
-
return index;
|
|
917
|
-
} else index++;
|
|
918
|
-
return start + 1;
|
|
919
|
-
}
|
|
920
|
-
function findQuotedEnd(code, start, quote, multiline = false) {
|
|
921
|
-
let index = start + 1;
|
|
922
|
-
while (index < code.length) if (code[index] === "\\") index += 2;
|
|
923
|
-
else if (code[index] === quote) return index + 1;
|
|
924
|
-
else if (!multiline && code[index] === "\n") return index;
|
|
925
|
-
else index++;
|
|
926
|
-
return code.length;
|
|
927
|
-
}
|
|
928
|
-
function findLineEnd(code, start) {
|
|
929
|
-
const end = code.indexOf("\n", start);
|
|
930
|
-
return end < 0 ? code.length : end;
|
|
931
|
-
}
|
|
932
|
-
function previousCodeIndex(code, index, ranges) {
|
|
933
|
-
let before = index - 1;
|
|
934
|
-
let rangeIndex = ranges.length - 1;
|
|
935
|
-
while (before >= 0) {
|
|
936
|
-
if (/\s/.test(code[before])) {
|
|
937
|
-
before--;
|
|
938
|
-
continue;
|
|
939
|
-
}
|
|
940
|
-
const range = ranges[rangeIndex];
|
|
941
|
-
if (range && range.end > before) {
|
|
942
|
-
rangeIndex--;
|
|
943
|
-
if (range.className === "comment" && range.start <= before) {
|
|
944
|
-
before = range.start - 1;
|
|
945
|
-
continue;
|
|
946
|
-
}
|
|
947
|
-
} else break;
|
|
948
|
-
}
|
|
949
|
-
return before;
|
|
950
|
-
}
|
|
951
|
-
//#endregion
|
|
952
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/js.js
|
|
953
|
-
const js = defineLanguage({
|
|
954
|
-
name: "js",
|
|
955
|
-
aliases: [
|
|
956
|
-
"javascript",
|
|
957
|
-
"mjs",
|
|
958
|
-
"cjs",
|
|
959
|
-
"js-vue"
|
|
960
|
-
],
|
|
961
|
-
tokenize: (code) => collectScriptRanges(code)
|
|
962
|
-
});
|
|
963
|
-
//#endregion
|
|
964
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/json.js
|
|
965
|
-
const json = defineLanguage({
|
|
966
|
-
name: "json",
|
|
967
|
-
aliases: [
|
|
968
|
-
"jsonc",
|
|
969
|
-
"json5",
|
|
970
|
-
"jsonl"
|
|
971
|
-
],
|
|
972
|
-
tokenize: patternTokenizer([
|
|
973
|
-
[/\/\/[^\n]*|\/\*[\s\S]*?\*\/|("(?:\\.|[^"\\])*")(?=\s*:)|"(?:\\.|[^"\\])*"/g, (match) => match[0].startsWith("//") || match[0].startsWith("/*") ? "comment" : match[1] ? "property" : "string"],
|
|
974
|
-
[/\b(?:false|null|true)\b/g, "literal"],
|
|
975
|
-
[/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/gi, "number"]
|
|
976
|
-
])
|
|
977
|
-
});
|
|
978
|
-
//#endregion
|
|
979
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/jsx.js
|
|
980
|
-
const jsx = defineLanguage({
|
|
981
|
-
name: "jsx",
|
|
982
|
-
tokenize: (code) => collectScriptRanges(code, true)
|
|
983
|
-
});
|
|
984
|
-
//#endregion
|
|
985
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/markdown.js
|
|
986
|
-
const markdown = defineLanguage({
|
|
987
|
-
name: "markdown",
|
|
988
|
-
aliases: ["md"],
|
|
989
|
-
tokenize(code, context) {
|
|
990
|
-
return collectPatternRanges(code, [
|
|
991
|
-
[/^#{1,6}\s.*$/gm, "heading"],
|
|
992
|
-
[/^.+\n(?:=+|-+)\s*$/gm, "heading"],
|
|
993
|
-
[/`[^`\n]+`/g, "code-inline"],
|
|
994
|
-
[/!?\[[^\]]+\]\([^)]+\)/g, "link"],
|
|
995
|
-
[/^\s{0,3}(?:>|[-*+] |\d+\. )/gm, "meta"]
|
|
996
|
-
], collectFencedCode(code, context));
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
function collectFencedCode(code, context) {
|
|
1000
|
-
const ranges = [];
|
|
1001
|
-
const opening = /^( {0,3})(`{3,}|~{3,})\s*([^\n]*)$/gm;
|
|
1002
|
-
let match;
|
|
1003
|
-
while (match = opening.exec(code)) {
|
|
1004
|
-
const marker = match[2];
|
|
1005
|
-
const contentStart = code.indexOf("\n", match.index + match[0].length);
|
|
1006
|
-
if (contentStart < 0) break;
|
|
1007
|
-
const closing = new RegExp(`^ {0,3}${marker[0]}{${marker.length},}\\s*$`, "gm");
|
|
1008
|
-
closing.lastIndex = contentStart + 1;
|
|
1009
|
-
const close = closing.exec(code);
|
|
1010
|
-
const contentEnd = close?.index ?? code.length;
|
|
1011
|
-
const info = match[3].trim().split(/\s+/)[0];
|
|
1012
|
-
const embedded = info && context.hasLanguage(info) ? offsetRanges(context.tokenize(code.slice(contentStart + 1, contentEnd), info), contentStart + 1) : [];
|
|
1013
|
-
ranges.push({
|
|
1014
|
-
start: match.index,
|
|
1015
|
-
end: contentStart,
|
|
1016
|
-
className: "meta"
|
|
1017
|
-
});
|
|
1018
|
-
fillCodeRange(contentStart + 1, contentEnd, embedded, ranges);
|
|
1019
|
-
if (close) ranges.push({
|
|
1020
|
-
start: close.index,
|
|
1021
|
-
end: close.index + close[0].length,
|
|
1022
|
-
className: "meta"
|
|
1023
|
-
});
|
|
1024
|
-
opening.lastIndex = close ? close.index + close[0].length : code.length;
|
|
1025
|
-
}
|
|
1026
|
-
return ranges;
|
|
1027
|
-
}
|
|
1028
|
-
function fillCodeRange(start, end, embedded, ranges) {
|
|
1029
|
-
let index = start;
|
|
1030
|
-
for (const range of embedded) {
|
|
1031
|
-
if (range.start > index) ranges.push({
|
|
1032
|
-
start: index,
|
|
1033
|
-
end: range.start,
|
|
1034
|
-
className: "code-inline"
|
|
1035
|
-
});
|
|
1036
|
-
ranges.push(range);
|
|
1037
|
-
index = range.end;
|
|
1038
|
-
}
|
|
1039
|
-
if (index < end) ranges.push({
|
|
1040
|
-
start: index,
|
|
1041
|
-
end,
|
|
1042
|
-
className: "code-inline"
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
//#endregion
|
|
1046
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/python.js
|
|
1047
|
-
const python = defineLanguage({
|
|
1048
|
-
name: "python",
|
|
1049
|
-
aliases: ["py"],
|
|
1050
|
-
tokenize: patternTokenizer([
|
|
1051
|
-
[/#[^\n]*|(?:br|rb|fr|rf|[rubf])?(?:"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')/gi, (match) => match[0].startsWith("#") ? "comment" : "string"],
|
|
1052
|
-
[/\b(?:and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g, "keyword"],
|
|
1053
|
-
[/\b(?:False|None|True|NotImplemented|Ellipsis)\b/g, "literal"],
|
|
1054
|
-
[/@[A-Za-z_][\w.]*/g, "function"],
|
|
1055
|
-
[
|
|
1056
|
-
/\bdef\s+([A-Za-z_]\w*)/g,
|
|
1057
|
-
"function",
|
|
1058
|
-
1
|
|
1059
|
-
],
|
|
1060
|
-
[/\b(?:bool|bytes|dict|float|frozenset|int|list|object|set|str|tuple|type)\b/g, "type"],
|
|
1061
|
-
[/\b(?:0x[\da-f_]+|0b[01_]+|0o[0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:e[+-]?\d[\d_]*)?j?)\b/gi, "number"]
|
|
1062
|
-
])
|
|
1063
|
-
});
|
|
1064
|
-
//#endregion
|
|
1065
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/shell.js
|
|
1066
|
-
const shell = defineLanguage({
|
|
1067
|
-
name: "shell",
|
|
1068
|
-
aliases: [
|
|
1069
|
-
"bash",
|
|
1070
|
-
"sh",
|
|
1071
|
-
"zsh",
|
|
1072
|
-
"cmd",
|
|
1073
|
-
"console"
|
|
1074
|
-
],
|
|
1075
|
-
tokenize: patternTokenizer([
|
|
1076
|
-
collectShellLexicalRanges,
|
|
1077
|
-
[/\$[A-Za-z_][A-Za-z0-9_]*|\b[A-Z_][A-Z0-9_]*(?==)/g, "variable"],
|
|
1078
|
-
[/\b(?:case|do|done|elif|else|esac|export|fi|for|function|if|in|select|then|time|until|while)\b/g, "keyword"],
|
|
1079
|
-
[
|
|
1080
|
-
/(^|[\n;|&])\s*([A-Za-z0-9_./-]+)(?=\s|$)/g,
|
|
1081
|
-
"command",
|
|
1082
|
-
2
|
|
1083
|
-
]
|
|
1084
|
-
])
|
|
1085
|
-
});
|
|
1086
|
-
function collectShellLexicalRanges(code) {
|
|
1087
|
-
const heredocs = [];
|
|
1088
|
-
collectHeredocs(code, heredocs);
|
|
1089
|
-
const ranges = [...heredocs];
|
|
1090
|
-
let heredocIndex = 0;
|
|
1091
|
-
let index = 0;
|
|
1092
|
-
while (index < code.length) {
|
|
1093
|
-
while (heredocIndex < heredocs.length && heredocs[heredocIndex].end <= index) heredocIndex++;
|
|
1094
|
-
const heredoc = heredocs[heredocIndex];
|
|
1095
|
-
if (heredoc && heredoc.start <= index) {
|
|
1096
|
-
index = heredoc.end;
|
|
1097
|
-
continue;
|
|
1098
|
-
}
|
|
1099
|
-
const character = code[index];
|
|
1100
|
-
if (character === "\"" || character === "'") {
|
|
1101
|
-
const quote = character;
|
|
1102
|
-
let end = index + 1;
|
|
1103
|
-
while (end < code.length) if (code[end] === "\\" && quote === "\"") end += 2;
|
|
1104
|
-
else if (code[end] === quote) {
|
|
1105
|
-
end++;
|
|
1106
|
-
break;
|
|
1107
|
-
} else end++;
|
|
1108
|
-
end = Math.min(end, code.length);
|
|
1109
|
-
ranges.push({
|
|
1110
|
-
start: index,
|
|
1111
|
-
end,
|
|
1112
|
-
className: "string"
|
|
1113
|
-
});
|
|
1114
|
-
index = end;
|
|
1115
|
-
continue;
|
|
1116
|
-
}
|
|
1117
|
-
if (character === "$" && code[index + 1] === "{") {
|
|
1118
|
-
const close = code.indexOf("}", index + 2);
|
|
1119
|
-
const end = close < 0 ? code.length : close + 1;
|
|
1120
|
-
ranges.push({
|
|
1121
|
-
start: index,
|
|
1122
|
-
end,
|
|
1123
|
-
className: "variable"
|
|
1124
|
-
});
|
|
1125
|
-
index = end;
|
|
1126
|
-
continue;
|
|
1127
|
-
}
|
|
1128
|
-
if (character === "#" && (index === 0 || code[index - 1] === "\n" || /[\s;|&()]/.test(code[index - 1]))) {
|
|
1129
|
-
const newline = code.indexOf("\n", index);
|
|
1130
|
-
const end = newline < 0 ? code.length : newline;
|
|
1131
|
-
ranges.push({
|
|
1132
|
-
start: index,
|
|
1133
|
-
end,
|
|
1134
|
-
className: "comment"
|
|
1135
|
-
});
|
|
1136
|
-
index = end;
|
|
1137
|
-
continue;
|
|
1138
|
-
}
|
|
1139
|
-
index++;
|
|
1140
|
-
}
|
|
1141
|
-
return ranges;
|
|
1142
|
-
}
|
|
1143
|
-
function collectHeredocs(code, ranges) {
|
|
1144
|
-
const regex = /<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/g;
|
|
1145
|
-
let match;
|
|
1146
|
-
while (match = regex.exec(code)) {
|
|
1147
|
-
if (code[match.index - 1] === "<" || isInsideQuote(code, match.index)) continue;
|
|
1148
|
-
const bodyStartLine = code.indexOf("\n", match.index + match[0].length);
|
|
1149
|
-
if (bodyStartLine < 0) continue;
|
|
1150
|
-
const bodyStart = bodyStartLine + 1;
|
|
1151
|
-
const closingMatch = new RegExp(`^\\t*${match[2]}\\s*$`, "m").exec(code.slice(bodyStart));
|
|
1152
|
-
if (!closingMatch) {
|
|
1153
|
-
ranges.push({
|
|
1154
|
-
start: bodyStart,
|
|
1155
|
-
end: code.length,
|
|
1156
|
-
className: "string"
|
|
1157
|
-
});
|
|
1158
|
-
continue;
|
|
1159
|
-
}
|
|
1160
|
-
const end = bodyStart + closingMatch.index;
|
|
1161
|
-
if (end > bodyStart) ranges.push({
|
|
1162
|
-
start: bodyStart,
|
|
1163
|
-
end,
|
|
1164
|
-
className: "string"
|
|
1165
|
-
});
|
|
1166
|
-
const closingStart = bodyStart + closingMatch.index;
|
|
1167
|
-
ranges.push({
|
|
1168
|
-
start: closingStart,
|
|
1169
|
-
end: closingStart + closingMatch[0].length,
|
|
1170
|
-
className: "meta"
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
function isInsideQuote(code, index) {
|
|
1175
|
-
const lineStart = code.lastIndexOf("\n", index - 1) + 1;
|
|
1176
|
-
let quote = "";
|
|
1177
|
-
for (let cursor = lineStart; cursor < index; cursor++) if (code[cursor] === "\\" && quote !== "'") cursor++;
|
|
1178
|
-
else if (quote && code[cursor] === quote) quote = "";
|
|
1179
|
-
else if (!quote && (code[cursor] === "\"" || code[cursor] === "'")) quote = code[cursor];
|
|
1180
|
-
return Boolean(quote);
|
|
1181
|
-
}
|
|
1182
|
-
//#endregion
|
|
1183
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/sql.js
|
|
1184
|
-
const sql = defineLanguage({
|
|
1185
|
-
name: "sql",
|
|
1186
|
-
tokenize: patternTokenizer([
|
|
1187
|
-
[/--[^\n]*|\/\*[\s\S]*?\*\/|'(?:''|[^'])*'|"(?:""|[^"])*"/g, (match) => match[0].startsWith("--") || match[0].startsWith("/*") ? "comment" : "string"],
|
|
1188
|
-
[/\b(?:add|all|alter|and|as|asc|begin|between|by|case|check|column|commit|constraint|create|cross|database|default|delete|desc|distinct|drop|else|end|exists|foreign|from|full|group|having|index|inner|insert|into|join|key|left|like|limit|not|null|on|or|order|outer|primary|references|returning|right|rollback|select|set|table|then|union|unique|update|using|values|view|when|where|with)\b/gi, "keyword"],
|
|
1189
|
-
[/\b(?:false|null|true)\b/gi, "literal"],
|
|
1190
|
-
[/\b\d+(?:\.\d+)?\b/g, "number"],
|
|
1191
|
-
[/\b[A-Za-z_][A-Za-z0-9_]*(?=\s*\()/g, "function"]
|
|
1192
|
-
])
|
|
1193
|
-
});
|
|
1194
|
-
//#endregion
|
|
1195
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/toml.js
|
|
1196
|
-
const toml = defineLanguage({
|
|
1197
|
-
name: "toml",
|
|
1198
|
-
tokenize: patternTokenizer([
|
|
1199
|
-
[/#[^\n]*|"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g, (match) => match[0].startsWith("#") ? "comment" : "string"],
|
|
1200
|
-
[/^\s*\[\[?[^\]]+\]\]?/gm, "heading"],
|
|
1201
|
-
[
|
|
1202
|
-
/^\s*([A-Za-z0-9_.-]+)(?=\s*=)/gm,
|
|
1203
|
-
"property",
|
|
1204
|
-
1
|
|
1205
|
-
],
|
|
1206
|
-
[/\b(?:false|true)\b/g, "literal"],
|
|
1207
|
-
[/\b\d+(?:\.\d+)?\b/g, "number"]
|
|
1208
|
-
])
|
|
1209
|
-
});
|
|
1210
|
-
//#endregion
|
|
1211
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/ts.js
|
|
1212
|
-
const ts = defineLanguage({
|
|
1213
|
-
name: "ts",
|
|
1214
|
-
aliases: ["typescript", "angular-ts"],
|
|
1215
|
-
tokenize: (code) => collectScriptRanges(code)
|
|
1216
|
-
});
|
|
1217
|
-
//#endregion
|
|
1218
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/tsx.js
|
|
1219
|
-
const tsx = defineLanguage({
|
|
1220
|
-
name: "tsx",
|
|
1221
|
-
tokenize: (code) => collectScriptRanges(code, true)
|
|
1222
|
-
});
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/languages/yaml.js
|
|
1225
|
-
const yaml = defineLanguage({
|
|
1226
|
-
name: "yaml",
|
|
1227
|
-
aliases: ["yml"],
|
|
1228
|
-
tokenize(code) {
|
|
1229
|
-
const lexical = [...collectYamlBlockScalars(code), ...collectYamlLexicalRanges(code)];
|
|
1230
|
-
return collectPatternRanges(code, [
|
|
1231
|
-
[
|
|
1232
|
-
/^[ \t-]*([A-Za-z0-9_.-]+)(?=\s*:)/gm,
|
|
1233
|
-
"property",
|
|
1234
|
-
1
|
|
1235
|
-
],
|
|
1236
|
-
collectYamlValues,
|
|
1237
|
-
[/\b(?:false|null|true|yes|no|on|off|~)\b/gi, "literal"],
|
|
1238
|
-
[/\b\d+(?:\.\d+)?\b/g, "number"]
|
|
1239
|
-
], lexical);
|
|
1240
|
-
}
|
|
1241
|
-
});
|
|
1242
|
-
function collectYamlBlockScalars(code) {
|
|
1243
|
-
const ranges = [];
|
|
1244
|
-
const opening = /^(\s*)[\w.-]+:\s*[>|][+-]?\s*(?:#.*)?$/gm;
|
|
1245
|
-
let match;
|
|
1246
|
-
while (match = opening.exec(code)) {
|
|
1247
|
-
const start = code.indexOf("\n", match.index + match[0].length);
|
|
1248
|
-
if (start < 0) continue;
|
|
1249
|
-
const indentation = match[1].length;
|
|
1250
|
-
let end = start + 1;
|
|
1251
|
-
while (end < code.length) {
|
|
1252
|
-
const lineEnd = code.indexOf("\n", end);
|
|
1253
|
-
const next = lineEnd < 0 ? code.length : lineEnd;
|
|
1254
|
-
const line = code.slice(end, next);
|
|
1255
|
-
const content = line.trimStart();
|
|
1256
|
-
if (content && line.length - content.length <= indentation) break;
|
|
1257
|
-
end = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
1258
|
-
}
|
|
1259
|
-
if (end > start + 1) ranges.push({
|
|
1260
|
-
start: start + 1,
|
|
1261
|
-
end,
|
|
1262
|
-
className: "string"
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
return ranges;
|
|
1266
|
-
}
|
|
1267
|
-
function collectYamlLexicalRanges(code) {
|
|
1268
|
-
const ranges = [];
|
|
1269
|
-
let index = 0;
|
|
1270
|
-
while (index < code.length) {
|
|
1271
|
-
const character = code[index];
|
|
1272
|
-
if (character === "\"" || character === "'") {
|
|
1273
|
-
const quote = character;
|
|
1274
|
-
let end = index + 1;
|
|
1275
|
-
while (end < code.length && code[end] !== "\n") if (code[end] === "\\" && quote === "\"") end += 2;
|
|
1276
|
-
else if (code[end] === quote) {
|
|
1277
|
-
end++;
|
|
1278
|
-
break;
|
|
1279
|
-
} else end++;
|
|
1280
|
-
ranges.push({
|
|
1281
|
-
start: index,
|
|
1282
|
-
end,
|
|
1283
|
-
className: "string"
|
|
1284
|
-
});
|
|
1285
|
-
index = end;
|
|
1286
|
-
continue;
|
|
1287
|
-
}
|
|
1288
|
-
if (character === "#" && (index === 0 || code[index - 1] === "\n" || /\s/.test(code[index - 1]))) {
|
|
1289
|
-
const newline = code.indexOf("\n", index);
|
|
1290
|
-
const end = newline < 0 ? code.length : newline;
|
|
1291
|
-
ranges.push({
|
|
1292
|
-
start: index,
|
|
1293
|
-
end,
|
|
1294
|
-
className: "comment"
|
|
1295
|
-
});
|
|
1296
|
-
index = end;
|
|
1297
|
-
continue;
|
|
1298
|
-
}
|
|
1299
|
-
index++;
|
|
1300
|
-
}
|
|
1301
|
-
return ranges;
|
|
1302
|
-
}
|
|
1303
|
-
function collectYamlValues(code) {
|
|
1304
|
-
const ranges = [];
|
|
1305
|
-
const regex = /:\s*([^\n]*)/g;
|
|
1306
|
-
let match;
|
|
1307
|
-
while (match = regex.exec(code)) {
|
|
1308
|
-
const value = match[1];
|
|
1309
|
-
const trimmed = value.trimEnd();
|
|
1310
|
-
if (!trimmed) continue;
|
|
1311
|
-
const start = match.index + match[0].indexOf(value);
|
|
1312
|
-
let end = start + trimmed.length;
|
|
1313
|
-
const comment = /\s+#/.exec(trimmed);
|
|
1314
|
-
if (comment) end = start + comment.index;
|
|
1315
|
-
while (end > start && /\s/.test(code[end - 1])) end--;
|
|
1316
|
-
if (end > start) ranges.push({
|
|
1317
|
-
start,
|
|
1318
|
-
end,
|
|
1319
|
-
className: "string"
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
return ranges;
|
|
1323
|
-
}
|
|
1324
|
-
//#endregion
|
|
1325
|
-
//#region src/code/highlighter.ts
|
|
1326
|
-
/**
|
|
1327
|
-
* Kumo's shared highlighter. TanStack Highlight is synchronous, so there is
|
|
1328
|
-
* no provider or loading state: grammars are plain imports, created once.
|
|
1329
|
-
* Unknown languages render as escaped plain text.
|
|
1330
|
-
*/
|
|
1331
|
-
const highlighter = createHighlighter({ languages: [
|
|
1332
|
-
css,
|
|
1333
|
-
diff,
|
|
1334
|
-
graphql,
|
|
1335
|
-
html,
|
|
1336
|
-
js,
|
|
1337
|
-
json,
|
|
1338
|
-
jsx,
|
|
1339
|
-
markdown,
|
|
1340
|
-
python,
|
|
1341
|
-
shell,
|
|
1342
|
-
sql,
|
|
1343
|
-
toml,
|
|
1344
|
-
ts,
|
|
1345
|
-
tsx,
|
|
1346
|
-
yaml
|
|
1347
|
-
] });
|
|
1348
|
-
/** Highlight code to an HTML string (`<pre class="th-code">…</pre>`). Safe to call during SSR. */
|
|
1349
|
-
function highlightCode(code, lang, options = {}) {
|
|
1350
|
-
return highlighter.highlightToHtml(code, {
|
|
1351
|
-
lang,
|
|
1352
|
-
lineNumbers: options.lineNumbers,
|
|
1353
|
-
decorations: options.highlightLines?.map((line) => ({
|
|
1354
|
-
lines: line,
|
|
1355
|
-
className: "line-highlighted"
|
|
1356
|
-
}))
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
/** Resolve a language name or alias (`ts`, `bash`, `yml`) to the highlighter's canonical name. */
|
|
1360
|
-
function normalizeLanguage(lang) {
|
|
1361
|
-
return highlighter.normalizeLanguage(lang);
|
|
1362
|
-
}
|
|
1363
|
-
//#endregion
|
|
1364
|
-
export { normalizeLanguage as n, highlightCode as t };
|