@diagrammo/dgmo 0.92.1 → 0.94.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 (174) hide show
  1. package/dist/advanced.d.ts +103 -38
  2. package/dist/advanced.js +457 -423
  3. package/dist/block.d.ts +2 -2
  4. package/dist/block.js +75 -70
  5. package/dist/{chart-meta-BBqLnv5q.d.ts → chart-meta-BbjsRY7o.d.ts} +2 -2
  6. package/dist/chart-meta.d.ts +3 -3
  7. package/dist/chart-meta.js +25 -19
  8. package/dist/{chart-types-CbXlZFLd.d.ts → chart-types-Cppnp31G.d.ts} +173 -4
  9. package/dist/{charts-d3-QUUDVETP.js → charts-d3-SZV2SFTM.js} +7 -6
  10. package/dist/{chunk-ADNIO3XY.js → chunk-2FDQEQID.js} +5 -5
  11. package/dist/{chunk-QUGC7GWB.js → chunk-2HSHWPTO.js} +15 -15
  12. package/dist/{chunk-L5NW3PVL.js → chunk-2I4UQG7W.js} +1 -1
  13. package/dist/{chunk-2YAFDND3.js → chunk-2MS623GW.js} +4 -6
  14. package/dist/{chunk-73EYNV4O.js → chunk-2XMTZ5JR.js} +4 -6
  15. package/dist/{chunk-ZJAK6C7Y.js → chunk-3PP746YM.js} +6 -1
  16. package/dist/{chunk-MDVJYRJT.js → chunk-3TWBMU7K.js} +22 -22
  17. package/dist/{chunk-FTUMRSGT.js → chunk-3ZP3QC47.js} +8 -288
  18. package/dist/{chunk-J2E7EUER.js → chunk-4EX4OKGZ.js} +86 -23
  19. package/dist/{chunk-Y2V5AEVG.js → chunk-4SP6OUO7.js} +1952 -1824
  20. package/dist/{chunk-HIWHIYLD.js → chunk-4TEPDQHJ.js} +19 -19
  21. package/dist/{chunk-DEFBUZWV.js → chunk-5HAYT43L.js} +70 -54
  22. package/dist/{chunk-6WVX4KNP.js → chunk-5ZUZZDW5.js} +97 -297
  23. package/dist/{chunk-X5BUX2GK.js → chunk-6JCTW74W.js} +7 -5
  24. package/dist/{chunk-Q6W2K33N.js → chunk-6XLMTAEX.js} +1 -1
  25. package/dist/{chunk-ONYO5WJW.js → chunk-7IOZ6JE4.js} +21 -21
  26. package/dist/chunk-7SXV7NUS.js +416 -0
  27. package/dist/{chunk-NPWVOFB3.js → chunk-7WEYXYLC.js} +1 -1
  28. package/dist/{chunk-GE7ICBX6.js → chunk-AM42TLSZ.js} +102 -97
  29. package/dist/{chunk-WLLO3PZ3.js → chunk-AYUSD4Z6.js} +45 -19
  30. package/dist/{chunk-45QUTYPD.js → chunk-B25IWGDH.js} +69 -20
  31. package/dist/{chunk-JKST4RTT.js → chunk-BH2SF4TT.js} +6 -6
  32. package/dist/{chunk-6OIMUSDX.js → chunk-C6G36F5S.js} +9 -9
  33. package/dist/{chunk-DRFGIOZ6.js → chunk-CIHHTS5B.js} +4 -6
  34. package/dist/chunk-CYTFO2LF.js +209 -0
  35. package/dist/{chunk-Q2UFOKPB.js → chunk-DDIOWNHS.js} +22 -22
  36. package/dist/{chunk-Q6ZQX2HX.js → chunk-DLJJOCIT.js} +4 -6
  37. package/dist/{chunk-26BBJUBW.js → chunk-DNM3XZCK.js} +4 -6
  38. package/dist/{chunk-AUS7V54P.js → chunk-ERT7XDQW.js} +1 -1
  39. package/dist/{chunk-7ENDOHAA.js → chunk-FMAVHTYB.js} +919 -927
  40. package/dist/{chunk-URQIWIKX.js → chunk-FWVE373X.js} +4 -4
  41. package/dist/{chunk-VOR32OHN.js → chunk-G3HZ4PGE.js} +13 -15
  42. package/dist/{chunk-RBFJT23E.js → chunk-GWQRTA5W.js} +6 -6
  43. package/dist/chunk-GXCDD6NG.js +24 -0
  44. package/dist/{chunk-3PFMGNOM.js → chunk-HHVIE45A.js} +26 -11
  45. package/dist/{chunk-MXAP37W6.js → chunk-HI6R27YA.js} +16 -7
  46. package/dist/{chunk-QQPNCXAO.js → chunk-I37S3EZE.js} +18 -18
  47. package/dist/{chunk-YITHYQCL.js → chunk-IGJEKO2P.js} +8 -8
  48. package/dist/{chunk-BZX7QCXJ.js → chunk-IHN6WDEY.js} +15 -15
  49. package/dist/{chunk-QT3KDDXK.js → chunk-IN7XI6NO.js} +0 -7
  50. package/dist/{chunk-4QLGGQNO.js → chunk-IZHGT5HD.js} +44 -18
  51. package/dist/{chunk-5SSTVFPX.js → chunk-JT2BG7LM.js} +5 -7
  52. package/dist/{chunk-2BJW7FSF.js → chunk-KBEWVCK3.js} +1 -1
  53. package/dist/{chunk-DUPZ2BBY.js → chunk-KBHT5XEY.js} +143 -6
  54. package/dist/{chunk-V4D2ZQBE.js → chunk-KRPLP5LP.js} +6 -1
  55. package/dist/{chunk-QKY6W4NA.js → chunk-KSZB7TIY.js} +25 -25
  56. package/dist/{chunk-6ZL2XYM7.js → chunk-MLY5ALOV.js} +6 -6
  57. package/dist/{chunk-VSOZZYLK.js → chunk-NERQSSYD.js} +20 -9
  58. package/dist/{chunk-OQW4ETJX.js → chunk-NM5V5EKY.js} +6 -1
  59. package/dist/{chunk-EBSFSOJC.js → chunk-NOQB4KMV.js} +22 -22
  60. package/dist/{chunk-6BNNLVAR.js → chunk-NPDVWFAQ.js} +6 -1
  61. package/dist/{chunk-FSJ3ZA6N.js → chunk-OSSTOSXU.js} +12 -12
  62. package/dist/chunk-P7TRFL4P.js +54 -0
  63. package/dist/{chunk-A4PNWAUW.js → chunk-PGSGJLUR.js} +6 -1
  64. package/dist/{chunk-S7W75MIM.js → chunk-QKPOIJBT.js} +23 -5
  65. package/dist/{chunk-YO6AQU4A.js → chunk-QPQWY5RU.js} +12 -12
  66. package/dist/{chunk-NREU4JFE.js → chunk-RBVFNUAL.js} +6 -8
  67. package/dist/{chunk-5EBYPETE.js → chunk-RESEJSCV.js} +3 -5
  68. package/dist/{chunk-BRSM6Z34.js → chunk-RITTLIDJ.js} +14 -14
  69. package/dist/{chunk-MX4SZLSV.js → chunk-S5Y3OO3V.js} +16 -8
  70. package/dist/{chunk-O5WUZGPV.js → chunk-TASRGDYP.js} +18 -18
  71. package/dist/{chunk-HXULJZA2.js → chunk-TDAGJJPZ.js} +6 -1
  72. package/dist/chunk-UCHZJJIT.js +421 -0
  73. package/dist/{chunk-42UJ23H3.js → chunk-UIEKW4SG.js} +1 -0
  74. package/dist/{chunk-WFA6IULY.js → chunk-URRAWU5D.js} +5 -0
  75. package/dist/{chunk-IGKFOHBG.js → chunk-VBMRZCMQ.js} +13 -13
  76. package/dist/{chunk-JRWUHLRP.js → chunk-VDY2GR6U.js} +51 -8
  77. package/dist/{chunk-EJS3K44P.js → chunk-VGAMBOOC.js} +5 -3
  78. package/dist/{chunk-B5PEKSRH.js → chunk-VSAKEMDD.js} +6 -1
  79. package/dist/chunk-WTTIODDV.js +9 -0
  80. package/dist/{chunk-JLU52ZDT.js → chunk-XJQ6Z3FO.js} +10 -10
  81. package/dist/{chunk-KTGZDMDX.js → chunk-XKCRKD2B.js} +140 -53
  82. package/dist/{chunk-LRP5FXST.js → chunk-YQMIKX54.js} +61 -24
  83. package/dist/{chunk-H5UEVW6Q.js → chunk-ZD3QCNB7.js} +1 -1
  84. package/dist/clock.js +168 -0
  85. package/dist/completion-registry.js +3 -1
  86. package/dist/countdown.js +36 -395
  87. package/dist/{dgmo-router-4UAPPIKN.js → dgmo-router-E5O7RJSW.js} +50 -43
  88. package/dist/{dimensions-SCNVYLRF.js → dimensions-DS6FWLRY.js} +3 -3
  89. package/dist/{d3-BThYBTQk.d.ts → export-context-Ceh3wr0E.d.ts} +2 -8
  90. package/dist/{flowchart-parser-NA75YQ77.js → flowchart-parser-NZXASOZG.js} +8 -3
  91. package/dist/{flowchart-renderer-6MGGX4RC.js → flowchart-renderer-PTCRIANF.js} +17 -19
  92. package/dist/index.d.ts +8 -7
  93. package/dist/index.js +80 -74
  94. package/dist/{layout-MBVBAMPA.js → layout-3TSVAGWH.js} +2 -2
  95. package/dist/layout-ISSBWBH7.js +24 -0
  96. package/dist/layout-IT4ZTV6C.js +24 -0
  97. package/dist/{layout-BNLFQHSB.js → layout-U3AH6M7J.js} +9 -10
  98. package/dist/layout-VC3MXRB4.js +29 -0
  99. package/dist/layout-VDCJOZSH.js +11 -0
  100. package/dist/{layout-search-PMYL3VWS.js → layout-search-BBX2BMEF.js} +11 -12
  101. package/dist/{palettes-IN7ZFRJM.js → palettes-4Y7CL2QL.js} +4 -2
  102. package/dist/{parser-QYISOAGR.js → parser-4RFY7D52.js} +8 -3
  103. package/dist/{parser-3MK56JZC.js → parser-4Y6PODW6.js} +2 -2
  104. package/dist/{parser-GX5YLRIP.js → parser-7QKQ4P4P.js} +8 -3
  105. package/dist/{parser-2NWH5JUS.js → parser-A3AN76RQ.js} +2 -1
  106. package/dist/{parser-LCJ76UXS.js → parser-BT4NI6JY.js} +5 -1
  107. package/dist/{parser-FXDS4JDK.js → parser-F7NDRPMA.js} +2 -2
  108. package/dist/{parser-BES6LV3G.js → parser-GDLKUBTO.js} +5 -1
  109. package/dist/{parser-SEUTXN6U.js → parser-KJPPUN4D.js} +2 -2
  110. package/dist/{parser-SIKL4PLF.js → parser-KMKVFET2.js} +5 -1
  111. package/dist/{parser-5LW5JDYG.js → parser-NL73FSFI.js} +5 -1
  112. package/dist/{parser-VA7ZQQTA.js → parser-NUU3DVW4.js} +5 -1
  113. package/dist/{parser-XZUKNZPB.js → parser-R3LPEQIT.js} +7 -1
  114. package/dist/{parser-X23GRTQJ.js → parser-RCIEKN7Y.js} +5 -1
  115. package/dist/{parser-L6RWDXQN.js → parser-TAYRTCPR.js} +8 -3
  116. package/dist/redraw-AHW7EUUF.js +1698 -0
  117. package/dist/redraw-STZ4WJAI.js +73 -0
  118. package/dist/{renderer-LM4ICK6I.js → renderer-2LYX6NHN.js} +4 -5
  119. package/dist/{renderer-NHTR7IRR.js → renderer-3NLDX7DQ.js} +4 -5
  120. package/dist/{renderer-TO2NVJP3.js → renderer-4SE7R22T.js} +50 -45
  121. package/dist/{renderer-3IHQI4A4.js → renderer-53B523PM.js} +11 -10
  122. package/dist/{renderer-3JY6JAQJ.js → renderer-7OGGV327.js} +5 -6
  123. package/dist/{renderer-2FVUPBGV.js → renderer-AM7P4LN7.js} +1 -1
  124. package/dist/{renderer-5VKPB4LL.js → renderer-BXD5KVSR.js} +5 -5
  125. package/dist/{renderer-OAR5VPH4.js → renderer-DAZWHNLI.js} +2 -2
  126. package/dist/{renderer-WIU5BJUK.js → renderer-DDWDCM2K.js} +2 -2
  127. package/dist/{renderer-3QAFDXEY.js → renderer-FMTLSOCX.js} +16 -12
  128. package/dist/{renderer-JEJT3YET.js → renderer-HX6ICPDX.js} +2 -3
  129. package/dist/{renderer-NDA2FFYB.js → renderer-ISQJ2ELA.js} +5 -5
  130. package/dist/{renderer-XGG2UNXT.js → renderer-IXBOT6DU.js} +3 -4
  131. package/dist/{renderer-S3YCLJKL.js → renderer-J3GPDK73.js} +20 -22
  132. package/dist/{renderer-DVNMCYHZ.js → renderer-J7ZSTJUE.js} +15 -15
  133. package/dist/{renderer-ALWVK3EJ.js → renderer-JJ4QW3SK.js} +6 -6
  134. package/dist/{renderer-RUSFL7WU.js → renderer-JYHA6R2D.js} +8 -7
  135. package/dist/{renderer-5TZVFQ7K.js → renderer-KJ3V5BYP.js} +7 -8
  136. package/dist/{renderer-RSK6QFWN.js → renderer-LNP23NSM.js} +7 -9
  137. package/dist/{renderer-ZHGHTSNG.js → renderer-M5DUMITP.js} +13 -12
  138. package/dist/{renderer-O6DY46AV.js → renderer-MWZC7TMD.js} +7 -7
  139. package/dist/{renderer-DC7C5Q3G.js → renderer-NOYLNVTI.js} +2 -2
  140. package/dist/{renderer-ISSDGK54.js → renderer-O6RP52CQ.js} +3 -3
  141. package/dist/{renderer-ZGY7P4BM.js → renderer-OUDHH5MV.js} +19 -22
  142. package/dist/{renderer-QGIHLZOJ.js → renderer-PHLCYVSN.js} +9 -10
  143. package/dist/{renderer-VPIELEE5.js → renderer-QTPWRRJ7.js} +8 -9
  144. package/dist/{renderer-LQP3AGEJ.js → renderer-RUSQJFFC.js} +3 -4
  145. package/dist/{renderer-MM27BSBO.js → renderer-TINHO2IO.js} +3 -4
  146. package/dist/{renderer-7ZZG5HR3.js → renderer-UTEEJDGB.js} +9 -9
  147. package/dist/{renderer-J5FKF423.js → renderer-W4MUMXJE.js} +7 -4
  148. package/dist/{renderer-XO57LTU4.js → renderer-WPN2SXGT.js} +5 -5
  149. package/dist/{renderer-ZZ6MWVB7.js → renderer-XCLARXCK.js} +4 -4
  150. package/dist/{renderer-J666LZXJ.js → renderer-XOWDERU2.js} +8 -8
  151. package/dist/{state-parser-TIR2ORJY.js → state-parser-KPVW5CRI.js} +8 -3
  152. package/dist/{state-renderer-G6SUXU4J.js → state-renderer-ZVEI265C.js} +18 -21
  153. package/dist/{tag-groups-DsoVpAY-.d.ts → tag-groups-DydewK3D.d.ts} +2 -173
  154. package/dist/{themes-DRNjxX7Q.d.ts → themes-DzIH3Hjv.d.ts} +3 -2
  155. package/docs/ai-integration.md +1 -1
  156. package/docs/language-reference.md +23 -2
  157. package/gallery/fixtures/whiteboard.dgmo +3 -0
  158. package/package.json +2 -6
  159. package/dist/chunk-3Y63RFJL.js +0 -75
  160. package/dist/chunk-5DH3KYFH.js +0 -20
  161. package/dist/chunk-O753JUEZ.js +0 -67
  162. package/dist/chunk-RJNZHFNG.js +0 -51
  163. package/dist/chunk-Z6DXWULM.js +0 -23
  164. package/dist/layout-5USEVQBY.js +0 -25
  165. package/dist/layout-J3AGFZZ7.js +0 -10
  166. package/dist/layout-S3RLVPH4.js +0 -25
  167. package/dist/layout-WRG4APSJ.js +0 -32
  168. package/dist/{chunk-DGUGE67L.js → chunk-CDYV46JE.js} +3 -3
  169. package/dist/{chunk-TKAB3FTK.js → chunk-DRQSB72S.js} +11 -11
  170. package/dist/{chunk-ZKP77MB3.js → chunk-FVTYJUXR.js} +5 -5
  171. package/dist/{chunk-MA42PIGJ.js → chunk-H5NVCOEJ.js} +4 -4
  172. package/dist/{chunk-BEA4D7OS.js → chunk-IXHWS2HI.js} +3 -3
  173. package/dist/{chunk-SOHZDW6N.js → chunk-UXNA2H2V.js} +3 -3
  174. package/dist/{chunk-NO3UX6AP.js → chunk-V2NQV7VL.js} +4 -4
