zombie-mermaid 2.2.3 → 2.2.6

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 (321) hide show
  1. package/README.md +4 -4
  2. package/dist/ascii.cjs +1 -11
  3. package/dist/ascii.d.cts +1 -167
  4. package/dist/ascii.d.ts +1 -167
  5. package/dist/ascii.js +1 -6591
  6. package/dist/cli.js +836 -10946
  7. package/dist/index.cjs +2 -81
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +42 -680
  10. package/dist/index.d.ts +42 -680
  11. package/dist/index.js +408 -10002
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp.cjs +1 -17909
  14. package/dist/mcp.d.cts +1 -11
  15. package/dist/mcp.d.ts +1 -11
  16. package/dist/mcp.js +1 -17884
  17. package/package.json +29 -29
  18. package/src/__tests__/workspace-package-boundaries.test.ts +15 -16
  19. package/src/__tests__/xychart-parser-categories.test.ts +78 -0
  20. package/src/ascii-entry.ts +14 -0
  21. package/src/cli/html-viewer.ts +5 -0
  22. package/src/mcp-entry.ts +21 -0
  23. package/dist/ascii.cjs.map +0 -1
  24. package/dist/ascii.js.map +0 -1
  25. package/dist/mcp.cjs.map +0 -1
  26. package/dist/mcp.js.map +0 -1
  27. package/packages/ascii-renderer/LICENSE +0 -22
  28. package/packages/ascii-renderer/src/ansi.ts +0 -490
  29. package/packages/ascii-renderer/src/canvas.ts +0 -658
  30. package/packages/ascii-renderer/src/class-diagram.ts +0 -2001
  31. package/packages/ascii-renderer/src/converter.ts +0 -446
  32. package/packages/ascii-renderer/src/coords.ts +0 -58
  33. package/packages/ascii-renderer/src/display-width.ts +0 -151
  34. package/packages/ascii-renderer/src/draw-arrows.ts +0 -549
  35. package/packages/ascii-renderer/src/draw-boxes.ts +0 -267
  36. package/packages/ascii-renderer/src/draw-bundles.ts +0 -611
  37. package/packages/ascii-renderer/src/draw-lines.ts +0 -174
  38. package/packages/ascii-renderer/src/draw-subgraphs.ts +0 -108
  39. package/packages/ascii-renderer/src/draw.ts +0 -337
  40. package/packages/ascii-renderer/src/edge-bundling.ts +0 -435
  41. package/packages/ascii-renderer/src/edge-cell-styles.ts +0 -81
  42. package/packages/ascii-renderer/src/edge-routing.ts +0 -1049
  43. package/packages/ascii-renderer/src/er-diagram.ts +0 -1488
  44. package/packages/ascii-renderer/src/flowchart.ts +0 -94
  45. package/packages/ascii-renderer/src/grid-occupancy.ts +0 -234
  46. package/packages/ascii-renderer/src/grid.ts +0 -1267
  47. package/packages/ascii-renderer/src/hyperlinks.ts +0 -248
  48. package/packages/ascii-renderer/src/index.ts +0 -163
  49. package/packages/ascii-renderer/src/lane-search.ts +0 -68
  50. package/packages/ascii-renderer/src/multiline-utils.ts +0 -82
  51. package/packages/ascii-renderer/src/pathfinder.ts +0 -448
  52. package/packages/ascii-renderer/src/registry.ts +0 -88
  53. package/packages/ascii-renderer/src/sequence.ts +0 -1318
  54. package/packages/ascii-renderer/src/shapes/circle.ts +0 -31
  55. package/packages/ascii-renderer/src/shapes/corners.ts +0 -273
  56. package/packages/ascii-renderer/src/shapes/diamond.ts +0 -31
  57. package/packages/ascii-renderer/src/shapes/hexagon.ts +0 -31
  58. package/packages/ascii-renderer/src/shapes/index.ts +0 -123
  59. package/packages/ascii-renderer/src/shapes/rectangle.ts +0 -199
  60. package/packages/ascii-renderer/src/shapes/rounded.ts +0 -31
  61. package/packages/ascii-renderer/src/shapes/special.ts +0 -352
  62. package/packages/ascii-renderer/src/shapes/stadium.ts +0 -122
  63. package/packages/ascii-renderer/src/shapes/state.ts +0 -204
  64. package/packages/ascii-renderer/src/shapes/types.ts +0 -78
  65. package/packages/ascii-renderer/src/territory.ts +0 -136
  66. package/packages/ascii-renderer/src/types.ts +0 -454
  67. package/packages/ascii-renderer/src/validate.ts +0 -189
  68. package/packages/ascii-renderer/src/xychart.ts +0 -1085
  69. package/packages/core/LICENSE +0 -22
  70. package/packages/core/src/click-directive.ts +0 -106
  71. package/packages/core/src/color-utils.ts +0 -205
  72. package/packages/core/src/diagram-type.ts +0 -35
  73. package/packages/core/src/direction-override.ts +0 -46
  74. package/packages/core/src/direction.ts +0 -56
  75. package/packages/core/src/index.ts +0 -34
  76. package/packages/core/src/init-directive.ts +0 -248
  77. package/packages/core/src/multiline-utils.ts +0 -275
  78. package/packages/core/src/statements.ts +0 -197
  79. package/packages/core/src/style-directives.ts +0 -214
  80. package/packages/core/src/text-metrics.ts +0 -498
  81. package/packages/core/src/theme.ts +0 -696
  82. package/packages/core/src/types.ts +0 -670
  83. package/packages/mcp/LICENSE +0 -22
  84. package/packages/mcp/src/index.ts +0 -17
  85. package/packages/mcp/src/server.ts +0 -135
  86. package/packages/mcp/src/tools/check-sequence-activations.ts +0 -91
  87. package/packages/mcp/src/tools/fix-sequence-activations.ts +0 -77
  88. package/packages/mcp/src/tools/render-ascii.ts +0 -99
  89. package/packages/mcp/src/tools/render-svg.ts +0 -95
  90. package/packages/mermaid-parser/LICENSE +0 -22
  91. package/packages/mermaid-parser/src/class/format.ts +0 -15
  92. package/packages/mermaid-parser/src/class/parser.ts +0 -593
  93. package/packages/mermaid-parser/src/class/types.ts +0 -166
  94. package/packages/mermaid-parser/src/er/parser.ts +0 -286
  95. package/packages/mermaid-parser/src/er/types.ts +0 -99
  96. package/packages/mermaid-parser/src/expanded-shapes.ts +0 -376
  97. package/packages/mermaid-parser/src/index.ts +0 -48
  98. package/packages/mermaid-parser/src/sequence/activation-check.ts +0 -149
  99. package/packages/mermaid-parser/src/sequence/activation-fix.ts +0 -112
  100. package/packages/mermaid-parser/src/sequence/box-color.ts +0 -85
  101. package/packages/mermaid-parser/src/sequence/parser.ts +0 -613
  102. package/packages/mermaid-parser/src/sequence/types.ts +0 -242
  103. package/packages/mermaid-parser/src/xychart/colors.ts +0 -177
  104. package/packages/mermaid-parser/src/xychart/parser.ts +0 -203
  105. package/packages/mermaid-parser/src/xychart/types.ts +0 -150
  106. package/packages/svg-renderer/LICENSE +0 -22
  107. package/packages/svg-renderer/src/class/layout.ts +0 -360
  108. package/packages/svg-renderer/src/class/renderer.ts +0 -636
  109. package/packages/svg-renderer/src/edge-curves.ts +0 -204
  110. package/packages/svg-renderer/src/elk-instance.ts +0 -292
  111. package/packages/svg-renderer/src/er/layout.ts +0 -200
  112. package/packages/svg-renderer/src/er/renderer.ts +0 -493
  113. package/packages/svg-renderer/src/index.ts +0 -58
  114. package/packages/svg-renderer/src/layout-engine/constants.ts +0 -19
  115. package/packages/svg-renderer/src/layout-engine/edge-bundling.ts +0 -379
  116. package/packages/svg-renderer/src/layout-engine/elk-adapter-utils.ts +0 -81
  117. package/packages/svg-renderer/src/layout-engine/elk-graph-builder.ts +0 -240
  118. package/packages/svg-renderer/src/layout-engine/from-elk.ts +0 -685
  119. package/packages/svg-renderer/src/layout-engine/layer-alignment.ts +0 -174
  120. package/packages/svg-renderer/src/layout-engine/to-elk.ts +0 -695
  121. package/packages/svg-renderer/src/layout-engine.ts +0 -74
  122. package/packages/svg-renderer/src/layout.ts +0 -8
  123. package/packages/svg-renderer/src/renderer.ts +0 -1485
  124. package/packages/svg-renderer/src/resolve-colors.ts +0 -339
  125. package/packages/svg-renderer/src/sequence/layout.ts +0 -698
  126. package/packages/svg-renderer/src/sequence/renderer.ts +0 -546
  127. package/packages/svg-renderer/src/shape-clipping.ts +0 -197
  128. package/packages/svg-renderer/src/styles.ts +0 -118
  129. package/packages/svg-renderer/src/xychart/layout.ts +0 -682
  130. package/packages/svg-renderer/src/xychart/renderer.ts +0 -684
  131. package/src/__tests__/ascii-canvas-write.test.ts +0 -137
  132. package/src/__tests__/ascii-charset-border-junctions.test.ts +0 -63
  133. package/src/__tests__/ascii-cjk-width.test.ts +0 -150
  134. package/src/__tests__/ascii-class-box-occupancy.test.ts +0 -462
  135. package/src/__tests__/ascii-class-column-width-488-489.test.ts +0 -639
  136. package/src/__tests__/ascii-class-cross-level-jog-corruption.test.ts +0 -187
  137. package/src/__tests__/ascii-class-detour-label-routing-487.test.ts +0 -114
  138. package/src/__tests__/ascii-class-diagram-compartments.test.ts +0 -70
  139. package/src/__tests__/ascii-class-label-box-collision.test.ts +0 -60
  140. package/src/__tests__/ascii-class-label-row-collision-531.test.ts +0 -135
  141. package/src/__tests__/ascii-class-label-territory-row-awareness.test.ts +0 -57
  142. package/src/__tests__/ascii-class-padding.test.ts +0 -104
  143. package/src/__tests__/ascii-class-parent-alignment-971.test.ts +0 -139
  144. package/src/__tests__/ascii-class-parent-alignment-972.test.ts +0 -208
  145. package/src/__tests__/ascii-class-reciprocal-relationships-448.test.ts +0 -169
  146. package/src/__tests__/ascii-combining-mark-width.test.ts +0 -70
  147. package/src/__tests__/ascii-coords-overlay.test.ts +0 -64
  148. package/src/__tests__/ascii-decision-lr-box-start.test.ts +0 -106
  149. package/src/__tests__/ascii-display-width-unit.test.ts +0 -154
  150. package/src/__tests__/ascii-draw-arrows-coverage.test.ts +0 -171
  151. package/src/__tests__/ascii-draw-arrows-single-point-path.test.ts +0 -112
  152. package/src/__tests__/ascii-edge-bundling-rank-violation-454.test.ts +0 -72
  153. package/src/__tests__/ascii-edge-ending-glyphs.test.ts +0 -206
  154. package/src/__tests__/ascii-edge-label-diagonal-fallback-418.test.ts +0 -95
  155. package/src/__tests__/ascii-edge-routing-fixes.test.ts +0 -178
  156. package/src/__tests__/ascii-edge-routing-single-point-path.test.ts +0 -107
  157. package/src/__tests__/ascii-edge-styles.test.ts +0 -149
  158. package/src/__tests__/ascii-emoji-cluster-width.test.ts +0 -101
  159. package/src/__tests__/ascii-er-box-occupancy.test.ts +0 -251
  160. package/src/__tests__/ascii-er-cardinality.test.ts +0 -40
  161. package/src/__tests__/ascii-er-corner-glyphs.test.ts +0 -249
  162. package/src/__tests__/ascii-er-jog-stray-line.test.ts +0 -111
  163. package/src/__tests__/ascii-er-label-padding.test.ts +0 -118
  164. package/src/__tests__/ascii-er-padding.test.ts +0 -114
  165. package/src/__tests__/ascii-er-relationship-label-corruption-350.test.ts +0 -458
  166. package/src/__tests__/ascii-er-relationship-overwrite.test.ts +0 -325
  167. package/src/__tests__/ascii-er-stray-connectors.test.ts +0 -347
  168. package/src/__tests__/ascii-er-unrelated-stem-separation-411.test.ts +0 -98
  169. package/src/__tests__/ascii-er-vertical-one-marker.test.ts +0 -110
  170. package/src/__tests__/ascii-label-line-terminal-fallback.test.ts +0 -172
  171. package/src/__tests__/ascii-lane-search.test.ts +0 -207
  172. package/src/__tests__/ascii-multibox-cjk-width.test.ts +0 -184
  173. package/src/__tests__/ascii-multiline.test.ts +0 -291
  174. package/src/__tests__/ascii-padding-edge-cases.test.ts +0 -154
  175. package/src/__tests__/ascii-pathfinder-route-edge.test.ts +0 -194
  176. package/src/__tests__/ascii-sequence-alt-else-label.test.ts +0 -236
  177. package/src/__tests__/ascii-sequence-block-wall-clearance.test.ts +0 -217
  178. package/src/__tests__/ascii-sequence-box-group.test.ts +0 -159
  179. package/src/__tests__/ascii-sequence-cjk-width.test.ts +0 -235
  180. package/src/__tests__/ascii-sequence-create-destroy.test.ts +0 -114
  181. package/src/__tests__/ascii-sequence-form-invariants.test.ts +0 -432
  182. package/src/__tests__/ascii-sequence-mermaid-parity.test.ts +0 -219
  183. package/src/__tests__/ascii-sequence-notes.test.ts +0 -61
  184. package/src/__tests__/ascii-sequence-padding.test.ts +0 -119
  185. package/src/__tests__/ascii-sequence-self-arrow.test.ts +0 -206
  186. package/src/__tests__/ascii-shape-diamond.test.ts +0 -38
  187. package/src/__tests__/ascii-shape-rectangle.test.ts +0 -258
  188. package/src/__tests__/ascii-shape-rounded.test.ts +0 -36
  189. package/src/__tests__/ascii-shapes-circle.test.ts +0 -41
  190. package/src/__tests__/ascii-shapes-hexagon.test.ts +0 -42
  191. package/src/__tests__/ascii-shapes-special.test.ts +0 -349
  192. package/src/__tests__/ascii-shapes-stadium.test.ts +0 -217
  193. package/src/__tests__/ascii-shapes-state.test.ts +0 -234
  194. package/src/__tests__/ascii-state-bidirectional-label-swap-530.test.ts +0 -130
  195. package/src/__tests__/ascii-subgraph-direction-honored-445.test.ts +0 -90
  196. package/src/__tests__/ascii-subgraph-label-border-clip.test.ts +0 -152
  197. package/src/__tests__/ascii-subgraph-title-padding.test.ts +0 -77
  198. package/src/__tests__/ascii-territory-unit.test.ts +0 -219
  199. package/src/__tests__/ascii-validate.test.ts +0 -220
  200. package/src/__tests__/ascii.test.ts +0 -328
  201. package/src/__tests__/box-color.test.ts +0 -80
  202. package/src/__tests__/class-arrow-directions.test.ts +0 -505
  203. package/src/__tests__/click-directive.test.ts +0 -63
  204. package/src/__tests__/color-utils.test.ts +0 -186
  205. package/src/__tests__/diagram-type.test.ts +0 -28
  206. package/src/__tests__/draw-lines.test.ts +0 -93
  207. package/src/__tests__/edge-cell-styles.test.ts +0 -180
  208. package/src/__tests__/elk-adapter-utils.test.ts +0 -166
  209. package/src/__tests__/grid-occupancy.test.ts +0 -240
  210. package/src/__tests__/helpers/ascii-form.ts +0 -142
  211. package/src/__tests__/helpers/terminal-display-width.ts +0 -74
  212. package/src/__tests__/mcp-check-sequence-activations-tool.test.ts +0 -85
  213. package/src/__tests__/mcp-fix-sequence-activations-tool.test.ts +0 -134
  214. package/src/__tests__/mcp-server.test.ts +0 -163
  215. package/src/__tests__/pathfinder.test.ts +0 -246
  216. package/src/__tests__/sequence-activation-fix.test.ts +0 -91
  217. package/src/__tests__/testdata/ascii/ampersand_lhs.txt +0 -18
  218. package/src/__tests__/testdata/ascii/ampersand_lhs_and_rhs.txt +0 -18
  219. package/src/__tests__/testdata/ascii/ampersand_rhs.txt +0 -18
  220. package/src/__tests__/testdata/ascii/ampersand_td_fanin.txt +0 -18
  221. package/src/__tests__/testdata/ascii/ampersand_td_fanout.txt +0 -18
  222. package/src/__tests__/testdata/ascii/ampersand_without_edge.txt +0 -18
  223. package/src/__tests__/testdata/ascii/back_reference_from_child.txt +0 -10
  224. package/src/__tests__/testdata/ascii/backlink_from_bottom.txt +0 -22
  225. package/src/__tests__/testdata/ascii/backlink_from_top.txt +0 -22
  226. package/src/__tests__/testdata/ascii/backlink_with_short_y_padding.txt +0 -20
  227. package/src/__tests__/testdata/ascii/cls_all_relationships.txt +0 -19
  228. package/src/__tests__/testdata/ascii/cls_annotation.txt +0 -29
  229. package/src/__tests__/testdata/ascii/cls_association.txt +0 -14
  230. package/src/__tests__/testdata/ascii/cls_basic.txt +0 -15
  231. package/src/__tests__/testdata/ascii/cls_dependency.txt +0 -14
  232. package/src/__tests__/testdata/ascii/cls_inheritance.txt +0 -20
  233. package/src/__tests__/testdata/ascii/cls_methods.txt +0 -21
  234. package/src/__tests__/testdata/ascii/comments.txt +0 -23
  235. package/src/__tests__/testdata/ascii/custom_padding.txt +0 -10
  236. package/src/__tests__/testdata/ascii/duplicate_labels.txt +0 -19
  237. package/src/__tests__/testdata/ascii/er_attributes.txt +0 -21
  238. package/src/__tests__/testdata/ascii/er_basic.txt +0 -8
  239. package/src/__tests__/testdata/ascii/er_identifying.txt +0 -18
  240. package/src/__tests__/testdata/ascii/flowchart_tb_simple.txt +0 -29
  241. package/src/__tests__/testdata/ascii/graph_bt_direction.txt +0 -28
  242. package/src/__tests__/testdata/ascii/graph_tb_direction.txt +0 -26
  243. package/src/__tests__/testdata/ascii/nested_subgraphs_with_labels.txt +0 -36
  244. package/src/__tests__/testdata/ascii/preserve_order_of_definition.txt +0 -23
  245. package/src/__tests__/testdata/ascii/self_reference.txt +0 -10
  246. package/src/__tests__/testdata/ascii/self_reference_with_edge.txt +0 -10
  247. package/src/__tests__/testdata/ascii/seq_basic.txt +0 -17
  248. package/src/__tests__/testdata/ascii/seq_multiple_messages.txt +0 -25
  249. package/src/__tests__/testdata/ascii/seq_self_message.txt +0 -18
  250. package/src/__tests__/testdata/ascii/single_node.txt +0 -8
  251. package/src/__tests__/testdata/ascii/single_node_longer_name.txt +0 -8
  252. package/src/__tests__/testdata/ascii/subgraph_complex_mixed.txt +0 -38
  253. package/src/__tests__/testdata/ascii/subgraph_complex_nested.txt +0 -49
  254. package/src/__tests__/testdata/ascii/subgraph_direction_override.txt +0 -47
  255. package/src/__tests__/testdata/ascii/subgraph_empty.txt +0 -10
  256. package/src/__tests__/testdata/ascii/subgraph_mixed_nodes.txt +0 -20
  257. package/src/__tests__/testdata/ascii/subgraph_mixed_nodes_td.txt +0 -48
  258. package/src/__tests__/testdata/ascii/subgraph_multiple_edges.txt +0 -32
  259. package/src/__tests__/testdata/ascii/subgraph_multiple_nodes.txt +0 -16
  260. package/src/__tests__/testdata/ascii/subgraph_nested.txt +0 -24
  261. package/src/__tests__/testdata/ascii/subgraph_nested_with_external.txt +0 -30
  262. package/src/__tests__/testdata/ascii/subgraph_node_outside_lr.txt +0 -17
  263. package/src/__tests__/testdata/ascii/subgraph_single_node.txt +0 -16
  264. package/src/__tests__/testdata/ascii/subgraph_td_direction.txt +0 -26
  265. package/src/__tests__/testdata/ascii/subgraph_td_multiple.txt +0 -44
  266. package/src/__tests__/testdata/ascii/subgraph_td_multiple_paddingy.txt +0 -42
  267. package/src/__tests__/testdata/ascii/subgraph_three_levels_nested.txt +0 -32
  268. package/src/__tests__/testdata/ascii/subgraph_three_separate.txt +0 -24
  269. package/src/__tests__/testdata/ascii/subgraph_two_separate.txt +0 -20
  270. package/src/__tests__/testdata/ascii/subgraph_with_labels.txt +0 -20
  271. package/src/__tests__/testdata/ascii/three_nodes.txt +0 -9
  272. package/src/__tests__/testdata/ascii/three_nodes_single_line.txt +0 -8
  273. package/src/__tests__/testdata/ascii/two_layer_single_graph.txt +0 -19
  274. package/src/__tests__/testdata/ascii/two_layer_single_graph_longer_names.txt +0 -19
  275. package/src/__tests__/testdata/ascii/two_nodes_linked.txt +0 -8
  276. package/src/__tests__/testdata/ascii/two_nodes_longer_names.txt +0 -8
  277. package/src/__tests__/testdata/ascii/two_root_nodes.txt +0 -19
  278. package/src/__tests__/testdata/ascii/two_root_nodes_longer_names.txt +0 -19
  279. package/src/__tests__/testdata/ascii/two_single_root_nodes.txt +0 -19
  280. package/src/__tests__/testdata/unicode/ampersand_lhs.txt +0 -18
  281. package/src/__tests__/testdata/unicode/ampersand_lhs_and_rhs.txt +0 -18
  282. package/src/__tests__/testdata/unicode/ampersand_rhs.txt +0 -18
  283. package/src/__tests__/testdata/unicode/ampersand_without_edge.txt +0 -18
  284. package/src/__tests__/testdata/unicode/back_reference_from_child.txt +0 -10
  285. package/src/__tests__/testdata/unicode/backlink_from_bottom.txt +0 -22
  286. package/src/__tests__/testdata/unicode/backlink_from_top.txt +0 -22
  287. package/src/__tests__/testdata/unicode/cls_all_relationships.txt +0 -19
  288. package/src/__tests__/testdata/unicode/cls_annotation.txt +0 -29
  289. package/src/__tests__/testdata/unicode/cls_association.txt +0 -14
  290. package/src/__tests__/testdata/unicode/cls_basic.txt +0 -15
  291. package/src/__tests__/testdata/unicode/cls_dependency.txt +0 -14
  292. package/src/__tests__/testdata/unicode/cls_inheritance.txt +0 -20
  293. package/src/__tests__/testdata/unicode/cls_methods.txt +0 -21
  294. package/src/__tests__/testdata/unicode/comments.txt +0 -23
  295. package/src/__tests__/testdata/unicode/duplicate_labels.txt +0 -19
  296. package/src/__tests__/testdata/unicode/er_attributes.txt +0 -21
  297. package/src/__tests__/testdata/unicode/er_basic.txt +0 -8
  298. package/src/__tests__/testdata/unicode/er_identifying.txt +0 -18
  299. package/src/__tests__/testdata/unicode/graph_bt_direction.txt +0 -28
  300. package/src/__tests__/testdata/unicode/preserve_order_of_definition.txt +0 -23
  301. package/src/__tests__/testdata/unicode/self_reference.txt +0 -10
  302. package/src/__tests__/testdata/unicode/self_reference_with_edge.txt +0 -10
  303. package/src/__tests__/testdata/unicode/seq_basic.txt +0 -17
  304. package/src/__tests__/testdata/unicode/seq_multiple_messages.txt +0 -25
  305. package/src/__tests__/testdata/unicode/seq_self_message.txt +0 -18
  306. package/src/__tests__/testdata/unicode/single_node.txt +0 -8
  307. package/src/__tests__/testdata/unicode/single_node_longer_name.txt +0 -8
  308. package/src/__tests__/testdata/unicode/three_nodes.txt +0 -9
  309. package/src/__tests__/testdata/unicode/three_nodes_single_line.txt +0 -8
  310. package/src/__tests__/testdata/unicode/two_layer_single_graph.txt +0 -19
  311. package/src/__tests__/testdata/unicode/two_layer_single_graph_longer_names.txt +0 -19
  312. package/src/__tests__/testdata/unicode/two_nodes_linked.txt +0 -8
  313. package/src/__tests__/testdata/unicode/two_nodes_longer_names.txt +0 -8
  314. package/src/__tests__/testdata/unicode/two_root_nodes.txt +0 -19
  315. package/src/__tests__/testdata/unicode/two_root_nodes_longer_names.txt +0 -19
  316. package/src/__tests__/testdata/unicode/two_single_root_nodes.txt +0 -19
  317. package/src/__tests__/text-metrics.test.ts +0 -473
  318. package/src/__tests__/theme-palette-contrast.test.ts +0 -84
  319. package/src/__tests__/theme.test.ts +0 -132
  320. package/src/__tests__/xychart-ascii.test.ts +0 -376
  321. package/src/__tests__/xychart-colors.test.ts +0 -149
