@diagrammo/dgmo 0.46.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (534) hide show
  1. package/dist/advanced.d.ts +3 -855
  2. package/dist/advanced.js +541 -70107
  3. package/dist/analyzer-UYKBXAKR.js +15 -0
  4. package/dist/auto.js +1 -1
  5. package/dist/auto.mjs +1 -1
  6. package/dist/block.js +83 -69417
  7. package/dist/calculator-LDYQCDDY.js +11 -0
  8. package/dist/charts-d3-QOZHKTCT.js +25 -0
  9. package/dist/chunk-2DXMZRWJ.js +800 -0
  10. package/dist/chunk-2LACINWN.js +786 -0
  11. package/dist/chunk-33LCUH4H.js +893 -0
  12. package/dist/chunk-3CIOJ5YJ.js +35 -0
  13. package/dist/chunk-3HDBAXF5.js +86 -0
  14. package/dist/chunk-3JLKYGBQ.js +290 -0
  15. package/dist/chunk-3MQQNXPD.js +415 -0
  16. package/dist/chunk-3R5POCTZ.js +967 -0
  17. package/dist/chunk-3SMGIJDD.js +112 -0
  18. package/dist/chunk-44CM72SQ.js +409 -0
  19. package/dist/chunk-4GRI7MEB.js +1604 -0
  20. package/dist/chunk-4OHACBGX.js +606 -0
  21. package/dist/chunk-5DH3KYFH.js +21 -0
  22. package/dist/chunk-5MLYVTYM.js +76 -0
  23. package/dist/chunk-5QXL4NYS.js +553 -0
  24. package/dist/chunk-5WRI5ZAA.js +31 -0
  25. package/dist/chunk-6EK55ART.js +117 -0
  26. package/dist/chunk-6FZYCKXB.js +2065 -0
  27. package/dist/chunk-6HO5ZTXK.js +277 -0
  28. package/dist/chunk-6KFWC4CO.js +7 -0
  29. package/dist/chunk-6MTWIQVO.js +121 -0
  30. package/dist/chunk-6NYWYNBI.js +329 -0
  31. package/dist/chunk-6SM5NJQH.js +620 -0
  32. package/dist/chunk-725LDASD.js +422 -0
  33. package/dist/chunk-76OWZ3BA.js +130 -0
  34. package/{src/block/parser.ts → dist/chunk-7JEGTRLD.js} +100 -189
  35. package/dist/chunk-A44USUV7.js +923 -0
  36. package/dist/chunk-A4GOY3PE.js +25 -0
  37. package/dist/chunk-A4VFQH5G.js +251 -0
  38. package/dist/chunk-AELOBFW5.js +375 -0
  39. package/dist/chunk-AN2MOO5T.js +522 -0
  40. package/dist/chunk-BMR4CIEO.js +41 -0
  41. package/dist/chunk-BS7SV7C3.js +51 -0
  42. package/dist/chunk-BUPDIHML.js +613 -0
  43. package/dist/chunk-BUVJFRPY.js +887 -0
  44. package/dist/chunk-C3Z4DX3V.js +112 -0
  45. package/dist/chunk-CI2G3OEB.js +1818 -0
  46. package/dist/chunk-CKNVO24D.js +54 -0
  47. package/dist/chunk-CUVHQHZ7.js +391 -0
  48. package/dist/chunk-CXK4DZH3.js +114 -0
  49. package/dist/{editor.cjs → chunk-DKEPS5LH.js} +14 -225
  50. package/dist/chunk-DU7W62N5.js +487 -0
  51. package/dist/chunk-DZAQBW35.js +751 -0
  52. package/dist/chunk-EB6FPQUP.js +316 -0
  53. package/dist/chunk-EMS2SK26.js +376 -0
  54. package/dist/chunk-ERLBPDGU.js +510 -0
  55. package/dist/chunk-EVCVDTXE.js +732 -0
  56. package/dist/chunk-FCIIHT24.js +384 -0
  57. package/dist/chunk-FFUN5D66.js +97 -0
  58. package/dist/chunk-FITOLXSX.js +714 -0
  59. package/dist/chunk-FMDSF3OV.js +68 -0
  60. package/dist/chunk-FNB3PNGF.js +410 -0
  61. package/dist/chunk-G2H74XJZ.js +2104 -0
  62. package/dist/chunk-GMR5MFHJ.js +339 -0
  63. package/dist/chunk-H6PI3KJT.js +305 -0
  64. package/dist/chunk-I46X5VUA.js +59 -0
  65. package/dist/chunk-I5IGB56C.js +255 -0
  66. package/dist/chunk-IH6ZMVQ5.js +3950 -0
  67. package/dist/chunk-IJZFN3HM.js +463 -0
  68. package/dist/chunk-IPWPWM6R.js +3079 -0
  69. package/dist/chunk-IYULMRBE.js +23 -0
  70. package/dist/chunk-IZMRON6C.js +167 -0
  71. package/dist/chunk-J5FIXQRT.js +813 -0
  72. package/dist/chunk-JED6ZDEE.js +73 -0
  73. package/dist/chunk-JEUJOX5X.js +136 -0
  74. package/dist/chunk-JM4LEPY3.js +436 -0
  75. package/dist/chunk-L3UHP6TD.js +101 -0
  76. package/dist/chunk-L66GEFB6.js +524 -0
  77. package/dist/chunk-LIOHW36Z.js +469 -0
  78. package/dist/chunk-LP7EC4MI.js +16 -0
  79. package/dist/chunk-MITI6NOL.js +548 -0
  80. package/dist/chunk-MO5YHHMQ.js +168 -0
  81. package/dist/chunk-MZSBFAPJ.js +885 -0
  82. package/dist/chunk-NNAAJVBU.js +9 -0
  83. package/dist/chunk-NOTA6TEI.js +47 -0
  84. package/dist/chunk-NURGB5Z4.js +335 -0
  85. package/dist/chunk-NX4EQS3U.js +1062 -0
  86. package/dist/chunk-NXMESY4J.js +1 -0
  87. package/dist/chunk-OJR3MQYV.js +1458 -0
  88. package/dist/chunk-OURHMODR.js +454 -0
  89. package/dist/chunk-P235SVAH.js +1057 -0
  90. package/dist/chunk-P4RH4OSP.js +1038 -0
  91. package/dist/chunk-P6T66CCZ.js +226 -0
  92. package/dist/chunk-PBAHEPLQ.js +223 -0
  93. package/dist/chunk-PBHE5UG6.js +1530 -0
  94. package/dist/chunk-PDKUANDZ.js +35 -0
  95. package/dist/chunk-PWIHZ6NJ.js +296 -0
  96. package/{src/c4/layout.ts → dist/chunk-QEBUY5NY.js} +384 -1140
  97. package/dist/chunk-QLCCJEJI.js +253 -0
  98. package/dist/chunk-QOOUC2J5.js +52 -0
  99. package/dist/chunk-QYTPPDAO.js +402 -0
  100. package/dist/chunk-R3XI2VC7.js +801 -0
  101. package/dist/chunk-RCERWOJR.js +154 -0
  102. package/dist/chunk-RJE5JTVK.js +362 -0
  103. package/dist/chunk-RTLBSQ3G.js +1155 -0
  104. package/dist/chunk-RUNNI6VE.js +448 -0
  105. package/dist/chunk-RVMRZAPB.js +354 -0
  106. package/dist/chunk-RYEGFMUO.js +955 -0
  107. package/dist/chunk-RZCF2VVM.js +528 -0
  108. package/dist/chunk-SML67VPV.js +1025 -0
  109. package/dist/chunk-SQ7IY53Q.js +44 -0
  110. package/dist/chunk-SQAG3UXH.js +161 -0
  111. package/dist/chunk-SRTU6HMQ.js +1851 -0
  112. package/dist/chunk-T2OE3YQB.js +550 -0
  113. package/dist/chunk-T3UBLACL.js +299 -0
  114. package/dist/chunk-TLVIHFRO.js +296 -0
  115. package/dist/chunk-TYS6CSS5.js +52 -0
  116. package/dist/chunk-U6EQI3U6.js +130 -0
  117. package/dist/chunk-UJ4FJLBF.js +86 -0
  118. package/dist/chunk-ULOEATBZ.js +347 -0
  119. package/dist/chunk-UNCCZ3NU.js +127 -0
  120. package/dist/chunk-USZW2HHU.js +197 -0
  121. package/dist/chunk-UWN33VNX.js +1610 -0
  122. package/dist/chunk-UZ7EZW3B.js +40 -0
  123. package/dist/chunk-VOKGH627.js +37 -0
  124. package/dist/chunk-WBRZJOEC.js +204 -0
  125. package/dist/chunk-WCSOJFU3.js +380 -0
  126. package/dist/chunk-WCT3NYCV.js +160 -0
  127. package/dist/chunk-WVAJFAIA.js +529 -0
  128. package/dist/chunk-X5LCYCL5.js +394 -0
  129. package/dist/chunk-XAKEUMEJ.js +1256 -0
  130. package/dist/chunk-Y2ZE3MSG.js +590 -0
  131. package/dist/chunk-Y3J7VR52.js +646 -0
  132. package/dist/chunk-Y5QGVTVC.js +33 -0
  133. package/dist/chunk-YAA6IID3.js +548 -0
  134. package/dist/chunk-YGJTDXVR.js +692 -0
  135. package/{src/utils/time-ticks.ts → dist/chunk-YRYKTYMQ.js} +45 -112
  136. package/dist/chunk-YYVTBZZC.js +61 -0
  137. package/dist/chunk-Z5CGSFJB.js +647 -0
  138. package/{src/gantt/calculator.ts → dist/chunk-Z72XRXD4.js} +236 -428
  139. package/dist/chunk-ZGR7ULFJ.js +978 -0
  140. package/dist/chunk-ZJEL4H2R.js +851 -0
  141. package/dist/chunk-ZO27FGJS.js +554 -0
  142. package/dist/collapse-CLPJD2RL.js +11 -0
  143. package/dist/collapse-SLINJQW6.js +9 -0
  144. package/dist/collapse-ZWUFFCK2.js +9 -0
  145. package/dist/compute-G55RG53N.js +8 -0
  146. package/dist/dgmo-router-DZCIDUO5.js +73 -0
  147. package/dist/dimensions-J3FHIMJ6.js +22 -0
  148. package/dist/element.js +1 -1
  149. package/dist/element.mjs +1 -1
  150. package/dist/flowchart-parser-ZNSKIBVR.js +21 -0
  151. package/dist/flowchart-renderer-ZAEOL4DX.js +35 -0
  152. package/dist/index.d.ts +3 -469
  153. package/dist/index.js +137 -69685
  154. package/dist/layout-46N4JJYK.js +17 -0
  155. package/dist/layout-5RA6QWR6.js +26 -0
  156. package/dist/layout-5T6RH5M6.js +14 -0
  157. package/dist/layout-7QXCNOVS.js +13 -0
  158. package/dist/layout-EE6GE46Y.js +17 -0
  159. package/dist/layout-G23F7LDH.js +9 -0
  160. package/dist/layout-HRBZPFCN.js +23 -0
  161. package/dist/layout-HWDSRX5E.js +20 -0
  162. package/dist/layout-HYZPWAK5.js +18 -0
  163. package/dist/layout-N76NR4ZO.js +19 -0
  164. package/dist/layout-OB3RI63S.js +14 -0
  165. package/dist/layout-S2QBYSK2.js +15 -0
  166. package/dist/layout-UM5F4DJB.js +15 -0
  167. package/dist/layout-search-OYV77HHS.js +1655 -0
  168. package/dist/load-data-EHDDZ5ZS.js +8 -0
  169. package/dist/palettes-PRJ2RI6D.js +56 -0
  170. package/dist/parser-2MFP2H2E.js +11 -0
  171. package/dist/parser-3STE62GB.js +21 -0
  172. package/dist/parser-4FL2CMDG.js +18 -0
  173. package/dist/parser-4OGOBJJ4.js +13 -0
  174. package/dist/parser-6BTRLKRZ.js +15 -0
  175. package/dist/parser-AQETEVRW.js +21 -0
  176. package/dist/parser-CFZD5IBL.js +12 -0
  177. package/dist/parser-FUSKFGZN.js +16 -0
  178. package/dist/parser-I6KXEYFK.js +13 -0
  179. package/dist/parser-IXSZZQHY.js +18 -0
  180. package/dist/parser-JAL2HD4I.js +13 -0
  181. package/dist/parser-KNSQSKQO.js +20 -0
  182. package/dist/parser-N5O4IHUN.js +13 -0
  183. package/dist/parser-NGU3ETO6.js +16 -0
  184. package/dist/parser-NRAI6O25.js +19 -0
  185. package/dist/parser-O5J4VBII.js +11 -0
  186. package/dist/parser-OV7NOBW6.js +21 -0
  187. package/dist/parser-PQ3POX45.js +23 -0
  188. package/dist/parser-TFZFBVWN.js +11 -0
  189. package/dist/parser-TRTHDFPP.js +18 -0
  190. package/dist/parser-VQP2UJ6W.js +11 -0
  191. package/dist/parser-XDVELHRK.js +13 -0
  192. package/dist/parser-XKRP7QKP.js +11 -0
  193. package/dist/parser-Y6WTBU76.js +14 -0
  194. package/dist/parser-ZSDPZYQP.js +12 -0
  195. package/dist/renderer-2XQQQ6QR.js +28 -0
  196. package/dist/renderer-5NDVNDAZ.js +26 -0
  197. package/dist/renderer-6EEZHMH4.js +26 -0
  198. package/dist/renderer-6W5462RB.js +43 -0
  199. package/dist/renderer-7MVLWWQD.js +22 -0
  200. package/dist/renderer-AWWAF6XD.js +33 -0
  201. package/dist/renderer-BYCNMBF7.js +34 -0
  202. package/dist/renderer-CLJHQPBJ.js +29 -0
  203. package/dist/renderer-GHPZMFU2.js +15 -0
  204. package/dist/renderer-JGBKUCZD.js +16 -0
  205. package/dist/renderer-KQB7UGDS.js +19 -0
  206. package/dist/renderer-PGX2TKVS.js +24 -0
  207. package/dist/renderer-QIWVHWZO.js +15 -0
  208. package/dist/renderer-RPOA5YPZ.js +35 -0
  209. package/dist/renderer-SMIBCRVB.js +24 -0
  210. package/dist/renderer-T7YKC5VP.js +28 -0
  211. package/dist/renderer-TOCOVLHS.js +37 -0
  212. package/dist/renderer-UWA5XS74.js +39 -0
  213. package/dist/renderer-VACVQYML.js +25 -0
  214. package/dist/renderer-W4M6QLIJ.js +37 -0
  215. package/dist/renderer-WZRREQ2P.js +23 -0
  216. package/dist/renderer-YY2OSF6E.js +27 -0
  217. package/dist/renderer-Z7I3W2PP.js +24 -0
  218. package/dist/renderer-ZGNTUWC4.js +22 -0
  219. package/dist/renderer-ZTR3DER3.js +19 -0
  220. package/dist/renderer-radial-C32GPJQ7.js +21 -0
  221. package/dist/resolver-NOAA7ID7.js +13 -0
  222. package/dist/state-collapse-HCGD6IVJ.js +8 -0
  223. package/dist/state-parser-Z2V23ATR.js +18 -0
  224. package/dist/state-renderer-RFYHSP4K.js +34 -0
  225. package/dist/themes-1-CuKpeH.d.ts +908 -0
  226. package/package.json +19 -70
  227. package/dist/advanced.cjs +0 -71648
  228. package/dist/advanced.d.cts +0 -6571
  229. package/dist/auto.cjs +0 -70648
  230. package/dist/auto.d.cts +0 -54
  231. package/dist/block.cjs +0 -70208
  232. package/dist/block.d.cts +0 -115
  233. package/dist/editor.d.cts +0 -26
  234. package/dist/element.cjs +0 -70530
  235. package/dist/element.d.cts +0 -62
  236. package/dist/highlight.cjs +0 -852
  237. package/dist/highlight.d.cts +0 -49
  238. package/dist/index.cjs +0 -70491
  239. package/dist/index.d.cts +0 -626
  240. package/dist/pert.cjs +0 -325
  241. package/dist/pert.d.cts +0 -559
  242. package/src/advanced.ts +0 -873
  243. package/src/arc/parser.ts +0 -15
  244. package/src/arc/renderer.ts +0 -633
  245. package/src/auto/index.ts +0 -621
  246. package/src/auto/shared.ts +0 -370
  247. package/src/auto/styles.ts +0 -73
  248. package/src/block/layout.ts +0 -198
  249. package/src/block/renderer.ts +0 -484
  250. package/src/block/types.ts +0 -67
  251. package/src/boxes-and-lines/collapse.ts +0 -96
  252. package/src/boxes-and-lines/focus.ts +0 -257
  253. package/src/boxes-and-lines/label-placement.ts +0 -339
  254. package/src/boxes-and-lines/layout-grouped.ts +0 -912
  255. package/src/boxes-and-lines/layout-layered.ts +0 -722
  256. package/src/boxes-and-lines/layout-search.ts +0 -1678
  257. package/src/boxes-and-lines/layout.ts +0 -398
  258. package/src/boxes-and-lines/parser.ts +0 -1181
  259. package/src/boxes-and-lines/renderer.ts +0 -1465
  260. package/src/boxes-and-lines/types.ts +0 -66
  261. package/src/c4/parser.ts +0 -1158
  262. package/src/c4/renderer.ts +0 -2008
  263. package/src/c4/types.ts +0 -89
  264. package/src/chart-type-registry.ts +0 -529
  265. package/src/chart-types.ts +0 -225
  266. package/src/chart.ts +0 -685
  267. package/src/charts-d3/bar.ts +0 -338
  268. package/src/charts-d3/chord.ts +0 -140
  269. package/src/charts-d3/function.ts +0 -147
  270. package/src/charts-d3/funnel.ts +0 -104
  271. package/src/charts-d3/heatmap.ts +0 -145
  272. package/src/charts-d3/index.ts +0 -337
  273. package/src/charts-d3/interactions.ts +0 -477
  274. package/src/charts-d3/line.ts +0 -344
  275. package/src/charts-d3/mount.ts +0 -151
  276. package/src/charts-d3/pie.ts +0 -117
  277. package/src/charts-d3/polar.ts +0 -89
  278. package/src/charts-d3/radar.ts +0 -0
  279. package/src/charts-d3/sankey.ts +0 -0
  280. package/src/charts-d3/scatter.ts +0 -185
  281. package/src/charts-d3/shared.ts +0 -208
  282. package/src/class/layout.ts +0 -326
  283. package/src/class/parser.ts +0 -635
  284. package/src/class/renderer.ts +0 -793
  285. package/src/class/types.ts +0 -58
  286. package/src/cli-banner.ts +0 -106
  287. package/src/cli.ts +0 -1080
  288. package/src/colors-diagnostics.ts +0 -35
  289. package/src/colors.ts +0 -379
  290. package/src/completion-types.ts +0 -27
  291. package/src/completion.ts +0 -2668
  292. package/src/cycle/layout.ts +0 -1026
  293. package/src/cycle/parser.ts +0 -387
  294. package/src/cycle/renderer.ts +0 -653
  295. package/src/cycle/types.ts +0 -101
  296. package/src/d3.ts +0 -1434
  297. package/src/data-chart-parser.ts +0 -1007
  298. package/src/dgmo-router.ts +0 -296
  299. package/src/diagnostics-registry.ts +0 -108
  300. package/src/diagnostics.ts +0 -0
  301. package/src/dimensions.ts +0 -20
  302. package/src/directives-registry.ts +0 -396
  303. package/src/editor/dgmo.grammar +0 -76
  304. package/src/editor/dgmo.grammar.d.ts +0 -2
  305. package/src/editor/dgmo.grammar.js +0 -18
  306. package/src/editor/dgmo.grammar.terms.d.ts +0 -5
  307. package/src/editor/dgmo.grammar.terms.js +0 -35
  308. package/src/editor/highlight-api.ts +0 -596
  309. package/src/editor/highlight.ts +0 -36
  310. package/src/editor/index.ts +0 -27
  311. package/src/editor/keywords.ts +0 -128
  312. package/src/editor/tokens.ts +0 -30
  313. package/src/element/index.ts +0 -432
  314. package/src/embed/css.ts +0 -312
  315. package/src/embed/escape.ts +0 -15
  316. package/src/embed/index.ts +0 -280
  317. package/src/er/classify.ts +0 -228
  318. package/src/er/layout.ts +0 -530
  319. package/src/er/parser.ts +0 -750
  320. package/src/er/renderer.ts +0 -725
  321. package/src/er/types.ts +0 -52
  322. package/src/error-card.ts +0 -269
  323. package/src/event-line/diagnostics.ts +0 -117
  324. package/src/event-line/parser.ts +0 -643
  325. package/src/event-line/renderer.ts +0 -1742
  326. package/src/event-line/types.ts +0 -74
  327. package/src/fonts.ts +0 -3
  328. package/src/gantt/parser.ts +0 -1641
  329. package/src/gantt/renderer.ts +0 -3787
  330. package/src/gantt/resolver.ts +0 -172
  331. package/src/gantt/types.ts +0 -206
  332. package/src/graph/diagnostics.ts +0 -64
  333. package/src/graph/edge-spline.ts +0 -29
  334. package/src/graph/flowchart-parser.ts +0 -759
  335. package/src/graph/flowchart-renderer.ts +0 -817
  336. package/src/graph/layout.ts +0 -472
  337. package/src/graph/notes.ts +0 -21
  338. package/src/graph/state-collapse.ts +0 -78
  339. package/src/graph/state-parser.ts +0 -574
  340. package/src/graph/state-renderer.ts +0 -653
  341. package/src/graph/types.ts +0 -65
  342. package/src/index.ts +0 -261
  343. package/src/infra/compute.ts +0 -1385
  344. package/src/infra/layout.ts +0 -888
  345. package/src/infra/parser.ts +0 -1234
  346. package/src/infra/renderer.ts +0 -2534
  347. package/src/infra/roles.ts +0 -75
  348. package/src/infra/types.ts +0 -216
  349. package/src/infra/validation.ts +0 -201
  350. package/src/journey-map/layout.ts +0 -490
  351. package/src/journey-map/parser.ts +0 -557
  352. package/src/journey-map/renderer.ts +0 -1580
  353. package/src/journey-map/types.ts +0 -47
  354. package/src/kanban/mutations.ts +0 -175
  355. package/src/kanban/parser.ts +0 -509
  356. package/src/kanban/renderer.ts +0 -1449
  357. package/src/kanban/types.ts +0 -39
  358. package/src/label-layout.ts +0 -368
  359. package/src/map/colorize.ts +0 -54
  360. package/src/map/completion.ts +0 -316
  361. package/src/map/context-labels.ts +0 -609
  362. package/src/map/data/PROVENANCE.json +0 -1
  363. package/src/map/data/README.md +0 -40
  364. package/src/map/data/airport-collisions.json +0 -1
  365. package/src/map/data/airports.json +0 -1
  366. package/src/map/data/gazetteer.json +0 -1
  367. package/src/map/data/lakes.json +0 -1
  368. package/src/map/data/mountain-ranges.json +0 -1
  369. package/src/map/data/na-lakes.json +0 -1
  370. package/src/map/data/na-land.json +0 -1
  371. package/src/map/data/region-names.json +0 -1
  372. package/src/map/data/rivers.json +0 -1
  373. package/src/map/data/types.ts +0 -121
  374. package/src/map/data/us-states.json +0 -1
  375. package/src/map/data/water-bodies.json +0 -1
  376. package/src/map/data/world-coarse.json +0 -1
  377. package/src/map/data/world-detail.json +0 -1
  378. package/src/map/diagnostics.ts +0 -134
  379. package/src/map/dimensions.ts +0 -150
  380. package/src/map/geo-query.ts +0 -295
  381. package/src/map/geo.ts +0 -438
  382. package/src/map/invert.ts +0 -111
  383. package/src/map/layout.ts +0 -5069
  384. package/src/map/legend-band.ts +0 -127
  385. package/src/map/load-data.ts +0 -186
  386. package/src/map/parser.ts +0 -783
  387. package/src/map/renderer.ts +0 -1445
  388. package/src/map/resolved-types.ts +0 -160
  389. package/src/map/resolver.ts +0 -1146
  390. package/src/map/types.ts +0 -194
  391. package/src/mindmap/collapse.ts +0 -67
  392. package/src/mindmap/layout.ts +0 -649
  393. package/src/mindmap/parser.ts +0 -430
  394. package/src/mindmap/renderer.ts +0 -637
  395. package/src/mindmap/text-wrap.ts +0 -218
  396. package/src/mindmap/types.ts +0 -56
  397. package/src/org/collapse.ts +0 -151
  398. package/src/org/layout.ts +0 -1262
  399. package/src/org/parser.ts +0 -519
  400. package/src/org/renderer.ts +0 -866
  401. package/src/org/resolver.ts +0 -636
  402. package/src/palettes/atlas.ts +0 -77
  403. package/src/palettes/blueprint.ts +0 -73
  404. package/src/palettes/catppuccin.ts +0 -84
  405. package/src/palettes/color-utils.ts +0 -443
  406. package/src/palettes/index.ts +0 -67
  407. package/src/palettes/nord.ts +0 -67
  408. package/src/palettes/registry.ts +0 -114
  409. package/src/palettes/slate.ts +0 -73
  410. package/src/palettes/tidewater.ts +0 -73
  411. package/src/palettes/tokyo-night.ts +0 -86
  412. package/src/palettes/types.ts +0 -88
  413. package/src/pert/analyzer.ts +0 -1183
  414. package/src/pert/diagnostics.ts +0 -110
  415. package/src/pert/index.ts +0 -43
  416. package/src/pert/internal.ts +0 -252
  417. package/src/pert/layout.ts +0 -971
  418. package/src/pert/monte-carlo.ts +0 -446
  419. package/src/pert/parser.ts +0 -1606
  420. package/src/pert/renderer.ts +0 -4009
  421. package/src/pert/share-normalize.ts +0 -62
  422. package/src/pert/types.ts +0 -604
  423. package/src/pyramid/parser.ts +0 -185
  424. package/src/pyramid/renderer.ts +0 -768
  425. package/src/pyramid/types.ts +0 -28
  426. package/src/quadrant/parser.ts +0 -18
  427. package/src/quadrant/renderer.ts +0 -638
  428. package/src/raci/diagnostics.ts +0 -213
  429. package/src/raci/index.ts +0 -23
  430. package/src/raci/mutations.ts +0 -321
  431. package/src/raci/parser.ts +0 -699
  432. package/src/raci/renderer.ts +0 -1627
  433. package/src/raci/types.ts +0 -82
  434. package/src/raci/variants.ts +0 -320
  435. package/src/render.ts +0 -268
  436. package/src/ring/parser.ts +0 -212
  437. package/src/ring/renderer.ts +0 -490
  438. package/src/ring/types.ts +0 -27
  439. package/src/sequence/collapse.ts +0 -174
  440. package/src/sequence/parser.ts +0 -1596
  441. package/src/sequence/participant-inference.ts +0 -152
  442. package/src/sequence/renderer.ts +0 -3168
  443. package/src/sequence/tag-resolution.ts +0 -164
  444. package/src/sharing.ts +0 -211
  445. package/src/sitemap/collapse.ts +0 -100
  446. package/src/sitemap/layout.ts +0 -925
  447. package/src/sitemap/parser.ts +0 -755
  448. package/src/sitemap/renderer.ts +0 -828
  449. package/src/sitemap/types.ts +0 -42
  450. package/src/slope/parser.ts +0 -18
  451. package/src/slope/renderer.ts +0 -378
  452. package/src/swimlane/diagnostics.ts +0 -94
  453. package/src/swimlane/layout.ts +0 -597
  454. package/src/swimlane/parser.ts +0 -613
  455. package/src/swimlane/renderer.ts +0 -681
  456. package/src/swimlane/types.ts +0 -151
  457. package/src/tech-radar/interactive.ts +0 -1129
  458. package/src/tech-radar/layout.ts +0 -197
  459. package/src/tech-radar/parser.ts +0 -436
  460. package/src/tech-radar/renderer.ts +0 -1239
  461. package/src/tech-radar/shared.ts +0 -151
  462. package/src/tech-radar/types.ts +0 -86
  463. package/src/themes.ts +0 -22
  464. package/src/timeline/parser.ts +0 -472
  465. package/src/timeline/renderer.ts +0 -3024
  466. package/src/timeline/types.ts +0 -33
  467. package/src/timeline/viz-parser.ts +0 -21
  468. package/src/treemap/diagnostics.ts +0 -62
  469. package/src/treemap/layout-radial.ts +0 -233
  470. package/src/treemap/layout.ts +0 -189
  471. package/src/treemap/parser.ts +0 -463
  472. package/src/treemap/renderer-radial.ts +0 -438
  473. package/src/treemap/renderer.ts +0 -572
  474. package/src/treemap/treemap-shared.ts +0 -309
  475. package/src/treemap/types.ts +0 -60
  476. package/src/utils/arrow-markers.ts +0 -51
  477. package/src/utils/arrows-diagnostics.ts +0 -62
  478. package/src/utils/arrows.ts +0 -227
  479. package/src/utils/brand.ts +0 -61
  480. package/src/utils/card.ts +0 -183
  481. package/src/utils/collapse-engine/tree-edges.ts +0 -115
  482. package/src/utils/collapse-engine/tree.ts +0 -117
  483. package/src/utils/d3-helpers.ts +0 -219
  484. package/src/utils/d3-types.ts +0 -9
  485. package/src/utils/description-helpers.ts +0 -38
  486. package/src/utils/duration.ts +0 -312
  487. package/src/utils/export-container.ts +0 -41
  488. package/src/utils/expr-eval.ts +0 -27
  489. package/src/utils/fit-canvas.ts +0 -64
  490. package/src/utils/hover-styles.ts +0 -673
  491. package/src/utils/inline-markdown.ts +0 -96
  492. package/src/utils/legend-constants.ts +0 -48
  493. package/src/utils/legend-d3.ts +0 -618
  494. package/src/utils/legend-integration.ts +0 -107
  495. package/src/utils/legend-layout.ts +0 -776
  496. package/src/utils/legend-svg.ts +0 -214
  497. package/src/utils/legend-types.ts +0 -272
  498. package/src/utils/name-normalize.ts +0 -163
  499. package/src/utils/note-box/constants.ts +0 -25
  500. package/src/utils/note-box/index.ts +0 -11
  501. package/src/utils/note-box/metrics.ts +0 -90
  502. package/src/utils/note-box/svg.ts +0 -331
  503. package/src/utils/notes/bounds.ts +0 -30
  504. package/src/utils/notes/build.ts +0 -131
  505. package/src/utils/notes/index.ts +0 -18
  506. package/src/utils/notes/model.ts +0 -19
  507. package/src/utils/notes/parse.ts +0 -131
  508. package/src/utils/notes/place.ts +0 -177
  509. package/src/utils/notes/resolve.ts +0 -88
  510. package/src/utils/number-format.ts +0 -36
  511. package/src/utils/parsing.ts +0 -953
  512. package/src/utils/reserved-key-registry.ts +0 -239
  513. package/src/utils/safe-href.ts +0 -38
  514. package/src/utils/scaling.ts +0 -97
  515. package/src/utils/svg-embed.ts +0 -251
  516. package/src/utils/tag-groups.ts +0 -607
  517. package/src/utils/text-measure.ts +0 -122
  518. package/src/utils/title-constants.ts +0 -24
  519. package/src/utils/visual-conventions.ts +0 -61
  520. package/src/utils/wrapped-desc.ts +0 -87
  521. package/src/venn/parser.ts +0 -18
  522. package/src/venn/renderer.ts +0 -1047
  523. package/src/version-control/diagnostics.ts +0 -67
  524. package/src/version-control/parser.ts +0 -544
  525. package/src/version-control/renderer.ts +0 -724
  526. package/src/version-control/types.ts +0 -100
  527. package/src/visualizations/parse.ts +0 -1560
  528. package/src/visualizations/types.ts +0 -262
  529. package/src/wireframe/layout.ts +0 -479
  530. package/src/wireframe/parser.ts +0 -1114
  531. package/src/wireframe/renderer.ts +0 -1318
  532. package/src/wireframe/types.ts +0 -110
  533. package/src/wordcloud/parser.ts +0 -18
  534. package/src/wordcloud/renderer.ts +0 -357