@@ -5,23 +5,29 @@ import {
5
5
  NODE_LABEL_LINE_HEIGHT,
6
6
  layoutGraph,
7
7
  wrapNodeLabel
8
- } from "./chunk-5SSTVFPX.js";
8
+ } from "./chunk-JT2BG7LM.js";
9
9
  import {
10
10
  appendArrowheadMarkers
11
11
  } from "./chunk-XBJJP2HN.js";
12
- import {
13
- NOTE_BADGE_RADIUS,
14
- noteConnectorPoints,
15
- renderNoteBadge,
16
- renderNoteBox,
17
- renderNoteConnector
18
- } from "./chunk-JRWUHLRP.js";
19
12
  import {
20
13
  fitDiagramToCanvas
21
14
  } from "./chunk-EPDBWATV.js";
15
+ import {
16
+ serializeSvg
17
+ } from "./chunk-CYRB2JTN.js";
22
18
  import {
23
19
  ScaleContext
24
20
  } from "./chunk-24YPR5EH.js";
21
+ import {
22
+ INLINE_HEADER_PAD,
23
+ layoutInlineHeader,
24
+ measureTitleWidth
25
+ } from "./chunk-UIEKW4SG.js";
26
+ import {
27
+ TITLE_FONT_SIZE,
28
+ TITLE_FONT_WEIGHT,
29
+ TITLE_Y
30
+ } from "./chunk-VLC6WNRD.js";
25
31
  import {
26
32
  ARROWHEAD_HEIGHT,
27
33
  ARROWHEAD_WIDTH,
@@ -30,19 +36,18 @@ import {
30
36
  NODE_STROKE_WIDTH
31
37
  } from "./chunk-XCKNFFKM.js";
32
38
  import {
33
- serializeSvg
34
- } from "./chunk-CYRB2JTN.js";
39
+ parseFlowchart
40
+ } from "./chunk-DNM3XZCK.js";
35
41
  import {
36
- TITLE_FONT_SIZE,
37
- TITLE_FONT_WEIGHT,
38
- TITLE_Y
39
- } from "./chunk-VLC6WNRD.js";
42
+ NOTE_BADGE_RADIUS,
43
+ noteConnectorPoints,
44
+ renderNoteBadge,
45
+ renderNoteBox,
46
+ renderNoteConnector
47
+ } from "./chunk-VDY2GR6U.js";
40
48
  import {
41
49
  FONT_FAMILY
42
50
  } from "./chunk-ICLB27PZ.js";
