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,658 +0,0 @@
1
- // ============================================================================
2
- // ASCII renderer — 2D text canvas
3
- //
4
- // Ported from AlexanderGrooff/mermaid-ascii cmd/draw.go.
5
- // The canvas is a column-major 2D array of single-character strings.
6
- // canvas[x][y] gives the character at column x, row y.
7
- // ============================================================================
8
-
9
- import type {
10
- Canvas,
11
- DrawingCoord,
12
- RoleCanvas,
13
- CharRole,
14
- AsciiTheme,
15
- ColorMode,
16
- } from './types.ts'
17
- import { colorizeLine, DEFAULT_ASCII_THEME } from './ansi.ts'
18
- import { toDisplayCells } from './display-width.ts'
19
- import { joinWithLinks } from './hyperlinks.ts'
20
- import type { LinkCanvas } from './hyperlinks.ts'
21
-
22
- /**
23
- * Create a blank canvas filled with spaces.
24
- * Dimensions are inclusive: mkCanvas(3, 2) creates a 4x3 grid (indices 0..3, 0..2).
25
- */
26
- export function mkCanvas(x: number, y: number): Canvas {
27
- const canvas: Canvas = []
28
- for (let i = 0; i <= x; i++) {
29
- const col: string[] = []
30
- for (let j = 0; j <= y; j++) {
31
- col.push(' ')
32
- }
33
- canvas.push(col)
34
- }
35
- return canvas
36
- }
37
-
38
- /** Create a blank canvas with the same dimensions as the given canvas. */
39
- export function copyCanvas(source: Canvas): Canvas {
40
- const [maxX, maxY] = getCanvasSize(source)
41
- return mkCanvas(maxX, maxY)
42
- }
43
-
44
- // ============================================================================
45
- // Role canvas creation and management
46
- // ============================================================================
47
-
48
- /**
49
- * Create a blank role canvas filled with nulls.
50
- * Same dimensions as mkCanvas — column-major, roleCanvas[x][y].
51
- */
52
- export function mkRoleCanvas(x: number, y: number): RoleCanvas {
53
- const roleCanvas: RoleCanvas = []
54
- for (let i = 0; i <= x; i++) {
55
- const col: (CharRole | null)[] = []
56
- for (let j = 0; j <= y; j++) {
57
- col.push(null)
58
- }
59
- roleCanvas.push(col)
60
- }
61
- return roleCanvas
62
- }
63
-
64
- /** Create a blank role canvas with the same dimensions as the given role canvas. */
65
- export function copyRoleCanvas(source: RoleCanvas): RoleCanvas {
66
- const maxX = source.length - 1
67
- const maxY = (source[0]?.length ?? 1) - 1
68
- return mkRoleCanvas(maxX, maxY)
69
- }
70
-
71
- /**
72
- * Grow the role canvas to fit at least (newX, newY), preserving existing roles.
73
- * Mutates the role canvas in place and returns it.
74
- */
75
- export function increaseRoleCanvasSize(
76
- roleCanvas: RoleCanvas,
77
- newX: number,
78
- newY: number,
79
- ): RoleCanvas {
80
- const currX = roleCanvas.length - 1
81
- const currY = (roleCanvas[0]?.length ?? 1) - 1
82
- const targetX = Math.max(newX, currX)
83
- const targetY = Math.max(newY, currY)
84
- const grown = mkRoleCanvas(targetX, targetY)
85
- for (let x = 0; x < grown.length; x++) {
86
- for (let y = 0; y < (grown[0]?.length ?? 0); y++) {
87
- if (x < roleCanvas.length && y < (roleCanvas[0]?.length ?? 0)) {
88
- grown[x]![y] = roleCanvas[x]![y]!
89
- }
90
- }
91
- }
92
- roleCanvas.length = 0
93
- roleCanvas.push(...grown)
94
- return roleCanvas
95
- }
96
-
97
- /**
98
- * Set a role at a specific coordinate.
99
- * Expands the role canvas if necessary.
100
- */
101
- export function setRole(
102
- roleCanvas: RoleCanvas,
103
- x: number,
104
- y: number,
105
- role: CharRole,
106
- ): void {
107
- if (x >= roleCanvas.length || y >= (roleCanvas[0]?.length ?? 0)) {
108
- increaseRoleCanvasSize(roleCanvas, x, y)
109
- }
110
- roleCanvas[x]![y] = role
111
- }
112
-
113
- /**
114
- * Merge role canvases — same logic as mergeCanvases but for roles.
115
- * Non-null roles in overlays overwrite null roles in base.
116
- */
117
- export function mergeRoleCanvases(
118
- base: RoleCanvas,
119
- offset: DrawingCoord,
120
- ...overlays: RoleCanvas[]
121
- ): RoleCanvas {
122
- let maxX = base.length - 1
123
- let maxY = (base[0]?.length ?? 1) - 1
124
-
125
- for (const overlay of overlays) {
126
- const oX = overlay.length - 1
127
- const oY = (overlay[0]?.length ?? 1) - 1
128
- maxX = Math.max(maxX, oX + offset.x)
129
- maxY = Math.max(maxY, oY + offset.y)
130
- }
131
-
132
- const merged = mkRoleCanvas(maxX, maxY)
133
-
134
- // Copy base
135
- for (let x = 0; x <= maxX; x++) {
136
- for (let y = 0; y <= maxY; y++) {
137
- if (x < base.length && y < (base[0]?.length ?? 0)) {
138
- merged[x]![y] = base[x]![y]!
139
- }
140
- }
141
- }
142
-
143
- // Apply overlays
144
- for (const overlay of overlays) {
145
- for (let x = 0; x < overlay.length; x++) {
146
- for (let y = 0; y < (overlay[0]?.length ?? 0); y++) {
147
- const role = overlay[x]?.[y]
148
- if (role !== null && role !== undefined) {
149
- const mx = x + offset.x
150
- const my = y + offset.y
151
- merged[mx]![my] = role
152
- }
153
- }
154
- }
155
- }
156
-
157
- return merged
158
- }
159
-
160
- /** Returns [maxX, maxY] — the highest valid indices in each dimension. */
161
- export function getCanvasSize(canvas: Canvas): [number, number] {
162
- return [canvas.length - 1, (canvas[0]?.length ?? 1) - 1]
163
- }
164
-
165
- /**
166
- * Grow the canvas to fit at least (newX, newY), preserving existing content.
167
- * Mutates the canvas in place and returns it.
168
- */
169
- export function increaseSize(
170
- canvas: Canvas,
171
- newX: number,
172
- newY: number,
173
- ): Canvas {
174
- const [currX, currY] = getCanvasSize(canvas)
175
- const targetX = Math.max(newX, currX)
176
- const targetY = Math.max(newY, currY)
177
- const grown = mkCanvas(targetX, targetY)
178
- for (let x = 0; x < grown.length; x++) {
179
- for (let y = 0; y < (grown[0]?.length ?? 0); y++) {
180
- if (x < canvas.length && y < (canvas[0]?.length ?? 0)) {
181
- grown[x]![y] = canvas[x]![y]!
182
- }
183
- }
184
- }
185
- // Mutate in place: splice old contents and replace with grown
186
- canvas.length = 0
187
- canvas.push(...grown)
188
- return canvas
189
- }
190
-
191
- /**
192
- * Bounds-checked write to a single canvas cell.
193
- *
194
- * Sets the character at (x, y) if the coordinate falls within the canvas;
195
- * out-of-range coordinates are silently clipped (a no-op) instead of
196
- * mutating the canvas. This is the single write path drawing modules should
197
- * use instead of indexing `canvas[x]![y] = ch` directly, which had three
198
- * different out-of-range behaviors depending on axis — none of them a clean
199
- * bounds check:
200
- * - x out of range: threw, via the `canvas[x]!` non-null assertion.
201
- * - y too large (but x in range): did *not* throw — JS silently
202
- * ragged-extends that column's array. This was observable downstream:
203
- * `mergeCanvases`/`canvasToString` would read the extended slot back as
204
- * `undefined`, which `canvasToString` then concatenates into the output
205
- * as the literal string `"undefined"`.
206
- * - y negative (but x in range): silently set an own property keyed by
207
- * the negative index (e.g. `arr[-1]`) rather than a real array element;
208
- * rendering code never reads it back, so this was a silent no-op.
209
- * `write()` normalizes all three cases to the same silent no-op. That is a
210
- * behavior *change*, not a preservation of the prior status quo — callers
211
- * migrating to `write()` need their own bounds check if they relied on the
212
- * old per-axis behavior (see `drawSubgraphLabel` in `draw-subgraphs.ts`,
213
- * which needs a tighter, exclusive bound than `write()`'s own clip to avoid
214
- * overwriting a subgraph's border with an oversized title).
215
- *
216
- * When `roleTracking` is provided, the role is recorded via `setRole`
217
- * alongside the character write (used by callers, like the sequence-diagram
218
- * and xychart renderers, that track character roles inline rather than
219
- * deriving them from the finished canvas afterward). `role` and
220
- * `roleCanvas` are bundled into one parameter so a call can't pass one
221
- * without the other — passing just a role with nowhere to record it would
222
- * otherwise type-check while silently dropping the role, an error only
223
- * visible in colorized/ANSI output.
224
- */
225
- export function write(
226
- canvas: Canvas,
227
- x: number,
228
- y: number,
229
- ch: string,
230
- roleTracking?: { role: CharRole; roleCanvas: RoleCanvas },
231
- ): void {
232
- const [maxX, maxY] = getCanvasSize(canvas)
233
- if (x < 0 || x > maxX || y < 0 || y > maxY) return
234
- canvas[x]![y] = ch
235
- if (roleTracking) {
236
- setRole(roleTracking.roleCanvas, x, y, roleTracking.role)
237
- }
238
- }
239
-
240
- // ============================================================================
241
- // Junction merging — Unicode box-drawing character compositing
242
- // ============================================================================
243
-
244
- /** All Unicode box-drawing characters that participate in junction merging. */
245
- const JUNCTION_CHARS = new Set([
246
- '─',
247
- '│',
248
- '┌',
249
- '┐',
250
- '└',
251
- '┘',
252
- '├',
253
- '┤',
254
- '┬',
255
- '┴',
256
- '┼',
257
- '╴',
258
- '╵',
259
- '╶',
260
- '╷',
261
- ])
262
-
263
- export function isJunctionChar(c: string): boolean {
264
- return JUNCTION_CHARS.has(c)
265
- }
266
-
267
- /** Check if a character is alphanumeric (part of a label). */
268
- function isAlphanumeric(c: string): boolean {
269
- return /^[a-zA-Z0-9]$/.test(c)
270
- }
271
-
272
- /**
273
- * When two junction characters overlap during canvas merging,
274
- * resolve them to the correct combined junction.
275
- * E.g., '─' overlapping '│' becomes '┼'.
276
- */
277
- const JUNCTION_MAP: Record<string, Record<string, string>> = {
278
- '─': {
279
- '│': '┼',
280
- '┌': '┬',
281
- '┐': '┬',
282
- '└': '┴',
283
- '┘': '┴',
284
- '├': '┼',
285
- '┤': '┼',
286
- '┬': '┬',
287
- '┴': '┴',
288
- },
289
- '│': {
290
- '─': '┼',
291
- '┌': '├',
292
- '┐': '┤',
293
- '└': '├',
294
- '┘': '┤',
295
- '├': '├',
296
- '┤': '┤',
297
- '┬': '┼',
298
- '┴': '┼',
299
- },
300
- '┌': {
301
- '─': '┬',
302
- '│': '├',
303
- '┐': '┬',
304
- '└': '├',
305
- '┘': '┼',
306
- '├': '├',
307
- '┤': '┼',
308
- '┬': '┬',
309
- '┴': '┼',
310
- },
311
- '┐': {
312
- '─': '┬',
313
- '│': '┤',
314
- '┌': '┬',
315
- '└': '┼',
316
- '┘': '┤',
317
- '├': '┼',
318
- '┤': '┤',
319
- '┬': '┬',
320
- '┴': '┼',
321
- },
322
- '└': {
323
- '─': '┴',
324
- '│': '├',
325
- '┌': '├',
326
- '┐': '┼',
327
- '┘': '┴',
328
- '├': '├',
329
- '┤': '┼',
330
- '┬': '┼',
331
- '┴': '┴',
332
- },
333
- '┘': {
334
- '─': '┴',
335
- '│': '┤',
336
- '┌': '┼',
337
- '┐': '┤',
338
- '└': '┴',
339
- '├': '┼',
340
- '┤': '┤',
341
- '┬': '┼',
342
- '┴': '┴',
343
- },
344
- '├': {
345
- '─': '┼',
346
- '│': '├',
347
- '┌': '├',
348
- '┐': '┼',
349
- '└': '├',
350
- '┘': '┼',
351
- '┤': '┼',
352
- '┬': '┼',
353
- '┴': '┼',
354
- },
355
- '┤': {
356
- '─': '┼',
357
- '│': '┤',
358
- '┌': '┼',
359
- '┐': '┤',
360
- '└': '┼',
361
- '┘': '┤',
362
- '├': '┼',
363
- '┬': '┼',
364
- '┴': '┼',
365
- },
366
- '┬': {
367
- '─': '┬',
368
- '│': '┼',
369
- '┌': '┬',
370
- '┐': '┬',
371
- '└': '┼',
372
- '┘': '┼',
373
- '├': '┼',
374
- '┤': '┼',
375
- '┴': '┼',
376
- },
377
- '┴': {
378
- '─': '┴',
379
- '│': '┼',
380
- '┌': '┼',
381
- '┐': '┼',
382
- '└': '┴',
383
- '┘': '┴',
384
- '├': '┼',
385
- '┤': '┼',
386
- '┬': '┼',
387
- },
388
- }
389
-
390
- export function mergeJunctions(c1: string, c2: string): string {
391
- return JUNCTION_MAP[c1]?.[c2] ?? c1
392
- }
393
-
394
- // ============================================================================
395
- // Canvas merging — composite multiple canvases with offset
396
- // ============================================================================
397
-
398
- /**
399
- * Merge overlay canvases onto a base canvas at the given offset.
400
- * Non-space characters in overlays overwrite the base.
401
- * When both characters are Unicode junction chars, they're merged intelligently.
402
- */
403
- export function mergeCanvases(
404
- base: Canvas,
405
- offset: DrawingCoord,
406
- useAscii: boolean,
407
- ...overlays: Canvas[]
408
- ): Canvas {
409
- let [maxX, maxY] = getCanvasSize(base)
410
- for (const overlay of overlays) {
411
- const [oX, oY] = getCanvasSize(overlay)
412
- maxX = Math.max(maxX, oX + offset.x)
413
- maxY = Math.max(maxY, oY + offset.y)
414
- }
415
-
416
- const merged = mkCanvas(maxX, maxY)
417
-
418
- // Copy base
419
- for (let x = 0; x <= maxX; x++) {
420
- for (let y = 0; y <= maxY; y++) {
421
- if (x < base.length && y < (base[0]?.length ?? 0)) {
422
- merged[x]![y] = base[x]![y]!
423
- }
424
- }
425
- }
426
-
427
- // Apply overlays
428
- for (const overlay of overlays) {
429
- for (let x = 0; x < overlay.length; x++) {
430
- for (let y = 0; y < (overlay[0]?.length ?? 0); y++) {
431
- const c = overlay[x]![y]!
432
- if (c !== ' ') {
433
- const mx = x + offset.x
434
- const my = y + offset.y
435
- const current = merged[mx]![my]!
436
- if (!useAscii && isJunctionChar(c) && isJunctionChar(current)) {
437
- merged[mx]![my] = mergeJunctions(current, c)
438
- } else if (isAlphanumeric(current) && isAlphanumeric(c)) {
439
- // Don't overwrite existing label text with new label text
440
- // This prevents label collisions (first label wins)
441
- } else {
442
- merged[mx]![my] = c
443
- }
444
- }
445
- }
446
- }
447
- }
448
-
449
- return merged
450
- }
451
-
452
- // ============================================================================
453
- // Canvas → string conversion
454
- // ============================================================================
455
-
456
- /** Options for converting canvas to string with optional coloring. */
457
- export interface CanvasToStringOptions {
458
- /** Role canvas for applying colors. If not provided, output is plain text. */
459
- roleCanvas?: RoleCanvas
460
- /** Color mode for terminal output. Default: 'none' */
461
- colorMode?: ColorMode
462
- /** Theme colors for ASCII output. Uses default theme if not provided. */
463
- theme?: AsciiTheme
464
- /**
465
- * Link canvas (see hyperlinks.ts) — each run of cells carrying an href is
466
- * wrapped in an OSC 8 terminal-hyperlink escape pair. Ignored in 'html'
467
- * color mode, which is rendered by a browser, not a terminal.
468
- */
469
- linkCanvas?: LinkCanvas
470
- }
471
-
472
- /**
473
- * Convert the canvas to a multi-line string (row by row, left to right).
474
- * Optionally applies ANSI color codes based on character roles, and OSC 8
475
- * hyperlink escapes based on the link canvas.
476
- */
477
- export function canvasToString(
478
- canvas: Canvas,
479
- options?: CanvasToStringOptions,
480
- ): string {
481
- const [maxX, maxY] = getCanvasSize(canvas)
482
- const lines: string[] = []
483
-
484
- const roleCanvas = options?.roleCanvas
485
- const colorMode = options?.colorMode ?? 'none'
486
- const theme = options?.theme ?? DEFAULT_ASCII_THEME
487
- const linkCanvas = colorMode === 'html' ? undefined : options?.linkCanvas
488
-
489
- for (let y = 0; y <= maxY; y++) {
490
- if (colorMode === 'none' || !roleCanvas) {
491
- // Plain text output — no colors
492
- const chars: string[] = []
493
- for (let x = 0; x <= maxX; x++) {
494
- chars.push(canvas[x]![y]!)
495
- }
496
- if (linkCanvas) {
497
- const links = chars.map((_, x) => linkCanvas[x]?.[y] ?? null)
498
- lines.push(joinWithLinks(chars, links))
499
- } else {
500
- lines.push(chars.join(''))
501
- }
502
- } else {
503
- // Colored output — collect chars, roles, and links for this row
504
- const chars: string[] = []
505
- const roles: (CharRole | null)[] = []
506
- const links: (string | null)[] = []
507
- for (let x = 0; x <= maxX; x++) {
508
- chars.push(canvas[x]![y]!)
509
- roles.push(roleCanvas[x]?.[y] ?? null)
510
- links.push(linkCanvas?.[x]?.[y] ?? null)
511
- }
512
- lines.push(
513
- colorizeLine(
514
- chars,
515
- roles,
516
- theme,
517
- colorMode,
518
- linkCanvas ? links : undefined,
519
- ),
520
- )
521
- }
522
- }
523
-
524
- return lines.join('\n')
525
- }
526
-
527
- // ============================================================================
528
- // Canvas vertical flip — used for BT (bottom-to-top) direction support.
529
- //
530
- // The ASCII renderer lays out graphs top-down (TD). For BT direction, we
531
- // flip the finished canvas vertically and remap directional characters so
532
- // arrows point upward and corners are mirrored correctly.
533
- // ============================================================================
534
-
535
- /**
536
- * Characters that change meaning when the Y-axis is flipped.
537
- * Symmetric characters (─, │, ├, ┤, ┼) are unchanged.
538
- */
539
- const VERTICAL_FLIP_MAP: Record<string, string> = {
540
- // Unicode arrows
541
- '▲': '▼',
542
- '▼': '▲',
543
- '◤': '◣',
544
- '◣': '◤',
545
- '◥': '◢',
546
- '◢': '◥',
547
- // ASCII arrows
548
- '^': 'v',
549
- v: '^',
550
- // Unicode corners
551
- '┌': '└',
552
- '└': '┌',
553
- '┐': '┘',
554
- '┘': '┐',
555
- // Unicode junctions (T-pieces flip vertically)
556
- '┬': '┴',
557
- '┴': '┬',
558
- // Box-start junctions (exit points from node boxes)
559
- '╵': '╷',
560
- '╷': '╵',
561
- }
562
-
563
- /**
564
- * Flip the canvas vertically (mirror across the horizontal center).
565
- * Reverses row order within each column and remaps directional characters
566
- * (arrows, corners, junctions) so they point the correct way after flip.
567
- *
568
- * Used to transform a TD-rendered canvas into BT output.
569
- * Mutates the canvas in place and returns it.
570
- */
571
- export function flipCanvasVertically(canvas: Canvas): Canvas {
572
- // Reverse each column array (Y-axis flip in column-major layout)
573
- for (const col of canvas) {
574
- col.reverse()
575
- }
576
-
577
- // Remap directional characters that change meaning after vertical flip
578
- for (const col of canvas) {
579
- for (const [y, ch] of col.entries()) {
580
- const flipped = VERTICAL_FLIP_MAP[ch]
581
- if (flipped) col[y] = flipped
582
- }
583
- }
584
-
585
- return canvas
586
- }
587
-
588
- /**
589
- * Flip the role canvas vertically to match flipCanvasVertically.
590
- * Mutates the role canvas in place and returns it.
591
- */
592
- export function flipRoleCanvasVertically(roleCanvas: RoleCanvas): RoleCanvas {
593
- for (const col of roleCanvas) {
594
- col.reverse()
595
- }
596
- return roleCanvas
597
- }
598
-
599
- /**
600
- * Draw text string onto the canvas starting at the given coordinate.
601
- * By default, preserves existing non-space characters (labels don't overwrite each other).
602
- * Set forceOverwrite=true to always overwrite (for box content).
603
- *
604
- * Wide characters (CJK/kana/hangul/fullwidth-form/emoji — see
605
- * `isWideChar`/`toDisplayCells` in `display-width.ts`) occupy two grid cells:
606
- * the glyph itself followed by a placeholder cell. This keeps grid-cell
607
- * count in sync with the two terminal columns the glyph actually renders as,
608
- * so text drawn here lines up with widths computed via `displayWidth`.
609
- */
610
- export function drawText(
611
- canvas: Canvas,
612
- start: DrawingCoord,
613
- text: string,
614
- forceOverwrite = false,
615
- ): void {
616
- const cells = toDisplayCells(text)
617
- increaseSize(canvas, start.x + cells.length, start.y)
618
- for (const [i, cell] of cells.entries()) {
619
- const x = start.x + i
620
- const current = canvas[x]![start.y]!
621
- // Only write if target is empty or we're forcing overwrite
622
- if (forceOverwrite || current === ' ') {
623
- canvas[x]![start.y] = cell
624
- }
625
- }
626
- }
627
-
628
- /**
629
- * Set the canvas size to fit all grid columns and rows.
630
- * Called after layout to ensure the canvas covers the full drawing area.
631
- */
632
- export function setCanvasSizeToGrid(
633
- canvas: Canvas,
634
- columnWidth: Map<number, number>,
635
- rowHeight: Map<number, number>,
636
- ): void {
637
- let maxX = 0
638
- let maxY = 0
639
- for (const w of columnWidth.values()) maxX += w
640
- for (const h of rowHeight.values()) maxY += h
641
- increaseSize(canvas, maxX - 1, maxY - 1)
642
- }
643
-
644
- /**
645
- * Set the role canvas size to match the grid dimensions.
646
- * Should be called alongside setCanvasSizeToGrid.
647
- */
648
- export function setRoleCanvasSizeToGrid(
649
- roleCanvas: RoleCanvas,
650
- columnWidth: Map<number, number>,
651
- rowHeight: Map<number, number>,
652
- ): void {
653
- let maxX = 0
654
- let maxY = 0
655
- for (const w of columnWidth.values()) maxX += w
656
- for (const h of rowHeight.values()) maxY += h
657
- increaseRoleCanvasSize(roleCanvas, maxX - 1, maxY - 1)
658
- }