@diagrammo/dgmo 0.47.0 → 0.48.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 (345) hide show
  1. package/dist/advanced.js +11 -11
  2. package/dist/auto.js +16 -16
  3. package/dist/auto.mjs +41 -12
  4. package/dist/block.js +4 -4
  5. package/dist/{chunk-FNB3PNGF.js → chunk-7DTWEFUE.js} +3 -3
  6. package/dist/{chunk-2DXMZRWJ.js → chunk-B65G5DNL.js} +8 -1
  7. package/dist/{chunk-RZCF2VVM.js → chunk-B7JUCQUA.js} +3 -1
  8. package/dist/{chunk-DU7W62N5.js → chunk-FANX6UJR.js} +3 -3
  9. package/dist/{chunk-6FZYCKXB.js → chunk-HSH73DP6.js} +2 -2
  10. package/dist/{chunk-P4RH4OSP.js → chunk-ILKORZ3H.js} +2 -2
  11. package/dist/{chunk-Y5QGVTVC.js → chunk-JTSMEYIZ.js} +7 -3
  12. package/dist/{chunk-RCERWOJR.js → chunk-ODZVHU3R.js} +1 -2
  13. package/dist/{chunk-DZAQBW35.js → chunk-SGZYXELT.js} +3 -7
  14. package/dist/{chunk-CUVHQHZ7.js → chunk-THXCFRTU.js} +3 -3
  15. package/dist/{chunk-IH6ZMVQ5.js → chunk-UC7TFHUM.js} +29 -11
  16. package/dist/{chunk-EMS2SK26.js → chunk-ZBWMSD5N.js} +3 -1
  17. package/dist/cli.cjs +15 -15
  18. package/dist/{dgmo-router-DZCIDUO5.js → dgmo-router-X35VLZLM.js} +3 -3
  19. package/dist/element.js +16 -16
  20. package/dist/element.mjs +41 -12
  21. package/dist/{flowchart-renderer-ZAEOL4DX.js → flowchart-renderer-SNDSII4D.js} +2 -2
  22. package/dist/index.d.ts +4 -2
  23. package/dist/index.js +4 -4
  24. package/dist/{parser-FUSKFGZN.js → parser-2EWECDSA.js} +2 -2
  25. package/dist/{renderer-UWA5XS74.js → renderer-4JHRUBE6.js} +3 -3
  26. package/dist/{renderer-WZRREQ2P.js → renderer-5MYBMBYO.js} +2 -2
  27. package/dist/{renderer-TOCOVLHS.js → renderer-B2OMQIQG.js} +3 -3
  28. package/dist/{renderer-2XQQQ6QR.js → renderer-N43WR5GV.js} +3 -3
  29. package/dist/{renderer-T7YKC5VP.js → renderer-ZRNG54CW.js} +3 -3
  30. package/dist/{state-renderer-RFYHSP4K.js → state-renderer-B4DQBM6M.js} +2 -2
  31. package/package.json +23 -71
  32. package/dist/advanced.cjs +0 -71648
  33. package/dist/advanced.d.cts +0 -5719
  34. package/dist/auto.cjs +0 -70648
  35. package/dist/auto.d.cts +0 -54
  36. package/dist/block.cjs +0 -70208
  37. package/dist/block.d.cts +0 -115
  38. package/dist/editor.cjs +0 -526
  39. package/dist/editor.d.cts +0 -26
  40. package/dist/element.cjs +0 -70530
  41. package/dist/element.d.cts +0 -62
  42. package/dist/highlight.cjs +0 -852
  43. package/dist/highlight.d.cts +0 -49
  44. package/dist/index.cjs +0 -70491
  45. package/dist/index.d.cts +0 -160
  46. package/dist/pert.cjs +0 -325
  47. package/dist/pert.d.cts +0 -559
  48. package/dist/themes-1-CuKpeH.d.cts +0 -908
  49. package/src/advanced.ts +0 -873
  50. package/src/arc/parser.ts +0 -15
  51. package/src/arc/renderer.ts +0 -633
  52. package/src/auto/index.ts +0 -621
  53. package/src/auto/shared.ts +0 -370
  54. package/src/auto/styles.ts +0 -73
  55. package/src/block/layout.ts +0 -198
  56. package/src/block/parser.ts +0 -427
  57. package/src/block/renderer.ts +0 -484
  58. package/src/block/types.ts +0 -67
  59. package/src/boxes-and-lines/collapse.ts +0 -96
  60. package/src/boxes-and-lines/focus.ts +0 -257
  61. package/src/boxes-and-lines/label-placement.ts +0 -339
  62. package/src/boxes-and-lines/layout-grouped.ts +0 -912
  63. package/src/boxes-and-lines/layout-layered.ts +0 -722
  64. package/src/boxes-and-lines/layout-search.ts +0 -1678
  65. package/src/boxes-and-lines/layout.ts +0 -398
  66. package/src/boxes-and-lines/parser.ts +0 -1181
  67. package/src/boxes-and-lines/renderer.ts +0 -1465
  68. package/src/boxes-and-lines/types.ts +0 -66
  69. package/src/c4/layout.ts +0 -2441
  70. package/src/c4/parser.ts +0 -1158
  71. package/src/c4/renderer.ts +0 -2008
  72. package/src/c4/types.ts +0 -89
  73. package/src/chart-type-registry.ts +0 -529
  74. package/src/chart-types.ts +0 -225
  75. package/src/chart.ts +0 -685
  76. package/src/charts-d3/bar.ts +0 -338
  77. package/src/charts-d3/chord.ts +0 -140
  78. package/src/charts-d3/function.ts +0 -147
  79. package/src/charts-d3/funnel.ts +0 -104
  80. package/src/charts-d3/heatmap.ts +0 -145
  81. package/src/charts-d3/index.ts +0 -337
  82. package/src/charts-d3/interactions.ts +0 -477
  83. package/src/charts-d3/line.ts +0 -344
  84. package/src/charts-d3/mount.ts +0 -151
  85. package/src/charts-d3/pie.ts +0 -117
  86. package/src/charts-d3/polar.ts +0 -89
  87. package/src/charts-d3/radar.ts +0 -0
  88. package/src/charts-d3/sankey.ts +0 -0
  89. package/src/charts-d3/scatter.ts +0 -185
  90. package/src/charts-d3/shared.ts +0 -208
  91. package/src/class/layout.ts +0 -326
  92. package/src/class/parser.ts +0 -635
  93. package/src/class/renderer.ts +0 -793
  94. package/src/class/types.ts +0 -58
  95. package/src/cli-banner.ts +0 -106
  96. package/src/cli.ts +0 -1080
  97. package/src/colors-diagnostics.ts +0 -35
  98. package/src/colors.ts +0 -379
  99. package/src/completion-types.ts +0 -27
  100. package/src/completion.ts +0 -2668
  101. package/src/cycle/layout.ts +0 -1026
  102. package/src/cycle/parser.ts +0 -387
  103. package/src/cycle/renderer.ts +0 -653
  104. package/src/cycle/types.ts +0 -101
  105. package/src/d3.ts +0 -1434
  106. package/src/data-chart-parser.ts +0 -1007
  107. package/src/dgmo-router.ts +0 -296
  108. package/src/diagnostics-registry.ts +0 -108
  109. package/src/diagnostics.ts +0 -0
  110. package/src/dimensions.ts +0 -20
  111. package/src/directives-registry.ts +0 -396
  112. package/src/editor/dgmo.grammar +0 -76
  113. package/src/editor/dgmo.grammar.d.ts +0 -2
  114. package/src/editor/dgmo.grammar.js +0 -18
  115. package/src/editor/dgmo.grammar.terms.d.ts +0 -5
  116. package/src/editor/dgmo.grammar.terms.js +0 -35
  117. package/src/editor/highlight-api.ts +0 -596
  118. package/src/editor/highlight.ts +0 -36
  119. package/src/editor/index.ts +0 -27
  120. package/src/editor/keywords.ts +0 -128
  121. package/src/editor/tokens.ts +0 -30
  122. package/src/element/index.ts +0 -432
  123. package/src/embed/css.ts +0 -312
  124. package/src/embed/escape.ts +0 -15
  125. package/src/embed/index.ts +0 -280
  126. package/src/er/classify.ts +0 -228
  127. package/src/er/layout.ts +0 -530
  128. package/src/er/parser.ts +0 -750
  129. package/src/er/renderer.ts +0 -725
  130. package/src/er/types.ts +0 -52
  131. package/src/error-card.ts +0 -269
  132. package/src/event-line/diagnostics.ts +0 -117
  133. package/src/event-line/parser.ts +0 -643
  134. package/src/event-line/renderer.ts +0 -1742
  135. package/src/event-line/types.ts +0 -74
  136. package/src/fonts.ts +0 -3
  137. package/src/gantt/calculator.ts +0 -979
  138. package/src/gantt/parser.ts +0 -1641
  139. package/src/gantt/renderer.ts +0 -3787
  140. package/src/gantt/resolver.ts +0 -172
  141. package/src/gantt/types.ts +0 -206
  142. package/src/graph/diagnostics.ts +0 -64
  143. package/src/graph/edge-spline.ts +0 -29
  144. package/src/graph/flowchart-parser.ts +0 -759
  145. package/src/graph/flowchart-renderer.ts +0 -817
  146. package/src/graph/layout.ts +0 -472
  147. package/src/graph/notes.ts +0 -21
  148. package/src/graph/state-collapse.ts +0 -78
  149. package/src/graph/state-parser.ts +0 -574
  150. package/src/graph/state-renderer.ts +0 -653
  151. package/src/graph/types.ts +0 -65
  152. package/src/index.ts +0 -261
  153. package/src/infra/compute.ts +0 -1385
  154. package/src/infra/layout.ts +0 -888
  155. package/src/infra/parser.ts +0 -1234
  156. package/src/infra/renderer.ts +0 -2534
  157. package/src/infra/roles.ts +0 -75
  158. package/src/infra/types.ts +0 -216
  159. package/src/infra/validation.ts +0 -201
  160. package/src/journey-map/layout.ts +0 -490
  161. package/src/journey-map/parser.ts +0 -557
  162. package/src/journey-map/renderer.ts +0 -1580
  163. package/src/journey-map/types.ts +0 -47
  164. package/src/kanban/mutations.ts +0 -175
  165. package/src/kanban/parser.ts +0 -509
  166. package/src/kanban/renderer.ts +0 -1449
  167. package/src/kanban/types.ts +0 -39
  168. package/src/label-layout.ts +0 -368
  169. package/src/map/colorize.ts +0 -54
  170. package/src/map/completion.ts +0 -316
  171. package/src/map/context-labels.ts +0 -609
  172. package/src/map/data/PROVENANCE.json +0 -1
  173. package/src/map/data/README.md +0 -40
  174. package/src/map/data/airport-collisions.json +0 -1
  175. package/src/map/data/airports.json +0 -1
  176. package/src/map/data/gazetteer.json +0 -1
  177. package/src/map/data/lakes.json +0 -1
  178. package/src/map/data/mountain-ranges.json +0 -1
  179. package/src/map/data/na-lakes.json +0 -1
  180. package/src/map/data/na-land.json +0 -1
  181. package/src/map/data/region-names.json +0 -1
  182. package/src/map/data/rivers.json +0 -1
  183. package/src/map/data/types.ts +0 -121
  184. package/src/map/data/us-states.json +0 -1
  185. package/src/map/data/water-bodies.json +0 -1
  186. package/src/map/data/world-coarse.json +0 -1
  187. package/src/map/data/world-detail.json +0 -1
  188. package/src/map/diagnostics.ts +0 -134
  189. package/src/map/dimensions.ts +0 -150
  190. package/src/map/geo-query.ts +0 -295
  191. package/src/map/geo.ts +0 -438
  192. package/src/map/invert.ts +0 -111
  193. package/src/map/layout.ts +0 -5069
  194. package/src/map/legend-band.ts +0 -127
  195. package/src/map/load-data.ts +0 -186
  196. package/src/map/parser.ts +0 -783
  197. package/src/map/renderer.ts +0 -1445
  198. package/src/map/resolved-types.ts +0 -160
  199. package/src/map/resolver.ts +0 -1146
  200. package/src/map/types.ts +0 -194
  201. package/src/mindmap/collapse.ts +0 -67
  202. package/src/mindmap/layout.ts +0 -649
  203. package/src/mindmap/parser.ts +0 -430
  204. package/src/mindmap/renderer.ts +0 -637
  205. package/src/mindmap/text-wrap.ts +0 -218
  206. package/src/mindmap/types.ts +0 -56
  207. package/src/org/collapse.ts +0 -151
  208. package/src/org/layout.ts +0 -1262
  209. package/src/org/parser.ts +0 -519
  210. package/src/org/renderer.ts +0 -866
  211. package/src/org/resolver.ts +0 -636
  212. package/src/palettes/atlas.ts +0 -77
  213. package/src/palettes/blueprint.ts +0 -73
  214. package/src/palettes/catppuccin.ts +0 -84
  215. package/src/palettes/color-utils.ts +0 -443
  216. package/src/palettes/index.ts +0 -67
  217. package/src/palettes/nord.ts +0 -67
  218. package/src/palettes/registry.ts +0 -114
  219. package/src/palettes/slate.ts +0 -73
  220. package/src/palettes/tidewater.ts +0 -73
  221. package/src/palettes/tokyo-night.ts +0 -86
  222. package/src/palettes/types.ts +0 -88
  223. package/src/pert/analyzer.ts +0 -1183
  224. package/src/pert/diagnostics.ts +0 -110
  225. package/src/pert/index.ts +0 -43
  226. package/src/pert/internal.ts +0 -252
  227. package/src/pert/layout.ts +0 -971
  228. package/src/pert/monte-carlo.ts +0 -446
  229. package/src/pert/parser.ts +0 -1606
  230. package/src/pert/renderer.ts +0 -4009
  231. package/src/pert/share-normalize.ts +0 -62
  232. package/src/pert/types.ts +0 -604
  233. package/src/pyramid/parser.ts +0 -185
  234. package/src/pyramid/renderer.ts +0 -768
  235. package/src/pyramid/types.ts +0 -28
  236. package/src/quadrant/parser.ts +0 -18
  237. package/src/quadrant/renderer.ts +0 -638
  238. package/src/raci/diagnostics.ts +0 -213
  239. package/src/raci/index.ts +0 -23
  240. package/src/raci/mutations.ts +0 -321
  241. package/src/raci/parser.ts +0 -699
  242. package/src/raci/renderer.ts +0 -1627
  243. package/src/raci/types.ts +0 -82
  244. package/src/raci/variants.ts +0 -320
  245. package/src/render.ts +0 -268
  246. package/src/ring/parser.ts +0 -212
  247. package/src/ring/renderer.ts +0 -490
  248. package/src/ring/types.ts +0 -27
  249. package/src/sequence/collapse.ts +0 -174
  250. package/src/sequence/parser.ts +0 -1596
  251. package/src/sequence/participant-inference.ts +0 -152
  252. package/src/sequence/renderer.ts +0 -3168
  253. package/src/sequence/tag-resolution.ts +0 -164
  254. package/src/sharing.ts +0 -211
  255. package/src/sitemap/collapse.ts +0 -100
  256. package/src/sitemap/layout.ts +0 -925
  257. package/src/sitemap/parser.ts +0 -755
  258. package/src/sitemap/renderer.ts +0 -828
  259. package/src/sitemap/types.ts +0 -42
  260. package/src/slope/parser.ts +0 -18
  261. package/src/slope/renderer.ts +0 -378
  262. package/src/swimlane/diagnostics.ts +0 -94
  263. package/src/swimlane/layout.ts +0 -597
  264. package/src/swimlane/parser.ts +0 -613
  265. package/src/swimlane/renderer.ts +0 -681
  266. package/src/swimlane/types.ts +0 -151
  267. package/src/tech-radar/interactive.ts +0 -1129
  268. package/src/tech-radar/layout.ts +0 -197
  269. package/src/tech-radar/parser.ts +0 -436
  270. package/src/tech-radar/renderer.ts +0 -1239
  271. package/src/tech-radar/shared.ts +0 -151
  272. package/src/tech-radar/types.ts +0 -86
  273. package/src/themes.ts +0 -22
  274. package/src/timeline/parser.ts +0 -472
  275. package/src/timeline/renderer.ts +0 -3024
  276. package/src/timeline/types.ts +0 -33
  277. package/src/timeline/viz-parser.ts +0 -21
  278. package/src/treemap/diagnostics.ts +0 -62
  279. package/src/treemap/layout-radial.ts +0 -233
  280. package/src/treemap/layout.ts +0 -189
  281. package/src/treemap/parser.ts +0 -463
  282. package/src/treemap/renderer-radial.ts +0 -438
  283. package/src/treemap/renderer.ts +0 -572
  284. package/src/treemap/treemap-shared.ts +0 -309
  285. package/src/treemap/types.ts +0 -60
  286. package/src/utils/arrow-markers.ts +0 -51
  287. package/src/utils/arrows-diagnostics.ts +0 -62
  288. package/src/utils/arrows.ts +0 -227
  289. package/src/utils/brand.ts +0 -61
  290. package/src/utils/card.ts +0 -183
  291. package/src/utils/collapse-engine/tree-edges.ts +0 -115
  292. package/src/utils/collapse-engine/tree.ts +0 -117
  293. package/src/utils/d3-helpers.ts +0 -219
  294. package/src/utils/d3-types.ts +0 -9
  295. package/src/utils/description-helpers.ts +0 -38
  296. package/src/utils/duration.ts +0 -312
  297. package/src/utils/export-container.ts +0 -41
  298. package/src/utils/expr-eval.ts +0 -27
  299. package/src/utils/fit-canvas.ts +0 -64
  300. package/src/utils/hover-styles.ts +0 -673
  301. package/src/utils/inline-markdown.ts +0 -96
  302. package/src/utils/legend-constants.ts +0 -48
  303. package/src/utils/legend-d3.ts +0 -618
  304. package/src/utils/legend-integration.ts +0 -107
  305. package/src/utils/legend-layout.ts +0 -776
  306. package/src/utils/legend-svg.ts +0 -214
  307. package/src/utils/legend-types.ts +0 -272
  308. package/src/utils/name-normalize.ts +0 -163
  309. package/src/utils/note-box/constants.ts +0 -25
  310. package/src/utils/note-box/index.ts +0 -11
  311. package/src/utils/note-box/metrics.ts +0 -90
  312. package/src/utils/note-box/svg.ts +0 -331
  313. package/src/utils/notes/bounds.ts +0 -30
  314. package/src/utils/notes/build.ts +0 -131
  315. package/src/utils/notes/index.ts +0 -18
  316. package/src/utils/notes/model.ts +0 -19
  317. package/src/utils/notes/parse.ts +0 -131
  318. package/src/utils/notes/place.ts +0 -177
  319. package/src/utils/notes/resolve.ts +0 -88
  320. package/src/utils/number-format.ts +0 -36
  321. package/src/utils/parsing.ts +0 -953
  322. package/src/utils/reserved-key-registry.ts +0 -239
  323. package/src/utils/safe-href.ts +0 -38
  324. package/src/utils/scaling.ts +0 -97
  325. package/src/utils/svg-embed.ts +0 -251
  326. package/src/utils/tag-groups.ts +0 -607
  327. package/src/utils/text-measure.ts +0 -122
  328. package/src/utils/time-ticks.ts +0 -253
  329. package/src/utils/title-constants.ts +0 -24
  330. package/src/utils/visual-conventions.ts +0 -61
  331. package/src/utils/wrapped-desc.ts +0 -87
  332. package/src/venn/parser.ts +0 -18
  333. package/src/venn/renderer.ts +0 -1047
  334. package/src/version-control/diagnostics.ts +0 -67
  335. package/src/version-control/parser.ts +0 -544
  336. package/src/version-control/renderer.ts +0 -724
  337. package/src/version-control/types.ts +0 -100
  338. package/src/visualizations/parse.ts +0 -1560
  339. package/src/visualizations/types.ts +0 -262
  340. package/src/wireframe/layout.ts +0 -479
  341. package/src/wireframe/parser.ts +0 -1114
  342. package/src/wireframe/renderer.ts +0 -1318
  343. package/src/wireframe/types.ts +0 -110
  344. package/src/wordcloud/parser.ts +0 -18
  345. package/src/wordcloud/renderer.ts +0 -357