43
- import {
44
- parseFlowchart
45
- } from "./chunk-26BBJUBW.js";
46
51
  import {
47
52
  fillModeFromOptions
48
53
  } from "./chunk-TIIZIAGS.js";
@@ -331,7 +336,7 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
331
336
  const titleHeight = showTitle ? 40 : 0;
332
337
  const diagramW = layout.width;
333
338
  const diagramH = layout.height;
334
- const { scale, offsetX, offsetY, canvasHeight, canvasWidth } = fitDiagramToCanvas({
339
+ const fit = fitDiagramToCanvas({
335
340
  width,
336
341
  height,
337
342
  diagramW,
@@ -341,6 +346,27 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
341
346
  maxScale: MAX_SCALE,
342
347
  exportMode: !!exportDims
343
348
  });
349
+ const { scale, offsetY, canvasHeight } = fit;
350
+ let { offsetX, canvasWidth } = fit;
351
+ if (showTitle && exportDims) {
352
+ const titleW = Math.ceil(
353
+ measureTitleWidth(graph.title, sTitleFontSize) + INLINE_HEADER_PAD * 2
354
+ );
355
+ if (titleW > canvasWidth) {
356
+ offsetX += (titleW - canvasWidth) / 2;
357
+ canvasWidth = titleW;
358
+ }
359
+ }
360
+ const header = layoutInlineHeader({
361
+ requested: false,
362
+ title: graph.title ?? "",
363
+ hasLegend: false,
364
+ legendWidth: 0,
365
+ legendHeight: 0,
366
+ containerWidth: canvasWidth,
367
+ titleBandHeight: titleHeight,
368
+ legendReserve: 0
369
+ });
344
370
  const svg = d3Selection.select(container).append("svg").attr("width", canvasWidth).attr("height", canvasHeight).attr("viewBox", `0 0 ${canvasWidth} ${canvasHeight}`).attr("preserveAspectRatio", "xMidYMin meet").style("font-family", FONT_FAMILY);
345
371
  if (ctx.isBelowFloor) {
346
372
  svg.attr("width", "100%");
@@ -355,7 +381,7 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
355
381
  colors: edgeColors
356
382
  });
357
383
  if (showTitle) {
358
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", sTitleY).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", sTitleFontSize).attr("font-weight", TITLE_FONT_WEIGHT).style(
384
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", header.titleX).attr("y", sTitleY).attr("text-anchor", header.titleAnchor).attr("fill", palette.text).attr("font-size", sTitleFontSize).attr("font-weight", TITLE_FONT_WEIGHT).style(
359
385
  "cursor",
360
386
  onClickItem && graph.titleLineNumber ? "pointer" : "default"
361
387
  ).text(graph.title);
@@ -1,15 +1,22 @@
1
- import {
2
- renderInlineText
3
- } from "./chunk-S7W75MIM.js";
4
1
  import {
5
2
  renderNodeCard
6
3
  } from "./chunk-R2K5L4UA.js";
4
+ import {
5
+ placeEdgeLabels
6
+ } from "./chunk-IN7XI6NO.js";
7
+ import {
8
+ serializeSvg
9
+ } from "./chunk-CYRB2JTN.js";
7
10
  import {
8
11
  ScaleContext
9
12
  } from "./chunk-24YPR5EH.js";
10
13
  import {
11
- renderIntegratedLegend
12
- } from "./chunk-NMS5XSLX.js";
14
+ layoutInlineHeader
15
+ } from "./chunk-UIEKW4SG.js";
16
+ import {
17
+ TITLE_FONT_SIZE,
18
+ TITLE_FONT_WEIGHT
19
+ } from "./chunk-VLC6WNRD.js";
13
20
  import {
14
21
  ARROWHEAD_HEIGHT,
15
22
  ARROWHEAD_WIDTH,
@@ -30,25 +37,21 @@ import {
30
37
  SEPARATOR_GAP
31
38
  } from "./chunk-XCKNFFKM.js";
32
39
  import {
33
- layoutInlineHeader
34
- } from "./chunk-42UJ23H3.js";
35
- import {
36
- serializeSvg
37
- } from "./chunk-CYRB2JTN.js";
40
+ renderIntegratedLegend
41
+ } from "./chunk-NMS5XSLX.js";
38
42
  import {
39
43
  getLegendExtent,
40
44
  getMaxLegendReservedHeight
41
45
  } from "./chunk-JILEYZ2V.js";
