@diagrammo/dgmo 0.25.2 → 0.25.4

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 (51) hide show
  1. package/README.md +69 -884
  2. package/package.json +1 -1
  3. package/src/cli.ts +0 -9
  4. package/src/d3.ts +180 -46
  5. package/src/render.ts +80 -39
  6. package/src/utils/svg-embed.ts +12 -3
  7. package/dist/advanced.cjs +0 -62454
  8. package/dist/advanced.d.cts +0 -5684
  9. package/dist/advanced.d.ts +0 -5684
  10. package/dist/advanced.js +0 -62207
  11. package/dist/auto.cjs +0 -59764
  12. package/dist/auto.css +0 -214
  13. package/dist/auto.d.cts +0 -39
  14. package/dist/auto.d.ts +0 -39
  15. package/dist/auto.js +0 -437
  16. package/dist/auto.mjs +0 -59774
  17. package/dist/cli.cjs +0 -465
  18. package/dist/editor.cjs +0 -432
  19. package/dist/editor.d.cts +0 -26
  20. package/dist/editor.d.ts +0 -26
  21. package/dist/editor.js +0 -401
  22. package/dist/highlight.cjs +0 -720
  23. package/dist/highlight.d.cts +0 -32
  24. package/dist/highlight.d.ts +0 -32
  25. package/dist/highlight.js +0 -690
  26. package/dist/index.cjs +0 -58947
  27. package/dist/index.d.cts +0 -375
  28. package/dist/index.d.ts +0 -375
  29. package/dist/index.js +0 -58951
  30. package/dist/internal.cjs +0 -62456
  31. package/dist/internal.d.cts +0 -5684
  32. package/dist/internal.d.ts +0 -5684
  33. package/dist/internal.js +0 -62207
  34. package/dist/map-data/PROVENANCE.json +0 -1
  35. package/dist/map-data/gazetteer.json +0 -1
  36. package/dist/map-data/lakes.json +0 -1
  37. package/dist/map-data/mountain-ranges.json +0 -1
  38. package/dist/map-data/na-lakes.json +0 -1
  39. package/dist/map-data/na-land.json +0 -1
  40. package/dist/map-data/region-names.json +0 -1
  41. package/dist/map-data/rivers.json +0 -1
  42. package/dist/map-data/us-states.json +0 -1
  43. package/dist/map-data/water-bodies.json +0 -1
  44. package/dist/map-data/world-coarse.json +0 -1
  45. package/dist/map-data/world-detail.json +0 -1
  46. package/dist/pert.cjs +0 -325
  47. package/dist/pert.d.cts +0 -554
  48. package/dist/pert.d.ts +0 -554
  49. package/dist/pert.js +0 -294
  50. package/src/editor/dgmo.grammar.js +0 -18
  51. package/src/editor/dgmo.grammar.terms.js +0 -35