@@ -1,1181 +0,0 @@
1
- // ============================================================
2
- // Boxes and Lines Diagram — Parser
3
- // ============================================================
4
-
5
- import { makeDgmoError, suggest } from '../diagnostics';
6
- import type { DgmoError } from '../diagnostics';
7
- import { parseInArrowLabel } from '../utils/arrows';
8
- import { normalizeName } from '../utils/name-normalize';
9
- import type { ParsedBoxesAndLines, BLNode, BLEdge, BLGroup } from './types';
10
- import {
11
- matchTagBlockHeading,
12
- injectDefaultTagMetadata,
13
- validateTagValues,
14
- validateTagGroupNames,
15
- stripDefaultModifier,
16
- finalizeAutoTagColors,
17
- AUTO_TAG_COLOR_SENTINEL,
18
- tagAttrKey,
19
- } from '../utils/tag-groups';
20
- import type { TagGroup } from '../utils/tag-groups';
21
- import type { Writable } from '../utils/brand';
22
- import {
23
- extractColor,
24
- parseFirstLine,
25
- OPTION_NOCOLON_RE,
26
- peelRampColors,
27
- splitNameAndMeta,
28
- tryParseSharedOption,
29
- warnUnknownMetaKeys,
30
- } from '../utils/parsing';
31
- import {
32
- BOXES_AND_LINES_REGISTRY,
33
- withTagAliases,
34
- } from '../utils/reserved-key-registry';
35
- import { tryCollectNote, resolveNotes, type DiagramNote } from '../utils/notes';
36
- import type { PaletteColors } from '../palettes';
37
-
38
- const MAX_GROUP_DEPTH = 2;
39
-
40
- /** Boxes-and-lines requires explicit first line — no heuristic detection. */
41
- export function looksLikeBoxesAndLines(_content: string): boolean {
42
- return false;
43
- }
44
-
45
- /** Measure leading whitespace (tabs = 4 spaces) */
46
- function measureIndent(line: string): number {
47
- let count = 0;
48
- for (const ch of line) {
49
- if (ch === ' ') count++;
50
- else if (ch === '\t') count += 4;
51
- else break;
52
- }
53
- return count;
54
- }
55
-
56
- /**
57
- * Parse the trailing meta segment of a structural line — accepts both
58
- * the legacy `| key: value, …` and the new §1.4 same-line `key: value, …`
59
- * forms (a leading `|` is tolerated and stripped). Extracts
60
- * `description` separately so callers can hang it on the node body.
61
- */
62
- function parseTailMeta(
63
- rawTail: string,
64
- metaAliasMap: Map<string, string>
65
- ): { metadata: Record<string, string>; description?: string[] } {
66
- const segment = rawTail.trim();
67
- if (!segment) return { metadata: {} };
68
-
69
- const metadata: Record<string, string> = {};
70
- let description: string[] | undefined;
71
-
72
- for (const item of segment.split(',')) {
73
- const trimmed = item.trim();
74
- if (!trimmed) continue;
75
-
76
- const colonIdx = trimmed.indexOf(':');
77
- if (colonIdx >= 0) {
78
- const rawKey = trimmed.slice(0, colonIdx).trim().toLowerCase();
79
- const value = trimmed.slice(colonIdx + 1).trim();
80
- if (rawKey === 'description') {
81
- description = [value];
82
- } else {
83
- const resolvedKey = metaAliasMap.get(rawKey) ?? rawKey;
84
- metadata[resolvedKey] = value;
85
- }
86
- }
87
- // Bare words are ignored (no status system)
88
- }
89
-
90
- return { metadata, ...(description !== undefined && { description }) };
91
- }
92
-
93
- /** Convert group label to internal ID */
94
- function groupId(label: string): string {
95
- return `__group_${label}`;
96
- }
97
-
98
- // Local mutable shapes — element-level metadata/description need to be
99
- // mutated during parse (cascading group metadata, description collection).
100
- // These widen the readonly fields to writable; assignment back into the
101
- // readonly-typed ParsedBoxesAndLines is covariant on Record → Readonly<Record>.
102
- type MutBLNode = Omit<Writable<BLNode>, 'metadata' | 'description'> & {
103
- metadata: Record<string, string>;
104
- description?: string[];
105
- };
106
- type MutBLEdge = Omit<Writable<BLEdge>, 'metadata'> & {
107
- metadata: Record<string, string>;
108
- };
109
- type MutBLGroup = Omit<Writable<BLGroup>, 'metadata' | 'children'> & {
110
- metadata: Record<string, string>;
111
- children: string[];
112
- };
113
-
114
- export function parseBoxesAndLines(
115
- content: string,
116
- palette?: PaletteColors
117
- ): ParsedBoxesAndLines {
118
- const options: Record<string, string> = {};
119
- const notes: DiagramNote[] = [];
120
- const initialHiddenTagValues = new Map<string, Set<string>>();
121
- const nodes: MutBLNode[] = [];
122
- const edges: MutBLEdge[] = [];
123
- const groups: MutBLGroup[] = [];
124
- // Trailing `layout` block (Canvas Editor spike): node-id → absolute {x,y}.
125
- const nodePositions = new Map<string, { x: number; y: number }>();
126
- const result: Writable<ParsedBoxesAndLines> = {
127
- type: 'boxes-and-lines',
128
- title: null,
129
- titleLineNumber: null,
130
- nodes,
131
- edges,
132
- groups,
133
- tagGroups: [],
134
- options,
135
- initialHiddenTagValues,
136
- direction: 'LR',
137
- diagnostics: [],
138
- error: null,
139
- };
140
-
141
- const lines = content.split('\n');
142
- const nodeLabels = new Set<string>();
143
- const groupLabels = new Set<string>();
144
- let lastNodeLabel: string | null = null;
145
- let lastSourceIsGroup = false;
146
- let lastNodeIndent = 0;
147
-
148
- // Description collection state
149
- let descState: {
150
- nodeLabel: string;
151
- indent: number;
152
- lines: string[];
153
- edgeSeen: boolean;
154
- } | null = null;
155
-
156
- function flushDescription() {
157
- if (descState && descState.lines.length > 0) {
158
- const node = nodes.find((n) => n.label === descState!.nodeLabel);
159
- if (node) {
160
- const existing = node.description ?? [];
161
- node.description = [...existing, ...descState!.lines];
162
- }
163
- }
164
- descState = null;
165
- }
166
-
167
- // Group stack for nesting
168
- interface GroupState {
169
- group: MutBLGroup;
170
- indent: number;
171
- depth: number;
172
- }
173
- const groupStack: GroupState[] = [];
174
-
175
- // Tag block state
176
- let contentStarted = false;
177
- // `layout` coordinate-block state (Canvas Editor spike). Unlike tag blocks,
178
- // this is a TRAILING appendix — it may appear after diagram content.
179
- let inLayoutBlock = false;
180
- const LAYOUT_ENTRY_RE =
181
- /^(.+?):\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*$/;
182
- let currentTagGroup: Writable<TagGroup> | null = null;
183
- // metaAliasMap: tag-group metadata-key aliases (per A1).
184
- const metaAliasMap = new Map<string, string>();
185
- // nameAliasMap: TD-18 entity-name aliases (`a` → `<canonical id>`). Per C8.
186
- const nameAliasMap = new Map<string, string>();
187
- function peelAlias(label: string): { label: string; alias?: string } {
188
- const trimmed = label.trim();
189
- const m = trimmed.match(/^(.*?)\s+as\s+([A-Za-z][A-Za-z0-9_]{0,11})\s*$/);
190
- if (!m) return { label: trimmed };
191
- // Regex capture groups present after successful match.
192
- return { label: m[1]!.trim(), alias: m[2]! };
193
- }
194
- const pushWarning = (lineNumber: number, message: string) => {
195
- result.diagnostics.push(makeDgmoError(lineNumber, message, 'warning'));
196
- };
197
-
198
- /** Get the innermost active group, if any */
199
- function currentGroupState(): GroupState | null {
200
- // In-bounds by length guard.
201
- return groupStack.length > 0 ? groupStack[groupStack.length - 1]! : null;
202
- }
203
-
204
- /** Close groups that are at or deeper than a given indent level */
205
- function closeGroupsToIndent(indent: number) {
206
- while (
207
- groupStack.length > 0 &&
208
- // In-bounds by length guard.
209
- groupStack[groupStack.length - 1]!.indent >= indent
210
- ) {
211
- const gs = groupStack.pop()!;
212
- result.groups.push(gs.group);
213
- }
214
- }
215
-
216
- /** Ensure a node exists (implicit creation) */
217
- function ensureNode(label: string, lineNum: number) {
218
- const key = normalizeName(label);
219
- if (!nodeLabels.has(key)) {
220
- result.nodes.push({
221
- label,
222
- lineNumber: lineNum,
223
- metadata: {},
224
- });
225
- nodeLabels.add(key);
226
- }
227
- }
228
-
229
- for (let i = 0; i < lines.length; i++) {
230
- const lineNum = i + 1;
231
- // In-bounds by loop guard.
232
- const raw = lines[i]!;
233
- const trimmed = raw.trim();
234
- const indent = measureIndent(raw);
235
-
236
- // Skip blanks and comments
237
- if (!trimmed || trimmed.startsWith('//')) continue;
238
-
239
- // First line: `boxes-and-lines [Title]`
240
- const firstLineResult = parseFirstLine(trimmed);
241
- if (firstLineResult && !contentStarted && i < 5) {
242
- if (firstLineResult.chartType !== 'boxes-and-lines') {
243
- const diag = makeDgmoError(
244
- lineNum,
245
- `Expected chart type "boxes-and-lines", got "${firstLineResult.chartType}"`
246
- );
247
- result.diagnostics.push(diag);
248
- result.error = diag.message;
249
- return result;
250
- }
251
- if (firstLineResult.title) {
252
- result.title = firstLineResult.title;
253
- result.titleLineNumber = lineNum;
254
- }
255
- continue;
256
- }
257
-
258
- // Directives (non-indented, before or during content)
259
- if (indent === 0) {
260
- // direction TB / direction LR
261
- const dirMatch = trimmed.match(/^direction\s+(TB|LR)$/i);
262
- if (dirMatch) {
263
- // Regex capture group present after successful match.
264
- result.direction = dirMatch[1]!.toUpperCase() as 'LR' | 'TB';
265
- continue;
266
- }
267
-
268
- // hide directive: `hide team:Backend, team:Frontend`
269
- const hideMatch = trimmed.match(/^hide\s+(.+)/i);
270
- if (hideMatch && !trimmed.match(/^hide\s*\|/)) {
271
- // Regex capture group present after successful match.
272
- const pairs = hideMatch[1]!.split(',');
273
- for (const pair of pairs) {
274
- const colonIdx = pair.indexOf(':');
275
- if (colonIdx > 0) {
276
- const groupKey = pair.substring(0, colonIdx).trim().toLowerCase();
277
- const value = pair
278
- .substring(colonIdx + 1)
279
- .trim()
280
- .toLowerCase();
281
- if (groupKey && value) {
282
- if (!initialHiddenTagValues.has(groupKey)) {
283
- initialHiddenTagValues.set(groupKey, new Set());
284
- }
285
- initialHiddenTagValues.get(groupKey)!.add(value);
286
- }
287
- }
288
- }
289
- continue;
290
- }
291
-
292
- // heat / show-values directives — pre-content only (like
293
- // active-tag). Explicit regex branches: a bare flag and a
294
- // `key value` form won't both match the active-tag OPTION codepath.
295
- if (!contentStarted) {
296
- const metricMatch = trimmed.match(/^heat\s+(.+)$/i);
297
- if (metricMatch) {
298
- // Regex capture group present after successful match.
299
- const { label, low, high } = peelRampColors(metricMatch[1]!.trim());
300
- result.boxMetric = label;
301
- if (high !== undefined) result.boxMetricColor = high;
302
- if (low !== undefined) result.boxMetricLowColor = low;
303
- continue;
304
- }
305
- if (/^show-values$/i.test(trimmed)) {
306
- result.showValues = true;
307
- continue;
308
- }
309
- }
310
-
311
- // active-tag directive
312
- if (!contentStarted) {
313
- const optMatch = trimmed.match(OPTION_NOCOLON_RE);
314
- if (optMatch) {
315
- // Regex capture groups present after successful match.
316
- const key = optMatch[1]!.toLowerCase();
317
- const value = optMatch[2]!.trim();
318
- if (key === 'active-tag') {
319
- options[key] = value;
320
- continue;
321
- }
322
- }
323
- if (tryParseSharedOption(trimmed, options)) {
324
- continue;
325
- }
326
- }
327
- }
328
-
329
- // Note annotation (top-level): `note <Box> [inline body]` + an optional
330
- // indented body. Checked before tag/group/node/edge matching so a note is
331
- // never mistaken for a box; gated to indent 0. `note -> X` is excluded.
332
- if (indent === 0) {
333
- const noteResult = tryCollectNote(
334
- lines,
335
- i,
336
- indent,
337
- palette,
338
- result.diagnostics
339
- );
340
- if (noteResult) {
341
- if (noteResult.note) notes.push(noteResult.note);
342
- i = noteResult.lastIndex;
343
- continue;
344
- }
345
- }
346
-
347
- // Tag group heading — must be checked BEFORE group/node/edge matching
348
- const tagBlockMatch = matchTagBlockHeading(trimmed);
349
- if (tagBlockMatch && indent === 0) {
350
- if (contentStarted) {
351
- result.diagnostics.push(
352
- makeDgmoError(
353
- lineNum,
354
- 'Tag groups must appear before diagram content',
355
- 'error'
356
- )
357
- );
358
- continue;
359
- }
360
- const newTagGroup: Writable<TagGroup> = {
361
- name: tagBlockMatch.name,
362
- ...(tagBlockMatch.alias !== undefined && {
363
- alias: tagBlockMatch.alias,
364
- }),
365
- entries: [],
366
- lineNumber: lineNum,
367
- };
368
- currentTagGroup = newTagGroup;
369
- if (tagBlockMatch.alias) {
370
- metaAliasMap.set(
371
- normalizeName(tagBlockMatch.alias),
372
- tagAttrKey(tagBlockMatch.name)
373
- );
374
- }
375
- metaAliasMap.set(
376
- normalizeName(tagBlockMatch.name),
377
- tagAttrKey(tagBlockMatch.name)
378
- );
379
- if (tagBlockMatch.inlineValues) {
380
- for (const rawVal of tagBlockMatch.inlineValues) {
381
- const { text: cleanVal, isDefault } = stripDefaultModifier(rawVal);
382
- const { label, color } = extractColor(
383
- cleanVal,
384
- palette,
385
- result.diagnostics,
386
- lineNum
387
- );
388
- newTagGroup.entries.push({
389
- value: label,
390
- color: color ?? AUTO_TAG_COLOR_SENTINEL,
391
- lineNumber: lineNum,
392
- });
393
- if (isDefault) newTagGroup.defaultValue = label;
394
- }
395
- if (!newTagGroup.defaultValue && newTagGroup.entries.length > 0) {
396
- // In-bounds by length guard.
397
- newTagGroup.defaultValue = newTagGroup.entries[0]!.value;
398
- }
399
- }
400
- result.tagGroups.push(newTagGroup);
401
- continue;
402
- }
403
-
404
- // Tag group entries (indented under tag heading)
405
- if (currentTagGroup && !contentStarted && indent > 0) {
406
- const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
407
- const { label, color } = extractColor(
408
- cleanEntry,
409
- palette,
410
- result.diagnostics,
411
- lineNum
412
- );
413
- currentTagGroup.entries.push({
414
- value: label,
415
- color: color ?? AUTO_TAG_COLOR_SENTINEL,
416
- lineNumber: lineNum,
417
- });
418
- if (isDefault) {
419
- currentTagGroup.defaultValue = label;
420
- } else if (currentTagGroup.entries.length === 1) {
421
- currentTagGroup.defaultValue = label;
422
- }
423
- continue;
424
- }
425
-
426
- // Non-indented line closes tag group
427
- if (currentTagGroup && indent === 0) {
428
- currentTagGroup = null;
429
- }
430
-
431
- // `layout` coordinate block (Canvas Editor spike). A bare `layout` heading
432
- // at indent 0 opens the block; indented `<node-id>: <x>, <y>` entries map a
433
- // node to an absolute position. Any non-indented line closes it. Quarantined
434
- // before group/node/edge matching so the entries don't parse as nodes.
435
- if (!inLayoutBlock && indent === 0 && trimmed === 'layout') {
436
- // Disambiguate from a node legitimately NAMED `layout`: only treat this as
437
- // the coordinate appendix when the next non-blank line is an indented
438
- // `<id>: <x>, <y>` entry. Otherwise fall through and parse `layout` as a
439
- // normal node (no silent data loss).
440
- let isBlock = false;
441
- for (let j = i + 1; j < lines.length; j++) {
442
- const peek = lines[j]!;
443
- if (!peek.trim()) continue;
444
- isBlock = measureIndent(peek) > 0 && LAYOUT_ENTRY_RE.test(peek.trim());
445
- break;
446
- }
447
- if (isBlock) {
448
- flushDescription();
449
- closeGroupsToIndent(0);
450
- inLayoutBlock = true;
451
- continue;
452
- }
453
- }
454
- if (inLayoutBlock) {
455
- if (indent > 0) {
456
- const lm = trimmed.match(LAYOUT_ENTRY_RE);
457
- if (lm) {
458
- nodePositions.set(lm[1]!.trim(), {
459
- x: Number(lm[2]),
460
- y: Number(lm[3]),
461
- });
462
- } else {
463
- result.diagnostics.push(
464
- makeDgmoError(
465
- lineNum,
466
- `Invalid layout entry "${trimmed}" — expected "<node-id>: <x>, <y>"`,
467
- 'warning'
468
- )
469
- );
470
- }
471
- continue;
472
- }
473
- // indent 0 → block ends; fall through to process this line normally.
474
- inLayoutBlock = false;
475
- }
476
-
477
- // Description collection: indented non-edge lines under a node
478
- if (descState !== null) {
479
- if (indent > descState.indent) {
480
- // Check if this is an edge line
481
- if (trimmed.includes('->') || trimmed.includes('<->')) {
482
- descState.edgeSeen = true;
483
- // Fall through to normal edge processing
484
- } else if (descState.edgeSeen) {
485
- // Text after edges — emit warning
486
- result.diagnostics.push(
487
- makeDgmoError(
488
- lineNum,
489
- `Move description lines above edges for '${descState.nodeLabel}' — descriptions must come before -> lines`,
490
- 'warning'
491
- )
492
- );
493
- continue;
494
- } else if (
495
- /^-\s*\w/.test(trimmed) &&
496
- !trimmed.startsWith('- ') &&
497
- !trimmed.includes('->') &&
498
- !trimmed.includes('<->')
499
- ) {
500
- // Looks like a malformed edge (e.g. "-Target" but not "- list item")
501
- result.diagnostics.push(
502
- makeDgmoError(
503
- lineNum,
504
- `Looks like an incomplete edge — did you mean "-> ${trimmed.slice(1).trim()}"?`,
505
- 'warning'
506
- )
507
- );
508
- descState.lines.push(trimmed);
509
- continue;
510
- } else {
511
- // Collect as description
512
- descState.lines.push(trimmed);
513
- continue;
514
- }
515
- } else {
516
- // Indent decreased — flush description
517
- flushDescription();
518
- }
519
- }
520
-
521
- // Close groups that are no longer scoped by indent
522
- if (indent === 0) {
523
- closeGroupsToIndent(0);
524
- } else if (groupStack.length > 0) {
525
- // Close groups deeper than current indent
526
- closeGroupsToIndent(indent);
527
- }
528
-
529
- // Group-to-group edge: [Group A] -> [Group B] or [Group A] <-> [Group B]
530
- const groupEdgeMatch = trimmed.match(
531
- /^\[(.+?)\]\s*(<->|->)\s*\[(.+?)\](.*)$/
532
- );
533
- if (groupEdgeMatch) {
534
- contentStarted = true;
535
- currentTagGroup = null;
536
- const sourceLabel = groupEdgeMatch[1];
537
- const arrow = groupEdgeMatch[2];
538
- const targetLabel = groupEdgeMatch[3];
539
- const rawTail = groupEdgeMatch[4] ?? '';
540
-
541
- const edgeMeta = parseTailMeta(rawTail, metaAliasMap).metadata;
542
-
543
- result.edges.push({
544
- // Regex capture groups present after successful match.
545
- source: groupId(sourceLabel!),
546
- target: groupId(targetLabel!),
547
- bidirectional: arrow === '<->',
548
- lineNumber: lineNum,
549
- metadata: edgeMeta,
550
- });
551
- continue;
552
- }
553
-
554
- // Labeled group-to-group edge: [Group A] -label-> [Group B]
555
- const labeledGroupEdgeMatch = trimmed.match(
556
- /^\[(.+?)\]\s*(?:<-(.+)->|-(.+)->)\s*\[(.+?)\](.*)$/
557
- );
558
- if (labeledGroupEdgeMatch) {
559
- contentStarted = true;
560
- currentTagGroup = null;
561
- const sourceLabel = labeledGroupEdgeMatch[1];
562
- const biLabel = labeledGroupEdgeMatch[2];
563
- const uniLabel = labeledGroupEdgeMatch[3];
564
- const targetLabel = labeledGroupEdgeMatch[4];
565
- const rawTail = labeledGroupEdgeMatch[5] ?? '';
566
-
567
- const edgeMeta = parseTailMeta(rawTail, metaAliasMap).metadata;
568
-
569
- const labeledEdgeLabel = (biLabel ?? uniLabel)?.trim();
570
- result.edges.push({
571
- // Regex capture groups present after successful match.
572
- source: groupId(sourceLabel!),
573
- target: groupId(targetLabel!),
574
- ...(labeledEdgeLabel !== undefined && { label: labeledEdgeLabel }),
575
- bidirectional: !!biLabel,
576
- lineNumber: lineNum,
577
- metadata: edgeMeta,
578
- });
579
- continue;
580
- }
581
-
582
- // Group header: [Group Name] or [Group Name] key: value
583
- const groupMatch = trimmed.match(/^\[(.+?)\](.*)$/);
584
- if (groupMatch && !trimmed.includes('->') && !trimmed.includes('<->')) {
585
- contentStarted = true;
586
- currentTagGroup = null;
587
- flushDescription();
588
- // TD-18: peel optional `as <alias>` from the group label.
589
- // Regex capture group present after successful match.
590
- const groupPeeled = peelAlias(groupMatch[1]!);
591
- const label = groupPeeled.label;
592
- if (groupPeeled.alias)
593
- nameAliasMap.set(groupPeeled.alias, groupId(label));
594
-
595
- // Check nesting depth
596
- const currentDepth = groupStack.length + 1;
597
- if (currentDepth > MAX_GROUP_DEPTH) {
598
- result.diagnostics.push(
599
- makeDgmoError(
600
- lineNum,
601
- `Group nesting exceeds maximum depth of ${MAX_GROUP_DEPTH}`,
602
- 'warning'
603
- )
604
- );
605
- continue;
606
- }
607
-
608
- const groupMeta = parseTailMeta(
609
- groupMatch[2] ?? '',
610
- metaAliasMap
611
- ).metadata;
612
-
613
- const parentGs = currentGroupState();
614
- const group: MutBLGroup = {
615
- label,
616
- children: [],
617
- lineNumber: lineNum,
618
- metadata: groupMeta,
619
- ...(parentGs ? { parentGroup: parentGs.group.label } : {}),
620
- };
621
-
622
- // Add nested group as child of parent group
623
- if (parentGs && indent > parentGs.indent) {
624
- parentGs.group.children.push(label);
625
- }
626
-
627
- groupLabels.add(normalizeName(label));
628
- groupStack.push({ group, indent, depth: currentDepth });
629
- lastNodeLabel = label;
630
- lastSourceIsGroup = true;
631
- continue;
632
- }
633
-
634
- // Edge detection: contains `->` or `<->`
635
- if (trimmed.includes('->') || trimmed.includes('<->')) {
636
- contentStarted = true;
637
- currentTagGroup = null;
638
- let edgeText = trimmed;
639
-
640
- // Indented shorthand: `-> Target` or `-label-> Target`
641
- if (trimmed.startsWith('->') || /^-[^>].*->/.test(trimmed)) {
642
- // If the edge is at group-child indent level, use the containing group
643
- // UNLESS lastNodeLabel is a plain node (not a group) — then the edge
644
- // is indented under that node and should source from it.
645
- const gs = currentGroupState();
646
- const inGroup = gs && indent > gs.indent;
647
- // Edge is deeper than the last node → indented under that node, use it
648
- const indentedUnderNode =
649
- lastNodeLabel && !lastSourceIsGroup && indent > lastNodeIndent;
650
- if (inGroup && !indentedUnderNode) {
651
- const sourcePrefix = `[${gs.group.label}]`;
652
- edgeText = `${sourcePrefix} ${trimmed}`;
653
- } else if (lastNodeLabel) {
654
- const sourcePrefix = lastSourceIsGroup
655
- ? `[${lastNodeLabel}]`
656
- : lastNodeLabel;
657
- edgeText = `${sourcePrefix} ${trimmed}`;
658
- } else {
659
- result.diagnostics.push(
660
- makeDgmoError(
661
- lineNum,
662
- 'Indented edge has no preceding node to use as source',
663
- 'warning'
664
- )
665
- );
666
- continue;
667
- }
668
- }
669
-
670
- const edge = parseEdgeLine(
671
- edgeText,
672
- lineNum,
673
- metaAliasMap,
674
- result.diagnostics,
675
- nameAliasMap
676
- );
677
- if (edge) {
678
- result.edges.push(edge);
679
- // Add to current group if indented
680
- // (edges don't become group children, but their nodes might)
681
- }
682
- continue;
683
- }
684
-
685
- // Node: everything else
686
- contentStarted = true;
687
- currentTagGroup = null;
688
- flushDescription(); // Flush any pending description from previous node
689
- const node = parseNodeLine(
690
- trimmed,
691
- lineNum,
692
- metaAliasMap,
693
- result.diagnostics,
694
- nameAliasMap
695
- );
696
- if (!node) {
697
- result.diagnostics.push(
698
- makeDgmoError(lineNum, `Unexpected line: '${trimmed}'.`, 'warning')
699
- );
700
- continue;
701
- }
702
- lastNodeLabel = node.label;
703
- lastSourceIsGroup = false;
704
- lastNodeIndent = indent;
705
-
706
- const gs = currentGroupState();
707
- const isGroupChild = gs && indent > gs.indent;
708
-
709
- const key = normalizeName(node.label);
710
- if (nodeLabels.has(key)) {
711
- // Already declared — if inside a group, just add as child (no duplicate)
712
- if (isGroupChild) {
713
- gs.group.children.push(node.label);
714
- continue;
715
- }
716
- result.diagnostics.push(
717
- makeDgmoError(lineNum, `Duplicate node "${node.label}"`, 'warning')
718
- );
719
- } else {
720
- nodeLabels.add(key);
721
- }
722
-
723
- // Cascade group metadata into node (group provides defaults, node overrides)
724
- if (isGroupChild) {
725
- for (const [key, val] of Object.entries(gs.group.metadata)) {
726
- if (!(key in node.metadata)) {
727
- node.metadata[key] = val;
728
- }
729
- }
730
- gs.group.children.push(node.label);
731
- }
732
-
733
- result.nodes.push(node);
734
- descState = { nodeLabel: node.label, indent, lines: [], edgeSeen: false };
735
- }
736
-
737
- // Flush any remaining description
738
- flushDescription();
739
-
740
- // Close any remaining groups
741
- while (groupStack.length > 0) {
742
- const gs = groupStack.pop()!;
743
- result.groups.push(gs.group);
744
- }
745
-
746
- // Validate group references and implicitly create node endpoints
747
- const validEdges: BLEdge[] = [];
748
- for (const edge of result.edges) {
749
- let valid = true;
750
-
751
- // Check group references exist
752
- const allGroups = Array.from(groupLabels);
753
- if (edge.source.startsWith('__group_')) {
754
- const label = edge.source.slice('__group_'.length);
755
- const found = groupLabels.has(normalizeName(label));
756
- if (!found) {
757
- let msg = `Group '[${label}]' not found`;
758
- const hint = suggest(normalizeName(label), allGroups);
759
- if (hint) msg += `. ${hint}`;
760
- result.diagnostics.push(makeDgmoError(edge.lineNumber, msg));
761
- valid = false;
762
- }
763
- } else {
764
- ensureNode(edge.source, edge.lineNumber);
765
- }
766
-
767
- if (edge.target.startsWith('__group_')) {
768
- const label = edge.target.slice('__group_'.length);
769
- const found = groupLabels.has(normalizeName(label));
770
- if (!found) {
771
- let msg = `Group '[${label}]' not found`;
772
- const hint = suggest(normalizeName(label), allGroups);
773
- if (hint) msg += `. ${hint}`;
774
- result.diagnostics.push(makeDgmoError(edge.lineNumber, msg));
775
- valid = false;
776
- }
777
- } else {
778
- ensureNode(edge.target, edge.lineNumber);
779
- }
780
-
781
- if (valid) {
782
- validEdges.push(edge);
783
- }
784
- }
785
- result.edges = validEdges;
786
-
787
- // Resolve note refs against box labels (forward refs OK). The id→note
788
- // binding is recomputed in layout; this pass surfaces diagnostics.
789
- if (notes.length > 0) {
790
- result.notes = notes;
791
- resolveNotes(
792
- notes,
793
- result.nodes.map((n) => ({ id: n.label, label: n.label })),
794
- result.diagnostics
795
- );
796
- }
797
-
798
- // Assign palette colors to bare (colorless) tag values. Boxes-and-lines
799
- // resolves explicit tag colors against the Nord defaults (no palette is
800
- // passed to extractColor above), so auto colors match for consistency.
801
- finalizeAutoTagColors(result.tagGroups as Writable<TagGroup>[]);
802
-
803
- // Attach parsed `layout` positions. Validate coverage: unknown ids warn; a
804
- // PARTIAL block (some nodes unpositioned) is honored by neither pin nor seed —
805
- // the layout engine ignores it and auto-lays-out (Decision 3, AC12), so emit a
806
- // single diagnostic naming the gap.
807
- if (nodePositions.size > 0) {
808
- const nodeLabelSet = new Set(result.nodes.map((n) => n.label));
809
- for (const id of nodePositions.keys()) {
810
- if (!nodeLabelSet.has(id)) {
811
- pushWarning(0, `layout entry for unknown node "${id}" (ignored)`);
812
- }
813
- }
814
- const unpositioned = result.nodes
815
- .filter((n) => !nodePositions.has(n.label))
816
- .map((n) => n.label);
817
- if (unpositioned.length > 0) {
818
- pushWarning(
819
- 0,
820
- `layout block is partial — ${unpositioned.length} node(s) without coordinates ` +
821
- `(${unpositioned.slice(0, 5).join(', ')}${unpositioned.length > 5 ? '…' : ''}); ` +
822
- `ignoring the block and auto-laying-out`
823
- );
824
- }
825
- result.nodePositions = nodePositions;
826
- }
827
-
828
- // Post-parse: inject default tag metadata and validate tag values
829
- if (result.tagGroups.length > 0) {
830
- injectDefaultTagMetadata(result.nodes, result.tagGroups);
831
- validateTagValues(result.nodes, result.tagGroups, pushWarning, suggest);
832
- validateTagGroupNames(result.tagGroups, pushWarning, (line, msg) => {
833
- const diag = makeDgmoError(line, msg);
834
- result.diagnostics.push(diag);
835
- if (!result.error) result.error = diag.message;
836
- });
837
- }
838
-
839
- return result;
840
- }
841
-
842
- // ============================================================
843
- // Line parsers
844
- // ============================================================
845
-
846
- /**
847
- * Parse a node line. Supports both the new §1.4 same-line form
848
- * (`Label key: value, key2: value2`) and the legacy pipe form
849
- * (`Label | key: value, ...`); the top-of-loop pipe diagnostic
850
- * already fires for the latter.
851
- */
852
- function parseNodeLine(
853
- trimmed: string,
854
- lineNum: number,
855
- metaAliasMap: Map<string, string>,
856
- diagnostics: DgmoError[],
857
- nameAliasMap?: Map<string, string>
858
- ): MutBLNode | null {
859
- const registry = withTagAliases(
860
- BOXES_AND_LINES_REGISTRY,
861
- new Set(metaAliasMap.keys())
862
- );
863
- const split = splitNameAndMeta(
864
- trimmed,
865
- registry,
866
- metaAliasMap,
867
- undefined,
868
- diagnostics,
869
- lineNum
870
- );
871
- warnUnknownMetaKeys(
872
- split.meta,
873
- registry,
874
- (msg) => diagnostics.push(makeDgmoError(lineNum, msg, 'warning')),
875
- split.name
876
- );
877
-
878
- let label = split.name;
879
- const metadata: Record<string, string> = { ...split.meta };
880
- let description: string[] | undefined;
881
- // §1.5 trailing-token color sits in the label slot for nodes
882
- // that don't store color separately — re-attach so the literal
883
- // label text matches author intent.
884
- if (split.color !== undefined) {
885
- label = `${label} ${split.color}`;
886
- }
887
-
888
- // Promote a `description` key out of metadata for the new path.
889
- if (metadata['description'] !== undefined) {
890
- description = [metadata['description']];
891
- delete metadata['description'];
892
- }
893
-
894
- // Lift `heat: X` out of metadata into a typed numeric field (mirror of the
895
- // map parser's region `heat:`). Validate finite-numeric; delete from metadata
896
- // so it never becomes a `data-tag-value` attribute.
897
- let value: number | undefined;
898
- if (metadata['heat'] !== undefined) {
899
- const raw = metadata['heat'];
900
- const num = Number(raw);
901
- if (Number.isFinite(num)) {
902
- value = num;
903
- } else {
904
- diagnostics.push(
905
- makeDgmoError(lineNum, `heat must be a number (got "${raw}")`, 'error')
906
- );
907
- }
908
- delete metadata['heat'];
909
- }
910
-
911
- // TD-18 alias is now peeled by splitNameAndMeta — re-register if set.
912
- if (split.alias) {
913
- nameAliasMap?.set(normalizeName(split.alias), label);
914
- }
915
-
916
- if (!label) return null;
917
-
918
- return {
919
- label,
920
- lineNumber: lineNum,
921
- metadata,
922
- ...(description !== undefined && { description }),
923
- ...(value !== undefined && { value }),
924
- };
925
- }
926
-
927
- /**
928
- * Split the right-hand side of an edge (`Target k: v`) into a clean
929
- * target name + parsed metadata. The metadata cut is at the first
930
- * reserved key (via splitNameAndMeta + BOXES_AND_LINES_REGISTRY).
931
- *
932
- * `[Group]` bracket targets are preserved verbatim — the bracket
933
- * literal is the target name, not a structural sigil to peel.
934
- */
935
- function splitTargetAndMeta(
936
- rest: string,
937
- metaAliasMap: Map<string, string>
938
- ): { target: string; metadata: Record<string, string> } {
939
- // §1.4 same-line: cut at the first reserved-key colon. If the
940
- // target is wrapped in `[brackets]` (group endpoint), keep the
941
- // bracketed form intact.
942
- const registry = withTagAliases(
943
- BOXES_AND_LINES_REGISTRY,
944
- new Set(metaAliasMap.keys())
945
- );
946
- const split = splitNameAndMeta(rest, registry, metaAliasMap);
947
- let target = split.name;
948
- if (split.color !== undefined) {
949
- // Colors as trailing tokens stay on the target literal for
950
- // identifier-style endpoints; reattach.
951
- target = `${target} ${split.color}`;
952
- }
953
- return { target, metadata: split.meta };
954
- }
955
-
956
- /**
957
- * Convert `[Group Name]` to `__group_Group Name`, resolve TD-18 alias
958
- * literals to their canonical name, otherwise return as-is.
959
- */
960
- function resolveEndpoint(
961
- name: string,
962
- nameAliasMap?: Map<string, string>
963
- ): string {
964
- const m = name.match(/^\[(.+)\]$/);
965
- // Regex capture group present after successful match.
966
- if (m) return groupId(m[1]!.trim());
967
- if (nameAliasMap) {
968
- const aliased = nameAliasMap.get(name.trim());
969
- if (aliased !== undefined) return aliased;
970
- }
971
- return name;
972
- }
973
-
974
- /**
975
- * Parse an edge line. Supports:
976
- * - `Source -> Target`
977
- * - `Source -> Target key: value`
978
- * - `Source -label-> Target`
979
- * - `Source <-> Target`
980
- * - `Source <-label-> Target`
981
- * - `Source -label-> Target key: value`
982
- *
983
- * `[Group Name]` in source or target position is resolved to `__group_Group Name`.
984
- */
985
- function parseEdgeLine(
986
- trimmed: string,
987
- lineNum: number,
988
- metaAliasMap: Map<string, string>,
989
- diagnostics: DgmoError[],
990
- nameAliasMap?: Map<string, string>
991
- ): BLEdge | null {
992
- const edgeRegistry = withTagAliases(
993
- BOXES_AND_LINES_REGISTRY,
994
- new Set(metaAliasMap.keys())
995
- );
996
- // Check for bidirectional labeled: `Source <-label-> Target`
997
- const biLabeledMatch = trimmed.match(/^(.+?)\s*<-(.+)->\s*(.+)$/);
998
- if (biLabeledMatch) {
999
- // Regex capture groups present after successful match.
1000
- const rawSource = biLabeledMatch[1]!.trim();
1001
- const source = resolveEndpoint(rawSource, nameAliasMap);
1002
- const labelResult = parseInArrowLabel(biLabeledMatch[2]!, lineNum);
1003
- diagnostics.push(...labelResult.diagnostics);
1004
- const label = labelResult.label;
1005
- let rest = biLabeledMatch[3]!.trim();
1006
-
1007
- const { target: biTarget, metadata } = splitTargetAndMeta(
1008
- rest,
1009
- metaAliasMap
1010
- );
1011
- warnUnknownMetaKeys(metadata, edgeRegistry, (msg) =>
1012
- diagnostics.push(makeDgmoError(lineNum, msg, 'warning'))
1013
- );
1014
- rest = biTarget;
1015
-
1016
- if (!source || !rest) {
1017
- diagnostics.push(
1018
- makeDgmoError(lineNum, 'Edge is missing source or target')
1019
- );
1020
- return null;
1021
- }
1022
-
1023
- if (rawSource.endsWith(':') || rest.endsWith(':')) {
1024
- diagnostics.push(
1025
- makeDgmoError(
1026
- lineNum,
1027
- `Trailing colon is not valid — write '${rawSource.replace(/:$/, '')} <-> ${rest.replace(/:$/, '')}' instead`
1028
- )
1029
- );
1030
- return null;
1031
- }
1032
-
1033
- return {
1034
- source,
1035
- target: resolveEndpoint(rest, nameAliasMap),
1036
- ...(label !== undefined && { label }),
1037
- bidirectional: true,
1038
- lineNumber: lineNum,
1039
- metadata,
1040
- };
1041
- }
1042
-
1043
- // Check for bidirectional plain: `Source <-> Target`
1044
- const biIdx = trimmed.indexOf('<->');
1045
- if (biIdx >= 0) {
1046
- const rawSource = trimmed.slice(0, biIdx).trim();
1047
- const source = resolveEndpoint(rawSource, nameAliasMap);
1048
- let rest = trimmed.slice(biIdx + 3).trim();
1049
-
1050
- const { target: plainTarget, metadata } = splitTargetAndMeta(
1051
- rest,
1052
- metaAliasMap
1053
- );
1054
- warnUnknownMetaKeys(metadata, edgeRegistry, (msg) =>
1055
- diagnostics.push(makeDgmoError(lineNum, msg, 'warning'))
1056
- );
1057
- rest = plainTarget;
1058
-
1059
- if (!source || !rest) {
1060
- diagnostics.push(
1061
- makeDgmoError(lineNum, 'Edge is missing source or target')
1062
- );
1063
- return null;
1064
- }
1065
-
1066
- if (rawSource.endsWith(':') || rest.endsWith(':')) {
1067
- diagnostics.push(
1068
- makeDgmoError(
1069
- lineNum,
1070
- `Trailing colon is not valid — write '${rawSource.replace(/:$/, '')} <-> ${rest.replace(/:$/, '')}' instead`
1071
- )
1072
- );
1073
- return null;
1074
- }
1075
-
1076
- return {
1077
- source,
1078
- target: resolveEndpoint(rest, nameAliasMap),
1079
- bidirectional: true,
1080
- lineNumber: lineNum,
1081
- metadata,
1082
- };
1083
- }
1084
-
1085
- // Check for labeled arrow: `Source -label-> Target` (label lazy → split
1086
- // at the first arrow, consistent with the other parsers).
1087
- const labeledMatch = trimmed.match(/^(.+?)\s+-(.+?)->\s*(.+)$/);
1088
- if (labeledMatch) {
1089
- // Regex capture groups present after successful match.
1090
- const rawSource = labeledMatch[1]!.trim();
1091
- const source = resolveEndpoint(rawSource, nameAliasMap);
1092
- const labelResult = parseInArrowLabel(labeledMatch[2]!, lineNum);
1093
- diagnostics.push(...labelResult.diagnostics);
1094
- const label = labelResult.label;
1095
- let rest = labeledMatch[3]!.trim();
1096
-
1097
- if (label) {
1098
- const { target: labeledTarget, metadata } = splitTargetAndMeta(
1099
- rest,
1100
- metaAliasMap
1101
- );
1102
- warnUnknownMetaKeys(metadata, edgeRegistry, (msg) =>
1103
- diagnostics.push(makeDgmoError(lineNum, msg, 'warning'))
1104
- );
1105
- rest = labeledTarget;
1106
-
1107
- if (!source || !rest) {
1108
- diagnostics.push(
1109
- makeDgmoError(lineNum, 'Edge is missing source or target')
1110
- );
1111
- return null;
1112
- }
1113
-
1114
- if (rawSource.endsWith(':') || rest.endsWith(':')) {
1115
- diagnostics.push(
1116
- makeDgmoError(
1117
- lineNum,
1118
- `Trailing colon is not valid — write '${rawSource.replace(/:$/, '')} -> ${rest.replace(/:$/, '')}' instead`
1119
- )
1120
- );
1121
- return null;
1122
- }
1123
-
1124
- return {
1125
- source,
1126
- target: resolveEndpoint(rest, nameAliasMap),
1127
- label,
1128
- bidirectional: false,
1129
- lineNumber: lineNum,
1130
- metadata,
1131
- };
1132
- }
1133
- }
1134
-
1135
- // Plain arrow: `Source -> Target`
1136
- const arrowIdx = trimmed.indexOf('->');
1137
- if (arrowIdx < 0) return null;
1138
-
1139
- const rawSource = trimmed.slice(0, arrowIdx).trim();
1140
- const source = resolveEndpoint(rawSource, nameAliasMap);
1141
- let rest = trimmed.slice(arrowIdx + 2).trim();
1142
-
1143
- if (!source || !rest) {
1144
- diagnostics.push(
1145
- makeDgmoError(lineNum, 'Edge is missing source or target')
1146
- );
1147
- return null;
1148
- }
1149
-
1150
- const { target: plainTarget, metadata } = splitTargetAndMeta(
1151
- rest,
1152
- metaAliasMap
1153
- );
1154
- warnUnknownMetaKeys(metadata, edgeRegistry, (msg) =>
1155
- diagnostics.push(makeDgmoError(lineNum, msg, 'warning'))
1156
- );
1157
- rest = plainTarget;
1158
-
1159
- if (!rest) {
1160
- diagnostics.push(makeDgmoError(lineNum, 'Edge is missing target'));
1161
- return null;
1162
- }
1163
-
1164
- if (rawSource.endsWith(':') || rest.endsWith(':')) {
1165
- diagnostics.push(
1166
- makeDgmoError(
1167
- lineNum,
1168
- `Trailing colon is not valid — write '${rawSource.replace(/:$/, '')} -> ${rest.replace(/:$/, '')}' instead`
1169
- )
1170
- );
1171
- return null;
1172
- }
1173
-
1174
- return {
1175
- source,
1176
- target: resolveEndpoint(rest, nameAliasMap),
1177
- bidirectional: false,
1178
- lineNumber: lineNum,
1179
- metadata,
1180
- };
1181
- }