@diagrammo/dgmo 0.94.0 → 0.96.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 (220) hide show
  1. package/README.md +1 -1
  2. package/dist/advanced.d.ts +97 -570
  3. package/dist/advanced.js +176 -352
  4. package/dist/block.d.ts +6 -0
  5. package/dist/block.js +59 -57
  6. package/dist/{calculator-BNH3GSJE.js → calculator-GIB7POFX.js} +2 -2
  7. package/dist/{chart-meta-BbjsRY7o.d.ts → chart-meta-uImk4eTn.d.ts} +1 -1
  8. package/dist/chart-meta.d.ts +2 -2
  9. package/dist/chart-meta.js +16 -16
  10. package/dist/{chart-types-Cppnp31G.d.ts → chart-types-CBVYiLqy.d.ts} +1 -5
  11. package/dist/{charts-d3-SZV2SFTM.js → charts-d3-IRP5VANE.js} +5 -5
  12. package/dist/{chunk-MLY5ALOV.js → chunk-2BYFNZVM.js} +2 -2
  13. package/dist/{chunk-OSSTOSXU.js → chunk-2M3K6GD2.js} +3 -6
  14. package/dist/{chunk-CDM6XMOT.js → chunk-34JOHSVE.js} +2 -2
  15. package/dist/chunk-35A3J4Z5.js +14 -0
  16. package/dist/{chunk-HI6R27YA.js → chunk-3W73ZP6W.js} +9 -4
  17. package/dist/{chunk-IHN6WDEY.js → chunk-4B45SNZH.js} +5 -5
  18. package/dist/{chunk-AULZD45V.js → chunk-5ARANBIE.js} +2 -2
  19. package/dist/{chunk-DDIOWNHS.js → chunk-5BG4OSWJ.js} +6 -6
  20. package/dist/{chunk-6JCTW74W.js → chunk-5G4DOOX2.js} +1 -1
  21. package/dist/{chunk-JT2BG7LM.js → chunk-5GU6C5WB.js} +3 -3
  22. package/dist/{chunk-EBIDNRSR.js → chunk-5H7SA5ZD.js} +1 -1
  23. package/dist/{chunk-CN4RDJDV.js → chunk-5LG526X7.js} +1 -1
  24. package/dist/{chunk-VDY2GR6U.js → chunk-67N26CER.js} +2 -2
  25. package/dist/{chunk-G3HZ4PGE.js → chunk-67RKJEKF.js} +6 -6
  26. package/dist/{chunk-D3K4U3ZM.js → chunk-6K2W3FH7.js} +8 -5
  27. package/dist/{chunk-C6G36F5S.js → chunk-7UWVHNPM.js} +4 -4
  28. package/dist/{chunk-FWVE373X.js → chunk-AQRSEQZV.js} +1 -1
  29. package/dist/{chunk-BQO24BDM.js → chunk-AUXUNV73.js} +1 -1
  30. package/dist/{chunk-3PP746YM.js → chunk-B2YVZ3QU.js} +1 -1
  31. package/dist/{chunk-QPQWY5RU.js → chunk-B5CEV7IR.js} +3 -3
  32. package/dist/{chunk-J7Q4AB23.js → chunk-B7BSRVNC.js} +2 -2
  33. package/dist/{chunk-IXHWS2HI.js → chunk-BD4O4D2A.js} +2 -2
  34. package/dist/{chunk-4TEPDQHJ.js → chunk-BUVLLK3D.js} +7 -7
  35. package/dist/{chunk-B25IWGDH.js → chunk-CD7VQCDL.js} +8 -8
  36. package/dist/{chunk-I37S3EZE.js → chunk-CP73WWLN.js} +371 -286
  37. package/dist/{chunk-GI5R5B3S.js → chunk-D7DGLJ7N.js} +2 -2
  38. package/dist/{chunk-3TWBMU7K.js → chunk-DKCVAQU3.js} +9 -9
  39. package/dist/{chunk-KBDMEOLI.js → chunk-DPNSDCR3.js} +1 -1
  40. package/dist/{chunk-BRGRIZQB.js → chunk-DWMQ24JR.js} +2 -2
  41. package/dist/{chunk-4XYZJTFO.js → chunk-EM5SA7NC.js} +11 -3
  42. package/dist/{chunk-AM42TLSZ.js → chunk-EMGNCG5C.js} +1 -1
  43. package/dist/{chunk-3KVUFHUJ.js → chunk-EPB3UEMD.js} +2 -2
  44. package/dist/{chunk-NXU4N5WT.js → chunk-EZ6BI5LL.js} +1 -1
  45. package/dist/{chunk-2ZW4NBYX.js → chunk-FBK32S4D.js} +1 -1
  46. package/dist/{chunk-2I4UQG7W.js → chunk-FHX373L5.js} +1 -1
  47. package/dist/{chunk-AQQUJEDN.js → chunk-FKJWZWNU.js} +1 -1
  48. package/dist/{chunk-TIIZIAGS.js → chunk-FUYEXLAN.js} +6 -13
  49. package/dist/{chunk-TASRGDYP.js → chunk-GEHK4UD5.js} +3 -3
  50. package/dist/{chunk-ZD3QCNB7.js → chunk-GLL237AP.js} +2 -2
  51. package/dist/{chunk-PGSGJLUR.js → chunk-GM2SLMQW.js} +2 -2
  52. package/dist/{chunk-NOQB4KMV.js → chunk-H7JVKUA5.js} +5 -5
  53. package/dist/{chunk-DNM3XZCK.js → chunk-H7RQG4PH.js} +2 -2
  54. package/dist/{chunk-7SXV7NUS.js → chunk-HH3DHNQA.js} +2 -2
  55. package/dist/{chunk-GWQRTA5W.js → chunk-HZX4QZGR.js} +1 -1
  56. package/dist/{chunk-KBEWVCK3.js → chunk-I2I2FKAK.js} +1 -1
  57. package/dist/{chunk-2HSHWPTO.js → chunk-I3ZRIMR7.js} +10 -10
  58. package/dist/{chunk-7IOZ6JE4.js → chunk-IKXQ6NVR.js} +7 -7
  59. package/dist/{chunk-XJQ6Z3FO.js → chunk-IQZSKWE5.js} +3 -3
  60. package/dist/{chunk-3GUEYQGL.js → chunk-ITDF3MWD.js} +3 -3
  61. package/dist/{chunk-JXGSTBW6.js → chunk-IU7XKZA6.js} +2 -2
  62. package/dist/{chunk-RITTLIDJ.js → chunk-IZFJZCF6.js} +4 -4
  63. package/dist/{chunk-DRQSB72S.js → chunk-JBAFAKGX.js} +7 -7
  64. package/dist/{chunk-VSAKEMDD.js → chunk-JCC3B2GS.js} +8 -2
  65. package/dist/{chunk-66JTY4AN.js → chunk-JRN2CRXJ.js} +1 -1
  66. package/dist/{chunk-2FDQEQID.js → chunk-K2SFH3GJ.js} +2 -2
  67. package/dist/{chunk-NM5V5EKY.js → chunk-K2WXMXI2.js} +1 -1
  68. package/dist/{chunk-XKCRKD2B.js → chunk-KDWEOT54.js} +24 -12
  69. package/dist/{chunk-PVWIBKV2.js → chunk-KQAPFIYF.js} +2 -2
  70. package/dist/{chunk-4SACN2C5.js → chunk-LGUFJ7Y2.js} +1 -1
  71. package/dist/{chunk-AYUSD4Z6.js → chunk-LRHPBWOY.js} +5 -5
  72. package/dist/{chunk-DLJJOCIT.js → chunk-M4ZUIW3J.js} +3 -3
  73. package/dist/{chunk-CIHHTS5B.js → chunk-MAYTYF5S.js} +3 -3
  74. package/dist/{chunk-5ZUZZDW5.js → chunk-MVUNMJKO.js} +46 -52
  75. package/dist/{chunk-KBHT5XEY.js → chunk-MYHR3PMH.js} +194 -35
  76. package/dist/{chunk-NBAAIRFP.js → chunk-NI4L6HEU.js} +4 -1
  77. package/dist/{chunk-A2A2I4Z4.js → chunk-O2HNVNKO.js} +2 -2
  78. package/dist/{chunk-2XMTZ5JR.js → chunk-OAZ6BIIB.js} +3 -3
  79. package/dist/{chunk-IZHGT5HD.js → chunk-OO4GUE4E.js} +3 -3
  80. package/dist/{chunk-KSZB7TIY.js → chunk-OYGJZA24.js} +8 -8
  81. package/dist/{chunk-H6BT45SN.js → chunk-P2GNNEMN.js} +1 -1
  82. package/dist/{chunk-5HAYT43L.js → chunk-P3PSLC2K.js} +22 -6
  83. package/dist/{chunk-HHVIE45A.js → chunk-P6LKX3IQ.js} +4 -4
  84. package/dist/{chunk-NMS5XSLX.js → chunk-PGD6CNWO.js} +1 -1
  85. package/dist/{chunk-NVZ7R4EK.js → chunk-PWZEJNO6.js} +3 -3
  86. package/dist/{chunk-NPDVWFAQ.js → chunk-QEU6VM4O.js} +1 -1
  87. package/dist/{chunk-UIEKW4SG.js → chunk-R5L5E3TC.js} +0 -1
  88. package/dist/{chunk-2WQ3YZMN.js → chunk-RGFVHYDP.js} +2 -2
  89. package/dist/{chunk-YQMIKX54.js → chunk-RIK6WUMO.js} +62 -29
  90. package/dist/{chunk-BH2SF4TT.js → chunk-RTRORHSP.js} +1 -1
  91. package/dist/{chunk-4SP6OUO7.js → chunk-RVOSA4RR.js} +845 -193
  92. package/dist/{chunk-LKZCUFOW.js → chunk-SCYVGPLI.js} +2 -2
  93. package/dist/{chunk-XIUGSUE4.js → chunk-SIABEREK.js} +6 -2
  94. package/dist/{chunk-P7TRFL4P.js → chunk-SQBCNEJB.js} +4 -1
  95. package/dist/{chunk-3ZP3QC47.js → chunk-THTYCJGF.js} +2 -2
  96. package/dist/{chunk-4EX4OKGZ.js → chunk-TIPNNOZC.js} +5 -5
  97. package/dist/{chunk-UZ7EZW3B.js → chunk-TO53KK2P.js} +6 -1
  98. package/dist/{chunk-2MS623GW.js → chunk-TPCP2UOI.js} +3 -3
  99. package/dist/{chunk-Y3SIQN4J.js → chunk-TUOZ6AXC.js} +2 -2
  100. package/dist/{chunk-KRPLP5LP.js → chunk-U6N547QA.js} +1 -1
  101. package/dist/{chunk-RESEJSCV.js → chunk-VJ7NLYFE.js} +2 -2
  102. package/dist/{chunk-UXNA2H2V.js → chunk-VLI6AWS3.js} +2 -2
  103. package/dist/{chunk-TDAGJJPZ.js → chunk-VNAPEZX2.js} +1 -1
  104. package/dist/{chunk-EBVVMUAA.js → chunk-VVTCUIPN.js} +1 -1
  105. package/dist/{chunk-FVTYJUXR.js → chunk-W5MMPPGX.js} +2 -2
  106. package/dist/{chunk-BQMHJ6OW.js → chunk-WGNP5ND2.js} +20 -12
  107. package/dist/{chunk-5OTA2PUH.js → chunk-WLGOIMTI.js} +2 -2
  108. package/dist/{chunk-IGJEKO2P.js → chunk-WTPS73RM.js} +4 -4
  109. package/dist/{chunk-R6EGUTIV.js → chunk-YFIUABSF.js} +2 -2
  110. package/dist/{chunk-7PJBJ2DU.js → chunk-YSGOXZBB.js} +1 -1
  111. package/dist/{chunk-ZECJ7Q6C.js → chunk-YVIPJGFG.js} +2 -2
  112. package/dist/{chunk-5KKZXA44.js → chunk-ZBOIYC2G.js} +4 -2
  113. package/dist/{chunk-RBVFNUAL.js → chunk-ZOKD5F7M.js} +2 -2
  114. package/dist/{collapse-BSPH3BFM.js → collapse-6X5S2S3G.js} +2 -1
  115. package/dist/completion-registry.js +6 -37
  116. package/dist/copy-image.d.ts +34 -0
  117. package/dist/copy-image.js +96 -0
  118. package/dist/countdown.js +1 -1
  119. package/dist/dgmo-router-EPBQKQW2.js +100 -0
  120. package/dist/{dimensions-DS6FWLRY.js → dimensions-DBCRBZIU.js} +4 -4
  121. package/dist/editor.js +2 -7
  122. package/dist/{flowchart-parser-NZXASOZG.js → flowchart-parser-SM5LHF2D.js} +4 -4
  123. package/dist/{flowchart-renderer-PTCRIANF.js → flowchart-renderer-PPS2GTTD.js} +10 -10
  124. package/dist/highlight.js +3 -8
  125. package/dist/index.d.ts +42 -6
  126. package/dist/index.js +62 -57
  127. package/dist/{layout-MXHR3P35.js → layout-3J72UULM.js} +3 -3
  128. package/dist/{layout-U3AH6M7J.js → layout-AF4KA5B2.js} +4 -4
  129. package/dist/{layout-IT4ZTV6C.js → layout-FCFUVCRI.js} +7 -7
  130. package/dist/{layout-KV27UW25.js → layout-H2KP5A6M.js} +1 -1
  131. package/dist/{layout-ND26WVX2.js → layout-IXQNVRBE.js} +3 -3
  132. package/dist/{layout-ISSBWBH7.js → layout-KELSNWBD.js} +7 -7
  133. package/dist/{layout-JTIRCKAW.js → layout-LNVIH45F.js} +3 -3
  134. package/dist/{layout-VC3MXRB4.js → layout-MPSH3YWE.js} +7 -7
  135. package/dist/{layout-HFBK5UEG.js → layout-PPIVGJXD.js} +2 -2
  136. package/dist/{layout-RH3N46HP.js → layout-R6G4MEO3.js} +4 -3
  137. package/dist/{layout-search-BBX2BMEF.js → layout-search-C2TYUH4L.js} +5 -5
  138. package/dist/{parser-BT4NI6JY.js → parser-2AXU2MHJ.js} +3 -3
  139. package/dist/{parser-3QIFY5IN.js → parser-4BOP77CD.js} +2 -2
  140. package/dist/{parser-TAYRTCPR.js → parser-4GHAYZKZ.js} +5 -5
  141. package/dist/{parser-LTRQASGB.js → parser-5HQPPVHJ.js} +3 -3
  142. package/dist/{parser-EAQPZX2B.js → parser-5RUD4A3X.js} +3 -3
  143. package/dist/{parser-BJ7RJNUM.js → parser-6WURFLOB.js} +3 -3
  144. package/dist/{parser-R3LPEQIT.js → parser-722KLLAQ.js} +4 -4
  145. package/dist/{parser-KMKVFET2.js → parser-B7SCN7FG.js} +2 -2
  146. package/dist/{parser-TUAEX6ML.js → parser-BNRX35NT.js} +3 -3
  147. package/dist/{parser-NL73FSFI.js → parser-BPYHIG24.js} +3 -3
  148. package/dist/{parser-3LT3ZUUC.js → parser-CRJYLOHA.js} +2 -2
  149. package/dist/{parser-NUU3DVW4.js → parser-DGLKH4NT.js} +2 -2
  150. package/dist/{parser-5UZV32ZI.js → parser-DRUGM3R6.js} +2 -2
  151. package/dist/{parser-KLCSFQ3J.js → parser-DWV2CYBS.js} +3 -3
  152. package/dist/{parser-2IKPQVKX.js → parser-F3JJNIFC.js} +3 -3
  153. package/dist/{parser-EFF22GYO.js → parser-F75WNYMK.js} +3 -3
  154. package/dist/{parser-RTWPFKXG.js → parser-GBQY3WOZ.js} +3 -3
  155. package/dist/{parser-F7NDRPMA.js → parser-GM5B2EPW.js} +3 -3
  156. package/dist/{parser-K2DI26SC.js → parser-H6HT2WFQ.js} +2 -2
  157. package/dist/{parser-PEZ7RN43.js → parser-HM6FEX5K.js} +3 -3
  158. package/dist/{parser-YG625J5H.js → parser-L7SI3PW4.js} +4 -4
  159. package/dist/{parser-GMQJISZ6.js → parser-LUJX7AXO.js} +2 -2
  160. package/dist/{parser-A3AN76RQ.js → parser-MWINQNQW.js} +3 -3
  161. package/dist/{parser-KJPPUN4D.js → parser-OHBBDCG4.js} +2 -2
  162. package/dist/{parser-4RFY7D52.js → parser-QWTECQEC.js} +5 -5
  163. package/dist/{parser-4TBSWULQ.js → parser-TTGZYLYD.js} +3 -3
  164. package/dist/{parser-6TDWUKM5.js → parser-UHKROC7Z.js} +3 -3
  165. package/dist/{parser-H5OODY5N.js → parser-W6NX3AIV.js} +3 -3
  166. package/dist/{parser-GDLKUBTO.js → parser-WIKXZP4X.js} +2 -2
  167. package/dist/{parser-4Y6PODW6.js → parser-XEJP37GQ.js} +3 -3
  168. package/dist/{parser-RCIEKN7Y.js → parser-Y7QXD2UR.js} +2 -2
  169. package/dist/{parser-7QKQ4P4P.js → parser-ZV756RMP.js} +5 -5
  170. package/dist/{parser-KKF6Y5MM.js → parser-ZWWQZ4XZ.js} +4 -3
  171. package/dist/{redraw-AHW7EUUF.js → redraw-BZ4GI6IC.js} +6 -4
  172. package/dist/{redraw-STZ4WJAI.js → redraw-LEOXS7C6.js} +3 -3
  173. package/dist/{renderer-J3GPDK73.js → renderer-2MCV75JQ.js} +12 -12
  174. package/dist/{renderer-TINHO2IO.js → renderer-2V2XY2V7.js} +4 -4
  175. package/dist/{renderer-PHLCYVSN.js → renderer-5AEDVLAA.js} +8 -7
  176. package/dist/{renderer-W4MUMXJE.js → renderer-5GP7YUS4.js} +3 -3
  177. package/dist/{renderer-FMTLSOCX.js → renderer-66NCRXSC.js} +6 -6
  178. package/dist/{renderer-AM7P4LN7.js → renderer-6HU44IGJ.js} +4 -4
  179. package/dist/{renderer-JJ4QW3SK.js → renderer-7C76HP5W.js} +6 -6
  180. package/dist/{renderer-O6RP52CQ.js → renderer-7RAMBMTH.js} +6 -6
  181. package/dist/{renderer-M5DUMITP.js → renderer-BYLQ37T2.js} +8 -8
  182. package/dist/{renderer-7OGGV327.js → renderer-CVCCW7UT.js} +4 -4
  183. package/dist/{renderer-QTPWRRJ7.js → renderer-D6EH5UQ6.js} +6 -6
  184. package/dist/renderer-E3334XLT.js +84 -0
  185. package/dist/{renderer-IXBOT6DU.js → renderer-F7YGMEGQ.js} +2 -2
  186. package/dist/{renderer-XCLARXCK.js → renderer-GKY55M4Z.js} +5 -5
  187. package/dist/{renderer-KJ3V5BYP.js → renderer-LFZKG2GR.js} +5 -5
  188. package/dist/{renderer-2LYX6NHN.js → renderer-LJPUCG3U.js} +5 -5
  189. package/dist/{renderer-DAZWHNLI.js → renderer-MGF2NNGG.js} +3 -3
  190. package/dist/{renderer-HX6ICPDX.js → renderer-MVBAQP3M.js} +4 -4
  191. package/dist/{renderer-XOWDERU2.js → renderer-MZIWP55B.js} +5 -5
  192. package/dist/{renderer-MWZC7TMD.js → renderer-N6PM5CSG.js} +7 -7
  193. package/dist/{renderer-ISQJ2ELA.js → renderer-N75E3UVY.js} +5 -5
  194. package/dist/{renderer-53B523PM.js → renderer-ONENGXFQ.js} +7 -7
  195. package/dist/{renderer-RUSQJFFC.js → renderer-PEJF6R2I.js} +2 -2
  196. package/dist/{renderer-36446HSH.js → renderer-QZJZIAT3.js} +2 -2
  197. package/dist/{renderer-UTEEJDGB.js → renderer-SYRH3B62.js} +6 -6
  198. package/dist/{renderer-LNP23NSM.js → renderer-TS5NHOQD.js} +6 -6
  199. package/dist/{renderer-J7ZSTJUE.js → renderer-VNJOZPSH.js} +7 -7
  200. package/dist/{renderer-OUDHH5MV.js → renderer-VNUDN6F5.js} +12 -12
  201. package/dist/{renderer-JYHA6R2D.js → renderer-VUXAAGUG.js} +5 -5
  202. package/dist/{renderer-BXD5KVSR.js → renderer-YJVQT7QG.js} +6 -6
  203. package/dist/{renderer-radial-WFUX3Z3C.js → renderer-radial-4R7AKETK.js} +5 -5
  204. package/dist/{state-parser-KPVW5CRI.js → state-parser-EQBBEKHR.js} +5 -5
  205. package/dist/{state-renderer-ZVEI265C.js → state-renderer-SOGZ2CNN.js} +12 -12
  206. package/dist/{themes-DzIH3Hjv.d.ts → themes-CbJL3w8L.d.ts} +1 -1
  207. package/docs/ai-integration.md +5 -6
  208. package/docs/language-reference.md +69 -105
  209. package/gallery/fixtures/whiteboard.dgmo +1 -0
  210. package/package.json +5 -1
  211. package/dist/chunk-6BQSDF77.js +0 -734
  212. package/dist/chunk-NWSPPGIE.js +0 -60
  213. package/dist/chunk-VBMRZCMQ.js +0 -1465
  214. package/dist/chunk-WZBZXZ6T.js +0 -636
  215. package/dist/dgmo-router-E5O7RJSW.js +0 -101
  216. package/dist/layout-D4L44NRG.js +0 -11
  217. package/dist/parser-YHDGKPZI.js +0 -14
  218. package/dist/renderer-4SE7R22T.js +0 -85
  219. package/dist/renderer-WPN2SXGT.js +0 -29
  220. package/gallery/fixtures/sketch.dgmo +0 -22
