@vanduo-oss/vd3-cbun 1.3.2 → 1.4.1

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