42
46
  import {
43
- TITLE_FONT_SIZE,
44
- TITLE_FONT_WEIGHT
45
- } from "./chunk-VLC6WNRD.js";
47
+ preprocessDescriptionLine
48
+ } from "./chunk-IYULMRBE.js";
49
+ import {
50
+ renderInlineText
51
+ } from "./chunk-QKPOIJBT.js";
46
52
  import {
47
53
  FONT_FAMILY
48
54
  } from "./chunk-ICLB27PZ.js";
49
- import {
50
- preprocessDescriptionLine
51
- } from "./chunk-IYULMRBE.js";
52
55
  import {
53
56
  tagAttrKey
54
57
  } from "./chunk-4SACN2C5.js";
@@ -101,6 +104,51 @@ function containerStroke(palette, nodeColor) {
101
104
  }
102
105
  var lineGenerator = d3Shape.line().x((d) => d.x).y((d) => d.y).curve(d3Shape.curveBasis);
103
106
  var lineGeneratorLinear = d3Shape.line().x((d) => d.x).y((d) => d.y).curve(d3Shape.curveLinear);
107
+ function placeSitemapEdgeLabels(layout, fontSize) {
108
+ const nodes = [
109
+ ...layout.nodes.map((n) => ({
110
+ label: n.id,
111
+ x: n.x,
112
+ y: n.y + n.height / 2,
113
+ width: n.width,
114
+ height: n.height
115
+ })),
116
+ ...layout.containers.map((c) => ({
117
+ label: c.nodeId,
118
+ x: c.x + c.width / 2,
119
+ y: c.y + c.labelHeight / 2,
120
+ width: c.width,
121
+ height: c.labelHeight
122
+ }))
123
+ ];
124
+ const adapted = {
125
+ nodes,
126
+ groups: [],
127
+ width: layout.width,
128
+ height: layout.height,
129
+ edges: layout.edges.map((e) => ({
130
+ source: e.sourceId,
131
+ target: e.targetId,
132
+ ...e.label !== void 0 && { label: e.label },
133
+ bidirectional: false,
134
+ lineNumber: e.lineNumber,
135
+ points: e.points,
136
+ yOffset: 0,
137
+ parallelCount: 1,
138
+ metadata: {}
139
+ }))
140
+ };
141
+ const placed = placeEdgeLabels(adapted, {
142
+ fontSize,
143
+ maxWidth: Number.POSITIVE_INFINITY
144
+ });
145
+ const out = /* @__PURE__ */ new Map();
146
+ placed.layout.edges.forEach((e, idx) => {
147
+ if (e.labelX !== void 0 && e.labelY !== void 0)
148
+ out.set(idx, { x: e.labelX, y: e.labelY });
149
+ });
150
+ return out;
151
+ }
104
152
  function renderSitemap(container, parsed, layout, palette, isDark, onClickItem, exportDims, activeTagGroup, hiddenAttributes, exportMode) {
105
153
  d3Selection.select(container).selectAll(":not([data-d3-tooltip])").remove();
106
154
  const width = exportDims?.width ?? container.clientWidth;
@@ -277,7 +325,8 @@ function renderSitemap(container, parsed, layout, palette, isDark, onClickItem,
277
325
  cG.append("rect").attr("y", c.height - sCollapseBarHeight).attr("width", c.width).attr("height", sCollapseBarHeight).attr("fill", stroke).attr("clip-path", `url(#${clipId})`).attr("class", "sitemap-collapse-bar");
278
326
  }
279
327
  }