@@ -1,636 +0,0 @@
1
- import {
2
- SKETCH_DIAGNOSTIC_CODES
3
- } from "./chunk-NWSPPGIE.js";
4
- import {
5
- parseInArrowLabel
6
- } from "./chunk-N7VMGZCU.js";
7
- import {
8
- normalizeName
9
- } from "./chunk-NOTA6TEI.js";
10
- import {
11
- AUTO_TAG_COLOR_SENTINEL,
12
- finalizeAutoTagColors,
13
- injectDefaultTagMetadata,
14
- matchTagBlockHeading,
15
- stripDefaultModifier,
16
- tagAttrKey,
17
- validateTagGroupNames,
18
- validateTagValues
19
- } from "./chunk-4SACN2C5.js";
20
- import {
21
- SKETCH_REGISTRY,
22
- extractColor,
23
- fillModeFromToken,
24
- measureIndent,
25
- parseFirstLine,
26
- recognizeGlobalBoolean,
27
- splitNameAndMeta,
28
- stripQuotes,
29
- warnUnknownMetaKeys,
30
- withTagAliases
31
- } from "./chunk-TIIZIAGS.js";
32
- import {
33
- NAME_DIAGNOSTIC_CODES,
34
- formatDgmoError,
35
- makeDgmoError,
36
- makeFail,
37
- nameMergedMessage,
38
- suggest
39
- } from "./chunk-BYU54C3S.js";
40
-
41
- // src/sketch/parser.ts
42
- var EDGE_FORMS = [
43
- { re: /^<-(.+?)->\s*(.+)$/, heads: "both", dashed: false, labeled: true },
44
- { re: /^<~(.+?)~>\s*(.+)$/, heads: "both", dashed: true, labeled: true },
45
- { re: /^<->\s*(.+)$/, heads: "both", dashed: false, labeled: false },
46
- { re: /^<~>\s*(.+)$/, heads: "both", dashed: true, labeled: false },
47
- { re: /^-(.+?)->\s*(.+)$/, heads: "one", dashed: false, labeled: true },
48
- { re: /^~(.+?)~>\s*(.+)$/, heads: "one", dashed: true, labeled: true },
49
- { re: /^->\s*(.+)$/, heads: "one", dashed: false, labeled: false },
50
- { re: /^~>\s*(.+)$/, heads: "one", dashed: true, labeled: false },
51
- { re: /^--\s+(.+)$/, heads: "none", dashed: false, labeled: false },
52
- { re: /^~~\s+(.+)$/, heads: "none", dashed: true, labeled: false },
53
- { re: /^-(.+?)-\s+(.+)$/, heads: "none", dashed: false, labeled: true },
54
- { re: /^~(.+?)~\s+(.+)$/, heads: "none", dashed: true, labeled: true }
55
- ];
56
- var EDGE_START_RE = /^[<\-~]/;
57
- var LEFT_ARROW_RE = /^<[-~](?![-~]?>)/;
58
- var BOX_RE = /^\[([^\]]*)\]\s*(.*)$/;
59
- var BOX_TAIL_ALIAS_RE = /^as\s+([A-Za-z][A-Za-z0-9_]{0,11})(?=\s|,|$)\s*,?\s*/;
60
- var AT_VALUE_RE = /^(-?\d+)\s+(-?\d+)$/;
61
- var SKETCH_AT_MAX = 2e3;
62
- var MAX_BOX_DEPTH = 2;
63
- function parseSketch(content, palette) {
64
- const options = {
65
- noLegend: false,
66
- legendInline: false,
67
- fillMode: void 0,
68
- noDescriptions: false,
69
- noTitle: false
70
- };
71
- const result = {
72
- type: "sketch",
73
- title: null,
74
- titleLineNumber: null,
75
- nodes: [],
76
- edges: [],
77
- boxes: [],
78
- tagGroups: [],
79
- options,
80
- diagnostics: [],
81
- error: null
82
- };
83
- const fail = makeFail(result);
84
- const pushError = (line, message, code) => {
85
- result.diagnostics.push(makeDgmoError(line, message, "error", code));
86
- };
87
- const warn = (line, message, code) => {
88
- result.diagnostics.push(makeDgmoError(line, message, "warning", code));
89
- };
90
- if (!content?.trim()) {
91
- return fail(0, "No content provided");
92
- }
93
- const lines = content.split("\n");
94
- const nodes = [];
95
- const boxes = [];
96
- const nodeById = /* @__PURE__ */ new Map();
97
- const aliasIndex = /* @__PURE__ */ new Map();
98
- const labelIndex = /* @__PURE__ */ new Map();
99
- const boxByNorm = /* @__PURE__ */ new Map();
100
- const pendingEdges = [];
101
- const tagAliasMap = /* @__PURE__ */ new Map();
102
- let idCounter = 0;
103
- const registryFor = () => withTagAliases(SKETCH_REGISTRY, new Set(tagAliasMap.keys()));
104
- const parseAt = (raw, lineNumber) => {
105
- if (raw === void 0) return null;
106
- const m = raw.trim().match(AT_VALUE_RE);
107
- if (!m) {
108
- warn(
109
- lineNumber,
110
- `Invalid at: value "${raw}" \u2014 expected two integers (at: C R); shape will flow-place`
111
- );
112
- return null;
113
- }
114
- const c = parseInt(m[1], 10);
115
- const r = parseInt(m[2], 10);
116
- if (!Number.isSafeInteger(c) || !Number.isSafeInteger(r) || Math.abs(c) > SKETCH_AT_MAX || Math.abs(r) > SKETCH_AT_MAX) {
117
- warn(
118
- lineNumber,
119
- `at: coordinate "${raw}" is out of range \u2014 half-slot coords must be whole numbers within \xB1${SKETCH_AT_MAX}; shape will flow-place`,
120
- SKETCH_DIAGNOSTIC_CODES.AT_OUT_OF_RANGE
121
- );
122
- return null;
123
- }
124
- return { c, r };
125
- };
126
- const liftReserved = (meta, lineNumber) => {
127
- const shapeRaw = meta["shape"];
128
- if (shapeRaw !== void 0) {
129
- pushError(
130
- lineNumber,
131
- `shape: ${shapeRaw.trim()} is not supported in sketch \u2014 every box is a plain rectangle; remove the shape: clause`,
132
- SKETCH_DIAGNOSTIC_CODES.SHAPE_UNSUPPORTED
133
- );
134
- delete meta["shape"];
135
- }
136
- const at = parseAt(meta["at"], lineNumber);
137
- delete meta["at"];
138
- delete meta["collapsed"];
139
- return { at };
140
- };
141
- const addShape = (trimmed, lineNumber, box) => {
142
- const snm = splitNameAndMeta(
143
- trimmed,
144
- registryFor(),
145
- tagAliasMap,
146
- palette,
147
- result.diagnostics,
148
- lineNumber
149
- );
150
- let label = stripQuotes(snm.name.trim()).trim();
151
- if (snm.color) label = `${label} ${snm.color}`.trim();
152
- if (!label) {
153
- warn(lineNumber, `Shape line has no name \u2014 ignored`);
154
- return null;
155
- }
156
- const meta = { ...snm.meta };
157
- warnUnknownMetaKeys(
158
- meta,
159
- registryFor(),
160
- (m) => warn(lineNumber, m),
161
- snm.name
162
- );
163
- const { at } = liftReserved(meta, lineNumber);
164
- const norm = normalizeName(label);
165
- if (snm.alias !== void 0 && aliasIndex.has(snm.alias)) {
166
- warn(
167
- lineNumber,
168
- `Duplicate alias "${snm.alias}" \u2014 the first declaration keeps it`
169
- );
170
- }
171
- const alias = snm.alias !== void 0 && !aliasIndex.has(snm.alias) ? snm.alias : void 0;
172
- if (alias === void 0 && snm.alias === void 0) {
173
- const existing = labelIndex.get(norm);
174
- if (existing && existing.length > 0) {
175
- const first = nodeById.get(existing[0]);
176
- for (const [k, v] of Object.entries(meta)) {
177
- if (!(k in first.metadata)) first.metadata[k] = v;
178
- }
179
- if (first.at === null && at !== null) first.at = at;
180
- warn(
181
- lineNumber,
182
- nameMergedMessage({
183
- incomingDisplay: label,
184
- incomingLine: lineNumber,
185
- existingDisplay: first.label,
186
- existingLine: first.lineNumber
187
- }),
188
- NAME_DIAGNOSTIC_CODES.NAME_MERGED
189
- );
190
- return first;
191
- }
192
- }
193
- const id = `sketch-node-${++idCounter}`;
194
- const node = {
195
- id,
196
- label,
197
- ...alias !== void 0 && { alias },
198
- at,
199
- metadata: meta,
200
- ...box !== null && { boxLabel: box.label },
201
- lineNumber
202
- };
203
- nodes.push(node);
204
- nodeById.set(id, node);
205
- if (alias !== void 0) aliasIndex.set(alias, id);
206
- const list = labelIndex.get(norm);
207
- if (list) list.push(id);
208
- else labelIndex.set(norm, [id]);
209
- if (box !== null) box.children.push(id);
210
- return node;
211
- };
212
- const parseBoxTail = (tail, lineNumber) => {
213
- let rest = tail.trim();
214
- let alias;
215
- const aliasMatch = rest.match(BOX_TAIL_ALIAS_RE);
216
- if (aliasMatch) {
217
- alias = aliasMatch[1];
218
- rest = rest.slice(aliasMatch[0].length);
219
- }
220
- let collapsed = false;
221
- rest = rest.replace(/(^|,|\s)collapsed(?=\s|,|$)/i, (_m, pre) => {
222
- collapsed = true;
223
- return pre === "," ? "," : pre;
224
- });
225
- const meta = {};
226
- let at = null;
227
- for (const seg of rest.split(",")) {
228
- const t = seg.trim();
229
- if (!t) continue;
230
- const colonIdx = t.indexOf(":");
231
- if (colonIdx < 0) {
232
- warn(lineNumber, `Unrecognized box metadata "${t}" \u2014 ignored`);
233
- continue;
234
- }
235
- const rawKey = t.slice(0, colonIdx).trim().toLowerCase();
236
- const value = t.slice(colonIdx + 1).trim();
237
- if (rawKey === "at") {
238
- at = parseAt(value, lineNumber);
239
- } else if (value) {
240
- meta[tagAliasMap.get(rawKey) ?? rawKey] = value;
241
- }
242
- }
243
- return { ...alias !== void 0 && { alias }, at, collapsed, meta };
244
- };
245
- const openBox = (label, tail, lineNumber, parentBoxId) => {
246
- const norm = normalizeName(label);
247
- const existing = boxByNorm.get(norm);
248
- const { alias, at, collapsed, meta } = parseBoxTail(tail, lineNumber);
249
- if (existing) {
250
- warn(
251
- lineNumber,
252
- `Box "${label}" already declared on line ${existing.lineNumber} \u2014 shapes are added to it`
253
- );
254
- return existing;
255
- }
256
- const box = {
257
- id: `[${norm}]`,
258
- label: label.trim(),
259
- ...alias !== void 0 && { alias },
260
- at,
261
- metadata: meta,
262
- collapsed,
263
- children: [],
264
- childBoxes: [],
265
- parentBoxId,
266
- lineNumber
267
- };
268
- boxes.push(box);
269
- if (parentBoxId !== null) {
270
- boxByNorm.get(normalizeName(parentBoxId.slice(1, -1)))?.childBoxes.push(box.id);
271
- }
272
- boxByNorm.set(norm, box);
273
- if (alias !== void 0) {
274
- if (aliasIndex.has(alias)) {
275
- warn(
276
- lineNumber,
277
- `Duplicate alias "${alias}" \u2014 the first declaration keeps it`
278
- );
279
- } else {
280
- aliasIndex.set(alias, box.id);
281
- }
282
- }
283
- return box;
284
- };
285
- const addEdge = (trimmed, lineNumber, sourceId) => {
286
- for (const form of EDGE_FORMS) {
287
- const m = trimmed.match(form.re);
288
- if (!m) continue;
289
- let label;
290
- let targetRegion;
291
- if (form.labeled) {
292
- const labelResult = parseInArrowLabel(m[1], lineNumber);
293
- result.diagnostics.push(...labelResult.diagnostics);
294
- label = labelResult.label;
295
- targetRegion = m[2];
296
- } else {
297
- targetRegion = m[1];
298
- }
299
- const snm = splitNameAndMeta(
300
- targetRegion.trim(),
301
- registryFor(),
302
- tagAliasMap,
303
- palette,
304
- result.diagnostics,
305
- lineNumber,
306
- { peelAlias: false }
307
- );
308
- let targetRaw = snm.name.trim();
309
- if (snm.color) targetRaw = `${targetRaw} ${snm.color}`.trim();
310
- const meta = { ...snm.meta };
311
- delete meta["at"];
312
- delete meta["shape"];
313
- warnUnknownMetaKeys(meta, registryFor(), (msg) => warn(lineNumber, msg));
314
- if (!targetRaw) {
315
- warn(lineNumber, `Edge has no target \u2014 ignored`);
316
- return;
317
- }
318
- pendingEdges.push({
319
- sourceId,
320
- targetRaw,
321
- ...label !== void 0 && { label },
322
- heads: form.heads,
323
- dashed: form.dashed,
324
- metadata: meta,
325
- lineNumber
326
- });
327
- return;
328
- }
329
- if (LEFT_ARROW_RE.test(trimmed)) {
330
- pushError(
331
- lineNumber,
332
- `Left-pointing arrows are not supported \u2014 write the edge from the other side (B -> A instead of A <- B)`
333
- );
334
- return;
335
- }
336
- warn(lineNumber, `Malformed edge "${trimmed}" \u2014 ignored`);
337
- };
338
- let firstLineConsumed = false;
339
- let contentStarted = false;
340
- let currentTagGroup = null;
341
- const boxStack = [];
342
- const boxAt = (indent) => {
343
- while (boxStack.length > 0 && indent <= boxStack[boxStack.length - 1].indent) {
344
- boxStack.pop();
345
- }
346
- return boxStack[boxStack.length - 1] ?? null;
347
- };
348
- let currentShape = null;
349
- for (let i = 0; i < lines.length; i++) {
350
- const raw = lines[i];
351
- const lineNumber = i + 1;
352
- const trimmed = raw.trim();
353
- if (!trimmed) {
354
- currentTagGroup = null;
355
- continue;
356
- }
357
- if (trimmed.startsWith("//")) continue;
358
- const indent = measureIndent(raw);
359
- if (!firstLineConsumed) {
360
- firstLineConsumed = true;
361
- const firstLine = parseFirstLine(trimmed);
362
- if (firstLine?.chartType !== "sketch") {
363
- let msg = `Expected chart type "sketch", got "${firstLine?.chartType ?? trimmed.split(/\s+/)[0]}"`;
364
- const hint = suggest(firstLine?.chartType ?? "", ["sketch"]);
365
- if (hint) msg += `. ${hint}`;
366
- return fail(lineNumber, msg);
367
- }
368
- result.title = firstLine.title ?? null;
369
- result.titleLineNumber = lineNumber;
370
- continue;
371
- }
372
- if (indent === 0) {
373
- const tagBlockMatch = matchTagBlockHeading(trimmed);
374
- if (tagBlockMatch) {
375
- if (contentStarted) {
376
- pushError(
377
- lineNumber,
378
- "Tag groups must appear before sketch content",
379
- "E_TAG_DECLARED_AFTER_CONTENT"
380
- );
381
- continue;
382
- }
383
- currentTagGroup = {
384
- name: tagBlockMatch.name,
385
- ...tagBlockMatch.alias !== void 0 && {
386
- alias: tagBlockMatch.alias
387
- },
388
- entries: [],
389
- lineNumber
390
- };
391
- if (tagBlockMatch.alias) {
392
- tagAliasMap.set(
393
- tagBlockMatch.alias.toLowerCase(),
394
- tagAttrKey(tagBlockMatch.name)
395
- );
396
- }
397
- tagAliasMap.set(
398
- tagAttrKey(tagBlockMatch.name),
399
- tagAttrKey(tagBlockMatch.name)
400
- );
401
- if (tagBlockMatch.inlineValues) {
402
- for (const entry of tagBlockMatch.inlineValues) {
403
- const { text: cleanEntry, isDefault } = stripDefaultModifier(entry);
404
- const { label, color } = extractColor(
405
- cleanEntry,
406
- palette,
407
- result.diagnostics,
408
- lineNumber
409
- );
410
- if (isDefault) currentTagGroup.defaultValue = label;
411
- currentTagGroup.entries.push({
412
- value: label,
413
- color: color ?? AUTO_TAG_COLOR_SENTINEL,
414
- // When a color resolved, the recognized name is the entry's last
415
- // token — keep it so a reparse can tell authored from auto.
416
- ...color !== void 0 && {
417
- authoredColor: cleanEntry.trim().split(/\s+/).pop()
418
- },
419
- lineNumber
420
- });
421
- }
422
- }
423
- result.tagGroups.push(currentTagGroup);
424
- continue;
425
- }
426
- }
427
- if (currentTagGroup && indent > 0) {
428
- const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
429
- const { label, color } = extractColor(
430
- cleanEntry,
431
- palette,
432
- result.diagnostics,
433
- lineNumber
434
- );
435
- if (isDefault) currentTagGroup.defaultValue = label;
436
- currentTagGroup.entries.push({
437
- value: label,
438
- color: color ?? AUTO_TAG_COLOR_SENTINEL,
439
- // When a color resolved, the recognized name is the entry's last token
440
- // — keep it so a reparse can tell authored from auto.
441
- ...color !== void 0 && {
442
- authoredColor: cleanEntry.trim().split(/\s+/).pop()
443
- },
444
- lineNumber
445
- });
446
- continue;
447
- }
448
- currentTagGroup = null;
449
- if (indent === 0 && /^legend-inline\s*$/i.test(trimmed)) {
450
- options.legendInline = true;
451
- continue;
452
- }
453
- if (indent === 0 && /^no-legend\s*$/i.test(trimmed)) {
454
- options.noLegend = true;
455
- continue;
456
- }
457
- if (indent === 0 && fillModeFromToken(trimmed) !== null) {
458
- const fm = fillModeFromToken(trimmed);
459
- options.fillMode = fm === "tint" ? void 0 : fm;
460
- continue;
461
- }
462
- if (indent === 0 && /^no-descriptions\s*$/i.test(trimmed)) {
463
- options.noDescriptions = true;
464
- continue;
465
- }
466
- if (indent === 0) {
467
- const shared = recognizeGlobalBoolean(trimmed);
468
- if (shared !== null) {
469
- if (shared === "no-title") options.noTitle = true;
470
- continue;
471
- }
472
- }
473
- contentStarted = true;
474
- if (trimmed.startsWith(">")) {
475
- const descLine = trimmed.slice(1).replace(/^ /, "");
476
- if (indent > 0 && currentShape && indent > currentShape.indent) {
477
- const node2 = nodeById.get(currentShape.id);
478
- if (node2) {
479
- node2.description = node2.description === void 0 ? descLine : `${node2.description}
480
- ${descLine}`;
481
- }
482
- } else {
483
- warn(
484
- lineNumber,
485
- `Description "${trimmed}" has no shape \u2014 indent it under the shape it describes`
486
- );
487
- }
488
- continue;
489
- }
490
- if (EDGE_START_RE.test(trimmed)) {
491
- if (indent > 0 && currentShape && indent > currentShape.indent) {
492
- addEdge(trimmed, lineNumber, currentShape.id);
493
- } else if (indent > 0 && boxAt(indent)) {
494
- addEdge(trimmed, lineNumber, boxAt(indent).box.id);
495
- } else {
496
- warn(
497
- lineNumber,
498
- `Edge "${trimmed}" has no source shape \u2014 indent it under the shape it leaves from`
499
- );
500
- }
501
- continue;
502
- }
503
- const boxMatch = trimmed.match(BOX_RE);
504
- if (boxMatch) {
505
- const label = boxMatch[1].trim();
506
- if (!label) {
507
- warn(lineNumber, "Box has no label \u2014 ignored");
508
- continue;
509
- }
510
- while (boxStack.length > 0 && indent <= boxStack[boxStack.length - 1].indent) {
511
- boxStack.pop();
512
- }
513
- const depth = boxStack.length + 1;
514
- if (depth > MAX_BOX_DEPTH) {
515
- pushError(
516
- lineNumber,
517
- `Box "${label}" is nested ${depth} levels deep \u2014 sketch boxes nest to depth ${MAX_BOX_DEPTH}; its shapes join the box above it`,
518
- SKETCH_DIAGNOSTIC_CODES.BOX_DEPTH
519
- );
520
- continue;
521
- }
522
- const parent = boxStack[boxStack.length - 1] ?? null;
523
- const box = openBox(
524
- label,
525
- boxMatch[2] ?? "",
526
- lineNumber,
527
- parent ? parent.box.id : null
528
- );
529
- boxStack.push({ box, indent });
530
- currentShape = null;
531
- continue;
532
- }
533
- if (indent === 0) {
534
- boxStack.length = 0;
535
- const node2 = addShape(trimmed, lineNumber, null);
536
- currentShape = node2 ? { id: node2.id, indent } : null;
537
- continue;
538
- }
539
- const owner = boxAt(indent);
540
- if (owner) {
541
- const node2 = addShape(trimmed, lineNumber, owner.box);
542
- currentShape = node2 ? { id: node2.id, indent } : currentShape;
543
- continue;
544
- }
545
- warn(
546
- lineNumber,
547
- `Indented line "${trimmed}" has no parent box \u2014 treated as a top-level shape`
548
- );
549
- const node = addShape(trimmed, lineNumber, null);
550
- currentShape = node ? { id: node.id, indent } : currentShape;
551
- }
552
- const allTargets = [
553
- ...aliasIndex.keys(),
554
- ...nodes.map((n) => n.label),
555
- ...boxes.map((b) => b.label)
556
- ];
557
- for (const pe of pendingEdges) {
558
- let targetId;
559
- const bracketMatch = pe.targetRaw.match(/^\[([^\]]*)\]$/);
560
- if (bracketMatch) {
561
- targetId = boxByNorm.get(normalizeName(bracketMatch[1]))?.id ?? null;
562
- } else if (aliasIndex.has(pe.targetRaw)) {
563
- targetId = aliasIndex.get(pe.targetRaw);
564
- } else {
565
- const norm = normalizeName(stripQuotes(pe.targetRaw).trim());
566
- const labelHits = labelIndex.get(norm) ?? [];
567
- if (labelHits.length > 1) {
568
- pushError(
569
- pe.lineNumber,
570
- `Edge target "${pe.targetRaw}" matches more than one shape \u2014 give each duplicate an alias (as x) and target the alias`,
571
- SKETCH_DIAGNOSTIC_CODES.AMBIGUOUS_TARGET
572
- );
573
- continue;
574
- }
575
- targetId = labelHits[0] ?? boxByNorm.get(norm)?.id ?? null;
576
- }
577
- if (targetId === null) {
578
- let msg = `Unknown edge target "${pe.targetRaw}"`;
579
- const hint = suggest(pe.targetRaw, allTargets);
580
- if (hint) msg += `. ${hint}`;
581
- warn(pe.lineNumber, msg);
582
- continue;
583
- }
584
- if (targetId === pe.sourceId) {
585
- warn(pe.lineNumber, `Edge from "${pe.targetRaw}" to itself \u2014 ignored`);
586
- continue;
587
- }
588
- result.edges.push({
589
- sourceId: pe.sourceId,
590
- targetId,
591
- ...pe.label !== void 0 && { label: pe.label },
592
- heads: pe.heads,
593
- dashed: pe.dashed,
594
- metadata: pe.metadata,
595
- lineNumber: pe.lineNumber
596
- });
597
- }
598
- finalizeAutoTagColors(result.tagGroups, palette);
599
- if (result.tagGroups.length > 0) {
600
- const tagKeys = result.tagGroups.map((g) => tagAttrKey(g.name));
601
- for (const box of boxes) {
602
- for (const childId of box.children) {
603
- const child = nodeById.get(childId);
604
- if (!child) continue;
605
- for (const k of tagKeys) {
606
- if (!(k in child.metadata) && box.metadata[k] !== void 0) {
607
- child.metadata[k] = box.metadata[k];
608
- }
609
- }
610
- }
611
- }
612
- injectDefaultTagMetadata([...nodes, ...boxes], result.tagGroups);
613
- validateTagValues(
614
- [...nodes, ...boxes, ...result.edges],
615
- result.tagGroups,
616
- (line, message) => warn(line, message),
617
- suggest
618
- );
619
- validateTagGroupNames(
620
- result.tagGroups,
621
- (line, message) => warn(line, message)
622
- );
623
- }
624
- result.nodes = nodes;
625
- result.boxes = boxes;
626
- if (nodes.length === 0 && boxes.length === 0 && !result.error) {
627
- const diag = makeDgmoError(1, "No shapes found in sketch");
628
- result.diagnostics.push(diag);
629
- result.error = formatDgmoError(diag);
630
- }
631
- return result;
632
- }
633
-
634
- export {
635
- parseSketch
636
- };