@@ -1,643 +0,0 @@
1
- // ============================================================
2
- // Event Line — Parser (spec §28)
3
- // ============================================================
4
- //
5
- // Consistency-locked syntax (decision #16) — every token reuses an idiom:
6
- // - event + date = timeline §15 line-prefix (`2012-02-05 XLVI`), date optional
7
- // - tag = trailing same-line metadata (`… XLVI g: Pop`)
8
- // - description = pyramid/ring bare indented body (`- ` bullets + markdown)
9
- // - directives = `no-scale` / `no-box` / `side above|below`
10
- //
11
- // Structure mirrors treemap's header/tag-block/content phases and pyramid's
12
- // bare-body description collection.
13
-
14
- import type { PaletteColors } from '../palettes';
15
- import {
16
- emit,
17
- formatDgmoError,
18
- makeDgmoError,
19
- makeFail,
20
- suggest,
21
- } from '../diagnostics';
22
- import type { DgmoError } from '../diagnostics';
23
- import { EVENT_LINE_DX } from './diagnostics';
24
- import type { Writable } from '../utils/brand';
25
- import type { TagGroup } from '../utils/tag-groups';
26
- import {
27
- matchTagBlockHeading,
28
- validateTagValues,
29
- validateTagGroupNames,
30
- stripDefaultModifier,
31
- finalizeAutoTagColors,
32
- injectDefaultTagMetadata,
33
- AUTO_TAG_COLOR_SENTINEL,
34
- tagAttrKey,
35
- } from '../utils/tag-groups';
36
- import {
37
- measureIndent,
38
- extractColor,
39
- parseFirstLine,
40
- splitNameAndMeta,
41
- tryParseSharedOption,
42
- warnUnknownMetaKeys,
43
- } from '../utils/parsing';
44
- import {
45
- EVENT_LINE_REGISTRY,
46
- withTagAliases,
47
- } from '../utils/reserved-key-registry';
48
- import { extractDatePrefix, parseTimelineDate } from '../timeline/parser';
49
- import type {
50
- EventLineEra,
51
- EventLineEvent,
52
- EventLineOptions,
53
- ParsedEventLine,
54
- } from './types';
55
-
56
- /** A non-ISO date attempt: leading digits with a slash or dot separator. */
57
- const NON_ISO_DATE_RE = /^\d{1,4}[/.]\d/;
58
- /** `TBD` date line-prefix (case-insensitive) — a future, unscheduled event. */
59
- const TBD_RE = /^TBD\b/i;
60
- /** `side above` / `side below` / `side alternate` — card placement. */
61
- const SIDE_RE = /^side\s+(above|below|alternate)\b/i;
62
- /** Era run delimiter `[Name]` (§28.6a) with optional trailing `collapsed`/color. */
63
- const ERA_RE = /^\[([^\]]+)\]\s*(.*)$/;
64
- /** `collapsed: true|false` inside an era's trailing metadata. */
65
- const ERA_COLLAPSED_RE = /\bcollapsed:\s*(true|false)\b/i;
66
- /** Legacy `section <Name>` — superseded by `[Name]`; emits a guiding warning. */
67
- const SECTION_SEAM_RE = /^section\b/i;
68
- /** `direction <X>` — only LR (horizontal) is supported; TB/BT are fast-follow. */
69
- const DIRECTION_RE = /^direction\s+(\w+)/i;
70
-
71
- export function parseEventLine(
72
- content: string,
73
- palette?: PaletteColors
74
- ): ParsedEventLine {
75
- const options: Writable<EventLineOptions> = {
76
- scale: true,
77
- side: 'alternate',
78
- noTitle: false,
79
- noBox: false,
80
- noLegend: false,
81
- };
82
- const result: Writable<ParsedEventLine> = {
83
- type: 'event-line',
84
- title: null,
85
- titleLineNumber: null,
86
- events: [],
87
- eras: [],
88
- tagGroups: [],
89
- options,
90
- diagnostics: [],
91
- error: null,
92
- };
93
-
94
- const fail = makeFail(result);
95
- const pushWarning = (line: number, message: string, code?: string): void => {
96
- result.diagnostics.push(makeDgmoError(line, message, 'warning', code));
97
- };
98
- const pushError = (line: number, message: string, code?: string): void => {
99
- const diag = makeDgmoError(line, message, 'error', code);
100
- result.diagnostics.push(diag);
101
- if (!result.error) result.error = formatDgmoError(diag);
102
- };
103
-
104
- if (!content?.trim()) return fail(0, 'No content provided');
105
-
106
- const lines = content.split('\n');
107
- let contentStarted = false;
108
- let headerParsed = false;
109
- const sharedOptions: Record<string, string> = {};
110
-
111
- let currentTagGroup: Writable<TagGroup> | null = null;
112
- let currentEvent: Writable<EventLineEvent> | null = null;
113
- let currentEra: string | null = null;
114
- // Indent of the open era's `[Name]` bracket; events must be indented deeper
115
- // to belong to it. -1 ⇒ no era open (an indent-0 event is then era-less).
116
- let eraIndent = -1;
117
- // Indent of the current event; a line indented deeper is its description.
118
- let currentEventIndent = 0;
119
- const aliasMap = new Map<string, string>();
120
-
121
- for (let i = 0; i < lines.length; i++) {
122
- const line = lines[i]!;
123
- const lineNumber = i + 1;
124
- const trimmed = line.trim();
125
-
126
- if (!trimmed) {
127
- currentTagGroup = null;
128
- continue;
129
- }
130
- if (trimmed.startsWith('//')) continue;
131
-
132
- const indent = measureIndent(line);
133
-
134
- // ── First line: `event-line [Title]` ──
135
- if (!headerParsed) {
136
- const firstLine = parseFirstLine(trimmed);
137
- if (firstLine?.chartType === 'event-line') {
138
- result.title = firstLine.title ?? null;
139
- result.titleLineNumber = lineNumber;
140
- headerParsed = true;
141
- continue;
142
- }
143
- let msg = 'Expected "event-line [Title]" as the first line.';
144
- const hint = suggest(firstLine?.chartType ?? trimmed, ['event-line']);
145
- if (hint) msg += ` ${hint}`;
146
- return fail(lineNumber, msg);
147
- }
148
-
149
- // ── Tag group heading: `tag Genre as g` (before content) ──
150
- const tagBlockMatch = matchTagBlockHeading(trimmed);
151
- if (tagBlockMatch) {
152
- if (contentStarted) {
153
- pushError(
154
- lineNumber,
155
- 'Tag groups must appear before event-line content',
156
- 'E_TAG_DECLARED_AFTER_CONTENT'
157
- );
158
- continue;
159
- }
160
- currentTagGroup = {
161
- name: tagBlockMatch.name,
162
- ...(tagBlockMatch.alias !== undefined && {
163
- alias: tagBlockMatch.alias,
164
- }),
165
- entries: [],
166
- lineNumber,
167
- };
168
- if (tagBlockMatch.alias) {
169
- aliasMap.set(
170
- tagBlockMatch.alias.toLowerCase(),
171
- tagAttrKey(tagBlockMatch.name)
172
- );
173
- }
174
- aliasMap.set(
175
- tagAttrKey(tagBlockMatch.name),
176
- tagAttrKey(tagBlockMatch.name)
177
- );
178
- result.tagGroups.push(currentTagGroup);
179
- continue;
180
- }
181
-
182
- // ── Tag entries (indented `Value color` under a heading) ──
183
- if (currentTagGroup && !contentStarted && indent > 0) {
184
- const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
185
- const { label, color } = extractColor(
186
- cleanEntry,
187
- palette,
188
- result.diagnostics,
189
- lineNumber
190
- );
191
- if (isDefault || currentTagGroup.entries.length === 0) {
192
- currentTagGroup.defaultValue = label;
193
- }
194
- currentTagGroup.entries.push({
195
- value: label,
196
- color: color ?? AUTO_TAG_COLOR_SENTINEL,
197
- lineNumber,
198
- });
199
- continue;
200
- }
201
-
202
- // ── Content phase: indentation classifies each line. ──
203
- //
204
- // Eras are top-level `[Name]` section headers whose member events are
205
- // INDENTED beneath them (the org §7 / version-control §29 idiom); an event
206
- // at indent 0 sits OUTSIDE any era. A line indented deeper than its event
207
- // is that event's description body (§28.4).
208
-
209
- // Description body — any line indented deeper than its event. Checked
210
- // before the era bracket so a bracketed prose line (` [aside]`) under an
211
- // event stays a description rather than opening a spurious era.
212
- if (currentEvent && indent > currentEventIndent) {
213
- const descLine = trimmed.startsWith('- ')
214
- ? `• ${trimmed.substring(2)}`
215
- : trimmed;
216
- currentEvent.description.push(descLine);
217
- continue;
218
- }
219
-
220
- // ── Era run delimiter: `[Name]` (§28.6a) — a section header whose member
221
- // events are indented beneath it. Dedenting to (or past) the bracket's
222
- // own indent leaves the era. Optional trailing `collapsed: true` and/or
223
- // a color name tint/fold the era.
224
- const eraMatch = trimmed.match(ERA_RE);
225
- if (eraMatch) {
226
- contentStarted = true;
227
- currentTagGroup = null;
228
- currentEvent = null;
229
- const name = eraMatch[1]!.trim();
230
- let rest = (eraMatch[2] ?? '').trim();
231
- let collapsed = false;
232
- const cm = rest.match(ERA_COLLAPSED_RE);
233
- if (cm) {
234
- collapsed = cm[1]!.toLowerCase() === 'true';
235
- rest = (
236
- rest.slice(0, cm.index) + rest.slice(cm.index! + cm[0].length)
237
- ).trim();
238
- }
239
- let color: string | null = null;
240
- if (rest) {
241
- // A lone trailing color token tints the era (named colors only; a hex
242
- // value is flagged by extractColor and left uncolored). Prefix a
243
- // placeholder so extractColor's trailing-token rule sees it.
244
- const token = rest.split(/\s+/).pop()!;
245
- const ex = extractColor(
246
- `x ${token}`,
247
- palette,
248
- result.diagnostics,
249
- lineNumber
250
- );
251
- if (ex.color !== undefined) color = token;
252
- }
253
- const era: EventLineEra = { name, color, collapsed, lineNumber };
254
- result.eras.push(era);
255
- currentEra = name;
256
- eraIndent = indent;
257
- continue;
258
- }
259
-
260
- // ── Top-level (indent 0) directives and reserved seams. ──
261
- if (indent === 0) {
262
- currentTagGroup = null;
263
- if (trimmed.toLowerCase() === 'no-scale') {
264
- options.scale = false;
265
- continue;
266
- }
267
- const sideMatch = trimmed.match(SIDE_RE);
268
- if (sideMatch) {
269
- options.side = sideMatch[1]!.toLowerCase() as EventLineOptions['side'];
270
- continue;
271
- }
272
- if (trimmed.toLowerCase() === 'no-box') {
273
- options.noBox = true;
274
- continue;
275
- }
276
- if (trimmed.toLowerCase() === 'no-legend') {
277
- options.noLegend = true;
278
- continue;
279
- }
280
- const dirMatch = trimmed.match(DIRECTION_RE);
281
- if (dirMatch) {
282
- const dir = dirMatch[1]!.toUpperCase();
283
- if (dir !== 'LR') {
284
- result.diagnostics.push(
285
- emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
286
- reason: `event-line is horizontal-only in v1; \`direction ${dir}\` (vertical orientation) is a fast-follow.`,
287
- })
288
- );
289
- }
290
- continue;
291
- }
292
- if (tryParseSharedOption(trimmed, sharedOptions)) continue;
293
- if (SECTION_SEAM_RE.test(trimmed)) {
294
- result.diagnostics.push(
295
- emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
296
- reason:
297
- 'Group events with `[Name]` era brackets (§28.6a), not `section`.',
298
- })
299
- );
300
- continue;
301
- }
302
- }
303
-
304
- // ── Event line ──
305
- // An event belongs to the open era only when indented beneath that era's
306
- // bracket; an indent-0 event sits outside any era and closes the run
307
- // (events outside eras are fully supported — they simply have `era: null`).
308
- const inEra = currentEra !== null && indent > eraIndent;
309
- if (!inEra) currentEra = null;
310
- contentStarted = true;
311
- const event = parseEventHeader(
312
- trimmed,
313
- lineNumber,
314
- currentEra,
315
- aliasMap,
316
- result.diagnostics,
317
- pushWarning
318
- );
319
- result.events.push(event);
320
- currentEvent = event;
321
- currentEventIndent = indent;
322
- }
323
-
324
- options.noTitle = sharedOptions['no-title'] === 'on';
325
-
326
- resolveFutureEvents(result.events as Writable<EventLineEvent>[]);
327
-
328
- // Finalize tag colors + validate (flat topology → no cascade).
329
- finalizeAutoTagColors(result.tagGroups as Writable<TagGroup>[], palette);
330
- if (result.tagGroups.length > 0) {
331
- validateTagValues(result.events, result.tagGroups, pushWarning, suggest);
332
- validateTagGroupNames(result.tagGroups, pushWarning);
333
- // A tag group's first value is its implicit default (§28.5): an event with
334
- // no explicit value belongs to it. Materialize that into metadata — like
335
- // org/boxes-and-lines/pert — so color AND legend focus treat the default as
336
- // a real category (e.g. hovering "Scope" lights every untagged event).
337
- injectDefaultTagMetadata(result.events, result.tagGroups);
338
- }
339
-
340
- if (result.events.length === 0 && !result.error) {
341
- const diag = emit(EVENT_LINE_DX.NO_EVENTS, result.titleLineNumber ?? 1);
342
- result.diagnostics.push(diag);
343
- result.error = formatDgmoError(diag);
344
- }
345
-
346
- // Eras render as date-spanning brackets, so an event dated outside its era's
347
- // chronological position makes adjacent era brackets overlap (§28.6a). Only
348
- // meaningful when the date scale drives x-position.
349
- const eraFlaggedLines = new Set<number>();
350
- if (options.scale) {
351
- validateEraDateOrder(result.events, result.eras, (err) => {
352
- eraFlaggedLines.add(err.line);
353
- result.diagnostics.push(err);
354
- });
355
- }
356
-
357
- // Any dated event listed before an earlier-dated one is out of chronological
358
- // order — a likely authoring slip (and, to-scale, it plots to the left of an
359
- // event listed above it). Era-spanning inversions already get the richer
360
- // ERA_DATE_ORDER message, so skip lines that check already flagged.
361
- validateEventDateOrder(result.events, eraFlaggedLines, result.diagnostics);
362
-
363
- return result;
364
- }
365
-
366
- /**
367
- * Infer a position for every FUTURE (`TBD`) event from its source-order DATED
368
- * neighbors, so the to-scale axis can place it even though it has no authored
369
- * date. A TBD between two dated events is INTERPOLATED into that gap (a tentative
370
- * "somewhere in here" point, with `futureSpan` carrying the gap for the whisker
371
- * cue); a TBD after the last dated event is parked just past it (the open
372
- * horizon, `futureSpan = null` → dashed spine tail); a TBD before the first
373
- * dated event lands in a lead-in pad. Multiple TBDs sharing one gap fan evenly
374
- * across it in source order. With no dated events at all, TBDs keep `dateValue`
375
- * null and ride along under even spacing.
376
- */
377
- function resolveFutureEvents(events: Writable<EventLineEvent>[]): void {
378
- const realVals = events
379
- .filter((e) => !e.future && e.dateValue !== null)
380
- .map((e) => e.dateValue!);
381
- if (realVals.length === 0) return;
382
-
383
- const hiAll = Math.max(...realVals);
384
- const loAll = Math.min(...realVals);
385
- const pad = hiAll > loAll ? (hiAll - loAll) * 0.15 : 1;
386
-
387
- // Nearest dated value before / after each event, in source order.
388
- const prevReal: (number | null)[] = [];
389
- let carry: number | null = null;
390
- for (const e of events) {
391
- prevReal.push(carry);
392
- if (!e.future && e.dateValue !== null) carry = e.dateValue;
393
- }
394
- const nextReal: (number | null)[] = new Array(events.length).fill(null);
395
- carry = null;
396
- for (let i = events.length - 1; i >= 0; i--) {
397
- nextReal[i] = carry;
398
- const e = events[i]!;
399
- if (!e.future && e.dateValue !== null) carry = e.dateValue;
400
- }
401
-
402
- // Group consecutive futures sharing the same (prev, next) bounds; fan evenly.
403
- let i = 0;
404
- while (i < events.length) {
405
- if (!events[i]!.future) {
406
- i++;
407
- continue;
408
- }
409
- const lo = prevReal[i]!;
410
- const hi = nextReal[i]!;
411
- let j = i;
412
- while (
413
- j < events.length &&
414
- events[j]!.future &&
415
- prevReal[j] === lo &&
416
- nextReal[j] === hi
417
- )
418
- j++;
419
- const group = events.slice(i, j);
420
- const g = group.length;
421
- if (lo !== null && hi !== null) {
422
- group.forEach((e, k) => {
423
- e.dateValue = lo + ((hi - lo) * (k + 1)) / (g + 1);
424
- e.futureSpan = [lo, hi];
425
- });
426
- } else if (lo === null && hi !== null) {
427
- const left = hi - pad;
428
- group.forEach((e, k) => {
429
- e.dateValue = left + ((hi - left) * (k + 1)) / (g + 1);
430
- e.futureSpan = [left, hi];
431
- });
432
- } else {
433
- // Trailing: park past the last dated event — the open horizon — evenly
434
- // spaced by `pad`, so a row of TBDs reads as a uniform march into the
435
- // future (the first sits `pad` past the last real date, each next `pad` on).
436
- group.forEach((e, k) => {
437
- e.dateValue = hiAll + pad * (k + 1);
438
- e.futureSpan = null;
439
- });
440
- }
441
- i = j;
442
- }
443
- }
444
-
445
- /**
446
- * Warn when dated events are listed out of chronological order — a later-listed
447
- * event dated before the dated event just above it. event-line reads
448
- * left-to-right by date, so a descending pair is almost always an authoring
449
- * slip. Undated events are skipped; coincident dates are in order.
450
- */
451
- function validateEventDateOrder(
452
- events: readonly EventLineEvent[],
453
- skipLines: ReadonlySet<number>,
454
- diagnostics: DgmoError[]
455
- ): void {
456
- let prev: EventLineEvent | null = null;
457
- for (const ev of events) {
458
- // Future (TBD) events carry an inferred dateValue, not an authored one —
459
- // never flag them (or use them as the reference) for chronological order.
460
- if (ev.future || ev.dateValue === null) continue;
461
- if (
462
- prev &&
463
- ev.dateValue < prev.dateValue! &&
464
- !skipLines.has(ev.lineNumber)
465
- ) {
466
- diagnostics.push(
467
- emit(EVENT_LINE_DX.DATE_ORDER, ev.lineNumber, {
468
- label: ev.label,
469
- date: ev.date,
470
- prevLabel: prev.label,
471
- prevDate: prev.date,
472
- })
473
- );
474
- }
475
- prev = ev;
476
- }
477
- }
478
-
479
- /**
480
- * Warn when a dated event sits in an era whose chronological run it breaks —
481
- * i.e. it is dated after a later era begins, or before an earlier era ends.
482
- * Eras are left-to-right date bands; a straggler makes their brackets overlap.
483
- */
484
- function validateEraDateOrder(
485
- events: readonly EventLineEvent[],
486
- eras: readonly EventLineEra[],
487
- emitWarn: (err: DgmoError) => void
488
- ): void {
489
- if (eras.length < 2) return;
490
- const order = new Map(eras.map((e, i) => [e.name, i]));
491
- const dated = events.filter(
492
- (e) =>
493
- !e.future && e.dateValue !== null && e.era !== null && order.has(e.era)
494
- );
495
- if (dated.length === 0) return;
496
-
497
- // Earliest and latest dated event per era index.
498
- const perEra = new Map<
499
- number,
500
- { min: EventLineEvent; max: EventLineEvent }
501
- >();
502
- for (const ev of dated) {
503
- const idx = order.get(ev.era!)!;
504
- const cur = perEra.get(idx);
505
- if (!cur) {
506
- perEra.set(idx, { min: ev, max: ev });
507
- } else {
508
- if (ev.dateValue! < cur.min.dateValue!) cur.min = ev;
509
- if (ev.dateValue! > cur.max.dateValue!) cur.max = ev;
510
- }
511
- }
512
-
513
- const n = eras.length;
514
- // prefixMax[k] = the latest-dated event across eras with index < k.
515
- // suffixMin[k] = the earliest-dated event across eras with index > k.
516
- const prefixMax: (EventLineEvent | null)[] = new Array(n).fill(null);
517
- const suffixMin: (EventLineEvent | null)[] = new Array(n).fill(null);
518
- for (let k = 1; k < n; k++) {
519
- const prev = perEra.get(k - 1)?.max ?? null;
520
- const carried = prefixMax[k - 1] ?? null;
521
- prefixMax[k] =
522
- prev && (!carried || prev.dateValue! > carried.dateValue!)
523
- ? prev
524
- : carried;
525
- }
526
- for (let k = n - 2; k >= 0; k--) {
527
- const next = perEra.get(k + 1)?.min ?? null;
528
- const carried = suffixMin[k + 1] ?? null;
529
- suffixMin[k] =
530
- next && (!carried || next.dateValue! < carried.dateValue!)
531
- ? next
532
- : carried;
533
- }
534
-
535
- for (const ev of dated) {
536
- const k = order.get(ev.era!)!;
537
- const ahead = suffixMin[k];
538
- const behind = prefixMax[k];
539
- if (ahead && ev.dateValue! > ahead.dateValue!) {
540
- emitWarn(
541
- emit(EVENT_LINE_DX.ERA_DATE_ORDER, ev.lineNumber, {
542
- label: ev.label,
543
- date: ev.date,
544
- era: ev.era,
545
- rel: 'after',
546
- otherEra: ahead.era,
547
- edge: 'begins',
548
- otherDate: ahead.date,
549
- })
550
- );
551
- } else if (behind && ev.dateValue! < behind.dateValue!) {
552
- emitWarn(
553
- emit(EVENT_LINE_DX.ERA_DATE_ORDER, ev.lineNumber, {
554
- label: ev.label,
555
- date: ev.date,
556
- era: ev.era,
557
- rel: 'before',
558
- otherEra: behind.era,
559
- edge: 'ends',
560
- otherDate: behind.date,
561
- })
562
- );
563
- }
564
- }
565
- }
566
-
567
- function parseEventHeader(
568
- trimmed: string,
569
- lineNumber: number,
570
- era: string | null,
571
- aliasMap: Map<string, string>,
572
- diagnostics: DgmoError[],
573
- pushWarning: (line: number, message: string, code?: string) => void
574
- ): Writable<EventLineEvent> {
575
- // Peel an optional ISO date line-prefix (timeline §15 idiom).
576
- let date: string | null = null;
577
- let dateValue: number | null = null;
578
- let future = false;
579
- let remainder = trimmed;
580
-
581
- // `TBD` line-prefix = a FUTURE, not-yet-scheduled event. Captioned verbatim;
582
- // its numeric position is resolved after parsing (just past the latest event).
583
- const tbdMatch = trimmed.match(TBD_RE);
584
- if (tbdMatch) {
585
- date = 'TBD';
586
- future = true;
587
- remainder = trimmed.slice(tbdMatch[0].length).trimStart();
588
- }
589
-
590
- const prefix = future ? null : extractDatePrefix(trimmed);
591
- if (prefix) {
592
- date = prefix.startDate;
593
- dateValue = parseTimelineDate(prefix.startDate);
594
- remainder = prefix.remainder || '';
595
- if (prefix.endDate) {
596
- diagnostics.push(
597
- emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
598
- reason:
599
- 'event-line events are points; a date range (`->`) is not supported — using the start date.',
600
- })
601
- );
602
- }
603
- } else if (!future && NON_ISO_DATE_RE.test(trimmed)) {
604
- const firstToken = trimmed.split(/\s+/)[0]!;
605
- diagnostics.push(
606
- emit(EVENT_LINE_DX.BAD_DATE, lineNumber, { token: firstToken })
607
- );
608
- }
609
-
610
- const registry = withTagAliases(
611
- EVENT_LINE_REGISTRY,
612
- new Set(aliasMap.keys())
613
- );
614
- const split = splitNameAndMeta(
615
- remainder,
616
- registry,
617
- aliasMap,
618
- undefined,
619
- diagnostics,
620
- lineNumber
621
- );
622
- warnUnknownMetaKeys(
623
- split.meta,
624
- registry,
625
- (msg) => pushWarning(lineNumber, msg),
626
- split.name
627
- );
628
-
629
- const metadata: Record<string, string> = { ...split.meta };
630
- if (split.color !== undefined) metadata['color'] = split.color;
631
-
632
- return {
633
- label: split.name || remainder.trim(),
634
- lineNumber,
635
- date,
636
- dateValue,
637
- future,
638
- futureSpan: null,
639
- metadata,
640
- description: [],
641
- era,
642
- };
643
- }