280
- for (const edge of layout.edges) {
328
+ const labelCentres = placeSitemapEdgeLabels(layout, sEdgeLabelFontSize);
329
+ for (const [edgeIdx, edge] of layout.edges.entries()) {
281
330
  if (edge.points.length < 2) continue;
282
331
  const edgeG = contentG.append("g").attr("class", "sitemap-edge-group").attr("data-line-number", String(edge.lineNumber)).attr("data-from", edge.sourceId).attr("data-to", edge.targetId);
283
332
  const edgeColor = palette.textMuted;
@@ -287,8 +336,8 @@ function renderSitemap(container, parsed, layout, palette, isDark, onClickItem,
287
336
  if (pathD) {
288
337
  edgeG.append("path").attr("d", pathD).attr("fill", "none").attr("stroke", edgeColor).attr("stroke-width", sEdgeStrokeWidth).attr("marker-end", `url(#${markerId})`).attr("class", "sitemap-edge");
289
338
  }
290
- if (edge.label && edge.points.length >= 2) {
291
- const mid = edge.points[Math.floor(edge.points.length / 2)];
339
+ const mid = labelCentres.get(edgeIdx);
340
+ if (edge.label && mid) {
292
341
  const labelW = measureText(edge.label, sEdgeLabelFontSize) + 10;
293
342
  const labelH = sEdgeLabelFontSize + 6;
294
343
  edgeG.append("rect").attr("x", mid.x - labelW / 2).attr("y", mid.y - labelH / 2 - 1).attr("width", labelW).attr("height", labelH).attr("rx", 3).attr("fill", palette.bg).attr("opacity", EDGE_LABEL_KNOCKOUT_OPACITY).attr("class", "sitemap-edge-label-bg");
@@ -460,7 +509,7 @@ function renderLegend(parent, legendGroups, palette, isDark, activeTagGroup, fix
460
509
  async function renderSitemapForExport(content, theme, palette) {
461
510
  const { parseSitemap } = await import("./parser-6TDWUKM5.js");
462
511
  const { layoutSitemap } = await import("./layout-ND26WVX2.js");
463
- const { getPalette, DEFAULT_PALETTE_ID } = await import("./palettes-IN7ZFRJM.js");
512
+ const { getPalette, DEFAULT_PALETTE_ID } = await import("./palettes-4Y7CL2QL.js");
464
513
  const isDark = theme === "dark";
465
514
  const defaultCfg = getPalette(DEFAULT_PALETTE_ID);
466
515
  const effectivePalette = palette ?? (isDark ? defaultCfg.dark : defaultCfg.light);
@@ -1,9 +1,3 @@
1
- import {
2
- wrapDescriptionLines
3
- } from "./chunk-NPWVOFB3.js";
4
- import {
5
- renderInlineText
6
- } from "./chunk-S7W75MIM.js";
7
1
  import {
8
2
  ScaleContext
9
3
  } from "./chunk-24YPR5EH.js";
@@ -12,6 +6,12 @@ import {
12
6
  TITLE_FONT_WEIGHT,
13
7
  TITLE_Y
14
8
  } from "./chunk-VLC6WNRD.js";
9
+ import {
10
+ wrapDescriptionLines
11
+ } from "./chunk-7WEYXYLC.js";
12
+ import {
13
+ renderInlineText
14
+ } from "./chunk-QKPOIJBT.js";
15
15
  import {
16
16
  FONT_FAMILY
17
17
  } from "./chunk-ICLB27PZ.js";
@@ -6,8 +6,13 @@ import {
6
6
  EMPHASIS_DIM_OPACITY
7
7
  } from "./chunk-2CW5ZTNH.js";
8
8
  import {
9
- renderIntegratedLegend
10
- } from "./chunk-NMS5XSLX.js";
9
+ layoutInlineHeader
10
+ } from "./chunk-UIEKW4SG.js";
11
+ import {
12
+ TITLE_FONT_SIZE,
13
+ TITLE_FONT_WEIGHT,
14
+ TITLE_Y
15
+ } from "./chunk-VLC6WNRD.js";
11
16
  import {
12
17
  CARD_RADIUS,
13
18
  EDGE_DASH,
@@ -20,17 +25,12 @@ import {
20
25
  SEPARATOR_GAP
21
26
  } from "./chunk-XCKNFFKM.js";
22
27
  import {
23
- layoutInlineHeader
24
- } from "./chunk-42UJ23H3.js";
28
+ renderIntegratedLegend
29
+ } from "./chunk-NMS5XSLX.js";
25
30
  import {
26
31
  getLegendExtent,
27
32
  getMaxLegendReservedHeight
28
33
  } from "./chunk-JILEYZ2V.js";
29
- import {
30
- TITLE_FONT_SIZE,
31
- TITLE_FONT_WEIGHT,
32
- TITLE_Y
33
- } from "./chunk-VLC6WNRD.js";
34
34
  import {
35
35
  FONT_FAMILY
36
36
  } from "./chunk-ICLB27PZ.js";
@@ -1,12 +1,10 @@
1
- import {
2
- tryCollectNote
3
- } from "./chunk-3Y63RFJL.js";
4
- import {
5
- resolveNotes
6
- } from "./chunk-O753JUEZ.js";
7
1
  import {
8
2
  validateLabelCharacters
9
3
  } from "./chunk-N7VMGZCU.js";
4
+ import {
5
+ resolveNotes,
6
+ tryCollectNote
7
+ } from "./chunk-7SXV7NUS.js";
10
8
  import {
11
9
  displayName,
12
10
  normalizeName
@@ -0,0 +1,209 @@
1
+ import {
2
+ COLOR_KEYS,
3
+ SEMANTIC_KEYS,
4
+ validateThemeFile
5
+ } from "./chunk-FMAVHTYB.js";
6
+ import {
7
+ BUILT_IN_PALETTE_IDS
8
+ } from "./chunk-3UR4F7FE.js";
9
+ import {
10
+ makeDgmoError
11
+ } from "./chunk-BYU54C3S.js";
12
+
13
+ // src/palettes/directive.ts
14
+ var PALETTE_LINE_RE = /^palette(?:\s+(.*))?$/;
15
+ var MODES = /* @__PURE__ */ new Set(["light", "dark"]);
16
+ var COLOR_NAMES = new Set(COLOR_KEYS);
17
+ var kebab = (key) => key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
18
+ var camel = (key) => key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
19
+ var ROLE_KEYS = new Set(SEMANTIC_KEYS.map(kebab));
20
+ function builtInList() {
21
+ return [...BUILT_IN_PALETTE_IDS].sort().join(", ");
22
+ }
23
+ function warn(line, message, code) {
24
+ return makeDgmoError(line, message, "warning", code);
25
+ }
26
+ function readBlock(name, headerLine, block) {
27
+ const diagnostics = [];
28
+ const sections = {};
29
+ const where = /* @__PURE__ */ new Map();
30
+ let section;
31
+ for (const { line, text } of block) {
32
+ const [key = "", value, ...rest] = text.trim().split(/\s+/);
33
+ if (MODES.has(key) && value === void 0) {
34
+ section = key;
35
+ if (sections[section]) {
36
+ diagnostics.push(
37
+ warn(
38
+ line,
39
+ `The "${section}" section appears twice in palette "${name}".`,
40
+ "W_PALETTE_INVALID"
41
+ )
42
+ );
43
+ }
44
+ sections[section] = { roles: {}, colors: {} };
45
+ where.set(section, line);
46
+ continue;
47
+ }
48
+ if (key === "colors" && value === void 0) continue;
49
+ if (!section) {
50
+ diagnostics.push(
51
+ warn(
52
+ line,
53
+ `"${key}" sits outside a light or dark section of palette "${name}".`,
54
+ "W_PALETTE_INVALID"
55
+ )
56
+ );
57
+ continue;
58
+ }
59
+ if (value === void 0 || rest.length > 0) {
60
+ diagnostics.push(
61
+ warn(
62
+ line,
63
+ `Write "${key}" as one key and one hex colour, e.g. "${key} #282a36".`,
64
+ "W_PALETTE_INVALID"
65
+ )
66
+ );
67
+ continue;
68
+ }
69
+ if (COLOR_NAMES.has(key)) {
70
+ sections[section].colors[key] = value;
71
+ where.set(`${section}.colors.${key}`, line);
72
+ } else {
73
+ const field = ROLE_KEYS.has(key) ? camel(key) : key;
74
+ sections[section].roles[field] = value;
75
+ where.set(`${section}.${field}`, line);
76
+ }
77
+ }
78
+ if (diagnostics.length > 0) return diagnostics;
79
+ const modes = Object.keys(sections);
80
+ const input = {
81
+ id: name.toLowerCase(),
82
+ name,
83
+ ...modes.length === 1 && { mode: modes[0] }
84
+ };
85
+ for (const mode of modes) {
86
+ const { roles, colors } = sections[mode];
87
+ input[mode] = { ...roles, colors };
88
+ }
89
+ const result = validateThemeFile(input);
90
+ if (result.ok) return { palette: result.palette, mode: result.mode };
91
+ return result.errors.map((error) => {
92
+ const field = /^(light|dark)(?:\.colors)?\.(\w+)/.exec(error) ?? /^(light|dark)\b[^:]*: (\w+) /.exec(error);
93
+ const at = field ? where.get(`${field[1]}.colors.${field[2]}`) ?? where.get(`${field[1]}.${field[2]}`) ?? where.get(field[1]) : void 0;
94
+ return warn(
95
+ at ?? headerLine,
96
+ `Palette "${name}" is not drawn \u2014 ${error.replace(/\b(text[A-Z]\w*|[a-z]+[A-Z]\w*)\b/g, kebab)}.`,
97
+ "W_PALETTE_INVALID"
98
+ );
99
+ });
100
+ }
101
+ function extractPaletteDirective(content) {
102
+ if (!/^palette\b/m.test(content)) return { content, diagnostics: [] };
103
+ const lines = content.split("\n");
104
+ const diagnostics = [];
105
+ let paletteId;
106
+ let palette;
107
+ let mode;
108
+ for (let i = 0; i < lines.length; i++) {
109
+ const match = PALETTE_LINE_RE.exec(lines[i].replace(/\r$/, ""));
110
+ if (!match) continue;
111
+ const lineNumber = i + 1;
112
+ lines[i] = "//";
113
+ const block = [];
114
+ let blockEnd = i;
115
+ for (let j = i + 1; j < lines.length; j++) {
116
+ const next = lines[j].replace(/\r$/, "");
117
+ if (next.trim() === "") continue;
118
+ if (!/^\s/.test(next)) break;
119
+ blockEnd = j;
120
+ block.push({ line: j + 1, text: next });
121
+ }
122
+ for (let j = i + 1; j <= blockEnd; j++) lines[j] = "//";
123
+ i = blockEnd;
124
+ const words = (match[1] ?? "").trim().split(/\s+/).filter(Boolean);
125
+ const name = words[0];
126
+ if (!name) {
127
+ diagnostics.push(
128
+ warn(
129
+ lineNumber,
130
+ `"palette" needs a palette name \u2014 one of ${builtInList()}.`,
131
+ "W_PALETTE_UNKNOWN"
132
+ )
133
+ );
134
+ continue;
135
+ }
136
+ if (block.length > 0) {
137
+ if (words.length > 1) {
138
+ diagnostics.push(
139
+ warn(
140
+ lineNumber,
141
+ `An embedded palette takes its name only \u2014 its sections say which modes it has.`,
142
+ "W_PALETTE_MODE_UNKNOWN"
143
+ )
144
+ );
145
+ }
146
+ const read = readBlock(name, lineNumber, block);
147
+ if (Array.isArray(read)) {
148
+ diagnostics.push(...read);
149
+ continue;
150
+ }
151
+ paletteId = void 0;
152
+ palette = read.palette;
153
+ mode = read.mode ?? void 0;
154
+ continue;
155
+ }
156
+ const id = name.toLowerCase();
157
+ if (!BUILT_IN_PALETTE_IDS.has(id)) {
158
+ diagnostics.push(
159
+ warn(
160
+ lineNumber,
161
+ `"${name}" is not a built-in palette \u2014 this diagram uses the default palette. Built-in palettes: ${builtInList()}. An embedded palette needs its colours in an indented block.`,
162
+ "W_PALETTE_UNKNOWN"
163
+ )
164
+ );
165
+ continue;
166
+ }
167
+ const modeWord = words[1];
168
+ if (words.length > 2 || modeWord !== void 0 && !MODES.has(modeWord)) {
169
+ diagnostics.push(
170
+ warn(
171
+ lineNumber,
172
+ `"palette ${name}" takes one optional mode word, light or dark \u2014 the rest of the line is ignored.`,
173
+ "W_PALETTE_MODE_UNKNOWN"
174
+ )
175
+ );
176
+ }
177
+ paletteId = id;
178
+ palette = void 0;
179
+ mode = modeWord !== void 0 && MODES.has(modeWord) ? modeWord : void 0;
180
+ }
181
+ return {
182
+ content: lines.join("\n"),
183
+ ...paletteId !== void 0 && { paletteId },
184
+ ...palette !== void 0 && { palette },
185
+ ...mode !== void 0 && { mode },
186
+ diagnostics
187
+ };
188
+ }
189
+ function choosePalette(directive, caller) {
190
+ const callerTheme = caller.theme ?? "light";
191
+ if (caller.paletteOverride !== void 0) {
192
+ return { paletteId: caller.paletteOverride, theme: callerTheme };
193
+ }
194
+ const fileId = directive.palette?.id ?? directive.paletteId;
195
+ if (fileId !== void 0) {
196
+ const theme = directive.mode === "dark" ? "dark" : directive.mode === "light" && callerTheme !== "transparent" ? "light" : callerTheme;
197
+ return {
198
+ paletteId: fileId,
199
+ ...directive.palette && { palette: directive.palette },
200
+ theme
201
+ };
202
+ }
203
+ return { paletteId: caller.palette ?? "slate", theme: callerTheme };
204
+ }
205
+
206
+ export {
207
+ extractPaletteDirective,
208
+ choosePalette
209
+ };
@@ -1,19 +1,21 @@
1
1
  import {
2
2
  layoutClassDiagram
3
- } from "./chunk-5EBYPETE.js";
3
+ } from "./chunk-RESEJSCV.js";
4
4
  import {
5
- NOTE_BADGE_RADIUS,
6
- noteConnectorPoints,
7
- renderNoteBadge,
8
- renderNoteBox,
9
- renderNoteConnector
10
- } from "./chunk-JRWUHLRP.js";
5
+ extractExportSvg,
6
+ runInExportContainer
7
+ } from "./chunk-TOHTKLKE.js";
11
8
  import {
12
9
  ScaleContext
13
10
  } from "./chunk-24YPR5EH.js";
14
11
  import {
15
- renderIntegratedLegend
16
- } from "./chunk-NMS5XSLX.js";
12
+ layoutInlineHeader
13
+ } from "./chunk-UIEKW4SG.js";
14
+ import {
15
+ TITLE_FONT_SIZE,
16
+ TITLE_FONT_WEIGHT,
17
+ TITLE_Y
18
+ } from "./chunk-VLC6WNRD.js";
17
19
  import {
18
20
  ARROWHEAD_HEIGHT,
19
21
  ARROWHEAD_WIDTH,
@@ -23,26 +25,24 @@ import {
23
25
  NODE_STROKE_WIDTH
24
26
  } from "./chunk-XCKNFFKM.js";
25
27
  import {
26
- extractExportSvg,
27
- runInExportContainer
28
- } from "./chunk-TOHTKLKE.js";
29
- import {
30
- layoutInlineHeader
31
- } from "./chunk-42UJ23H3.js";
28
+ renderIntegratedLegend
29
+ } from "./chunk-NMS5XSLX.js";
32
30
  import {
33
31
  getLegendExtent
34
32
  } from "./chunk-JILEYZ2V.js";
35
33
  import {
36
- TITLE_FONT_SIZE,
37
- TITLE_FONT_WEIGHT,
38
- TITLE_Y
39
- } from "./chunk-VLC6WNRD.js";
34
+ parseClassDiagram
35
+ } from "./chunk-DLJJOCIT.js";
36
+ import {
37
+ NOTE_BADGE_RADIUS,
38
+ noteConnectorPoints,
39
+ renderNoteBadge,
40
+ renderNoteBox,
41
+ renderNoteConnector
42
+ } from "./chunk-VDY2GR6U.js";
40
43
  import {
41
44
  FONT_FAMILY
42
45
  } from "./chunk-ICLB27PZ.js";
43
- import {
44
- parseClassDiagram
45
- } from "./chunk-Q6ZQX2HX.js";
46
46
  import {
47
47
  fillModeFromOptions,
48
48
  legendInlineRequested,
@@ -1,12 +1,10 @@
1
- import {
2
- tryCollectNote
3
- } from "./chunk-3Y63RFJL.js";
4
- import {
5
- resolveNotes
6
- } from "./chunk-O753JUEZ.js";
7
1
  import {
8
2
  validateLabelCharacters
9
3
  } from "./chunk-N7VMGZCU.js";
4
+ import {
5
+ resolveNotes,
6
+ tryCollectNote
7
+ } from "./chunk-7SXV7NUS.js";
10
8
  import {
11
9
  displayName,
12
10
  normalizeName
@@ -1,15 +1,13 @@
1
1
  import {
2
2
  GRAPH_DX
3
3
  } from "./chunk-TIVMAITN.js";
4
- import {
5
- tryCollectNote
6
- } from "./chunk-3Y63RFJL.js";
7
- import {
8
- resolveNotes
9
- } from "./chunk-O753JUEZ.js";
10
4
  import {
11
5
  parseInArrowLabel
12
6
  } from "./chunk-N7VMGZCU.js";
7
+ import {
8
+ resolveNotes,
9
+ tryCollectNote
10
+ } from "./chunk-7SXV7NUS.js";
13
11
  import {
14
12
  displayName,
15
13
  normalizeName
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  acyclicOrient
3
- } from "./chunk-EJS3K44P.js";
3
+ } from "./chunk-VGAMBOOC.js";
4
4
 
5
5
  // src/swimlane/layout.ts
6
6
  var MARGIN = 30;