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