@vanduo-oss/vd3-cbun 1.3.2 → 1.4.0
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/CHANGELOG.md +18 -0
- package/README.md +16 -9
- package/SKILL.md +24 -11
- package/dist/code-editor/core.d.ts +19 -2
- package/dist/code-editor/highlight.cjs +1242 -0
- package/dist/code-editor/highlight.cjs.map +7 -0
- package/dist/code-editor/highlight.d.ts +6 -0
- package/dist/code-editor/highlight.js +1219 -0
- package/dist/code-editor/highlight.js.map +7 -0
- package/dist/code-editor/index.cjs +694 -70
- package/dist/code-editor/index.cjs.map +4 -4
- package/dist/code-editor/index.d.ts +2 -0
- package/dist/code-editor/index.js +694 -70
- package/dist/code-editor/index.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/meta.json +144 -33
- package/package.json +6 -1
|
@@ -0,0 +1,1242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/code-editor/highlight.js
|
|
21
|
+
var highlight_exports = {};
|
|
22
|
+
__export(highlight_exports, {
|
|
23
|
+
LANGUAGES: () => LANGUAGES,
|
|
24
|
+
escapeHtml: () => escapeHtml,
|
|
25
|
+
highlight: () => highlight,
|
|
26
|
+
renderTokensToDom: () => renderTokensToDom,
|
|
27
|
+
renderTokensToHtml: () => renderTokensToHtml,
|
|
28
|
+
tokenize: () => tokenize
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(highlight_exports);
|
|
31
|
+
|
|
32
|
+
// src/code-editor/tokenizer/scanner.js
|
|
33
|
+
function matchRule(source, i, rules) {
|
|
34
|
+
for (let r = 0; r < rules.length; r++) {
|
|
35
|
+
const rule = rules[r];
|
|
36
|
+
if (rule.when && !rule.when(source, i)) continue;
|
|
37
|
+
let value;
|
|
38
|
+
if (rule.consume) {
|
|
39
|
+
const got = rule.consume(source, i);
|
|
40
|
+
if (!got || !got.value || got.value.length === 0) continue;
|
|
41
|
+
value = got.value;
|
|
42
|
+
} else {
|
|
43
|
+
rule.re.lastIndex = i;
|
|
44
|
+
const m = rule.re.exec(source);
|
|
45
|
+
if (!m || m[0].length === 0) continue;
|
|
46
|
+
value = m[0];
|
|
47
|
+
}
|
|
48
|
+
const tokens = rule.expand ? rule.expand(value) : [{ type: rule.type, value }];
|
|
49
|
+
return { tokens, length: value.length, value };
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function scan(source, rules) {
|
|
54
|
+
const tokens = [];
|
|
55
|
+
const n = source.length;
|
|
56
|
+
let i = 0;
|
|
57
|
+
let plainStart = -1;
|
|
58
|
+
const flushPlain = (end) => {
|
|
59
|
+
if (plainStart !== -1 && end > plainStart) {
|
|
60
|
+
tokens.push({ type: "plain", value: source.slice(plainStart, end) });
|
|
61
|
+
}
|
|
62
|
+
plainStart = -1;
|
|
63
|
+
};
|
|
64
|
+
while (i < n) {
|
|
65
|
+
const hit = matchRule(source, i, rules);
|
|
66
|
+
if (hit) {
|
|
67
|
+
flushPlain(i);
|
|
68
|
+
for (let k = 0; k < hit.tokens.length; k++) tokens.push(hit.tokens[k]);
|
|
69
|
+
i += hit.length;
|
|
70
|
+
} else {
|
|
71
|
+
if (plainStart === -1) plainStart = i;
|
|
72
|
+
i++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
flushPlain(n);
|
|
76
|
+
return coalesce(tokens);
|
|
77
|
+
}
|
|
78
|
+
function coalesce(tokens) {
|
|
79
|
+
if (tokens.length < 2) return tokens;
|
|
80
|
+
const out = [{ type: tokens[0].type, value: tokens[0].value }];
|
|
81
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
82
|
+
const cur = tokens[i];
|
|
83
|
+
const prev = out[out.length - 1];
|
|
84
|
+
if (cur.type === prev.type) prev.value += cur.value;
|
|
85
|
+
else out.push({ type: cur.type, value: cur.value });
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
function wordRegex(words, flags) {
|
|
90
|
+
const sorted = [...words].sort((a, b) => b.length - a.length);
|
|
91
|
+
return new RegExp("(?:" + sorted.join("|") + ")\\b", (flags || "") + "y");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/code-editor/tokenizer/javascript.js
|
|
95
|
+
var JS_KEYWORDS = [
|
|
96
|
+
"break",
|
|
97
|
+
"case",
|
|
98
|
+
"catch",
|
|
99
|
+
"class",
|
|
100
|
+
"const",
|
|
101
|
+
"continue",
|
|
102
|
+
"debugger",
|
|
103
|
+
"default",
|
|
104
|
+
"delete",
|
|
105
|
+
"do",
|
|
106
|
+
"else",
|
|
107
|
+
"export",
|
|
108
|
+
"extends",
|
|
109
|
+
"finally",
|
|
110
|
+
"for",
|
|
111
|
+
"function",
|
|
112
|
+
"if",
|
|
113
|
+
"import",
|
|
114
|
+
"in",
|
|
115
|
+
"instanceof",
|
|
116
|
+
"new",
|
|
117
|
+
"return",
|
|
118
|
+
"super",
|
|
119
|
+
"switch",
|
|
120
|
+
"this",
|
|
121
|
+
"throw",
|
|
122
|
+
"try",
|
|
123
|
+
"typeof",
|
|
124
|
+
"var",
|
|
125
|
+
"void",
|
|
126
|
+
"while",
|
|
127
|
+
"with",
|
|
128
|
+
"yield",
|
|
129
|
+
"async",
|
|
130
|
+
"await",
|
|
131
|
+
"let",
|
|
132
|
+
"static",
|
|
133
|
+
"get",
|
|
134
|
+
"set",
|
|
135
|
+
"of",
|
|
136
|
+
"as",
|
|
137
|
+
"from"
|
|
138
|
+
];
|
|
139
|
+
var TS_KEYWORDS = [
|
|
140
|
+
...JS_KEYWORDS,
|
|
141
|
+
"interface",
|
|
142
|
+
"type",
|
|
143
|
+
"enum",
|
|
144
|
+
"implements",
|
|
145
|
+
"declare",
|
|
146
|
+
"namespace",
|
|
147
|
+
"readonly",
|
|
148
|
+
"satisfies",
|
|
149
|
+
"abstract",
|
|
150
|
+
"public",
|
|
151
|
+
"private",
|
|
152
|
+
"protected",
|
|
153
|
+
"keyof",
|
|
154
|
+
"infer",
|
|
155
|
+
"is",
|
|
156
|
+
"asserts",
|
|
157
|
+
"override",
|
|
158
|
+
"module",
|
|
159
|
+
"string",
|
|
160
|
+
"number",
|
|
161
|
+
"boolean",
|
|
162
|
+
"object",
|
|
163
|
+
"symbol",
|
|
164
|
+
"bigint",
|
|
165
|
+
"any",
|
|
166
|
+
"unknown",
|
|
167
|
+
"never"
|
|
168
|
+
];
|
|
169
|
+
var BUILTINS = [
|
|
170
|
+
"console",
|
|
171
|
+
"window",
|
|
172
|
+
"document",
|
|
173
|
+
"globalThis",
|
|
174
|
+
"Math",
|
|
175
|
+
"JSON",
|
|
176
|
+
"Object",
|
|
177
|
+
"Array",
|
|
178
|
+
"String",
|
|
179
|
+
"Number",
|
|
180
|
+
"Boolean",
|
|
181
|
+
"Symbol",
|
|
182
|
+
"Promise",
|
|
183
|
+
"Map",
|
|
184
|
+
"Set",
|
|
185
|
+
"WeakMap",
|
|
186
|
+
"WeakSet",
|
|
187
|
+
"Date",
|
|
188
|
+
"RegExp",
|
|
189
|
+
"Error",
|
|
190
|
+
"Function",
|
|
191
|
+
"parseInt",
|
|
192
|
+
"parseFloat",
|
|
193
|
+
"isNaN",
|
|
194
|
+
"isFinite",
|
|
195
|
+
"require",
|
|
196
|
+
"module",
|
|
197
|
+
"exports",
|
|
198
|
+
"process",
|
|
199
|
+
"NaN",
|
|
200
|
+
"Infinity"
|
|
201
|
+
];
|
|
202
|
+
var REGEX_AFTER_KEYWORD = /* @__PURE__ */ new Set([
|
|
203
|
+
"return",
|
|
204
|
+
"throw",
|
|
205
|
+
"case",
|
|
206
|
+
"in",
|
|
207
|
+
"of",
|
|
208
|
+
"typeof",
|
|
209
|
+
"void",
|
|
210
|
+
"delete",
|
|
211
|
+
"new",
|
|
212
|
+
"else",
|
|
213
|
+
"do",
|
|
214
|
+
"yield",
|
|
215
|
+
"await",
|
|
216
|
+
"extends"
|
|
217
|
+
]);
|
|
218
|
+
function isWs(c) {
|
|
219
|
+
return c === 32 || c === 9 || c === 10 || c === 13;
|
|
220
|
+
}
|
|
221
|
+
function isWord(c) {
|
|
222
|
+
return c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 36 || c === 95;
|
|
223
|
+
}
|
|
224
|
+
function canStartRegex(source, i) {
|
|
225
|
+
let j = i - 1;
|
|
226
|
+
while (j >= 0 && isWs(source.charCodeAt(j))) j--;
|
|
227
|
+
if (j < 0) return true;
|
|
228
|
+
const c = source.charCodeAt(j);
|
|
229
|
+
if (c === 41 || c === 93) return false;
|
|
230
|
+
if ((c === 43 || c === 45) && j > 0 && source.charCodeAt(j - 1) === c) return false;
|
|
231
|
+
if (isWord(c)) {
|
|
232
|
+
let start = j;
|
|
233
|
+
while (start > 0 && isWord(source.charCodeAt(start - 1))) start--;
|
|
234
|
+
return REGEX_AFTER_KEYWORD.has(source.slice(start, j + 1));
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
function isRegexFlag(c) {
|
|
239
|
+
return c === 100 || c === 103 || c === 105 || c === 109 || c === 115 || c === 117 || c === 118 || c === 121;
|
|
240
|
+
}
|
|
241
|
+
function consumeRegex(source, i) {
|
|
242
|
+
const n = source.length;
|
|
243
|
+
let j = i + 1;
|
|
244
|
+
let inClass = false;
|
|
245
|
+
while (j < n) {
|
|
246
|
+
const c = source.charCodeAt(j);
|
|
247
|
+
if (c === 10) return null;
|
|
248
|
+
if (c === 92) {
|
|
249
|
+
j += 2;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (inClass) {
|
|
253
|
+
if (c === 93) inClass = false;
|
|
254
|
+
j++;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (c === 91) {
|
|
258
|
+
inClass = true;
|
|
259
|
+
j++;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (c === 47) {
|
|
263
|
+
j++;
|
|
264
|
+
while (j < n && isRegexFlag(source.charCodeAt(j))) j++;
|
|
265
|
+
return { value: source.slice(i, j) };
|
|
266
|
+
}
|
|
267
|
+
j++;
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
function skipQuoted(s, i) {
|
|
272
|
+
const q = s.charCodeAt(i);
|
|
273
|
+
let j = i + 1;
|
|
274
|
+
const n = s.length;
|
|
275
|
+
while (j < n) {
|
|
276
|
+
const c = s.charCodeAt(j);
|
|
277
|
+
if (c === 92) {
|
|
278
|
+
j += 2;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (c === q) return j + 1;
|
|
282
|
+
if (c === 10) return j;
|
|
283
|
+
j++;
|
|
284
|
+
}
|
|
285
|
+
return n;
|
|
286
|
+
}
|
|
287
|
+
function findTemplateInterpEnd(s, start) {
|
|
288
|
+
let depth = 1;
|
|
289
|
+
let i = start;
|
|
290
|
+
const n = s.length;
|
|
291
|
+
while (i < n && depth > 0) {
|
|
292
|
+
const c = s.charCodeAt(i);
|
|
293
|
+
if (c === 47 && s.charCodeAt(i + 1) === 47) {
|
|
294
|
+
const nl = s.indexOf("\n", i + 2);
|
|
295
|
+
if (nl < 0) return n;
|
|
296
|
+
i = nl;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (c === 47 && s.charCodeAt(i + 1) === 42) {
|
|
300
|
+
const end = s.indexOf("*/", i + 2);
|
|
301
|
+
i = end < 0 ? n : end + 2;
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (c === 34 || c === 39) {
|
|
305
|
+
i = skipQuoted(s, i);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (c === 96) {
|
|
309
|
+
i = skipTemplate(s, i);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (c === 123) depth++;
|
|
313
|
+
else if (c === 125) {
|
|
314
|
+
depth--;
|
|
315
|
+
if (depth === 0) return i;
|
|
316
|
+
}
|
|
317
|
+
i++;
|
|
318
|
+
}
|
|
319
|
+
return n;
|
|
320
|
+
}
|
|
321
|
+
function skipTemplate(s, i) {
|
|
322
|
+
let j = i + 1;
|
|
323
|
+
const n = s.length;
|
|
324
|
+
while (j < n) {
|
|
325
|
+
const c = s.charCodeAt(j);
|
|
326
|
+
if (c === 92) {
|
|
327
|
+
j += 2;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (c === 96) return j + 1;
|
|
331
|
+
if (c === 36 && s.charCodeAt(j + 1) === 123) {
|
|
332
|
+
const end = findTemplateInterpEnd(s, j + 2);
|
|
333
|
+
j = end < n && s.charCodeAt(end) === 125 ? end + 1 : end;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
j++;
|
|
337
|
+
}
|
|
338
|
+
return n;
|
|
339
|
+
}
|
|
340
|
+
function expandTemplateLiteral(value, rules) {
|
|
341
|
+
const out = [];
|
|
342
|
+
const n = value.length;
|
|
343
|
+
let i = 1;
|
|
344
|
+
let strStart = 0;
|
|
345
|
+
const flushString = (end) => {
|
|
346
|
+
if (end > strStart) out.push({ type: "string", value: value.slice(strStart, end) });
|
|
347
|
+
};
|
|
348
|
+
while (i < n) {
|
|
349
|
+
const c = value.charCodeAt(i);
|
|
350
|
+
if (c === 92) {
|
|
351
|
+
i += i + 1 < n ? 2 : 1;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (c === 96) {
|
|
355
|
+
flushString(i + 1);
|
|
356
|
+
return out;
|
|
357
|
+
}
|
|
358
|
+
if (c === 36 && i + 1 < n && value.charCodeAt(i + 1) === 123) {
|
|
359
|
+
flushString(i);
|
|
360
|
+
out.push({ type: "operator", value: "${" });
|
|
361
|
+
const innerStart = i + 2;
|
|
362
|
+
const innerEnd = findTemplateInterpEnd(value, innerStart);
|
|
363
|
+
const inner = value.slice(innerStart, innerEnd);
|
|
364
|
+
if (inner) {
|
|
365
|
+
const parts = scan(inner, rules);
|
|
366
|
+
for (let k = 0; k < parts.length; k++) out.push(parts[k]);
|
|
367
|
+
}
|
|
368
|
+
if (innerEnd < n && value.charCodeAt(innerEnd) === 125) {
|
|
369
|
+
out.push({ type: "punctuation", value: "}" });
|
|
370
|
+
i = innerEnd + 1;
|
|
371
|
+
} else {
|
|
372
|
+
i = innerEnd;
|
|
373
|
+
}
|
|
374
|
+
strStart = i;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
i++;
|
|
378
|
+
}
|
|
379
|
+
flushString(n);
|
|
380
|
+
return out;
|
|
381
|
+
}
|
|
382
|
+
function makeRules(keywords) {
|
|
383
|
+
const rules = [
|
|
384
|
+
{ type: "comment", re: /\/\/[^\n]*/y },
|
|
385
|
+
{ type: "comment", re: /\/\*[\s\S]*?(?:\*\/|$)/y },
|
|
386
|
+
// unterminated -> comment to EOF
|
|
387
|
+
{ type: "string", re: /"(?:[^"\\\n]|\\.)*"?/y },
|
|
388
|
+
{ type: "string", re: /'(?:[^'\\\n]|\\.)*'?/y },
|
|
389
|
+
{ expand: (value) => expandTemplateLiteral(value, rules), re: /`(?:[^`\\]|\\.)*`?/y },
|
|
390
|
+
{
|
|
391
|
+
type: "number",
|
|
392
|
+
re: /0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?n?/y
|
|
393
|
+
},
|
|
394
|
+
{ type: "keyword", re: wordRegex(keywords) },
|
|
395
|
+
{ type: "boolean", re: /(?:true|false)\b/y },
|
|
396
|
+
{ type: "null", re: /(?:null|undefined)\b/y },
|
|
397
|
+
{ type: "builtin", re: wordRegex(BUILTINS) },
|
|
398
|
+
{ type: "function", re: /[A-Za-z_$][\w$]*(?=\s*\()/y },
|
|
399
|
+
{ type: "plain", re: /[A-Za-z_$][\w$]*/y },
|
|
400
|
+
{
|
|
401
|
+
type: "regex",
|
|
402
|
+
when: (source, i) => source.charCodeAt(i) === 47 && canStartRegex(source, i),
|
|
403
|
+
consume: consumeRegex
|
|
404
|
+
},
|
|
405
|
+
{ type: "operator", re: /\.{3}|=>|[+\-*/%=<>!&|^~?]+/y },
|
|
406
|
+
{ type: "punctuation", re: /[{}()[\];,.:]/y }
|
|
407
|
+
];
|
|
408
|
+
return rules;
|
|
409
|
+
}
|
|
410
|
+
var JS_RULES = makeRules(JS_KEYWORDS);
|
|
411
|
+
var TS_RULES = makeRules(TS_KEYWORDS);
|
|
412
|
+
function tokenizeJavaScript(source) {
|
|
413
|
+
return scan(source, JS_RULES);
|
|
414
|
+
}
|
|
415
|
+
function tokenizeTypeScript(source) {
|
|
416
|
+
return scan(source, TS_RULES);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// src/code-editor/tokenizer/css.js
|
|
420
|
+
var PROPERTIES = [
|
|
421
|
+
"align-content",
|
|
422
|
+
"align-items",
|
|
423
|
+
"align-self",
|
|
424
|
+
"all",
|
|
425
|
+
"animation",
|
|
426
|
+
"animation-delay",
|
|
427
|
+
"animation-direction",
|
|
428
|
+
"animation-duration",
|
|
429
|
+
"animation-fill-mode",
|
|
430
|
+
"animation-iteration-count",
|
|
431
|
+
"animation-name",
|
|
432
|
+
"animation-play-state",
|
|
433
|
+
"animation-timing-function",
|
|
434
|
+
"appearance",
|
|
435
|
+
"aspect-ratio",
|
|
436
|
+
"backdrop-filter",
|
|
437
|
+
"backface-visibility",
|
|
438
|
+
"background",
|
|
439
|
+
"background-attachment",
|
|
440
|
+
"background-blend-mode",
|
|
441
|
+
"background-clip",
|
|
442
|
+
"background-color",
|
|
443
|
+
"background-image",
|
|
444
|
+
"background-origin",
|
|
445
|
+
"background-position",
|
|
446
|
+
"background-repeat",
|
|
447
|
+
"background-size",
|
|
448
|
+
"block-size",
|
|
449
|
+
"border",
|
|
450
|
+
"border-block",
|
|
451
|
+
"border-block-end",
|
|
452
|
+
"border-block-start",
|
|
453
|
+
"border-bottom",
|
|
454
|
+
"border-bottom-color",
|
|
455
|
+
"border-bottom-left-radius",
|
|
456
|
+
"border-bottom-right-radius",
|
|
457
|
+
"border-bottom-style",
|
|
458
|
+
"border-bottom-width",
|
|
459
|
+
"border-collapse",
|
|
460
|
+
"border-color",
|
|
461
|
+
"border-end-end-radius",
|
|
462
|
+
"border-end-start-radius",
|
|
463
|
+
"border-image",
|
|
464
|
+
"border-inline",
|
|
465
|
+
"border-inline-end",
|
|
466
|
+
"border-inline-start",
|
|
467
|
+
"border-left",
|
|
468
|
+
"border-left-color",
|
|
469
|
+
"border-left-style",
|
|
470
|
+
"border-left-width",
|
|
471
|
+
"border-radius",
|
|
472
|
+
"border-right",
|
|
473
|
+
"border-right-color",
|
|
474
|
+
"border-right-style",
|
|
475
|
+
"border-right-width",
|
|
476
|
+
"border-spacing",
|
|
477
|
+
"border-start-end-radius",
|
|
478
|
+
"border-start-start-radius",
|
|
479
|
+
"border-style",
|
|
480
|
+
"border-top",
|
|
481
|
+
"border-top-color",
|
|
482
|
+
"border-top-left-radius",
|
|
483
|
+
"border-top-right-radius",
|
|
484
|
+
"border-top-style",
|
|
485
|
+
"border-top-width",
|
|
486
|
+
"border-width",
|
|
487
|
+
"bottom",
|
|
488
|
+
"box-decoration-break",
|
|
489
|
+
"box-shadow",
|
|
490
|
+
"box-sizing",
|
|
491
|
+
"break-after",
|
|
492
|
+
"break-before",
|
|
493
|
+
"break-inside",
|
|
494
|
+
"caption-side",
|
|
495
|
+
"caret-color",
|
|
496
|
+
"clear",
|
|
497
|
+
"clip",
|
|
498
|
+
"clip-path",
|
|
499
|
+
"color",
|
|
500
|
+
"color-scheme",
|
|
501
|
+
"column-count",
|
|
502
|
+
"column-fill",
|
|
503
|
+
"column-gap",
|
|
504
|
+
"column-rule",
|
|
505
|
+
"column-span",
|
|
506
|
+
"column-width",
|
|
507
|
+
"columns",
|
|
508
|
+
"contain",
|
|
509
|
+
"container",
|
|
510
|
+
"content",
|
|
511
|
+
"counter-increment",
|
|
512
|
+
"counter-reset",
|
|
513
|
+
"cursor",
|
|
514
|
+
"direction",
|
|
515
|
+
"display",
|
|
516
|
+
"empty-cells",
|
|
517
|
+
"filter",
|
|
518
|
+
"flex",
|
|
519
|
+
"flex-basis",
|
|
520
|
+
"flex-direction",
|
|
521
|
+
"flex-flow",
|
|
522
|
+
"flex-grow",
|
|
523
|
+
"flex-shrink",
|
|
524
|
+
"flex-wrap",
|
|
525
|
+
"float",
|
|
526
|
+
"font",
|
|
527
|
+
"font-family",
|
|
528
|
+
"font-feature-settings",
|
|
529
|
+
"font-kerning",
|
|
530
|
+
"font-size",
|
|
531
|
+
"font-size-adjust",
|
|
532
|
+
"font-stretch",
|
|
533
|
+
"font-style",
|
|
534
|
+
"font-synthesis",
|
|
535
|
+
"font-variant",
|
|
536
|
+
"font-variation-settings",
|
|
537
|
+
"font-weight",
|
|
538
|
+
"gap",
|
|
539
|
+
"grid",
|
|
540
|
+
"grid-area",
|
|
541
|
+
"grid-auto-columns",
|
|
542
|
+
"grid-auto-flow",
|
|
543
|
+
"grid-auto-rows",
|
|
544
|
+
"grid-column",
|
|
545
|
+
"grid-column-end",
|
|
546
|
+
"grid-column-start",
|
|
547
|
+
"grid-row",
|
|
548
|
+
"grid-row-end",
|
|
549
|
+
"grid-row-start",
|
|
550
|
+
"grid-template",
|
|
551
|
+
"grid-template-areas",
|
|
552
|
+
"grid-template-columns",
|
|
553
|
+
"grid-template-rows",
|
|
554
|
+
"hanging-punctuation",
|
|
555
|
+
"height",
|
|
556
|
+
"hyphens",
|
|
557
|
+
"image-rendering",
|
|
558
|
+
"inline-size",
|
|
559
|
+
"inset",
|
|
560
|
+
"inset-block",
|
|
561
|
+
"inset-inline",
|
|
562
|
+
"isolation",
|
|
563
|
+
"justify-content",
|
|
564
|
+
"justify-items",
|
|
565
|
+
"justify-self",
|
|
566
|
+
"left",
|
|
567
|
+
"letter-spacing",
|
|
568
|
+
"line-break",
|
|
569
|
+
"line-clamp",
|
|
570
|
+
"line-height",
|
|
571
|
+
"list-style",
|
|
572
|
+
"list-style-image",
|
|
573
|
+
"list-style-position",
|
|
574
|
+
"list-style-type",
|
|
575
|
+
"margin",
|
|
576
|
+
"margin-block",
|
|
577
|
+
"margin-block-end",
|
|
578
|
+
"margin-block-start",
|
|
579
|
+
"margin-bottom",
|
|
580
|
+
"margin-inline",
|
|
581
|
+
"margin-inline-end",
|
|
582
|
+
"margin-inline-start",
|
|
583
|
+
"margin-left",
|
|
584
|
+
"margin-right",
|
|
585
|
+
"margin-top",
|
|
586
|
+
"mask",
|
|
587
|
+
"mask-image",
|
|
588
|
+
"max-block-size",
|
|
589
|
+
"max-height",
|
|
590
|
+
"max-inline-size",
|
|
591
|
+
"max-width",
|
|
592
|
+
"min-block-size",
|
|
593
|
+
"min-height",
|
|
594
|
+
"min-inline-size",
|
|
595
|
+
"min-width",
|
|
596
|
+
"mix-blend-mode",
|
|
597
|
+
"object-fit",
|
|
598
|
+
"object-position",
|
|
599
|
+
"offset",
|
|
600
|
+
"opacity",
|
|
601
|
+
"order",
|
|
602
|
+
"orphans",
|
|
603
|
+
"outline",
|
|
604
|
+
"outline-color",
|
|
605
|
+
"outline-offset",
|
|
606
|
+
"outline-style",
|
|
607
|
+
"outline-width",
|
|
608
|
+
"overflow",
|
|
609
|
+
"overflow-anchor",
|
|
610
|
+
"overflow-wrap",
|
|
611
|
+
"overflow-x",
|
|
612
|
+
"overflow-y",
|
|
613
|
+
"overscroll-behavior",
|
|
614
|
+
"padding",
|
|
615
|
+
"padding-block",
|
|
616
|
+
"padding-block-end",
|
|
617
|
+
"padding-block-start",
|
|
618
|
+
"padding-bottom",
|
|
619
|
+
"padding-inline",
|
|
620
|
+
"padding-inline-end",
|
|
621
|
+
"padding-inline-start",
|
|
622
|
+
"padding-left",
|
|
623
|
+
"padding-right",
|
|
624
|
+
"padding-top",
|
|
625
|
+
"page-break-after",
|
|
626
|
+
"page-break-before",
|
|
627
|
+
"page-break-inside",
|
|
628
|
+
"perspective",
|
|
629
|
+
"place-content",
|
|
630
|
+
"place-items",
|
|
631
|
+
"place-self",
|
|
632
|
+
"pointer-events",
|
|
633
|
+
"position",
|
|
634
|
+
"quotes",
|
|
635
|
+
"resize",
|
|
636
|
+
"right",
|
|
637
|
+
"rotate",
|
|
638
|
+
"row-gap",
|
|
639
|
+
"scale",
|
|
640
|
+
"scroll-behavior",
|
|
641
|
+
"scroll-margin",
|
|
642
|
+
"scroll-padding",
|
|
643
|
+
"scroll-snap-align",
|
|
644
|
+
"scroll-snap-type",
|
|
645
|
+
"shape-outside",
|
|
646
|
+
"tab-size",
|
|
647
|
+
"table-layout",
|
|
648
|
+
"text-align",
|
|
649
|
+
"text-align-last",
|
|
650
|
+
"text-decoration",
|
|
651
|
+
"text-decoration-color",
|
|
652
|
+
"text-decoration-line",
|
|
653
|
+
"text-decoration-style",
|
|
654
|
+
"text-decoration-thickness",
|
|
655
|
+
"text-emphasis",
|
|
656
|
+
"text-indent",
|
|
657
|
+
"text-overflow",
|
|
658
|
+
"text-rendering",
|
|
659
|
+
"text-shadow",
|
|
660
|
+
"text-transform",
|
|
661
|
+
"text-underline-offset",
|
|
662
|
+
"text-wrap",
|
|
663
|
+
"top",
|
|
664
|
+
"touch-action",
|
|
665
|
+
"transform",
|
|
666
|
+
"transform-origin",
|
|
667
|
+
"transition",
|
|
668
|
+
"transition-delay",
|
|
669
|
+
"transition-duration",
|
|
670
|
+
"transition-property",
|
|
671
|
+
"transition-timing-function",
|
|
672
|
+
"translate",
|
|
673
|
+
"unicode-bidi",
|
|
674
|
+
"user-select",
|
|
675
|
+
"vertical-align",
|
|
676
|
+
"visibility",
|
|
677
|
+
"white-space",
|
|
678
|
+
"widows",
|
|
679
|
+
"width",
|
|
680
|
+
"will-change",
|
|
681
|
+
"word-break",
|
|
682
|
+
"word-spacing",
|
|
683
|
+
"word-wrap",
|
|
684
|
+
"writing-mode",
|
|
685
|
+
"z-index"
|
|
686
|
+
];
|
|
687
|
+
function cssPropRegex(names) {
|
|
688
|
+
const sorted = [...names].sort((a, b) => b.length - a.length);
|
|
689
|
+
return new RegExp("(?:" + sorted.join("|") + ")(?=\\s*:)", "y");
|
|
690
|
+
}
|
|
691
|
+
var RULES = [
|
|
692
|
+
{ type: "comment", re: /\/\*[\s\S]*?(?:\*\/|$)/y },
|
|
693
|
+
// unterminated -> comment to EOF
|
|
694
|
+
{ type: "string", re: /"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/y },
|
|
695
|
+
{ type: "meta", re: /@[a-zA-Z-]+/y },
|
|
696
|
+
{ type: "keyword", re: /!important\b/y },
|
|
697
|
+
{ type: "number", re: /#[0-9a-fA-F]{3,8}\b/y },
|
|
698
|
+
{ type: "number", re: /-?(?:\d*\.\d+|\d+)(?:%|[a-zA-Z]{1,4})?/y },
|
|
699
|
+
{ type: "property", re: /--[\w-]+/y },
|
|
700
|
+
{ type: "property", re: cssPropRegex(PROPERTIES) },
|
|
701
|
+
{ type: "attribute", re: /[.#][a-zA-Z_-][\w-]*/y },
|
|
702
|
+
{ type: "meta", re: /::?[a-zA-Z_-][\w-]*/y },
|
|
703
|
+
{ type: "function", re: /[-a-zA-Z][\w-]*(?=\()/y },
|
|
704
|
+
{ type: "punctuation", re: /[{}()[\];:,]/y },
|
|
705
|
+
{ type: "operator", re: /[>+~*]/y },
|
|
706
|
+
// Catch-all: consume an identifier/dash run (or whitespace) in one match so
|
|
707
|
+
// the greedy property/function look-ahead rules run once per run, not once
|
|
708
|
+
// per character (keeps scanning linear).
|
|
709
|
+
{ type: "plain", re: /[-\w$]+|\s+/y }
|
|
710
|
+
];
|
|
711
|
+
function tokenizeCss(source) {
|
|
712
|
+
return scan(source, RULES);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// src/code-editor/tokenizer/html.js
|
|
716
|
+
function expandTag(value, vue) {
|
|
717
|
+
const out = [];
|
|
718
|
+
const open = /^<\/?/.exec(value)[0];
|
|
719
|
+
out.push({ type: "punctuation", value: open });
|
|
720
|
+
let rest = value.slice(open.length);
|
|
721
|
+
const name = /^[a-zA-Z][\w:-]*/.exec(rest);
|
|
722
|
+
if (name) {
|
|
723
|
+
out.push({ type: "tag", value: name[0] });
|
|
724
|
+
rest = rest.slice(name[0].length);
|
|
725
|
+
}
|
|
726
|
+
if (rest) {
|
|
727
|
+
const attrRules = vue ? [
|
|
728
|
+
{ type: "string", re: /"[^"]*"?|'[^']*'?/y },
|
|
729
|
+
{ type: "operator", re: /=/y },
|
|
730
|
+
{ type: "punctuation", re: /\/?>/y },
|
|
731
|
+
{ type: "meta", re: /(?:v-[\w:.@-]+|[@:][\w:.@-]*)/y },
|
|
732
|
+
{ type: "attribute", re: /[a-zA-Z_][\w:.-]*/y }
|
|
733
|
+
] : [
|
|
734
|
+
{ type: "string", re: /"[^"]*"?|'[^']*'?/y },
|
|
735
|
+
{ type: "operator", re: /=/y },
|
|
736
|
+
{ type: "punctuation", re: /\/?>/y },
|
|
737
|
+
{ type: "attribute", re: /[a-zA-Z_:@][\w:.-]*/y }
|
|
738
|
+
];
|
|
739
|
+
const inner = scanSlice(rest, attrRules);
|
|
740
|
+
for (let i = 0; i < inner.length; i++) out.push(inner[i]);
|
|
741
|
+
}
|
|
742
|
+
return out;
|
|
743
|
+
}
|
|
744
|
+
function scanSlice(source, rules) {
|
|
745
|
+
const tokens = [];
|
|
746
|
+
const n = source.length;
|
|
747
|
+
let i = 0;
|
|
748
|
+
let plainStart = -1;
|
|
749
|
+
const flushPlain = (end) => {
|
|
750
|
+
if (plainStart !== -1 && end > plainStart) {
|
|
751
|
+
tokens.push({ type: "plain", value: source.slice(plainStart, end) });
|
|
752
|
+
}
|
|
753
|
+
plainStart = -1;
|
|
754
|
+
};
|
|
755
|
+
while (i < n) {
|
|
756
|
+
const hit = matchRule(source, i, rules);
|
|
757
|
+
if (hit) {
|
|
758
|
+
flushPlain(i);
|
|
759
|
+
for (let k = 0; k < hit.tokens.length; k++) tokens.push(hit.tokens[k]);
|
|
760
|
+
i += hit.length;
|
|
761
|
+
} else {
|
|
762
|
+
if (plainStart === -1) plainStart = i;
|
|
763
|
+
i++;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
flushPlain(n);
|
|
767
|
+
return tokens;
|
|
768
|
+
}
|
|
769
|
+
function ieqChar(a, b) {
|
|
770
|
+
if (a === b) return true;
|
|
771
|
+
if (a >= 65 && a <= 90) return a + 32 === b;
|
|
772
|
+
if (b >= 65 && b <= 90) return b + 32 === a;
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
function findCloseTag(source, start, tagName) {
|
|
776
|
+
const n = source.length;
|
|
777
|
+
const tlen = tagName.length;
|
|
778
|
+
for (let i = start; i < n; i++) {
|
|
779
|
+
if (source.charCodeAt(i) !== 60) continue;
|
|
780
|
+
if (source.charCodeAt(i + 1) !== 47) continue;
|
|
781
|
+
let ok = true;
|
|
782
|
+
for (let k = 0; k < tlen; k++) {
|
|
783
|
+
if (!ieqChar(source.charCodeAt(i + 2 + k), tagName.charCodeAt(k))) {
|
|
784
|
+
ok = false;
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (!ok) continue;
|
|
789
|
+
let j = i + 2 + tlen;
|
|
790
|
+
while (j < n) {
|
|
791
|
+
const c = source.charCodeAt(j);
|
|
792
|
+
if (c === 32 || c === 9 || c === 10 || c === 13) j++;
|
|
793
|
+
else break;
|
|
794
|
+
}
|
|
795
|
+
if (j < n && source.charCodeAt(j) === 62) return { start: i, end: j + 1 };
|
|
796
|
+
}
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
function embedInfo(tagValue) {
|
|
800
|
+
const open = /^<(script|style)\b/i.exec(tagValue);
|
|
801
|
+
if (!open) return null;
|
|
802
|
+
if (!tagValue.endsWith(">") || tagValue.endsWith("/>")) return null;
|
|
803
|
+
const tag = open[1].toLowerCase();
|
|
804
|
+
if (tag === "style") return { tag: "style", lang: "css" };
|
|
805
|
+
const lang = /\blang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(tagValue);
|
|
806
|
+
const id = (lang && (lang[1] || lang[2] || lang[3]) || "").toLowerCase();
|
|
807
|
+
if (id === "ts" || id === "tsx" || id === "typescript")
|
|
808
|
+
return { tag: "script", lang: "typescript" };
|
|
809
|
+
return { tag: "script", lang: "javascript" };
|
|
810
|
+
}
|
|
811
|
+
function tokenizeEmbed(source, lang) {
|
|
812
|
+
if (lang === "typescript") return tokenizeTypeScript(source);
|
|
813
|
+
if (lang === "css") return tokenizeCss(source);
|
|
814
|
+
return tokenizeJavaScript(source);
|
|
815
|
+
}
|
|
816
|
+
function expandMustache(value) {
|
|
817
|
+
const out = [{ type: "meta", value: "{{" }];
|
|
818
|
+
let inner = value.slice(2);
|
|
819
|
+
let close = "";
|
|
820
|
+
if (value.length >= 4 && inner.endsWith("}}")) {
|
|
821
|
+
close = "}}";
|
|
822
|
+
inner = inner.slice(0, -2);
|
|
823
|
+
}
|
|
824
|
+
if (inner) {
|
|
825
|
+
const parts = tokenizeJavaScript(inner);
|
|
826
|
+
for (let i = 0; i < parts.length; i++) out.push(parts[i]);
|
|
827
|
+
}
|
|
828
|
+
if (close) out.push({ type: "meta", value: close });
|
|
829
|
+
return out;
|
|
830
|
+
}
|
|
831
|
+
function makeMarkupRules(vue) {
|
|
832
|
+
const expand = (value) => expandTag(value, vue);
|
|
833
|
+
const rules = [
|
|
834
|
+
{ type: "comment", re: /<!--[\s\S]*?-->/y },
|
|
835
|
+
{ type: "meta", re: /<!\[CDATA\[[\s\S]*?\]\]>/y },
|
|
836
|
+
{ type: "meta", re: /<!DOCTYPE[^>]*>/iy },
|
|
837
|
+
{
|
|
838
|
+
expand,
|
|
839
|
+
re: /<\/?[a-zA-Z][\w:-]*(?:\s+[^\s/>"'=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*\/?>/y
|
|
840
|
+
},
|
|
841
|
+
{ expand, re: /<\/?[a-zA-Z][\w:-]*/y },
|
|
842
|
+
{ type: "meta", re: /&[a-zA-Z][a-zA-Z0-9]*;|&#\d+;|&#x[0-9a-fA-F]+;/y }
|
|
843
|
+
];
|
|
844
|
+
if (vue) {
|
|
845
|
+
rules.splice(1, 0, { expand: expandMustache, re: /\{\{[\s\S]*?(?:\}\}|$)/y });
|
|
846
|
+
}
|
|
847
|
+
return rules;
|
|
848
|
+
}
|
|
849
|
+
var HTML_RULES = makeMarkupRules(false);
|
|
850
|
+
var VUE_RULES = makeMarkupRules(true);
|
|
851
|
+
function tokenizeMarkup(source, options) {
|
|
852
|
+
const vue = !!(options && options.vue);
|
|
853
|
+
const rules = vue ? VUE_RULES : HTML_RULES;
|
|
854
|
+
const tokens = [];
|
|
855
|
+
const n = source.length;
|
|
856
|
+
let i = 0;
|
|
857
|
+
let plainStart = -1;
|
|
858
|
+
const flushPlain = (end) => {
|
|
859
|
+
if (plainStart !== -1 && end > plainStart) {
|
|
860
|
+
tokens.push({ type: "plain", value: source.slice(plainStart, end) });
|
|
861
|
+
}
|
|
862
|
+
plainStart = -1;
|
|
863
|
+
};
|
|
864
|
+
while (i < n) {
|
|
865
|
+
const hit = matchRule(source, i, rules);
|
|
866
|
+
if (hit) {
|
|
867
|
+
flushPlain(i);
|
|
868
|
+
const embed = embedInfo(hit.value);
|
|
869
|
+
if (embed) {
|
|
870
|
+
for (let k = 0; k < hit.tokens.length; k++) tokens.push(hit.tokens[k]);
|
|
871
|
+
i += hit.length;
|
|
872
|
+
const close = findCloseTag(source, i, embed.tag);
|
|
873
|
+
const bodyEnd = close ? close.start : n;
|
|
874
|
+
const body = source.slice(i, bodyEnd);
|
|
875
|
+
if (body) {
|
|
876
|
+
const inner = tokenizeEmbed(body, embed.lang);
|
|
877
|
+
for (let k = 0; k < inner.length; k++) tokens.push(inner[k]);
|
|
878
|
+
}
|
|
879
|
+
if (close) {
|
|
880
|
+
const closeTokens = expandTag(source.slice(close.start, close.end), vue);
|
|
881
|
+
for (let k = 0; k < closeTokens.length; k++) tokens.push(closeTokens[k]);
|
|
882
|
+
i = close.end;
|
|
883
|
+
} else {
|
|
884
|
+
i = n;
|
|
885
|
+
}
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
for (let k = 0; k < hit.tokens.length; k++) tokens.push(hit.tokens[k]);
|
|
889
|
+
i += hit.length;
|
|
890
|
+
} else {
|
|
891
|
+
if (plainStart === -1) plainStart = i;
|
|
892
|
+
i++;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
flushPlain(n);
|
|
896
|
+
return coalesce(tokens);
|
|
897
|
+
}
|
|
898
|
+
function tokenizeHtml(source) {
|
|
899
|
+
return tokenizeMarkup(source, { vue: false });
|
|
900
|
+
}
|
|
901
|
+
function tokenizeVue(source) {
|
|
902
|
+
return tokenizeMarkup(source, { vue: true });
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// src/code-editor/tokenizer/json.js
|
|
906
|
+
var RULES2 = [
|
|
907
|
+
{ type: "property", re: /"(?:[^"\\]|\\.)*"(?=\s*:)/y },
|
|
908
|
+
{ type: "string", re: /"(?:[^"\\]|\\.)*"?/y },
|
|
909
|
+
{ type: "number", re: /-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/y },
|
|
910
|
+
{ type: "boolean", re: /\b(?:true|false)\b/y },
|
|
911
|
+
{ type: "null", re: /\bnull\b/y },
|
|
912
|
+
{ type: "punctuation", re: /[{}[\]:,]/y }
|
|
913
|
+
];
|
|
914
|
+
function tokenizeJson(source) {
|
|
915
|
+
return scan(source, RULES2);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/code-editor/tokenizer/markdown.js
|
|
919
|
+
var RULES3 = [
|
|
920
|
+
{ type: "string", re: /```[\s\S]*?```|~~~[\s\S]*?~~~|`[^`\n]*`/y },
|
|
921
|
+
{ type: "keyword", re: /^ {0,3}#{1,6} [^\n]*/my },
|
|
922
|
+
{ type: "comment", re: /^ {0,3}>[^\n]*/my },
|
|
923
|
+
{ type: "punctuation", re: /^ {0,3}(?:[-*+]|\d+\.)\s/my },
|
|
924
|
+
{ type: "meta", re: /^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/my },
|
|
925
|
+
{ type: "function", re: /!?\[[^\][\n]*\]\([^()\n]*\)/y },
|
|
926
|
+
{ type: "operator", re: /\*\*[^\n]*?\*\*|__[^\n]*?__/y },
|
|
927
|
+
{ type: "meta", re: /\*[^*\n]+?\*|_[^_\n]+?_/y }
|
|
928
|
+
];
|
|
929
|
+
function tokenizeMarkdown(source) {
|
|
930
|
+
return scan(source, RULES3);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/code-editor/tokenizer/shell.js
|
|
934
|
+
var KEYWORDS = [
|
|
935
|
+
"if",
|
|
936
|
+
"then",
|
|
937
|
+
"elif",
|
|
938
|
+
"else",
|
|
939
|
+
"fi",
|
|
940
|
+
"for",
|
|
941
|
+
"while",
|
|
942
|
+
"until",
|
|
943
|
+
"do",
|
|
944
|
+
"done",
|
|
945
|
+
"case",
|
|
946
|
+
"esac",
|
|
947
|
+
"function",
|
|
948
|
+
"in",
|
|
949
|
+
"select",
|
|
950
|
+
"return",
|
|
951
|
+
"break",
|
|
952
|
+
"continue",
|
|
953
|
+
"local",
|
|
954
|
+
"export",
|
|
955
|
+
"readonly",
|
|
956
|
+
"declare",
|
|
957
|
+
"typeset",
|
|
958
|
+
"set",
|
|
959
|
+
"unset",
|
|
960
|
+
"shift",
|
|
961
|
+
"exit",
|
|
962
|
+
"source",
|
|
963
|
+
"alias"
|
|
964
|
+
];
|
|
965
|
+
var BUILTINS2 = [
|
|
966
|
+
"echo",
|
|
967
|
+
"printf",
|
|
968
|
+
"read",
|
|
969
|
+
"cd",
|
|
970
|
+
"pwd",
|
|
971
|
+
"ls",
|
|
972
|
+
"cat",
|
|
973
|
+
"grep",
|
|
974
|
+
"sed",
|
|
975
|
+
"awk",
|
|
976
|
+
"cut",
|
|
977
|
+
"sort",
|
|
978
|
+
"uniq",
|
|
979
|
+
"head",
|
|
980
|
+
"tail",
|
|
981
|
+
"find",
|
|
982
|
+
"xargs",
|
|
983
|
+
"curl",
|
|
984
|
+
"wget",
|
|
985
|
+
"git",
|
|
986
|
+
"npm",
|
|
987
|
+
"pnpm",
|
|
988
|
+
"yarn",
|
|
989
|
+
"node",
|
|
990
|
+
"python",
|
|
991
|
+
"pip",
|
|
992
|
+
"docker",
|
|
993
|
+
"kubectl",
|
|
994
|
+
"make",
|
|
995
|
+
"chmod",
|
|
996
|
+
"chown",
|
|
997
|
+
"mkdir",
|
|
998
|
+
"rmdir",
|
|
999
|
+
"rm",
|
|
1000
|
+
"cp",
|
|
1001
|
+
"mv",
|
|
1002
|
+
"touch",
|
|
1003
|
+
"test",
|
|
1004
|
+
"sudo",
|
|
1005
|
+
"env",
|
|
1006
|
+
"which",
|
|
1007
|
+
"kill",
|
|
1008
|
+
"ps",
|
|
1009
|
+
"tar",
|
|
1010
|
+
"ssh"
|
|
1011
|
+
];
|
|
1012
|
+
var RULES4 = [
|
|
1013
|
+
{ type: "comment", re: /#[^\n]*/y },
|
|
1014
|
+
{ type: "string", re: /"(?:[^"\\]|\\.)*"?/y },
|
|
1015
|
+
{ type: "string", re: /'[^']*'?/y },
|
|
1016
|
+
{ type: "variable", re: /\$\{[^}\n]*\}?|\$[A-Za-z_]\w*|\$[@*#?$!0-9-]/y },
|
|
1017
|
+
{ type: "keyword", re: wordRegex(KEYWORDS) },
|
|
1018
|
+
{ type: "builtin", re: wordRegex(BUILTINS2) },
|
|
1019
|
+
{ type: "attribute", re: /(?:^|\s)-{1,2}[A-Za-z][\w-]*/y },
|
|
1020
|
+
{ type: "number", re: /\b\d+\b/y },
|
|
1021
|
+
{ type: "operator", re: /\|\||&&|[|&;<>]+/y },
|
|
1022
|
+
{ type: "punctuation", re: /[(){}[\]]/y }
|
|
1023
|
+
];
|
|
1024
|
+
function tokenizeShell(source) {
|
|
1025
|
+
return scan(source, RULES4);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/code-editor/tokenizer/python.js
|
|
1029
|
+
var KEYWORDS2 = [
|
|
1030
|
+
"def",
|
|
1031
|
+
"class",
|
|
1032
|
+
"return",
|
|
1033
|
+
"if",
|
|
1034
|
+
"elif",
|
|
1035
|
+
"else",
|
|
1036
|
+
"for",
|
|
1037
|
+
"while",
|
|
1038
|
+
"break",
|
|
1039
|
+
"continue",
|
|
1040
|
+
"pass",
|
|
1041
|
+
"import",
|
|
1042
|
+
"from",
|
|
1043
|
+
"as",
|
|
1044
|
+
"with",
|
|
1045
|
+
"try",
|
|
1046
|
+
"except",
|
|
1047
|
+
"finally",
|
|
1048
|
+
"raise",
|
|
1049
|
+
"yield",
|
|
1050
|
+
"lambda",
|
|
1051
|
+
"global",
|
|
1052
|
+
"nonlocal",
|
|
1053
|
+
"del",
|
|
1054
|
+
"assert",
|
|
1055
|
+
"async",
|
|
1056
|
+
"await",
|
|
1057
|
+
"in",
|
|
1058
|
+
"is",
|
|
1059
|
+
"not",
|
|
1060
|
+
"and",
|
|
1061
|
+
"or",
|
|
1062
|
+
"match",
|
|
1063
|
+
"case"
|
|
1064
|
+
];
|
|
1065
|
+
var BUILTINS3 = [
|
|
1066
|
+
"print",
|
|
1067
|
+
"len",
|
|
1068
|
+
"range",
|
|
1069
|
+
"int",
|
|
1070
|
+
"float",
|
|
1071
|
+
"str",
|
|
1072
|
+
"list",
|
|
1073
|
+
"dict",
|
|
1074
|
+
"set",
|
|
1075
|
+
"tuple",
|
|
1076
|
+
"bool",
|
|
1077
|
+
"bytes",
|
|
1078
|
+
"type",
|
|
1079
|
+
"isinstance",
|
|
1080
|
+
"issubclass",
|
|
1081
|
+
"super",
|
|
1082
|
+
"open",
|
|
1083
|
+
"enumerate",
|
|
1084
|
+
"zip",
|
|
1085
|
+
"map",
|
|
1086
|
+
"filter",
|
|
1087
|
+
"sorted",
|
|
1088
|
+
"reversed",
|
|
1089
|
+
"sum",
|
|
1090
|
+
"min",
|
|
1091
|
+
"max",
|
|
1092
|
+
"abs",
|
|
1093
|
+
"round",
|
|
1094
|
+
"input",
|
|
1095
|
+
"repr",
|
|
1096
|
+
"format",
|
|
1097
|
+
"object",
|
|
1098
|
+
"self",
|
|
1099
|
+
"cls",
|
|
1100
|
+
"Exception",
|
|
1101
|
+
"ValueError",
|
|
1102
|
+
"TypeError",
|
|
1103
|
+
"KeyError",
|
|
1104
|
+
"IndexError",
|
|
1105
|
+
"AttributeError",
|
|
1106
|
+
"RuntimeError"
|
|
1107
|
+
];
|
|
1108
|
+
var RULES5 = [
|
|
1109
|
+
{ type: "comment", re: /#[^\n]*/y },
|
|
1110
|
+
{
|
|
1111
|
+
type: "string",
|
|
1112
|
+
re: /[rRbBfFuU]{0,2}(?:"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?)/y
|
|
1113
|
+
},
|
|
1114
|
+
{ type: "meta", re: /@[A-Za-z_]\w*/y },
|
|
1115
|
+
{ type: "keyword", re: wordRegex(KEYWORDS2) },
|
|
1116
|
+
{ type: "boolean", re: /\b(?:True|False)\b/y },
|
|
1117
|
+
{ type: "null", re: /\bNone\b/y },
|
|
1118
|
+
{ type: "builtin", re: wordRegex(BUILTINS3) },
|
|
1119
|
+
{ type: "function", re: /[A-Za-z_]\w*(?=\s*\()/y },
|
|
1120
|
+
{
|
|
1121
|
+
type: "number",
|
|
1122
|
+
re: /\b0[xXoObB][0-9a-fA-F_]+\b|\b\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?[jJ]?\b/y
|
|
1123
|
+
},
|
|
1124
|
+
{ type: "operator", re: /:=|[+\-*/%=<>!&|^~@]+/y },
|
|
1125
|
+
{ type: "punctuation", re: /[()[\]{}:;,.]/y },
|
|
1126
|
+
// Catch-all: consume an identifier run (or whitespace) in one match so the
|
|
1127
|
+
// greedy function look-ahead rule runs once per run, not once per character.
|
|
1128
|
+
{ type: "plain", re: /\w+|\s+/y }
|
|
1129
|
+
];
|
|
1130
|
+
function tokenizePython(source) {
|
|
1131
|
+
return scan(source, RULES5);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// src/code-editor/tokenizer/index.js
|
|
1135
|
+
var TOKENIZERS = {
|
|
1136
|
+
javascript: tokenizeJavaScript,
|
|
1137
|
+
typescript: tokenizeTypeScript,
|
|
1138
|
+
html: tokenizeHtml,
|
|
1139
|
+
vue: tokenizeVue,
|
|
1140
|
+
css: tokenizeCss,
|
|
1141
|
+
json: tokenizeJson,
|
|
1142
|
+
markdown: tokenizeMarkdown,
|
|
1143
|
+
shell: tokenizeShell,
|
|
1144
|
+
python: tokenizePython
|
|
1145
|
+
};
|
|
1146
|
+
var LANGUAGES = Object.freeze([
|
|
1147
|
+
"plaintext",
|
|
1148
|
+
"javascript",
|
|
1149
|
+
"typescript",
|
|
1150
|
+
"html",
|
|
1151
|
+
"vue",
|
|
1152
|
+
"css",
|
|
1153
|
+
"json",
|
|
1154
|
+
"markdown",
|
|
1155
|
+
"shell",
|
|
1156
|
+
"python"
|
|
1157
|
+
]);
|
|
1158
|
+
var ALIASES = Object.freeze({
|
|
1159
|
+
js: "javascript",
|
|
1160
|
+
jsx: "javascript",
|
|
1161
|
+
mjs: "javascript",
|
|
1162
|
+
cjs: "javascript",
|
|
1163
|
+
ts: "typescript",
|
|
1164
|
+
tsx: "typescript",
|
|
1165
|
+
htm: "html",
|
|
1166
|
+
xml: "html",
|
|
1167
|
+
svg: "html",
|
|
1168
|
+
sh: "shell",
|
|
1169
|
+
bash: "shell",
|
|
1170
|
+
zsh: "shell",
|
|
1171
|
+
shellscript: "shell",
|
|
1172
|
+
py: "python",
|
|
1173
|
+
python3: "python",
|
|
1174
|
+
md: "markdown",
|
|
1175
|
+
mkd: "markdown",
|
|
1176
|
+
json5: "json",
|
|
1177
|
+
jsonc: "json",
|
|
1178
|
+
text: "plaintext",
|
|
1179
|
+
txt: "plaintext",
|
|
1180
|
+
plain: "plaintext"
|
|
1181
|
+
});
|
|
1182
|
+
function resolveLanguage(language) {
|
|
1183
|
+
const id = String(language || "plaintext").toLowerCase();
|
|
1184
|
+
return ALIASES[id] || id;
|
|
1185
|
+
}
|
|
1186
|
+
function getTokenizer(language) {
|
|
1187
|
+
return TOKENIZERS[resolveLanguage(language)] || null;
|
|
1188
|
+
}
|
|
1189
|
+
function tokenize(source, language) {
|
|
1190
|
+
if (!source) return [];
|
|
1191
|
+
const tokenizer = getTokenizer(language);
|
|
1192
|
+
if (!tokenizer) return [{ type: "plain", value: source }];
|
|
1193
|
+
return tokenizer(source);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// src/code-editor/highlight.js
|
|
1197
|
+
var ESCAPE_RE = /[&<>"']/g;
|
|
1198
|
+
var ESCAPE_MAP = {
|
|
1199
|
+
"&": "&",
|
|
1200
|
+
"<": "<",
|
|
1201
|
+
">": ">",
|
|
1202
|
+
'"': """,
|
|
1203
|
+
"'": "'"
|
|
1204
|
+
};
|
|
1205
|
+
function escapeHtml(str) {
|
|
1206
|
+
return String(str).replace(ESCAPE_RE, (ch) => ESCAPE_MAP[ch]);
|
|
1207
|
+
}
|
|
1208
|
+
function renderTokensToHtml(tokens) {
|
|
1209
|
+
let html = "";
|
|
1210
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1211
|
+
const t = tokens[i];
|
|
1212
|
+
if (t.type === "plain") {
|
|
1213
|
+
html += escapeHtml(t.value);
|
|
1214
|
+
} else {
|
|
1215
|
+
html += '<span class="vd-tk-' + t.type + '">' + escapeHtml(t.value) + "</span>";
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return html;
|
|
1219
|
+
}
|
|
1220
|
+
function highlight(source, language, options) {
|
|
1221
|
+
const html = renderTokensToHtml(tokenize(source, language));
|
|
1222
|
+
if (options && options.trailingNewline && (source.endsWith("\n") || source === "")) {
|
|
1223
|
+
return html + "\n";
|
|
1224
|
+
}
|
|
1225
|
+
return html;
|
|
1226
|
+
}
|
|
1227
|
+
function renderTokensToDom(tokens, doc) {
|
|
1228
|
+
const frag = doc.createDocumentFragment();
|
|
1229
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1230
|
+
const t = tokens[i];
|
|
1231
|
+
if (t.type === "plain") {
|
|
1232
|
+
frag.appendChild(doc.createTextNode(t.value));
|
|
1233
|
+
} else {
|
|
1234
|
+
const span = doc.createElement("span");
|
|
1235
|
+
span.className = "vd-tk-" + t.type;
|
|
1236
|
+
span.textContent = t.value;
|
|
1237
|
+
frag.appendChild(span);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return frag;
|
|
1241
|
+
}
|
|
1242
|
+
//# sourceMappingURL=highlight.cjs.map
|