package/dist/highlight.js DELETED
@@ -1,690 +0,0 @@
1
- // src/editor/dgmo.grammar.js
2
- import { LRParser } from "@lezer/lr";
3
-
4
- // src/editor/dgmo.grammar.terms.js
5
- var ChartType = 1;
6
- var TagKeyword = 2;
7
- var DirectiveKeyword = 3;
8
- var ControlKeyword = 4;
9
- var ModifierKeyword = 5;
10
-
11
- // src/editor/keywords.ts
12
- var CHART_TYPES = /* @__PURE__ */ new Set([
13
- // Diagram types
14
- "sequence",
15
- "flowchart",
16
- "class",
17
- "er",
18
- "org",
19
- "kanban",
20
- "c4",
21
- "state",
22
- "sitemap",
23
- "infra",
24
- "gantt",
25
- "pert",
26
- "boxes-and-lines",
27
- "wireframe",
28
- "tech-radar",
29
- "mindmap",
30
- "journey-map",
31
- "pyramid",
32
- "ring",
33
- "raci",
34
- "rasci",
35
- "daci",
36
- "cycle",
37
- // Data chart types
38
- "bar",
39
- "line",
40
- "pie",
41
- "doughnut",
42
- "area",
43
- "polar-area",
44
- "radar",
45
- "bar-stacked",
46
- "multi-line",
47
- "scatter",
48
- "sankey",
49
- "chord",
50
- "function",
51
- "heatmap",
52
- "funnel",
53
- // Visualization types
54
- "slope",
55
- "wordcloud",
56
- "arc",
57
- "timeline",
58
- "venn",
59
- "quadrant",
60
- "map"
61
- ]);
62
- var TAG_KEYWORD = "tag";
63
- var DIRECTIVE_KEYWORDS = /* @__PURE__ */ new Set([
64
- // Gantt
65
- "start",
66
- "era",
67
- "marker",
68
- "holiday",
69
- "workweek",
70
- "today-marker",
71
- "critical-path",
72
- "no-dependencies",
73
- "sort",
74
- // Tech-radar
75
- "rings",
76
- // Tags
77
- "tags",
78
- "import",
79
- "active-tag",
80
- "hide",
81
- "mode",
82
- "direction",
83
- // Boxes-and-lines
84
- "box-metric",
85
- "show-values",
86
- // ER
87
- "notation",
88
- // Class
89
- "extends",
90
- "implements",
91
- "abstract",
92
- "interface",
93
- "enum",
94
- // C4
95
- "containers",
96
- "components",
97
- "deployment",
98
- // Infra directives
99
- "sub-node-label",
100
- "show-sub-node-count",
101
- // Infra node properties
102
- "instances",
103
- "max-rps",
104
- "latency-ms",
105
- "uptime",
106
- "firewall-block",
107
- "ratelimit-rps",
108
- "cb-error-threshold",
109
- "cb-latency-threshold-ms",
110
- "buffer",
111
- "drain-rate",
112
- "retention-hours",
113
- "partitions",
114
- "slo-p90-latency-ms",
115
- "slo-availability",
116
- "slo-warning-margin",
117
- "cache-hit",
118
- "concurrency",
119
- "duration-ms",
120
- "cold-start-ms",
121
- "rps",
122
- // Sequence
123
- "activations",
124
- "no-activations",
125
- // Map (§24B) directives — cosmetics on by default, bare `no-*` opt-outs
126
- "region-metric",
127
- "poi-metric",
128
- "flow-metric",
129
- "locale",
130
- "active-tag",
131
- "caption",
132
- "no-legend",
133
- "no-coastline",
134
- "no-relief",
135
- "no-context-labels",
136
- "no-region-labels",
137
- "no-poi-labels",
138
- "no-colorize",
139
- "no-cluster-pois",
140
- "poi",
141
- "route",
142
- // Data charts
143
- "stacked",
144
- "no-name",
145
- "no-value",
146
- "no-percent",
147
- // Slope
148
- "period",
149
- // Quadrant
150
- "x-axis",
151
- "y-axis",
152
- "top-right",
153
- "top-left",
154
- "bottom-right",
155
- "bottom-left",
156
- // Layout
157
- "direction-tb",
158
- "direction-lr",
159
- // Fill mode (cross-chart-type)
160
- "solid-fill",
161
- // Pyramid
162
- "inverted",
163
- // Data chart metadata
164
- "title",
165
- "series",
166
- "orientation",
167
- "x-label",
168
- "y-label",
169
- "size-label",
170
- "columns",
171
- "rows",
172
- "labels",
173
- "rotate",
174
- "scale",
175
- "values",
176
- // Color (cross-chart-type)
177
- "color",
178
- // Title suppression (cross-chart-type)
179
- "no-title",
180
- // Flowchart layout
181
- "orientation-vertical",
182
- // RACI
183
- "variant-raci",
184
- "variant-rasci",
185
- "variant-daci",
186
- "roles",
187
- // Cycle
188
- "direction-counterclockwise",
189
- "circle-nodes",
190
- // Journey-map
191
- "persona",
192
- // Tech-radar
193
- "show-blip-legend",
194
- "trend",
195
- // Gantt
196
- "no-dependencies",
197
- "sprint-length",
198
- "sprint-number",
199
- "sprint-start",
200
- // Bar-stacked / data-chart layout
201
- "orientation-horizontal",
202
- // Function
203
- "x",
204
- "shade",
205
- // Wordcloud
206
- "max",
207
- "size",
208
- // Arc
209
- "order",
210
- // C4
211
- "technology",
212
- // Infra defaults + animate flags
213
- "default-rps",
214
- "default-latency-ms",
215
- "default-uptime",
216
- "animate",
217
- // PERT
218
- "time-unit",
219
- "default-confidence",
220
- "node-detail",
221
- "trials",
222
- "seed",
223
- "scrubber-trials",
224
- "start-date",
225
- "end-date"
226
- ]);
227
- var CONTROL_KEYWORDS = /* @__PURE__ */ new Set([
228
- "if",
229
- "else",
230
- "loop",
231
- "parallel",
232
- "note",
233
- // Wireframe elements
234
- "nav",
235
- "tabs",
236
- "table",
237
- "image",
238
- "modal",
239
- "skeleton",
240
- "alert",
241
- "progress",
242
- "chart",
243
- "mobile"
244
- ]);
245
- var STATUS_KEYWORDS = /* @__PURE__ */ new Set([
246
- "na",
247
- "todo",
248
- "wip",
249
- "done",
250
- "blocked",
251
- "in-progress",
252
- "backlog",
253
- "ready"
254
- // Tech-radar trend values (`new`, `up`, `down`, `stable`) are
255
- // intentionally NOT in this set — they collide with common English
256
- // prose ("Bring up coffee", "new requirement"). The tech-radar
257
- // parser still validates them explicitly, and the completion
258
- // provider still suggests them in trend-value position.
259
- ]);
260
- var MODIFIER_KEYWORDS = /* @__PURE__ */ new Set([
261
- "as",
262
- "alias",
263
- "aka",
264
- "position",
265
- "default",
266
- // ER column modifiers
267
- "pk",
268
- "fk",
269
- "nullable",
270
- "unique",
271
- // ER data types
272
- "int",
273
- "varchar",
274
- "text",
275
- "boolean",
276
- "date",
277
- "timestamp",
278
- "float",
279
- "decimal"
280
- ]);
281
-
282
- // src/editor/tokens.ts
283
- function specializeKeyword(value) {
284
- if (CHART_TYPES.has(value)) return ChartType;
285
- if (value === TAG_KEYWORD) return TagKeyword;
286
- if (DIRECTIVE_KEYWORDS.has(value)) return DirectiveKeyword;
287
- if (CONTROL_KEYWORDS.has(value)) return ControlKeyword;
288
- if (STATUS_KEYWORDS.has(value)) return ModifierKeyword;
289
- if (MODIFIER_KEYWORDS.has(value)) return ModifierKeyword;
290
- return -1;
291
- }
292
-
293
- // src/editor/dgmo.grammar.js
294
- var parser = LRParser.deserialize({
295
- version: 14,
296
- states: "!WQVQPOOOOQO'#DU'#DUOOQO'#DP'#DPO%]QPO'#CdOOQO'#DO'#DOQVQPOOOOQO-E6}-E6}OOQO,59O,59OOOQO-E6|-E6|",
297
- stateData: "&Q~OvOS~OPPOQPORPOSPOTPOVSOXPOYPOZPO[PO]PO^PO_PO`POaPObPOcPOdPOePOfPOgPOhPOiPOjPOkPOlPOmPOnPOoPOpPOqPOwSO~OPPOQPORPOSPOTPOXPOYPOZPO[PO]PO^PO_PO`POaPObPOcPOdPOePOfPOgPOhPOiPOjPOkPOlPOmPOnPOoPOpPOqPO~OwVO~P#]OVXYZ[]^_`ghijklmnabcdefopqk~",
298
- goto: "!byPPPPPPPPzPPPPPPPPPPPPPPPPPPPPPPPPP!O!UPPPP!]TSOTQTORWTSROTRURVQORT",
299
- nodeNames: "\u26A0 ChartType TagKeyword DirectiveKeyword ControlKeyword ModifierKeyword Document Comment ContentLine SyncArrow AsyncArrow Duration DateLiteral Percentage Number SectionMarker Url OpenBracket CloseBracket OpenParen CloseParen OpenAngle CloseAngle Pipe Colon Comma Plus Dash Tilde Star Question QuotedString Identifier Punct",
300
- maxTerm: 40,
301
- skippedNodes: [0],
302
- repeatNodeCount: 2,
303
- tokenData: "<v~RzOX#uXY#zYZ$VZp#upq#zqr#urs$[st#uux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!Q1|!Q![1|![!]9X!_!`1|!a!b1|!b!c1|!c!}1|#R#S1|#T#o1|~<aOg~q~~<hPl~q~!`!a<k~<pOY~~<sP;=`<%l#u",
304
- tokenizers: [0],
305
- topRules: { "Document": [0, 6] },
306
- specialized: [{ term: 32, get: (value, stack) => specializeKeyword(value, stack) << 1, external: specializeKeyword }],
307
- tokenPrec: 204
308
- });
309
-
310
- // src/editor/highlight-api.ts
311
- var NODE_TO_ROLE = {
312
- Comment: "comment",
313
- ChartType: "chartType",
314
- TagKeyword: "definitionKeyword",
315
- DirectiveKeyword: "keyword",
316
- ControlKeyword: "controlKeyword",
317
- ModifierKeyword: "modifier",
318
- SyncArrow: "operator",
319
- AsyncArrow: "operator",
320
- Dash: "operator",
321
- Tilde: "operator",
322
- Star: "operator",
323
- Question: "operator",
324
- Duration: "number",
325
- DateLiteral: "number",
326
- Number: "number",
327
- Percentage: "number",
328
- SectionMarker: "heading",
329
- Url: "url",
330
- OpenBracket: "bracket",
331
- CloseBracket: "bracket",
332
- OpenParen: "bracket",
333
- CloseParen: "bracket",
334
- OpenAngle: "bracket",
335
- CloseAngle: "bracket",
336
- // `|` is no longer DGMO's metadata delimiter as of 0.18.0 (§1.4).
337
- // Highlight legacy pipes in a deprecated-syntax color so authors
338
- // see the migration prompt visually before the parser diagnostic
339
- // fires. The lezer grammar still tokenizes `|` uniformly (it's a
340
- // valid character inside arrow labels and wireframe dropdowns), so
341
- // this paints surviving pipes too — acceptable noise for the
342
- // signal value during the 0.17.x → 0.18.0 transition.
343
- Pipe: "deprecatedSyntax",
344
- Colon: "separator",
345
- Plus: "separator",
346
- Comma: "punctuation",
347
- Punct: "punctuation",
348
- QuotedString: "string",
349
- Identifier: "default"
350
- };
351
- var OVERRIDE_IN_LABEL = /* @__PURE__ */ new Set([
352
- "ChartType",
353
- "TagKeyword",
354
- "DirectiveKeyword",
355
- "ControlKeyword",
356
- "ModifierKeyword",
357
- "Number",
358
- "Percentage",
359
- "Duration",
360
- "DateLiteral"
361
- ]);
362
- var KEYWORD_STARTS = /* @__PURE__ */ new Set([
363
- "TagKeyword",
364
- "DirectiveKeyword",
365
- "ControlKeyword",
366
- "ModifierKeyword",
367
- "SectionMarker",
368
- "Comment",
369
- "Duration",
370
- "DateLiteral"
371
- ]);
372
- function highlightDgmo(source) {
373
- const tree = parser.parse(source);
374
- const tokens = [];
375
- let pos = 0;
376
- const cursor = tree.cursor();
377
- function descend() {
378
- for (; ; ) {
379
- if (cursor.firstChild()) continue;
380
- emitLeaf();
381
- while (!cursor.nextSibling()) {
382
- if (!cursor.parent()) return;
383
- }
384
- }
385
- }
386
- function emitLeaf() {
387
- const from = cursor.from;
388
- const to = cursor.to;
389
- if (from > pos) {
390
- tokens.push({ text: source.slice(pos, from), role: "default" });
391
- }
392
- if (to > from) {
393
- const role = NODE_TO_ROLE[cursor.name] ?? "default";
394
- tokens.push({ text: source.slice(from, to), role });
395
- }
396
- pos = to;
397
- }
398
- descend();
399
- if (pos < source.length) {
400
- tokens.push({ text: source.slice(pos, source.length), role: "default" });
401
- }
402
- applyAttributeKeys(tokens);
403
- applyLabelOverrides(tokens);
404
- applyNoteContent(tokens);
405
- return tokens;
406
- }
407
- var ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
408
- "emotion",
409
- "role",
410
- "icon",
411
- "location",
412
- "email",
413
- "phone",
414
- "type",
415
- "domain",
416
- "assignee",
417
- "due",
418
- "status",
419
- "progress",
420
- "offset",
421
- "confidence",
422
- "width",
423
- "fanout",
424
- "description",
425
- "score",
426
- "pain",
427
- "opportunity",
428
- "thought",
429
- "collapsed",
430
- "tech",
431
- "span",
432
- "split",
433
- // Map (§24B) reserved keys
434
- "value",
435
- "label",
436
- "style"
437
- ]);
438
- function applyAttributeKeys(tokens) {
439
- for (let i = 0; i < tokens.length - 1; i++) {
440
- const t = tokens[i];
441
- if (t.role !== "default") continue;
442
- if (!ATTRIBUTE_KEYS.has(t.text)) continue;
443
- let j = i + 1;
444
- while (j < tokens.length && tokens[j].role === "default" && tokens[j].text.trim() === "") {
445
- j++;
446
- }
447
- if (j < tokens.length && tokens[j].text === ":" && tokens[j].role === "separator") {
448
- t.role = "propertyName";
449
- }
450
- }
451
- }
452
- function applyLabelOverrides(tokens) {
453
- const ROLE_TO_NODES = {};
454
- for (const [node, role] of Object.entries(NODE_TO_ROLE)) {
455
- (ROLE_TO_NODES[role] ??= []).push(node);
456
- }
457
- const lines = [[]];
458
- for (let i = 0; i < tokens.length; i++) {
459
- const t = tokens[i];
460
- const currentLine = lines[lines.length - 1];
461
- const role = t.role;
462
- let nodeName = "";
463
- for (const [node, r] of Object.entries(NODE_TO_ROLE)) {
464
- if (r === role) {
465
- nodeName = node;
466
- break;
467
- }
468
- }
469
- if (role === "operator") {
470
- const text = t.text;
471
- if (text === "->" || text.endsWith("->")) nodeName = "SyncArrow";
472
- else if (text === "~>" || text.endsWith("~>")) nodeName = "AsyncArrow";
473
- else if (text === "-") nodeName = "Dash";
474
- else if (text === "~") nodeName = "Tilde";
475
- else if (text === "*") nodeName = "Star";
476
- else if (text === "?") nodeName = "Question";
477
- } else if (role === "number") {
478
- const text = t.text;
479
- if (/^\d+[smhd]$/i.test(text)) nodeName = "Duration";
480
- else if (/^\d{4}-\d{2}-\d{2}/.test(text)) nodeName = "DateLiteral";
481
- else if (text.endsWith("%")) nodeName = "Percentage";
482
- else nodeName = "Number";
483
- } else if (role === "bracket") {
484
- const text = t.text;
485
- if (text === "[") nodeName = "OpenBracket";
486
- else if (text === "]") nodeName = "CloseBracket";
487
- else if (text === "(") nodeName = "OpenParen";
488
- else if (text === ")") nodeName = "CloseParen";
489
- else if (text === "<") nodeName = "OpenAngle";
490
- else if (text === ">") nodeName = "CloseAngle";
491
- } else if (role === "separator") {
492
- if (t.text === ":") nodeName = "Colon";
493
- else if (t.text === "+") nodeName = "Plus";
494
- } else if (role === "deprecatedSyntax") {
495
- if (t.text === "|") nodeName = "Pipe";
496
- } else if (role === "punctuation") {
497
- if (t.text === ",") nodeName = "Comma";
498
- else nodeName = "Punct";
499
- }
500
- currentLine.push({ idx: i, nodeName });
501
- if (t.text.includes("\n")) {
502
- lines.push([]);
503
- }
504
- }
505
- let seenFirstContent = false;
506
- for (const line of lines) {
507
- const nonWs = line.filter((ref) => tokens[ref.idx].text.trim().length > 0);
508
- if (nonWs.length === 0) continue;
509
- const firstTok = nonWs[0];
510
- if (KEYWORD_STARTS.has(firstTok.nodeName)) continue;
511
- if (firstTok.nodeName === "ChartType" && !seenFirstContent) {
512
- seenFirstContent = true;
513
- continue;
514
- }
515
- seenFirstContent = true;
516
- let firstDashTildeIdx = -1;
517
- let lastArrowIdx = -1;
518
- for (let li = 0; li < nonWs.length; li++) {
519
- const ref = nonWs[li];
520
- if ((ref.nodeName === "Dash" || ref.nodeName === "Tilde") && firstDashTildeIdx < 0) {
521
- firstDashTildeIdx = li;
522
- }
523
- if (ref.nodeName === "SyncArrow" || ref.nodeName === "AsyncArrow") {
524
- lastArrowIdx = li;
525
- }
526
- }
527
- const hasArrow = firstDashTildeIdx >= 0 && lastArrowIdx > firstDashTildeIdx;
528
- if (!hasArrow) continue;
529
- let labelHasIdentifier = false;
530
- for (let li = firstDashTildeIdx + 1; li < lastArrowIdx; li++) {
531
- if (nonWs[li].nodeName === "Identifier") {
532
- labelHasIdentifier = true;
533
- break;
534
- }
535
- }
536
- if (!labelHasIdentifier) continue;
537
- for (let li = firstDashTildeIdx + 1; li < lastArrowIdx; li++) {
538
- const ref = nonWs[li];
539
- if (OVERRIDE_IN_LABEL.has(ref.nodeName)) {
540
- tokens[ref.idx].role = "default";
541
- }
542
- if (ref.nodeName === "ChartType") {
543
- tokens[ref.idx].role = "default";
544
- }
545
- }
546
- }
547
- }
548
- var NOTE_HEAD_RE = /^note(\s|$)/i;
549
- function applyNoteContent(tokens) {
550
- const fullText = tokens.map((t) => t.text).join("");
551
- const lines = fullText.split("\n");
552
- let inNote = false;
553
- let noteIndent = 0;
554
- let charOffset = 0;
555
- for (const lineText of lines) {
556
- const lineStart = charOffset;
557
- const lineEnd = charOffset + lineText.length;
558
- const trimmed = lineText.trimStart();
559
- const indent = lineText.length - trimmed.length;
560
- if (NOTE_HEAD_RE.test(trimmed)) {
561
- inNote = true;
562
- noteIndent = indent;
563
- } else if (inNote) {
564
- if (trimmed.length === 0) {
565
- } else if (indent > noteIndent) {
566
- markTokensInRange(tokens, lineStart, lineEnd, "noteContent");
567
- } else {
568
- inNote = false;
569
- }
570
- }
571
- charOffset = lineEnd + 1;
572
- }
573
- }
574
- function markTokensInRange(tokens, from, to, role) {
575
- let pos = 0;
576
- for (const token of tokens) {
577
- const tokenEnd = pos + token.text.length;
578
- if (tokenEnd > from && pos < to && token.text.trim().length > 0) {
579
- token.role = role;
580
- }
581
- pos = tokenEnd;
582
- }
583
- }
584
- var NORD_ROLE_STYLES = {
585
- keyword: { color: "#81A1C1", fontWeight: "bold" },
586
- // nord9
587
- controlKeyword: { color: "#B48EAD", fontWeight: "bold" },
588
- // nord15
589
- definitionKeyword: { color: "#5E81AC", fontWeight: "bold" },
590
- // nord10
591
- modifier: { color: "#B48EAD" },
592
- // nord15
593
- chartType: { color: "#D08770", fontWeight: "bold" },
594
- // nord12
595
- operator: { color: "#BF616A", fontWeight: "bold" },
596
- // nord11
597
- number: { color: "#B48EAD" },
598
- // nord15
599
- comment: { color: "#616E88", fontStyle: "italic" },
600
- heading: { color: "#D08770", fontWeight: "bold" },
601
- // nord12
602
- bracket: { color: "#5E81AC" },
603
- // nord10
604
- separator: { color: "#88C0D0" },
605
- // nord8
606
- // Red-orange with strikethrough so legacy `|` reads as
607
- // "remove this." Distinct from `operator` which is bold red.
608
- deprecatedSyntax: { color: "#BF616A", textDecoration: "line-through" },
609
- // nord11
610
- url: { color: "#88C0D0", textDecoration: "underline" },
611
- // nord8
612
- colorAnnotation: { color: "#D08770", fontStyle: "italic" },
613
- // nord12
614
- punctuation: { color: "#616E88" },
615
- propertyName: { color: "#88C0D0" },
616
- // nord8
617
- string: { color: "#A3BE8C" },
618
- // nord14
619
- noteContent: { color: "#616E88", fontStyle: "italic" },
620
- default: {}
621
- };
622
- var ROLE_TO_ANSI = {
623
- comment: "\x1B[3;90m",
624
- // italic dim
625
- keyword: "\x1B[1;34m",
626
- // bold blue
627
- controlKeyword: "\x1B[1;35m",
628
- // bold magenta
629
- definitionKeyword: "\x1B[1;34m",
630
- // bold blue
631
- modifier: "\x1B[35m",
632
- // magenta
633
- chartType: "\x1B[1;33m",
634
- // bold yellow
635
- operator: "\x1B[1;31m",
636
- // bold red
637
- number: "\x1B[35m",
638
- // magenta
639
- heading: "\x1B[1;33m",
640
- // bold yellow
641
- bracket: "\x1B[34m",
642
- // blue
643
- separator: "\x1B[36m",
644
- // cyan
645
- deprecatedSyntax: "\x1B[9;31m",
646
- // strikethrough red
647
- url: "\x1B[4;36m",
648
- // underline cyan
649
- colorAnnotation: "\x1B[3;33m",
650
- // italic yellow
651
- punctuation: "\x1B[90m",
652
- // dim
653
- propertyName: "\x1B[36m",
654
- // cyan
655
- string: "\x1B[32m",
656
- // green
657
- noteContent: "\x1B[3;90m"
658
- // italic dim
659
- };
660
- var ANSI_RESET = "\x1B[0m";
661
- function renderAnsi(tokens, useColor) {
662
- if (!useColor) {
663
- return tokens.map((t) => t.text).join("");
664
- }
665
- let out = "";
666
- let inStyled = false;
667
- for (const token of tokens) {
668
- const ansi = ROLE_TO_ANSI[token.role];
669
- if (ansi) {
670
- if (inStyled) out += ANSI_RESET;
671
- out += ansi + token.text;
672
- inStyled = true;
673
- } else {
674
- if (inStyled) {
675
- out += ANSI_RESET;
676
- inStyled = false;
677
- }
678
- out += token.text;
679
- }
680
- }
681
- out += ANSI_RESET;
682
- return out;
683
- }
684
- export {
685
- NORD_ROLE_STYLES,
686
- ROLE_TO_ANSI,
687
- highlightDgmo,
688
- renderAnsi
689
- };
690
- //# sourceMappingURL=highlight.js.map