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,36 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { roundedRenderer } from '../../packages/ascii-renderer/src/shapes/rounded.ts'
3
- import { canvasToString } from '../../packages/ascii-renderer/src/canvas.ts'
4
- import type { ShapeRenderOptions } from '../../packages/ascii-renderer/src/shapes/types.ts'
5
-
6
- describe('roundedRenderer.render', () => {
7
- it('draws Unicode rounded corners around a single-line label', () => {
8
- const options: ShapeRenderOptions = { useAscii: false, padding: 1 }
9
- const dimensions = roundedRenderer.getDimensions('Start', options)
10
- const canvas = roundedRenderer.render('Start', dimensions, options)
11
- const text = canvasToString(canvas)
12
-
13
- const lines = text.split('\n')
14
- expect(lines[0]!.startsWith('╭')).toBe(true)
15
- expect(lines[0]!.endsWith('╮')).toBe(true)
16
- expect(lines[lines.length - 1]!.startsWith('╰')).toBe(true)
17
- expect(lines[lines.length - 1]!.endsWith('╯')).toBe(true)
18
- expect(text).toContain('Start')
19
- })
20
-
21
- it('draws ASCII rounded corners around a multi-line label', () => {
22
- const options: ShapeRenderOptions = { useAscii: true, padding: 2 }
23
- const label = 'Hello\nWorld'
24
- const dimensions = roundedRenderer.getDimensions(label, options)
25
- const canvas = roundedRenderer.render(label, dimensions, options)
26
- const text = canvasToString(canvas)
27
-
28
- const lines = text.split('\n')
29
- expect(lines[0]!.startsWith('.')).toBe(true)
30
- expect(lines[0]!.endsWith('.')).toBe(true)
31
- expect(lines[lines.length - 1]!.startsWith("'")).toBe(true)
32
- expect(lines[lines.length - 1]!.endsWith("'")).toBe(true)
33
- expect(text).toContain('Hello')
34
- expect(text).toContain('World')
35
- })
36
- })
@@ -1,41 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { circleRenderer } from '../../packages/ascii-renderer/src/shapes/circle.ts'
3
- import { canvasToString } from '../../packages/ascii-renderer/src/canvas.ts'
4
- import type { ShapeRenderOptions } from '../../packages/ascii-renderer/src/shapes/types.ts'
5
-
6
- function render(label: string, options: ShapeRenderOptions): string {
7
- const dimensions = circleRenderer.getDimensions(label, options)
8
- const canvas = circleRenderer.render(label, dimensions, options)
9
- return canvasToString(canvas)
10
- }
11
-
12
- describe('circleRenderer', () => {
13
- it('renders unicode circle corner markers around a short label', () => {
14
- const output = render('Hi', { useAscii: false, padding: 1 })
15
-
16
- expect(output).toBe(
17
- ['◯────◯', '│ │', '│ Hi │', '│ │', '◯────◯'].join('\n'),
18
- )
19
- })
20
-
21
- it('renders ascii circle corner markers around a short label', () => {
22
- const output = render('Hi', { useAscii: true, padding: 1 })
23
-
24
- expect(output).toBe(
25
- ['o----o', '| |', '| Hi |', '| |', 'o----o'].join('\n'),
26
- )
27
- })
28
-
29
- it('grows to fit a longer label and keeps it centered', () => {
30
- const output = render('Longer Label', { useAscii: false, padding: 2 })
31
- const lines = output.split('\n')
32
-
33
- expect(lines[0]).toBe('◯' + '─'.repeat(16) + '◯')
34
- expect(lines[lines.length - 1]).toBe('◯' + '─'.repeat(16) + '◯')
35
- expect(lines.some((l) => l.includes('Longer Label'))).toBe(true)
36
- for (const line of lines.slice(1, -1)) {
37
- expect(line.startsWith('│')).toBe(true)
38
- expect(line.endsWith('│')).toBe(true)
39
- }
40
- })
41
- })
@@ -1,42 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { hexagonRenderer } from '../../packages/ascii-renderer/src/shapes/hexagon.ts'
3
- import { canvasToString } from '../../packages/ascii-renderer/src/canvas.ts'
4
- import type { ShapeRenderOptions } from '../../packages/ascii-renderer/src/shapes/types.ts'
5
-
6
- describe('hexagonRenderer.render', () => {
7
- it('draws Unicode hexagon corner markers around a single-line label', () => {
8
- const options: ShapeRenderOptions = { useAscii: false, padding: 1 }
9
- const dimensions = hexagonRenderer.getDimensions('Step', options)
10
-
11
- const canvas = hexagonRenderer.render('Step', dimensions, options)
12
- const text = canvasToString(canvas)
13
- const lines = text.split('\n')
14
-
15
- expect(lines[0]).toMatch(/^⌜─+⌝$/)
16
- expect(lines[lines.length - 1]).toMatch(/^⌞─+⌟$/)
17
- expect(text).toContain('Step')
18
- for (const line of lines.slice(1, -1)) {
19
- expect(line.startsWith('│')).toBe(true)
20
- expect(line.endsWith('│')).toBe(true)
21
- }
22
- })
23
-
24
- it('draws ASCII hexagon corner markers around a multi-line label', () => {
25
- const options: ShapeRenderOptions = { useAscii: true, padding: 1 }
26
- const label = 'Long\nLabel'
27
- const dimensions = hexagonRenderer.getDimensions(label, options)
28
-
29
- const canvas = hexagonRenderer.render(label, dimensions, options)
30
- const text = canvasToString(canvas)
31
- const lines = text.split('\n')
32
-
33
- expect(lines[0]).toMatch(/^\*-+\*$/)
34
- expect(lines[lines.length - 1]).toMatch(/^\*-+\*$/)
35
- expect(text).toContain('Long')
36
- expect(text).toContain('Label')
37
- for (const line of lines.slice(1, -1)) {
38
- expect(line.startsWith('|')).toBe(true)
39
- expect(line.endsWith('|')).toBe(true)
40
- }
41
- })
42
- })
@@ -1,349 +0,0 @@
1
- /**
2
- * Coverage for src/ascii/shapes/special.ts — the "special" flowchart node
3
- * shapes: subroutine `[[text]]`, doublecircle `(((text)))`, cylinder
4
- * `[(text)]`, asymmetric `>text]`, trapezoid `[/text\]`, and trapezoid-alt
5
- * `[\text/]`. None of these shapes were exercised anywhere before this file.
6
- */
7
- import { describe, it, expect } from 'vitest'
8
- import { renderMermaidASCII } from '@zombie-mermaid/ascii-renderer'
9
- import { canvasToString } from '../../packages/ascii-renderer/src/canvas.ts'
10
- import {
11
- Up,
12
- Down,
13
- Left,
14
- Right,
15
- } from '../../packages/ascii-renderer/src/types.ts'
16
- import {
17
- subroutineRenderer,
18
- doublecircleRenderer,
19
- cylinderRenderer,
20
- asymmetricRenderer,
21
- trapezoidRenderer,
22
- parallelogramRenderer,
23
- parallelogramAltRenderer,
24
- trapezoidAltRenderer,
25
- } from '../../packages/ascii-renderer/src/shapes/special.ts'
26
- import type { ShapeRenderOptions } from '../../packages/ascii-renderer/src/shapes/types.ts'
27
-
28
- const unicodeOpts: ShapeRenderOptions = { useAscii: false, padding: 1 }
29
- const asciiOpts: ShapeRenderOptions = { useAscii: true, padding: 1 }
30
-
31
- describe('subroutine shape [[text]]', () => {
32
- it('renders with its distinctive corner markers in a flowchart', () => {
33
- const src = `flowchart TD
34
- A[[Subroutine]]`
35
- const out = renderMermaidASCII(src, { useAscii: false })
36
- expect(out).toContain('Subroutine')
37
- expect(out).toContain('╟')
38
- expect(out).toContain('╢')
39
- })
40
-
41
- it('renders the ASCII fallback in a flowchart', () => {
42
- const src = `flowchart TD
43
- A[[Task]]`
44
- const out = renderMermaidASCII(src, { useAscii: true })
45
- expect(out).toContain('Task')
46
- })
47
-
48
- it('computes dimensions with double borders on each side', () => {
49
- const dims = subroutineRenderer.getDimensions('Hi', unicodeOpts)
50
- expect(dims.gridColumns).toEqual([2, 4, 2])
51
- expect(dims.gridRows).toEqual([1, 3, 1])
52
- expect(dims.width).toBe(8)
53
- expect(dims.height).toBe(5)
54
- })
55
-
56
- it('draws double vertical bars on each side and centers the label', () => {
57
- const dims = subroutineRenderer.getDimensions('Hi', unicodeOpts)
58
- const canvas = subroutineRenderer.render('Hi', dims, unicodeOpts)
59
- const str = canvasToString(canvas)
60
- const lines = str.split('\n')
61
- expect(lines[0]).toBe('┌┬────┬┐')
62
- expect(lines[lines.length - 1]).toBe('└┴────┴┘')
63
- expect(lines.some((l) => l.includes('Hi'))).toBe(true)
64
- for (const line of lines.slice(1, -1)) {
65
- expect(line.slice(0, 2)).toBe('││')
66
- expect(line.slice(-2)).toBe('││')
67
- }
68
- })
69
-
70
- it('draws ASCII "+" borders when useAscii is set', () => {
71
- const dims = subroutineRenderer.getDimensions('Hi', asciiOpts)
72
- const canvas = subroutineRenderer.render('Hi', dims, asciiOpts)
73
- const str = canvasToString(canvas)
74
- const lines = str.split('\n')
75
- expect(lines[0]).toBe('++----++')
76
- expect(lines[lines.length - 1]).toBe('++----++')
77
- })
78
-
79
- it('stacks multiline labels centered vertically', () => {
80
- const dims = subroutineRenderer.getDimensions('one\ntwo', unicodeOpts)
81
- const canvas = subroutineRenderer.render('one\ntwo', dims, unicodeOpts)
82
- const str = canvasToString(canvas)
83
- expect(str).toContain('one')
84
- expect(str).toContain('two')
85
- })
86
-
87
- it('clips label cells that fall outside the pre-computed box bounds', () => {
88
- const dims = subroutineRenderer.getDimensions('Hi', unicodeOpts)
89
- const canvas = subroutineRenderer.render(
90
- 'Much Too Wide For This Box',
91
- dims,
92
- unicodeOpts,
93
- )
94
- expect(() => canvasToString(canvas)).not.toThrow()
95
- })
96
-
97
- it('reuses the shared box attachment point logic', () => {
98
- const dims = subroutineRenderer.getDimensions('Hi', unicodeOpts)
99
- const base = { x: 0, y: 0 }
100
- expect(subroutineRenderer.getAttachmentPoint(Down, dims, base)).toEqual({
101
- x: Math.floor(dims.width / 2),
102
- y: dims.height - 1,
103
- })
104
- expect(subroutineRenderer.getAttachmentPoint(Up, dims, base)).toEqual({
105
- x: Math.floor(dims.width / 2),
106
- y: 0,
107
- })
108
- })
109
- })
110
-
111
- describe('doublecircle shape (((text)))', () => {
112
- it('renders concentric-circle corner markers in a flowchart', () => {
113
- const src = `flowchart TD
114
- A(((Final)))`
115
- const out = renderMermaidASCII(src, { useAscii: false })
116
- expect(out).toContain('Final')
117
- expect(out).toContain('◎')
118
- })
119
-
120
- it('renders the ASCII fallback marker', () => {
121
- const src = `flowchart TD
122
- A(((Done)))`
123
- const out = renderMermaidASCII(src, { useAscii: true })
124
- expect(out).toContain('Done')
125
- expect(out).toContain('@')
126
- })
127
-
128
- it('delegates to the shared box renderer with doublecircle corners', () => {
129
- const dims = doublecircleRenderer.getDimensions('X', unicodeOpts)
130
- const canvas = doublecircleRenderer.render('X', dims, unicodeOpts)
131
- const str = canvasToString(canvas)
132
- const lines = str.split('\n')
133
- expect(lines[0]!.startsWith('◎')).toBe(true)
134
- expect(lines[0]!.endsWith('◎')).toBe(true)
135
- expect(lines[lines.length - 1]!.startsWith('◎')).toBe(true)
136
- })
137
- })
138
-
139
- describe('cylinder shape [(text)]', () => {
140
- it('renders a database cylinder in a flowchart', () => {
141
- const src = `flowchart TD
142
- A[(Database)]`
143
- const out = renderMermaidASCII(src, { useAscii: false })
144
- expect(out).toContain('Database')
145
- expect(out).toMatch(/╭─+╮/)
146
- expect(out).toMatch(/╰─+╯/)
147
- })
148
-
149
- it('renders ASCII-charset ellipse fallback characters', () => {
150
- const src = `flowchart TD
151
- A[(Store)]`
152
- const out = renderMermaidASCII(src, { useAscii: true })
153
- expect(out).toContain('Store')
154
- expect(out).toMatch(/\.-+\./)
155
- expect(out).toMatch(/'-+'/)
156
- })
157
-
158
- it('computes extra height for the curved top/bottom rows', () => {
159
- const dims = cylinderRenderer.getDimensions('DB', unicodeOpts)
160
- expect(dims.gridRows[0]).toBe(2)
161
- expect(dims.gridRows[2]).toBe(2)
162
- expect(dims.labelArea.y).toBe(3)
163
- })
164
-
165
- it('draws the double-row ellipse caps and centers the label', () => {
166
- const dims = cylinderRenderer.getDimensions('DB', unicodeOpts)
167
- const canvas = cylinderRenderer.render('DB', dims, unicodeOpts)
168
- const str = canvasToString(canvas)
169
- const lines = str.split('\n')
170
- expect(lines[0]!.startsWith('╭')).toBe(true)
171
- expect(lines[0]!.endsWith('╮')).toBe(true)
172
- expect(lines[1]).toMatch(/^│─+│$/)
173
- expect(lines[lines.length - 2]).toMatch(/^│─+│$/)
174
- expect(lines[lines.length - 1]!.startsWith('╰')).toBe(true)
175
- expect(lines[lines.length - 1]!.endsWith('╯')).toBe(true)
176
- expect(str).toContain('DB')
177
- })
178
-
179
- it('draws ASCII fallback caps', () => {
180
- const dims = cylinderRenderer.getDimensions('DB', asciiOpts)
181
- const canvas = cylinderRenderer.render('DB', dims, asciiOpts)
182
- const str = canvasToString(canvas)
183
- const lines = str.split('\n')
184
- expect(lines[0]!.startsWith('.')).toBe(true)
185
- expect(lines[0]!.endsWith('.')).toBe(true)
186
- expect(lines[lines.length - 1]!.startsWith("'")).toBe(true)
187
- expect(lines[lines.length - 1]!.endsWith("'")).toBe(true)
188
- })
189
-
190
- it('stacks multiline labels inside the cylinder body', () => {
191
- const dims = cylinderRenderer.getDimensions('one\ntwo', unicodeOpts)
192
- const canvas = cylinderRenderer.render('one\ntwo', dims, unicodeOpts)
193
- const str = canvasToString(canvas)
194
- expect(str).toContain('one')
195
- expect(str).toContain('two')
196
- })
197
-
198
- it('clips label cells that fall outside the pre-computed box bounds', () => {
199
- const dims = cylinderRenderer.getDimensions('DB', unicodeOpts)
200
- const canvas = cylinderRenderer.render(
201
- 'Much Too Wide For This Cylinder',
202
- dims,
203
- unicodeOpts,
204
- )
205
- expect(() => canvasToString(canvas)).not.toThrow()
206
- })
207
-
208
- it('reuses the shared box attachment point logic', () => {
209
- const dims = cylinderRenderer.getDimensions('DB', unicodeOpts)
210
- const base = { x: 2, y: 3 }
211
- const left = cylinderRenderer.getAttachmentPoint(Left, dims, base)
212
- const right = cylinderRenderer.getAttachmentPoint(Right, dims, base)
213
- expect(left.x).toBe(base.x)
214
- expect(right.x).toBe(base.x + dims.width - 1)
215
- })
216
- })
217
-
218
- describe('asymmetric (flag) shape >text]', () => {
219
- it('renders arrow markers on the left corners in a flowchart', () => {
220
- const src = `flowchart TD
221
- A>Flag]`
222
- const out = renderMermaidASCII(src, { useAscii: false })
223
- expect(out).toContain('Flag')
224
- expect(out).toContain('▷')
225
- })
226
-
227
- it('renders the ASCII fallback marker', () => {
228
- const src = `flowchart TD
229
- A>Note]`
230
- const out = renderMermaidASCII(src, { useAscii: true })
231
- expect(out).toContain('Note')
232
- expect(out).toContain('>')
233
- })
234
-
235
- it('delegates to the shared box renderer with asymmetric corners', () => {
236
- const dims = asymmetricRenderer.getDimensions('X', unicodeOpts)
237
- const canvas = asymmetricRenderer.render('X', dims, unicodeOpts)
238
- const str = canvasToString(canvas)
239
- const lines = str.split('\n')
240
- expect(lines[0]!.startsWith('▷')).toBe(true)
241
- expect(lines[0]!.endsWith('┐')).toBe(true)
242
- expect(lines[lines.length - 1]!.startsWith('▷')).toBe(true)
243
- expect(lines[lines.length - 1]!.endsWith('┘')).toBe(true)
244
- })
245
- })
246
-
247
- describe('trapezoid shape [/text\\]', () => {
248
- it('renders slope markers on the top corners in a flowchart', () => {
249
- const src = `flowchart TD
250
- A[/Wide Bottom\\]`
251
- const out = renderMermaidASCII(src, { useAscii: false })
252
- expect(out).toContain('Wide Bottom')
253
- })
254
-
255
- it('delegates to the shared box renderer with trapezoid corners', () => {
256
- const dims = trapezoidRenderer.getDimensions('X', unicodeOpts)
257
- const canvas = trapezoidRenderer.render('X', dims, unicodeOpts)
258
- const str = canvasToString(canvas)
259
- const lines = str.split('\n')
260
- expect(lines[0]!.startsWith('/')).toBe(true)
261
- expect(lines[0]!.endsWith('\\')).toBe(true)
262
- expect(lines[lines.length - 1]!.startsWith('└')).toBe(true)
263
- expect(lines[lines.length - 1]!.endsWith('┘')).toBe(true)
264
- })
265
- })
266
-
267
- describe('trapezoid-alt shape [\\text/]', () => {
268
- it('renders slope markers on the bottom corners in a flowchart', () => {
269
- const src = `flowchart TD
270
- A[\\Wide Top/]`
271
- const out = renderMermaidASCII(src, { useAscii: false })
272
- expect(out).toContain('Wide Top')
273
- })
274
-
275
- it('delegates to the shared box renderer with trapezoid-alt corners', () => {
276
- const dims = trapezoidAltRenderer.getDimensions('X', unicodeOpts)
277
- const canvas = trapezoidAltRenderer.render('X', dims, unicodeOpts)
278
- const str = canvasToString(canvas)
279
- const lines = str.split('\n')
280
- expect(lines[0]!.startsWith('┌')).toBe(true)
281
- expect(lines[0]!.endsWith('┐')).toBe(true)
282
- expect(lines[lines.length - 1]!.startsWith('\\')).toBe(true)
283
- expect(lines[lines.length - 1]!.endsWith('/')).toBe(true)
284
- })
285
- })
286
-
287
- describe('special shapes connected in a diagram', () => {
288
- it('renders edges between multiple special shapes without diagonal artifacts', () => {
289
- const src = `flowchart TD
290
- A[[Sub]] --> B[(DB)]
291
- B --> C(((Done)))
292
- C --> D>Flag]
293
- D --> E[/Trap\\]
294
- E --> F[\\TrapAlt/]`
295
- const out = renderMermaidASCII(src, { useAscii: false })
296
- expect(out).toContain('Sub')
297
- expect(out).toContain('DB')
298
- expect(out).toContain('Done')
299
- expect(out).toContain('Flag')
300
- expect(out).toContain('Trap')
301
- expect(out).toContain('TrapAlt')
302
- })
303
- })
304
-
305
- describe('parallelogram shapes [/text/] and [\\text\\]', () => {
306
- it('renders a lean-right parallelogram in a flowchart', () => {
307
- const out = renderMermaidASCII('flowchart TD\n A[/Lean Right/]', {
308
- useAscii: false,
309
- })
310
- expect(out).toContain('Lean Right')
311
- })
312
-
313
- it('renders a lean-left parallelogram in a flowchart', () => {
314
- const out = renderMermaidASCII('flowchart TD\n A[\\Lean Left\\]', {
315
- useAscii: false,
316
- })
317
- expect(out).toContain('Lean Left')
318
- })
319
-
320
- it('delegates to the shared box renderer with parallelogram corners', () => {
321
- const dims = parallelogramRenderer.getDimensions('X', unicodeOpts)
322
- const canvas = parallelogramRenderer.render('X', dims, unicodeOpts)
323
- const lines = canvasToString(canvas).split('\n')
324
- // Both sides slope the same way — that is what separates a parallelogram
325
- // from a trapezoid, whose corners oppose.
326
- expect(lines[0]!.startsWith('/')).toBe(true)
327
- expect(lines[0]!.endsWith('/')).toBe(true)
328
- expect(lines[lines.length - 1]!.startsWith('/')).toBe(true)
329
- expect(lines[lines.length - 1]!.endsWith('/')).toBe(true)
330
- })
331
-
332
- it('delegates to the shared box renderer with parallelogram-alt corners', () => {
333
- const dims = parallelogramAltRenderer.getDimensions('X', unicodeOpts)
334
- const canvas = parallelogramAltRenderer.render('X', dims, unicodeOpts)
335
- const lines = canvasToString(canvas).split('\n')
336
- expect(lines[0]!.startsWith('\\')).toBe(true)
337
- expect(lines[0]!.endsWith('\\')).toBe(true)
338
- expect(lines[lines.length - 1]!.startsWith('\\')).toBe(true)
339
- expect(lines[lines.length - 1]!.endsWith('\\')).toBe(true)
340
- })
341
-
342
- it('reports the same dimensions as the other box-based shapes', () => {
343
- // Parallelograms reuse getBoxDimensions, so their sizing must match
344
- // trapezoid's for the same label — a divergence would misalign the grid.
345
- expect(parallelogramRenderer.getDimensions('Label', unicodeOpts)).toEqual(
346
- trapezoidRenderer.getDimensions('Label', unicodeOpts),
347
- )
348
- })
349
- })
@@ -1,217 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { renderMermaidASCII } from '@zombie-mermaid/ascii-renderer'
3
- import { stadiumRenderer } from '../../packages/ascii-renderer/src/shapes/stadium.ts'
4
- import type { Canvas } from '../../packages/ascii-renderer/src/types.ts'
5
-
6
- function canvasToLines(canvas: Canvas): string[] {
7
- const height = canvas[0]?.length ?? 0
8
- const lines: string[] = []
9
- for (let y = 0; y < height; y++) {
10
- let row = ''
11
- for (let x = 0; x < canvas.length; x++) row += canvas[x]![y]
12
- lines.push(row)
13
- }
14
- return lines
15
- }
16
-
17
- describe('stadium shape (flowchart integration)', () => {
18
- it('renders a short single-line stadium label in unicode mode', () => {
19
- const ascii = renderMermaidASCII('graph TD\n A([Start])', {
20
- useAscii: false,
21
- })
22
- expect(ascii).toContain('Start')
23
- expect(ascii).toContain('(')
24
- expect(ascii).toContain(')')
25
- })
26
-
27
- it('renders a short single-line stadium label in ascii mode', () => {
28
- const ascii = renderMermaidASCII('graph TD\n A([Start])', {
29
- useAscii: true,
30
- })
31
- expect(ascii).toContain('Start')
32
- expect(ascii).toContain('(')
33
- expect(ascii).toContain(')')
34
- expect(ascii).toContain('-')
35
- })
36
-
37
- it('sizes the stadium wider for a longer label', () => {
38
- const shortAscii = renderMermaidASCII('graph TD\n A([Hi])', {
39
- useAscii: false,
40
- })
41
- const longAscii = renderMermaidASCII(
42
- 'graph TD\n A([This is a fairly long stadium label])',
43
- { useAscii: false },
44
- )
45
- const shortWidth = Math.max(...shortAscii.split('\n').map((l) => l.length))
46
- const longWidth = Math.max(...longAscii.split('\n').map((l) => l.length))
47
- expect(longAscii).toContain('This is a fairly long stadium label')
48
- expect(longWidth).toBeGreaterThan(shortWidth)
49
- })
50
-
51
- it('renders a two-line stadium label with lines stacked in order', () => {
52
- const ascii = renderMermaidASCII('graph TD\n A([Line1<br>Line2])', {
53
- useAscii: false,
54
- })
55
- expect(ascii).toContain('Line1')
56
- expect(ascii).toContain('Line2')
57
- const lines = ascii.split('\n')
58
- const line1Row = lines.findIndex((l) => l.includes('Line1'))
59
- const line2Row = lines.findIndex((l) => l.includes('Line2'))
60
- expect(line2Row).toBeGreaterThan(line1Row)
61
- })
62
-
63
- it('renders a three-line stadium label in ascii mode', () => {
64
- const ascii = renderMermaidASCII('graph TD\n A([One<br>Two<br>Three])', {
65
- useAscii: true,
66
- })
67
- expect(ascii).toContain('One')
68
- expect(ascii).toContain('Two')
69
- expect(ascii).toContain('Three')
70
- })
71
-
72
- it('connects an edge between two stadium nodes', () => {
73
- const ascii = renderMermaidASCII('graph TD\n A([Begin]) --> B([End])', {
74
- useAscii: false,
75
- })
76
- expect(ascii).toContain('Begin')
77
- expect(ascii).toContain('End')
78
- })
79
- })
80
-
81
- describe('stadiumRenderer.getDimensions', () => {
82
- it('sizes a single-line label with the given padding', () => {
83
- const dims = stadiumRenderer.getDimensions('Start', {
84
- useAscii: false,
85
- padding: 1,
86
- })
87
- expect(dims).toEqual({
88
- width: 11,
89
- height: 5,
90
- labelArea: { x: 3, y: 2, width: 5, height: 1 },
91
- gridColumns: [2, 7, 2],
92
- gridRows: [1, 3, 1],
93
- })
94
- })
95
-
96
- it('collapses to the minimum 3-row height with zero padding', () => {
97
- const dims = stadiumRenderer.getDimensions('Start', {
98
- useAscii: false,
99
- padding: 0,
100
- })
101
- expect(dims.height).toBe(3)
102
- expect(dims.width).toBe(9)
103
- })
104
-
105
- it('grows height for multi-line labels', () => {
106
- const dims = stadiumRenderer.getDimensions('Line1\nLine2', {
107
- useAscii: false,
108
- padding: 1,
109
- })
110
- expect(dims).toEqual({
111
- width: 11,
112
- height: 6,
113
- labelArea: { x: 3, y: 2, width: 5, height: 2 },
114
- gridColumns: [2, 7, 2],
115
- gridRows: [1, 4, 1],
116
- })
117
- })
118
-
119
- it('sizes width to the widest of several lines', () => {
120
- const dims = stadiumRenderer.getDimensions('Short\nA much longer line', {
121
- useAscii: false,
122
- padding: 1,
123
- })
124
- expect(dims.labelArea.width).toBe('A much longer line'.length)
125
- })
126
- })
127
-
128
- describe('stadiumRenderer.render', () => {
129
- it('renders a single-row pill when height collapses to 3', () => {
130
- const dims = stadiumRenderer.getDimensions('Start', {
131
- useAscii: false,
132
- padding: 0,
133
- })
134
- const canvas = stadiumRenderer.render('Start', dims, {
135
- useAscii: false,
136
- padding: 0,
137
- })
138
- expect(canvasToLines(canvas)).toEqual([
139
- ' ',
140
- '( Start )',
141
- ' ',
142
- ])
143
- })
144
-
145
- it('renders rounded corners for multi-row unicode mode', () => {
146
- const dims = stadiumRenderer.getDimensions('Line1\nLine2', {
147
- useAscii: false,
148
- padding: 1,
149
- })
150
- const canvas = stadiumRenderer.render('Line1\nLine2', dims, {
151
- useAscii: false,
152
- padding: 1,
153
- })
154
- expect(canvasToLines(canvas)).toEqual([
155
- '╭─────────╮',
156
- '│ │',
157
- '│ │',
158
- '│ Line1 │',
159
- '│ Line2 │',
160
- '╰─────────╯',
161
- ])
162
- })
163
-
164
- it('renders parentheses on all sides for multi-row ascii mode', () => {
165
- const dims = stadiumRenderer.getDimensions('Line1\nLine2', {
166
- useAscii: true,
167
- padding: 1,
168
- })
169
- const canvas = stadiumRenderer.render('Line1\nLine2', dims, {
170
- useAscii: true,
171
- padding: 1,
172
- })
173
- expect(canvasToLines(canvas)).toEqual([
174
- '(---------)',
175
- '( )',
176
- '( )',
177
- '( Line1 )',
178
- '( Line2 )',
179
- '(---------)',
180
- ])
181
- })
182
-
183
- it('centers an odd number of label lines around the vertical middle', () => {
184
- const dims = stadiumRenderer.getDimensions('One\nTwo\nThree', {
185
- useAscii: false,
186
- padding: 1,
187
- })
188
- const canvas = stadiumRenderer.render('One\nTwo\nThree', dims, {
189
- useAscii: false,
190
- padding: 1,
191
- })
192
- expect(canvasToLines(canvas)).toEqual([
193
- '╭─────────╮',
194
- '│ │',
195
- '│ One │',
196
- '│ Two │',
197
- '│ Three │',
198
- '│ │',
199
- '╰─────────╯',
200
- ])
201
- })
202
-
203
- it('clips label characters that fall outside the canvas bounds', () => {
204
- const dims = {
205
- width: 5,
206
- height: 3,
207
- labelArea: { x: 1, y: 1, width: 3, height: 1 },
208
- gridColumns: [1, 3, 1] as [number, number, number],
209
- gridRows: [1, 1, 1] as [number, number, number],
210
- }
211
- const canvas = stadiumRenderer.render('VeryLongLabelText', dims, {
212
- useAscii: false,
213
- padding: 0,
214
- })
215
- expect(canvasToLines(canvas)).toEqual([' ', '(gLa)', ' '])
216
- })
217
- })