@@ -1,78 +0,0 @@
1
- // ============================================================================
2
- // Shape renderer types — interface for pluggable ASCII shape renderers
3
- // ============================================================================
4
-
5
- import type {
6
- Canvas,
7
- DrawingCoord,
8
- Direction,
9
- AsciiNodeShape,
10
- } from '../types.ts'
11
-
12
- /**
13
- * Dimensions calculated for a shape, used by layout and rendering.
14
- */
15
- export interface ShapeDimensions {
16
- /** Total width in characters including borders */
17
- width: number
18
- /** Total height in characters including borders */
19
- height: number
20
- /** Label area bounds (where text can be placed) */
21
- labelArea: {
22
- x: number
23
- y: number
24
- width: number
25
- height: number
26
- }
27
- /** Grid column widths for the 3-column layout [left, center, right] */
28
- gridColumns: [number, number, number]
29
- /** Grid row heights for the 3-row layout [top, middle, bottom] */
30
- gridRows: [number, number, number]
31
- }
32
-
33
- /**
34
- * Options passed to shape renderers.
35
- */
36
- export interface ShapeRenderOptions {
37
- /** Use ASCII chars (+,-,|) vs Unicode box-drawing (┌,─,│) */
38
- useAscii: boolean
39
- /** Padding inside the shape */
40
- padding: number
41
- }
42
-
43
- /**
44
- * Interface for pluggable shape renderers.
45
- * Each shape type implements this interface.
46
- */
47
- export interface ShapeRenderer {
48
- /**
49
- * Calculate dimensions for this shape given a label.
50
- * Used during layout to determine node size.
51
- */
52
- getDimensions(label: string, options: ShapeRenderOptions): ShapeDimensions
53
-
54
- /**
55
- * Render the shape to a canvas.
56
- * Returns a standalone canvas containing just the shape.
57
- */
58
- render(
59
- label: string,
60
- dimensions: ShapeDimensions,
61
- options: ShapeRenderOptions,
62
- ): Canvas
63
-
64
- /**
65
- * Get the edge attachment point for a given direction.
66
- * Used by edge routing to determine where edges connect.
67
- */
68
- getAttachmentPoint(
69
- dir: Direction,
70
- dimensions: ShapeDimensions,
71
- baseCoord: DrawingCoord,
72
- ): DrawingCoord
73
- }
74
-
75
- /**
76
- * Registry of shape renderers keyed by shape type.
77
- */
78
- export type ShapeRegistry = Map<AsciiNodeShape, ShapeRenderer>
@@ -1,136 +0,0 @@
1
- // ============================================================================
2
- // ASCII renderer — 1-D territory allocation
3
- //
4
- // Splits contested horizontal space between items (labels) whose row spans
5
- // overlap, giving each a mutually exclusive [left, right] column range
6
- // derived purely from geometry — never from draw order or from what an
7
- // earlier item happened to render as.
8
- //
9
- // Extracted from `class-diagram.ts`'s `territoryByRel` precompute (issue
10
- // #618). It stayed out of the shared `Grid` occupancy model (issue #532)
11
- // deliberately: this is a 1-D interval-scheduling problem over item
12
- // midpoints, not a 2-D occupancy map, so there is nothing to reserve and
13
- // nothing to look up per cell. Keeping it storage-agnostic — the caller
14
- // supplies geometry, this module supplies only the allocation — means a
15
- // second renderer can adopt it without first adopting a grid.
16
- // ============================================================================
17
-
18
- /**
19
- * One item's placement geometry, in whatever units the caller works in
20
- * (columns and rows, for the ASCII renderers).
21
- *
22
- * `start`/`end` describe the item's *natural* span — where it would sit if
23
- * nothing else competed for the space — and must already be clamped exactly
24
- * the way the caller's own draw pass clamps it. Passing an unclamped span
25
- * under-detects real collisions: an item pinned at the canvas edge draws at
26
- * column 0 but would be compared here as if it were still off-canvas at its
27
- * raw negative position, so the overlap with its neighbour is missed
28
- * entirely (issue #447).
29
- *
30
- * `rowStart`/`rowEnd` are inclusive and must likewise be the item's *final*
31
- * resolved rows, not a pre-fallback ideal: two items whose ideal rows don't
32
- * overlap can still resolve onto the same actual row, and a territory
33
- * computed from the ideal rows leaves them unsplit — so the later one's
34
- * draw silently overwrites the earlier one's (issue #531).
35
- */
36
- export interface TerritoryGeometry {
37
- /** The item's preferred centre along the allocated axis. */
38
- idealMid: number
39
- /** Inclusive first column of the item's natural (uncontested) span. */
40
- start: number
41
- /** Inclusive last column of the item's natural (uncontested) span. */
42
- end: number
43
- /** Inclusive first row the item occupies. */
44
- rowStart: number
45
- /** Inclusive last row the item occupies. */
46
- rowEnd: number
47
- }
48
-
49
- /**
50
- * The columns an item may draw into, inclusive on both sides. An
51
- * unconstrained side is `-Infinity` / `Infinity` rather than a sentinel
52
- * number, so a caller can clamp or compare without special-casing.
53
- */
54
- export interface Territory {
55
- left: number
56
- right: number
57
- }
58
-
59
- /** Whether two items' row spans actually intersect. */
60
- function rowsOverlap(a: TerritoryGeometry, b: TerritoryGeometry): boolean {
61
- return a.rowStart <= b.rowEnd && b.rowStart <= a.rowEnd
62
- }
63
-
64
- /**
65
- * Allocate each item a horizontal territory, splitting contested space
66
- * evenly at the midpoint between two competing items' `idealMid` values.
67
- *
68
- * Two items are competitors only when *both* their row spans intersect and
69
- * their natural spans overlap; anything else leaves both sides unconstrained
70
- * (`±Infinity`). Competitors are found by scanning outward in `idealMid`
71
- * order for the nearest row-overlapping item on each side — not by stopping
72
- * at the immediately adjacent one, since a non-colliding item can sit
73
- * between two that genuinely do collide (issue #531).
74
- *
75
- * Allocating up front, before anything is drawn, is what makes placement
76
- * independent of iteration order. A *reactive* approach — only avoiding
77
- * cells an earlier iteration already wrote — cascades: one item shifted into
78
- * view at the canvas edge eats its neighbour's rightful columns, that
79
- * neighbour then has nothing left to claim and vanishes, and everything
80
- * after it drifts based on the leftovers. With fixed, mutually exclusive
81
- * territories, a genuinely insufficient width truncates every competitor
82
- * consistently instead of destroying an arbitrary subset (issue #447).
83
- *
84
- * `geometry` is called exactly once per item, in `items` order. Items
85
- * tying on `idealMid` keep their `items` order (the sort is stable).
86
- *
87
- * @param items Items to allocate for, in any order.
88
- * @param geometry Extracts an item's placement geometry.
89
- * @returns Each item mapped to its allocated territory. Every item in
90
- * `items` is present; passing the same item reference twice yields one
91
- * entry (the last one allocated).
92
- */
93
- export function allocateTerritory<T>(
94
- items: readonly T[],
95
- geometry: (item: T) => TerritoryGeometry,
96
- ): Map<T, Territory> {
97
- const ordered = items
98
- .map((item) => ({ item, geom: geometry(item) }))
99
- .sort((a, b) => a.geom.idealMid - b.geom.idealMid)
100
-
101
- /**
102
- * The nearest entry in `dir` (-1 left, +1 right) from `idx`, by `idealMid`
103
- * order, whose rows actually overlap `ordered[idx]`'s — skipping over any
104
- * immediately-adjacent entries that don't.
105
- */
106
- const nearestRowOverlapping = (
107
- idx: number,
108
- dir: -1 | 1,
109
- ): TerritoryGeometry | undefined => {
110
- const g = ordered[idx]
111
- if (!g) return undefined
112
- for (let j = idx + dir; j >= 0 && j < ordered.length; j += dir) {
113
- const candidate = ordered[j]
114
- if (candidate && rowsOverlap(candidate.geom, g.geom))
115
- return candidate.geom
116
- }
117
- return undefined
118
- }
119
-
120
- const territories = new Map<T, Territory>()
121
- for (const [i, entry] of ordered.entries()) {
122
- const g = entry.geom
123
- const prev = nearestRowOverlapping(i, -1)
124
- const next = nearestRowOverlapping(i, 1)
125
- const left =
126
- prev && prev.end >= g.start
127
- ? Math.floor((prev.idealMid + g.idealMid) / 2) + 1
128
- : -Infinity
129
- const right =
130
- next && g.end >= next.start
131
- ? Math.floor((g.idealMid + next.idealMid) / 2)
132
- : Infinity
133
- territories.set(entry.item, { left, right })
134
- }
135
- return territories
136
- }
@@ -1,454 +0,0 @@
1
- // ============================================================================
2
- // ASCII renderer — type definitions
3
- //
4
- // Ported from AlexanderGrooff/mermaid-ascii (Go).
5
- // These types model the grid-based coordinate system, 2D text canvas,
6
- // and graph structures used by the ASCII/Unicode renderer.
7
- // ============================================================================
8
-
9
- import type { NodeShape } from '@zombie-mermaid/core'
10
- import type { Grid } from './grid-occupancy.ts'
11
-
12
- // Re-export NodeShape for convenience
13
- export type { NodeShape }
14
-
15
- /**
16
- * Shape type for ASCII rendering — maps parser shapes to ASCII renderers.
17
- * Most shapes from the parser are supported, with fallback to 'rectangle'.
18
- */
19
- export type AsciiNodeShape = NodeShape
20
-
21
- /** Logical grid coordinate — nodes occupy 3x3 blocks on this grid. */
22
- export interface GridCoord {
23
- x: number
24
- y: number
25
- }
26
-
27
- /**
28
- * A mutable, render-wide A* iteration budget shared across every getPath
29
- * call made while routing one graph's edges (see pathfinder.ts's getPath
30
- * and grid.ts's createMapping). Bounds total pathfinding work for the whole
31
- * render, independent of any single call's own per-call iteration cap.
32
- */
33
- export interface PathBudget {
34
- remaining: number
35
- }
36
-
37
- /** Character-level coordinate on the 2D text canvas. */
38
- export interface DrawingCoord {
39
- x: number
40
- y: number
41
- }
42
-
43
- /**
44
- * Direction constants model positions on a node's 3x3 grid block.
45
- * Each node occupies grid cells [x..x+2, y..y+2].
46
- * Directions are offsets into that block, used for edge attachment points.
47
- *
48
- * (0,0) UL (1,0) Up (2,0) UR
49
- * (0,1) Left (1,1) Mid (2,1) Right
50
- * (0,2) LL (1,2) Down (2,2) LR
51
- */
52
- export interface Direction {
53
- readonly x: number
54
- readonly y: number
55
- }
56
-
57
- export const Up: Direction = { x: 1, y: 0 }
58
- export const Down: Direction = { x: 1, y: 2 }
59
- export const Left: Direction = { x: 0, y: 1 }
60
- export const Right: Direction = { x: 2, y: 1 }
61
- export const UpperRight: Direction = { x: 2, y: 0 }
62
- export const UpperLeft: Direction = { x: 0, y: 0 }
63
- export const LowerRight: Direction = { x: 2, y: 2 }
64
- export const LowerLeft: Direction = { x: 0, y: 2 }
65
- export const Middle: Direction = { x: 1, y: 1 }
66
-
67
- /** All named directions for iteration. */
68
- export const ALL_DIRECTIONS: readonly Direction[] = [
69
- Up,
70
- Down,
71
- Left,
72
- Right,
73
- UpperRight,
74
- UpperLeft,
75
- LowerRight,
76
- LowerLeft,
77
- Middle,
78
- ]
79
-
80
- /** Compare directions by value (not reference). */
81
- export function dirEquals(a: Direction, b: Direction): boolean {
82
- return a.x === b.x && a.y === b.y
83
- }
84
-
85
- declare const cardinalDirectionBrand: unique symbol
86
-
87
- /**
88
- * The 4 pure cardinal directions — Up/Down/Left/Right — the only Direction
89
- * values pathfinder.ts's routeEdge/tryDirectPath know how to turn into a
90
- * single L-shaped route (horizontal-first for Left/Right, vertical-first
91
- * for Up/Down). The other 5 Direction values (the four diagonals, plus
92
- * Middle) don't correspond to one routing axis. Direction can't
93
- * structurally distinguish these on its own — all 9 constants share the
94
- * same {x, y} shape — so this is a nominal brand: requireCardinalDirection
95
- * below is the only way to produce one, and it checks the actual value
96
- * rather than trusting a caller's claim.
97
- */
98
- export type CardinalDirection = Direction & {
99
- readonly [cardinalDirectionBrand]: true
100
- }
101
-
102
- function isCardinalDirection(d: Direction): d is CardinalDirection {
103
- return (
104
- dirEquals(d, Up) ||
105
- dirEquals(d, Down) ||
106
- dirEquals(d, Left) ||
107
- dirEquals(d, Right)
108
- )
109
- }
110
-
111
- /**
112
- * Narrow a Direction into a CardinalDirection, throwing if it isn't one of
113
- * Up/Down/Left/Right. Mirrors requireGridCoord/requirePathBudget elsewhere
114
- * in this module family: the invariant that routeEdge only ever receives a
115
- * cardinal direction lives in caller logic spread across edge-routing.ts
116
- * and edge-bundling.ts, not in Direction's type, so it's checked explicitly
117
- * at the boundary rather than trusted silently across modules.
118
- */
119
- export function requireCardinalDirection(d: Direction): CardinalDirection {
120
- if (!isCardinalDirection(d)) {
121
- throw new Error(
122
- `Expected a cardinal direction (Up/Down/Left/Right); got {x:${d.x}, y:${d.y}}`,
123
- )
124
- }
125
- return d
126
- }
127
-
128
- /**
129
- * 2D text canvas — column-major (canvas[x][y]).
130
- * Each cell holds a single character (or space).
131
- */
132
- export type Canvas = string[][]
133
-
134
- /** A node in the ASCII graph, positioned on the grid. */
135
- export interface AsciiNode {
136
- /** Unique identity key — the original node ID from the parser (e.g. "A", "B"). */
137
- name: string
138
- /** Human-readable label for rendering inside the box (e.g. "Web Server"). */
139
- displayLabel: string
140
- /** Node shape from the parser (e.g. "rectangle", "diamond", "circle"). */
141
- shape: AsciiNodeShape
142
- index: number
143
- gridCoord: GridCoord | null
144
- drawingCoord: DrawingCoord | null
145
- drawing: Canvas | null
146
- drawn: boolean
147
- styleClassName: string
148
- styleClass: AsciiStyleClass
149
- }
150
-
151
- /** Style class for colored node text (ported from Go's classDef). */
152
- export interface AsciiStyleClass {
153
- name: string
154
- styles: Record<string, string>
155
- }
156
-
157
- /** Edge line style for ASCII rendering. */
158
- export type AsciiEdgeStyle = 'solid' | 'dotted' | 'thick' | 'invisible'
159
-
160
- /** An edge in the ASCII graph, with a routed path. */
161
- export interface AsciiEdge {
162
- from: AsciiNode
163
- to: AsciiNode
164
- text: string
165
- path: GridCoord[]
166
- labelLine: GridCoord[]
167
- startDir: Direction
168
- endDir: Direction
169
- /** Line style: solid (default), dotted (-.->) or thick (==>) */
170
- style: AsciiEdgeStyle
171
- /** Whether to render an arrowhead at the start (source end) of the edge */
172
- hasArrowStart: boolean
173
- /** Whether to render an arrowhead at the end (target end) of the edge */
174
- hasArrowEnd: boolean
175
- /**
176
- * Terminator shape at the source end when it's a circle/cross marker
177
- * (`o--`/`x--`) rather than a plain arrowhead. Undefined draws the
178
- * regular arrowhead glyph (per `hasArrowStart`). See issue #330.
179
- */
180
- startMarker?: 'circle' | 'cross'
181
- /** Terminator shape at the target end (`--o`/`--x`). See `startMarker`. */
182
- endMarker?: 'circle' | 'cross'
183
- /** Bundle this edge belongs to (if any). Set during bundling analysis. */
184
- bundle?: EdgeBundle
185
- /**
186
- * For bundled edges: path from source/target to the junction point.
187
- * The full visual path is: pathToJunction + bundle.sharedPath (for fan-in)
188
- * or bundle.sharedPath + pathToJunction (for fan-out).
189
- */
190
- pathToJunction?: GridCoord[]
191
- /**
192
- * Set when this edge connects the same *pair* of nodes as one or more
193
- * sibling edges — either in the same direction (`A -->|One| B` and
194
- * `A -->|Two| B`) or, for a pair laid out side by side, in opposite
195
- * directions (`A -->|req| B` and `B -->|res| A`). See
196
- * `parallelGroupKey` in edge-routing.ts for the exact rule. This is as
197
- * opposed to edges that merely share one endpoint, which `bundle` above
198
- * already handles via fan-in/fan-out junctions.
199
- *
200
- * `index` is this edge's 0-based position within the group (declaration
201
- * order); `total` is the group's size. `index === 0` keeps the ordinary
202
- * single-edge route (determinePath's ordinary preferred/alternative
203
- * search), so a graph with no parallel edges renders identically to
204
- * before this field existed. `index > 0` routes through an offset lane
205
- * instead — see determinePath in edge-routing.ts — so sibling edges never
206
- * compute the identical path (and therefore identically-positioned,
207
- * mutually-corrupting labels; see #329 and #629).
208
- *
209
- * `usedOffsets` is the *same* Set object, by reference, on every edge in
210
- * the group (assigned once in assignParallelEdgeLanes) — the lane-offset
211
- * search in buildParallelLanePath can land two different lane indices on
212
- * the same actual offset when both have to detour around the same
213
- * obstacle (see that function's doc), so each successful search records
214
- * its chosen offset here and skips any offset a sibling already claimed,
215
- * keeping every lane in the group on a genuinely distinct path.
216
- */
217
- parallelLane?: { index: number; total: number; usedOffsets: Set<number> }
218
- }
219
-
220
- /** A subgraph container with bounding box for rendering. */
221
- export interface AsciiSubgraph {
222
- name: string
223
- nodes: AsciiNode[]
224
- parent: AsciiSubgraph | null
225
- children: AsciiSubgraph[]
226
- minX: number
227
- minY: number
228
- maxX: number
229
- maxY: number
230
- /** Optional direction override for layout within this subgraph (LR or TD). */
231
- direction?: 'LR' | 'TD'
232
- }
233
-
234
- // ============================================================================
235
- // Padding defaults
236
- //
237
- // Shared by every renderer that reads AsciiConfig's padding fields. Layouts
238
- // that predate `paddingX`/`paddingY`/`boxBorderPadding` becoming configurable
239
- // (sequence, class, ER — see issue #343) compute their own spacing as an
240
- // offset from these defaults rather than substituting the raw config value
241
- // directly, so that *not* passing a padding option still renders exactly as
242
- // it always has (no baseline/snapshot churn) while explicitly passing one
243
- // still visibly changes spacing. The flowchart/state grid layout (grid.ts)
244
- // predates this convention and uses `paddingX`/`paddingY` directly as its
245
- // column/row gap — don't "fix" that to go through these constants too, its
246
- // existing default already equals them, so behavior is identical.
247
- // ============================================================================
248
-
249
- /** `AsciiConfig.paddingX`'s default — see the block comment above. */
250
- export const DEFAULT_PADDING_X = 5
251
- /** `AsciiConfig.paddingY`'s default — see the block comment above. */
252
- export const DEFAULT_PADDING_Y = 5
253
- /** `AsciiConfig.boxBorderPadding`'s default — see the block comment above. */
254
- export const DEFAULT_BOX_BORDER_PADDING = 1
255
-
256
- /**
257
- * Derive a diagram-local spacing constant from a padding option, offset from
258
- * that option's default so a diagram whose own historical constant differs
259
- * from the shared default (e.g. class diagrams' 4-column gap vs. the shared
260
- * default of 5) still renders unchanged when the caller passes no explicit
261
- * padding override. `-x`/`-y`/`-p` still visibly widen or tighten spacing
262
- * because they shift `configValue` away from `defaultValue`.
263
- *
264
- * Shared by sequence.ts/class-diagram.ts/er-diagram.ts so the three
265
- * renderers wired up for issue #343 apply padding the same way instead of
266
- * each re-deriving this arithmetic.
267
- *
268
- * @param floor - Minimum result, so a large negative padding can't collapse
269
- * the spacing to zero or negative (which would overlap adjacent elements).
270
- */
271
- export function paddingOffset(
272
- configValue: number,
273
- defaultValue: number,
274
- base: number,
275
- floor: number,
276
- ): number {
277
- return Math.max(floor, base + (configValue - defaultValue))
278
- }
279
-
280
- /** Configuration for ASCII rendering. */
281
- export interface AsciiConfig {
282
- /** true = ASCII chars (+,-,|), false = Unicode box-drawing (┌,─,│). Default: false */
283
- useAscii: boolean
284
- /** Horizontal spacing between nodes. Default: 5 */
285
- paddingX: number
286
- /** Vertical spacing between nodes. Default: 5 */
287
- paddingY: number
288
- /** Padding inside node boxes. Default: 1 */
289
- boxBorderPadding: number
290
- /** Graph direction: "LR" or "TD". */
291
- graphDirection: 'LR' | 'TD'
292
- }
293
-
294
- /** Full ASCII graph state used during layout and rendering. */
295
- export interface AsciiGraph {
296
- nodes: AsciiNode[]
297
- edges: AsciiEdge[]
298
- canvas: Canvas
299
- /** Role canvas — tracks the role of each character for colored output. */
300
- roleCanvas: RoleCanvas
301
- /** Grid occupancy map — tracks which "x,y" cells are reserved. */
302
- grid: Grid
303
- columnWidth: Map<number, number>
304
- rowHeight: Map<number, number>
305
- subgraphs: AsciiSubgraph[]
306
- config: AsciiConfig
307
- /** Offset applied to all drawing coords to accommodate subgraph borders. */
308
- offsetX: number
309
- offsetY: number
310
- /** Edge bundles for parallel link visualization. Set during bundling analysis. */
311
- bundles: EdgeBundle[]
312
- /**
313
- * Render-wide A* iteration budget shared across every getPath call made
314
- * while routing this graph's edges. Bounds total pathfinding work (and
315
- * therefore memory) for graphs with many edges, independent of any
316
- * single call's own iteration cap. Set at the start of createMapping's
317
- * edge-routing phase; undefined before then. See pathfinder.ts's
318
- * PathBudget for details.
319
- */
320
- pathBudget?: PathBudget
321
- }
322
-
323
- // ============================================================================
324
- // Coordinate helpers
325
- // ============================================================================
326
-
327
- export function gridCoordEquals(a: GridCoord, b: GridCoord): boolean {
328
- return a.x === b.x && a.y === b.y
329
- }
330
-
331
- export function drawingCoordEquals(a: DrawingCoord, b: DrawingCoord): boolean {
332
- return a.x === b.x && a.y === b.y
333
- }
334
-
335
- /** Apply a direction offset to a grid coordinate (move into the 3x3 block). */
336
- export function gridCoordDirection(c: GridCoord, dir: Direction): GridCoord {
337
- return { x: c.x + dir.x, y: c.y + dir.y }
338
- }
339
-
340
- /** Key for storing GridCoord in a Map. */
341
- export function gridKey(c: GridCoord): string {
342
- return `${c.x},${c.y}`
343
- }
344
-
345
- /**
346
- * Get a node's grid coordinate. Every consumer of a node's `gridCoord` after
347
- * layout (edge routing, edge bundling, drawing) runs strictly after
348
- * `createMapping` (grid.ts) has placed every node, so this is always defined
349
- * for a real graph — but that guarantee lives in layout's control flow, not
350
- * in `AsciiNode`'s type (`gridCoord: GridCoord | null`), so it's narrowed
351
- * here explicitly rather than trusted silently across the module boundary.
352
- *
353
- * Lives here (not in grid.ts, where it originated) because it's a pure
354
- * predicate over `AsciiNode` with zero dependency on grid/layout state —
355
- * keeping it here lets `draw-boxes.ts` and `draw-bundles.ts` reuse it
356
- * without pulling in all of grid.ts's transitive imports.
357
- */
358
- export function requireGridCoord(node: AsciiNode): GridCoord {
359
- const gc = node.gridCoord
360
- if (gc === null) {
361
- /* v8 ignore next */
362
- throw new Error(
363
- `Node "${node.name}" has no gridCoord; grid layout must run before it is read`,
364
- )
365
- }
366
- return gc
367
- }
368
-
369
- /** Default empty style class. */
370
- export const EMPTY_STYLE: AsciiStyleClass = { name: '', styles: {} }
371
-
372
- // ============================================================================
373
- // Character role types for colored output
374
- // ============================================================================
375
-
376
- /**
377
- * Role of a character in the ASCII diagram, used for theming.
378
- * Each role maps to a different color when colors are enabled.
379
- */
380
- export type CharRole =
381
- | 'text' // Node labels, edge labels
382
- | 'border' // Node box borders, subgraph borders
383
- | 'line' // Edge lines (paths between nodes)
384
- | 'arrow' // Arrowheads (▲▼◄► or ^v<>)
385
- | 'corner' // Corner characters at path bends
386
- | 'junction' // Junction characters (┬┴├┤ where edges meet boxes)
387
-
388
- /**
389
- * Role canvas — parallel to Canvas, tracks the role of each character.
390
- * Same column-major structure: roleCanvas[x][y] gives the role at (x, y).
391
- * null means the character has no role (whitespace).
392
- */
393
- export type RoleCanvas = (CharRole | null)[][]
394
-
395
- /**
396
- * Theme colors for ASCII output — hex color strings.
397
- * Derived from the SVG theme system for visual consistency.
398
- */
399
- export interface AsciiTheme {
400
- /** Text color (node labels, edge labels) */
401
- fg: string
402
- /** Box border color (node borders, subgraph borders) */
403
- border: string
404
- /** Edge line color (paths between nodes) */
405
- line: string
406
- /** Arrowhead color (▲▼◄► or ^v<>) */
407
- arrow: string
408
- /** Theme accent color (optional, used by xycharts for series 0) */
409
- accent?: string
410
- /** Background color (optional, used by xycharts for dark-mode-aware shading) */
411
- bg?: string
412
- /** Corner character color (optional, defaults to line) */
413
- corner?: string
414
- /** Junction character color (optional, defaults to border) */
415
- junction?: string
416
- }
417
-
418
- /** Color mode for output. */
419
- export type ColorMode =
420
- | 'none' // No colors (plain text)
421
- | 'ansi16' // 16-color ANSI (basic terminals)
422
- | 'ansi256' // 256-color ANSI (xterm)
423
- | 'truecolor' // 24-bit RGB (modern terminals)
424
- | 'html' // HTML <span> tags with inline color styles (browsers)
425
-
426
- // ============================================================================
427
- // Edge bundling types
428
- // ============================================================================
429
-
430
- /**
431
- * Edge bundle — groups edges that share a common source or target.
432
- * Used to visually merge parallel links before they reach the shared node.
433
- *
434
- * For fan-in (A & B --> C): multiple sources converge to one target.
435
- * For fan-out (A --> B & C): one source diverges to multiple targets.
436
- */
437
- export interface EdgeBundle {
438
- /** Bundle type: fan-in = many→one, fan-out = one→many */
439
- type: 'fan-in' | 'fan-out'
440
- /** Edges in this bundle */
441
- edges: AsciiEdge[]
442
- /** The common node (target for fan-in, source for fan-out) */
443
- sharedNode: AsciiNode
444
- /** The non-shared nodes (sources for fan-in, targets for fan-out) */
445
- otherNodes: AsciiNode[]
446
- /** Junction point where edges merge/split — set during routing */
447
- junctionPoint: GridCoord | null
448
- /** Path from junction to shared node (drawn once for all edges) */
449
- sharedPath: GridCoord[]
450
- /** Direction when entering/exiting the junction */
451
- junctionDir: Direction
452
- /** Direction when entering/exiting the shared node */
453
- sharedNodeDir: Direction
454
- }