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,325 +0,0 @@
1
- // ============================================================================
2
- // ASCII ER diagram: relationship draws must not overwrite already-placed
3
- // text (GitHub issue #392)
4
- //
5
- // Relationships are drawn in declaration order. A later relationship's
6
- // straight connecting line, crow's-foot marker, or label can land on the
7
- // exact canvas cell an earlier relationship's label (or an entity's own
8
- // header/attribute text) already wrote, silently corrupting it — a stray
9
- // line glyph mid-word, or one label's characters spliced into another's.
10
- // This is a distinct mechanism from #351's jog-row collisions (fixed by
11
- // chooseFreeRow in #390): here nothing routes around anything, a later
12
- // write simply stomps an earlier one with no occupancy check at all.
13
- //
14
- // A vertical relationship's label goes one step further than plain
15
- // overwrite-avoidance: when multiple vertical relationships share the same
16
- // upper/lower entity "rows" (and so the same natural label row), simply
17
- // refusing to overwrite would silently drop every label but the first —
18
- // a real information loss, not just a corruption risk. Those labels
19
- // instead search nearby rows within the relationship's own vertical run
20
- // for a free spot before giving up.
21
- // ============================================================================
22
-
23
- import { describe, it, expect } from 'vitest'
24
- import { renderMermaidASCII } from '@zombie-mermaid/ascii-renderer'
25
-
26
- describe('ASCII ER relationship draws do not overwrite existing text (issue #392)', () => {
27
- it('does not let a later vertical relationship line cut through an earlier label', () => {
28
- // A-D's label "helloworld" and B-E's vertical connector line land on
29
- // the same canvas cell (both components span the same two rows), with
30
- // B-E's own label positioned clear of A-D's label span so this isolates
31
- // the line-vs-label collision from any label-vs-label collision.
32
- const ascii = renderMermaidASCII(
33
- `erDiagram
34
- A ||--o{ B : ab
35
- A ||--o{ C : ac
36
- A ||--o{ D : helloworld
37
- B ||--o{ E : be`,
38
- { colorMode: 'none' },
39
- )
40
-
41
- expect(ascii).toContain('helloworld')
42
- expect(ascii).toContain('be')
43
- })
44
-
45
- it('does not let one relationship label overwrite another relationship label', () => {
46
- // A-D's label "longlabelhere" and B-E's label "be" are both centered on
47
- // the same row (both components span the same two rows) and, without a
48
- // guard, B-E's label characters land on top of the tail of A-D's label.
49
- const ascii = renderMermaidASCII(
50
- `erDiagram
51
- A ||--o{ B : ab
52
- A ||--o{ C : ac
53
- A ||--o{ D : longlabelhere
54
- B ||--o{ E : be`,
55
- { colorMode: 'none' },
56
- )
57
-
58
- expect(ascii).toContain('longlabelhere')
59
- })
60
-
61
- it('does not let a same-row relationship line overwrite an unrelated entity name it must cross', () => {
62
- // A-C is a direct (non-adjacent) same-row relationship; entity B sits
63
- // physically between A and C, so A-C's straight line crosses B's box.
64
- // The routing itself (line running through the box) is a distinct,
65
- // out-of-scope defect (see #390's "known limitation" on non-adjacent
66
- // same-row collisions) — this test only asserts the crossing line
67
- // doesn't corrupt B's own header text.
68
- const ascii = renderMermaidASCII(
69
- `erDiagram
70
- A ||--o{ B : ab
71
- A ||--o{ C : ac
72
- A ||--o{ D : helloworld
73
- B ||--o{ E : be`,
74
- { colorMode: 'none' },
75
- )
76
-
77
- // The A-C line still crosses straight through B's row (the crossing
78
- // itself is the out-of-scope routing defect) — but B's own header
79
- // character must survive that crossing intact rather than being
80
- // replaced by a line glyph.
81
- const lines = ascii.split('\n')
82
- const crossingLine = lines.find(
83
- (l) => l.includes('A') && l.includes('C') && l.includes('B'),
84
- )
85
- expect(crossingLine).toBeDefined()
86
- expect(crossingLine).toContain('B')
87
- })
88
-
89
- it('never splices one overlapping label onto another, whatever the outcome', () => {
90
- // Real catalog sample ("ER: Blog Platform Schema"): USER-COMMENT's
91
- // "authors" label, POST-COMMENT's "has" label, and POST-TAG's
92
- // "tagged-with" label all naturally land on the same row. Before any
93
- // fix, the whole row was overwritten down to just "tagged-with"
94
- // (silently erasing "authors" and "has" entirely). A naive
95
- // per-character occupancy guard produces a worse failure mode here:
96
- // "tagged-with"'s free trailing characters ("ged-with") get written
97
- // right after "has", producing "hasged-with" — a new, plausible-
98
- // looking word that is neither original label. Whether a colliding
99
- // label ends up relocated to a free row nearby or dropped outright
100
- // (see the row-search test below for which one happens here), it must
101
- // never partially splice into whatever's already at its natural row.
102
- const ascii = renderMermaidASCII(
103
- `erDiagram
104
- USER ||--o{ POST : writes
105
- USER ||--o{ COMMENT : authors
106
- POST ||--o{ COMMENT : has
107
- POST }|--o{ TAG : tagged-with`,
108
- { colorMode: 'none' },
109
- )
110
-
111
- expect(ascii).not.toContain('hasged-with')
112
- expect(ascii).not.toContain('gedauthors')
113
- expect(ascii).toContain('authors')
114
- expect(ascii).toContain('has')
115
- })
116
-
117
- it('relocates a colliding vertical-relationship label to a free row instead of dropping it', () => {
118
- // Same real catalog sample as above. USER-COMMENT, POST-COMMENT, and
119
- // POST-TAG all share the same startY/endY (they connect the same pair
120
- // of entity "rows" in the grid layout), so their labels ("authors",
121
- // "has", "tagged-with") all compute the identical natural midY. Simply
122
- // dropping whichever one loses that collision — the earlier behavior —
123
- // is a real, visible information loss: a rendered relationship with no
124
- // label at all. There's free space a row away, clear of both text and
125
- // markers, so "tagged-with" should be relocated there rather than
126
- // vanish.
127
- const ascii = renderMermaidASCII(
128
- `erDiagram
129
- USER ||--o{ POST : writes
130
- USER ||--o{ COMMENT : authors
131
- POST ||--o{ COMMENT : has
132
- POST }|--o{ TAG : tagged-with`,
133
- { colorMode: 'none' },
134
- )
135
-
136
- expect(ascii).toContain('tagged-with')
137
- // And still not spliced together with "has" on its new row either.
138
- expect(ascii).not.toContain('hastagged-with')
139
- })
140
-
141
- it('positions a jogged label next to the marker for the entity it actually describes', () => {
142
- // Real catalog sample ("ER: Blog Platform Schema", used verbatim — see
143
- // the row-search test above for why the attribute blocks matter here).
144
- // A label's X position used to follow the relationship's column at its
145
- // *upper* entity (POST, in this case) even when a jog moved the path
146
- // over to the lower entity's column — so "tagged-with" rendered far
147
- // from TAG's own marker, floating in the gap between it and COMMENT's
148
- // markers with nothing visually tying it to what it describes. The
149
- // label now follows the same target column the lower marker uses, so
150
- // it sits immediately next to that marker instead.
151
- const ascii = renderMermaidASCII(
152
- `erDiagram
153
- USER {
154
- int id PK
155
- string username UK
156
- string email UK
157
- date joined
158
- }
159
- POST {
160
- int id PK
161
- string title
162
- text content
163
- int author_id FK
164
- date published
165
- }
166
- COMMENT {
167
- int id PK
168
- text body
169
- int post_id FK
170
- int user_id FK
171
- date created
172
- }
173
- TAG {
174
- int id PK
175
- string name UK
176
- }
177
- USER ||--o{ POST : writes
178
- USER ||--o{ COMMENT : authors
179
- POST ||--o{ COMMENT : has
180
- POST }|--o{ TAG : tagged-with`,
181
- { colorMode: 'none' },
182
- )
183
-
184
- const lines = ascii.split('\n')
185
- const labelRowIdx = lines.findIndex((l) => l.includes('tagged-with'))
186
- expect(labelRowIdx).toBeGreaterThanOrEqual(0)
187
- const row = lines[labelRowIdx]!
188
- const idx = row.indexOf('tagged-with')
189
- // Since issue #453, POST also has a second bottom attachment ("has")
190
- // converging on COMMENT, so POST's own attachment columns for "has"
191
- // and "tagged-with" are staggered instead of both centered on POST —
192
- // which in turn changes where "tagged-with"'s jog (and so its label)
193
- // lands. The label is preceded by the jog's own corner glyph ('┌ ')
194
- // rather than sitting flush after the marker on the same row.
195
- expect(row.slice(idx - 2, idx)).toBe('┌ ')
196
- const cornerCol = idx - 2
197
- // The marker sits at or adjacent to the corner's column, connected by
198
- // the vertical line the corner turns into — but not necessarily on the
199
- // very next row: issue #351's multi-row-obstruction routing can insert
200
- // an extra connector row between the jog and the marker, so the exact
201
- // row offset isn't fixed. Search a small vertical window below the
202
- // corner instead of requiring literal same-row-plus-one adjacency.
203
- const nearbyRows = [
204
- labelRowIdx + 1,
205
- labelRowIdx + 2,
206
- labelRowIdx + 3,
207
- ].filter((r) => r < lines.length)
208
- const hasAlignedMarker = nearbyRows.some((r) =>
209
- lines[r]!.slice(cornerCol - 1, cornerCol + 2).includes('○╟'),
210
- )
211
- expect(hasAlignedMarker).toBe(true)
212
- })
213
-
214
- it('drops a whole overlapping label in the same-row (horizontal) branch too', () => {
215
- // A-C is a direct, non-adjacent same-row relationship skipping over B,
216
- // so its label's clamped placement region spans the whole A..C gap and
217
- // can land on top of A-B's own (already-drawn, adjacent) label. The
218
- // vertical-branch case above exercises canPlaceLabelLine via the
219
- // vertical label loop; this exercises the same guard in the horizontal
220
- // label loop.
221
- const ascii = renderMermaidASCII(
222
- `erDiagram
223
- A ||--o{ B : early
224
- A ||--o{ C : longlonglabelhere
225
- A ||--o{ D : y
226
- B ||--o{ E : z`,
227
- { colorMode: 'none' },
228
- )
229
-
230
- expect(ascii).toContain('early')
231
- expect(ascii).not.toContain('longlonglabelhere')
232
-
233
- // Not just the whole string: a per-character collision guard (the
234
- // naive approach tried and rejected for canPlaceLabelLine, see above)
235
- // could still leak part of the dropped label — e.g. "longlon" or
236
- // "glabelhere" — into the gap right after "early" on the same row.
237
- // Nothing alphabetic should appear there at all.
238
- const labelRow = ascii.split('\n').find((l) => l.includes('early'))
239
- expect(labelRow).toBeDefined()
240
- const afterEarly = labelRow!.slice(
241
- labelRow!.indexOf('early') + 'early'.length,
242
- )
243
- expect(afterEarly).not.toMatch(/[A-Za-z]/)
244
- })
245
-
246
- it('preserves an unrelated entity box border when a same-row line crosses through it', () => {
247
- // Real catalog sample ("ER: Mixed Identifying & Non-Identifying"):
248
- // ORDER-SHIPMENT is a direct, non-adjacent same-row relationship
249
- // skipping over LINE_ITEM, so its dashed line crosses straight through
250
- // LINE_ITEM's box (the routing itself — crossing through the box at all
251
- // — is the separate, out-of-scope defect from #351/#390's "known
252
- // limitation"). Text protection alone (the earlier tests above) keeps
253
- // "LINE_ITEM" itself readable, but previously left the crossing line
254
- // free to erase the box's border characters on either side of it,
255
- // leaving an open-looking, broken box. Border cells are protected too.
256
- const ascii = renderMermaidASCII(
257
- `erDiagram
258
- ORDER ||--|{ LINE_ITEM : contains
259
- ORDER ||..o{ SHIPMENT : ships-via
260
- PRODUCT ||--o{ LINE_ITEM : includes
261
- PRODUCT ||..o{ REVIEW : receives`,
262
- { colorMode: 'none' },
263
- )
264
-
265
- expect(ascii).toContain('┌───────────┐')
266
- expect(ascii).toContain('└───────────┘')
267
- // The crossing dashed line still runs right up to LINE_ITEM's box (that
268
- // routing gap is out of scope), so its own '╌' sits just inside the
269
- // border on both sides — but the border characters themselves must
270
- // survive intact, not be replaced by more line/dash glyphs.
271
- expect(ascii).toMatch(/│.LINE_ITEM.│/)
272
- })
273
-
274
- it('pads a label with a blank cell when a later relationship jog runs flush against it', () => {
275
- // Real catalog sample ("ER: Blog Platform Schema", used verbatim —
276
- // this needs the entities' attribute blocks to reproduce the exact
277
- // geometry where it occurs): USER-COMMENT needs no horizontal jog of
278
- // its own (its two entities are already column-aligned), so its label
279
- // "authors" sits on a row that POST-COMMENT's much longer jog — a
280
- // different, later-processed relationship — later fills with dashes
281
- // clear across. isProtected alone keeps "authors" itself intact
282
- // (that's what the earlier tests above cover), but without this
283
- // padding the crossing dashes still ran flush against it on both sides
284
- // ("────authors────") — readable, but visually indistinguishable from
285
- // actual corruption at a glance.
286
- const ascii = renderMermaidASCII(
287
- `erDiagram
288
- USER {
289
- int id PK
290
- string username UK
291
- string email UK
292
- date joined
293
- }
294
- POST {
295
- int id PK
296
- string title
297
- text content
298
- int author_id FK
299
- date published
300
- }
301
- COMMENT {
302
- int id PK
303
- text body
304
- int post_id FK
305
- int user_id FK
306
- date created
307
- }
308
- TAG {
309
- int id PK
310
- string name UK
311
- }
312
- USER ||--o{ POST : writes
313
- USER ||--o{ COMMENT : authors
314
- POST ||--o{ COMMENT : has
315
- POST }|--o{ TAG : tagged-with`,
316
- { colorMode: 'none' },
317
- )
318
-
319
- const row = ascii.split('\n').find((l) => l.includes('authors'))
320
- expect(row).toBeDefined()
321
- const idx = row!.indexOf('authors')
322
- expect(row![idx - 1]).toBe(' ')
323
- expect(row![idx + 'authors'.length]).toBe(' ')
324
- })
325
- })
@@ -1,347 +0,0 @@
1
- // ============================================================================
2
- // ASCII ER diagram regression tests for issue #351:
3
- // 1. Stray/duplicated connector glyphs next to crow's-foot markers
4
- // 2. Edges (and their labels) routed through/over other relationships or
5
- // entity boxes
6
- // 3. Oversized blank gutters between disconnected components
7
- // ============================================================================
8
-
9
- import { describe, it, expect } from 'vitest'
10
- import { renderMermaidASCII } from '@zombie-mermaid/ascii-renderer'
11
- import {
12
- chooseFreeRow,
13
- isRowFree,
14
- } from '../../packages/ascii-renderer/src/er-diagram.ts'
15
- import { mkCanvas, write } from '../../packages/ascii-renderer/src/canvas.ts'
16
- import type { Canvas } from '../../packages/ascii-renderer/src/types.ts'
17
-
18
- /** Mark every cell in row `y` across [xStart, xEnd] as occupied. */
19
- function occupyRow(canvas: Canvas, y: number, xStart: number, xEnd: number) {
20
- for (let x = xStart; x <= xEnd; x++) write(canvas, x, y, '#')
21
- }
22
-
23
- describe('ASCII ER — no stray connector glyph next to a marker (issue #351)', () => {
24
- it('insets only the colliding "one" marker on a horizontal connector, leaving the non-colliding "zero-many" marker flush (Unicode) — issue #413', () => {
25
- const ascii = renderMermaidASCII(
26
- `erDiagram
27
- CUSTOMER ||--o{ ORDER : places`,
28
- { colorMode: 'none' },
29
- )
30
- // #390 briefly made every horizontal marker sit flush against the
31
- // border to avoid a "─│─" run (line-fill dash, lone "one" tick,
32
- // line-fill dash) that the #351 fix worried would read as a stray,
33
- // unexplained connector glyph. Review on #351/#413 found that concern
34
- // doesn't hold in a real terminal (adjacent monospace glyphs don't
35
- // visually fuse regardless of spacing), but a *blanket* revert back to
36
- // inset for every horizontal marker was its own overcorrection: it
37
- // adds an unrequested gap to markers that were never ambiguous in the
38
- // first place. "zero-many" ('○╟') doesn't share a glyph with the
39
- // border ('│') the way "one" ('│') does, so only "one" needs the
40
- // inset — "zero-many" stays flush, matching #390's original intent for
41
- // that glyph. This test locks in the per-side, collision-conditional
42
- // result instead of a uniform one.
43
- expect(ascii).toContain('CUSTOMER │─│')
44
- expect(ascii).toContain('○╟│ ORDER')
45
- })
46
-
47
- it('insets only the colliding "one" marker on a horizontal connector, leaving the non-colliding "zero-many" marker flush (ASCII) — issue #413', () => {
48
- const ascii = renderMermaidASCII(
49
- `erDiagram
50
- CUSTOMER ||--o{ ORDER : places`,
51
- { colorMode: 'none', useAscii: true },
52
- )
53
- // Same per-side reasoning as the Unicode case above, in the ASCII glyph set.
54
- expect(ascii).toContain('CUSTOMER |-|')
55
- expect(ascii).toContain('o<| ORDER')
56
- })
57
-
58
- it('leaves both markers flush on a horizontal connector when neither collides with the border', () => {
59
- const ascii = renderMermaidASCII(
60
- `erDiagram
61
- CUSTOMER }o--o{ ORDER : has`,
62
- { colorMode: 'none' },
63
- )
64
- // Neither "zero-many" marker ('╢○'/'○╟') shares a glyph with the
65
- // border ('│'), so a blanket inset (the reviewer's original diff,
66
- // applied uniformly) would add a gap to both sides for no reason.
67
- // Matches #390's original flush output exactly, since this case was
68
- // never part of the #413 collision in the first place.
69
- expect(ascii).toContain('CUSTOMER │╢○')
70
- expect(ascii).toContain('○╟│ ORDER')
71
- expect(ascii).not.toContain('CUSTOMER │─')
72
- expect(ascii).not.toContain('─│ ORDER')
73
- })
74
-
75
- it('does not leave a stray fill row between a vertical marker and its entity border', () => {
76
- // Forces a vertical (cross-row) connection: three entities with a
77
- // sqrt-based row limit of 2 per row wrap C onto its own row below A/B.
78
- const ascii = renderMermaidASCII(
79
- `erDiagram
80
- A ||--o{ B : ab
81
- A ||--o{ C : ac`,
82
- { colorMode: 'none' },
83
- )
84
- const lines = ascii.split('\n')
85
-
86
- // The zero-many marker for the A→C relationship ("○╟") must sit on the
87
- // row immediately before C's box starts — not with a leftover plain
88
- // "│" line-fill row (visually indistinguishable from a second "one"
89
- // tick) still separating it from the border. Before the fix, that
90
- // leftover row rendered as an extra stray "│" directly under "○╟".
91
- // Match only the *vertical* marker's own row — a bare "○╟" with nothing
92
- // but leading whitespace before it — not the A→B horizontal
93
- // relationship's identical-looking marker earlier in the output.
94
- const markerLineIdx = lines.findIndex((l) => /^\s*○╟\s*$/.test(l))
95
- expect(markerLineIdx).toBeGreaterThan(-1)
96
- const nextLine = lines[markerLineIdx + 1]
97
- expect(nextLine).toBeDefined()
98
- expect(nextLine!.trimStart().startsWith('┌')).toBe(true)
99
- })
100
-
101
- // The tests above only exercise the "one"/"zero-many" glyphs (`│`, `○╟`).
102
- // Review on #351 (https://github.com/dfadler/zombie-mermaid/issues/351#issuecomment-5497209031)
103
- // re-tested with a different cardinality combination — "zero-or-one"
104
- // (`│○`/`○│`) — confirming the vertical marker stays flush either way.
105
- // "zero-or-one" also collides with the border on the horizontal axis
106
- // (its leading/trailing glyph is the same `│` as the "one" marker), so
107
- // — unlike "zero-many" above — *both* sides of a `C |o--|| D` connector
108
- // get the inset, not just one. These two tests lock in that finding
109
- // directly rather than leaving it as a PR-description claim with no
110
- // regression coverage.
111
-
112
- it('insets the "zero-or-one" marker from the entity border on a horizontal connector, since it collides on both sides — issue #413', () => {
113
- const ascii = renderMermaidASCII(
114
- `erDiagram
115
- C |o--|| D : owns`,
116
- { colorMode: 'none' },
117
- )
118
- // Matches the reviewer's own quoted "main" (pre-#390) output exactly:
119
- // "C │─│○─│─│ D" — a fill dash separates each entity's border from its
120
- // own marker on both sides of the connector.
121
- expect(ascii).toContain('C │─│○')
122
- expect(ascii).toContain('─│─│ D')
123
- })
124
-
125
- it('does not leave a stray fill row before a vertical "zero-or-one" marker', () => {
126
- // Forces a vertical connection the same way as the test above (a
127
- // second entity fills row 1, wrapping the third onto its own row), but
128
- // with the reviewer's "zero-or-one" cardinality on the vertical
129
- // relationship instead of "zero-many" — confirming flush placement
130
- // stays clean on the vertical axis regardless of which marker glyph is
131
- // involved, unlike the horizontal case immediately above.
132
- const ascii = renderMermaidASCII(
133
- `erDiagram
134
- A ||--o{ B : ab
135
- A |o--|| C : owns`,
136
- { colorMode: 'none' },
137
- )
138
- const lines = ascii.split('\n')
139
- // A's own end of the A→C relationship ("│○") must sit on the row
140
- // immediately after A's box bottom border — not with a leftover blank
141
- // row still separating it from the border.
142
- const aBoxBottomIdx = lines.findIndex((l) => l.includes('└───┘ ab'))
143
- expect(aBoxBottomIdx).toBeGreaterThan(-1)
144
- const markerLine = lines[aBoxBottomIdx + 1]
145
- expect(markerLine).toBeDefined()
146
- expect(markerLine).toContain('│○')
147
- })
148
- })
149
-
150
- describe('ASCII ER — relationships routed without colliding (issue #351)', () => {
151
- it('gives independent relationships between the same two rows distinct jog rows', () => {
152
- // B→C and A→C both terminate on C's row from A/B's row above; before
153
- // the fix, every vertical relationship's horizontal jog used the exact
154
- // same geometric midpoint, so B→C's jog and A→C's label landed on the
155
- // identical row and overwrote each other.
156
- const ascii = renderMermaidASCII(
157
- `erDiagram
158
- A ||--o{ B : rel1
159
- B ||--o{ C : rel2
160
- A ||--o{ C : rel3`,
161
- { colorMode: 'none' },
162
- )
163
- const lines = ascii.split('\n')
164
-
165
- const rel2Line = lines.find((l) => l.includes('rel2'))
166
- const rel3Line = lines.find((l) => l.includes('rel3'))
167
- expect(rel2Line).toBeDefined()
168
- expect(rel3Line).toBeDefined()
169
- // Both labels must render intact (not merged/garbled into the same row).
170
- expect(rel2Line).not.toBe(rel3Line)
171
- expect(ascii).toContain('rel1')
172
- expect(ascii).toContain('rel2')
173
- expect(ascii).toContain('rel3')
174
- })
175
-
176
- it('does not cut a relationship label with another relationship’s jog line', () => {
177
- // Five entities across two component rows, closely mirroring the
178
- // issue's own description: a later relationship's vertical/horizontal
179
- // segment used to cut straight through an earlier relationship's label,
180
- // e.g. "appears_in" rendered as "appear│_in".
181
- const ascii = renderMermaidASCII(
182
- `erDiagram
183
- CUSTOMER ||--o{ ORDER : places
184
- ORDER ||--|{ LINE_ITEM : contains
185
- PRODUCT ||--o{ LINE_ITEM : appears_in
186
- CUSTOMER ||--o{ ADDRESS : has`,
187
- { colorMode: 'none' },
188
- )
189
- // Every label must render as one intact, uninterrupted word — not
190
- // split by a stray line character routed through its middle.
191
- expect(ascii).toContain('places')
192
- expect(ascii).toContain('contains')
193
- expect(ascii).toContain('appears_in')
194
- expect(ascii).toContain('has')
195
- expect(ascii).not.toMatch(/[a-z]+[─│┊╌][a-z]+/)
196
- })
197
-
198
- it('does not let a jog row collide with a label whose span falls outside the jog range (CodeRabbit review, PR #390)', () => {
199
- // A relationship's label is always drawn to the right of the upper
200
- // entity's own center column, regardless of which way its jog goes —
201
- // for a leftward jog (or a short rightward one) that label span sits
202
- // outside [lx, rx], the range renderErAscii originally checked for
203
- // occupancy before choosing a jog row. Found by a differential search
204
- // over random small diagrams comparing the old (narrow) and fixed
205
- // (label-span-widened) occupancy ranges; this is the minimal case that
206
- // reproduces it deterministically — DDDD--CCC's jog lands on a row
207
- // that BB--A's own label already used, and without the widened check
208
- // DDDD--CCC's own label ends up prefixed with a stray "│" bled through
209
- // from BB--A's vertical stem.
210
- const ascii = renderMermaidASCII(
211
- `erDiagram
212
- DDDD ||--o{ A : x0
213
- BB ||--o{ A : l1
214
- DDDD ||--o{ CCC : longerlabelhere2`,
215
- { colorMode: 'none' },
216
- )
217
- const lines = ascii.split('\n')
218
- const labelLine = lines.find((l) => l.includes('longerlabelhere2'))
219
- expect(labelLine).toBeDefined()
220
- const idx = labelLine!.indexOf('longerlabelhere2')
221
- // The characters immediately before the label must be plain fill dashes,
222
- // not a stray "│" bled through from an unrelated relationship's
223
- // vertical stem sharing this row.
224
- expect(labelLine!.slice(Math.max(0, idx - 3), idx)).not.toContain('│')
225
- })
226
- })
227
-
228
- describe('ASCII ER — compact gutters between disconnected components (issue #351)', () => {
229
- it('does not leave a large blank gutter between two small disconnected components', () => {
230
- const ascii = renderMermaidASCII(
231
- `erDiagram
232
- CUSTOMER ||--o{ ORDER : places
233
- PRODUCT ||--o{ LINE_ITEM : appears_in`,
234
- { colorMode: 'none' },
235
- )
236
- const lines = ascii.split('\n')
237
-
238
- // Count the run of fully-blank lines between the two components.
239
- const firstBoxLine = lines.findIndex((l) => l.includes('└'))
240
- const secondComponentLine = lines.findIndex(
241
- (l, i) => i > firstBoxLine && l.includes('PRODUCT'),
242
- )
243
- expect(firstBoxLine).toBeGreaterThan(-1)
244
- expect(secondComponentLine).toBeGreaterThan(firstBoxLine)
245
-
246
- let blankRun = 0
247
- for (let i = firstBoxLine + 1; i < secondComponentLine; i++) {
248
- if (lines[i]!.trim() === '') blankRun++
249
- }
250
- // Before the fix, componentGap=6 produced a run of 6 fully blank rows
251
- // for this exact diagram. A visual break is still expected, but not a
252
- // gutter that dwarfs the content itself.
253
- expect(blankRun).toBeLessThanOrEqual(3)
254
-
255
- // Sanity: both components still render in full.
256
- expect(ascii).toContain('CUSTOMER')
257
- expect(ascii).toContain('ORDER')
258
- expect(ascii).toContain('PRODUCT')
259
- expect(ascii).toContain('LINE_ITEM')
260
- })
261
- })
262
-
263
- describe('chooseFreeRow / isRowFree (unit)', () => {
264
- // renderErAscii's fixed vGap=4 only ever produces a 2-row-wide candidate
265
- // interval, so the geometric midpoint is always the interval's first
266
- // (topmost) row — the "scan upward" half of chooseFreeRow's search can
267
- // never find a free row through the full render pipeline alone. These
268
- // tests exercise that logic directly against a wider, constructed range.
269
-
270
- it('returns the geometric midpoint when it is free', () => {
271
- const canvas = mkCanvas(20, 20)
272
- expect(chooseFreeRow(canvas, 0, 6, 0, 10, -1)).toBe(3)
273
- })
274
-
275
- it('scans downward when the midpoint is occupied', () => {
276
- const canvas = mkCanvas(20, 20)
277
- occupyRow(canvas, 3, 0, 10) // midpoint occupied
278
- expect(chooseFreeRow(canvas, 0, 6, 0, 10, -1)).toBe(4)
279
- })
280
-
281
- it('scans upward when the midpoint and every row below it are occupied', () => {
282
- const canvas = mkCanvas(20, 20)
283
- occupyRow(canvas, 3, 0, 10) // midpoint
284
- occupyRow(canvas, 4, 0, 10) // one below
285
- // row 2 (one above the midpoint) stays free
286
- expect(chooseFreeRow(canvas, 0, 6, 0, 10, -1)).toBe(2)
287
- })
288
-
289
- it('falls back to the geometric midpoint when every candidate row is occupied', () => {
290
- const canvas = mkCanvas(20, 20)
291
- for (let y = 1; y <= 5; y++) occupyRow(canvas, y, 0, 10)
292
- expect(chooseFreeRow(canvas, 0, 6, 0, 10, -1)).toBe(3)
293
- })
294
-
295
- it('ignores the skipped column when checking occupancy', () => {
296
- const canvas = mkCanvas(20, 20)
297
- write(canvas, 5, 3, '#') // only the skipped column is occupied
298
- expect(isRowFree(canvas, 3, 0, 10, 5)).toBe(true)
299
- expect(isRowFree(canvas, 3, 0, 10, -1)).toBe(false)
300
- })
301
-
302
- // CodeRabbit review on PR #390: a column past the canvas's current width
303
- // was reported as `undefined` by a plain index and treated as occupied,
304
- // even though nothing had actually been drawn there yet — a label routinely
305
- // grows the canvas on write (see increaseSize at the label call sites),
306
- // so a not-yet-allocated column is "not drawn", not "occupied".
307
- it('treats a column past the canvas width as free, not occupied', () => {
308
- const canvas = mkCanvas(5, 5) // columns 0..5 only
309
- expect(isRowFree(canvas, 2, 0, 10, -1)).toBe(true)
310
- expect(chooseFreeRow(canvas, 0, 6, 0, 10, -1)).toBe(3) // still the midpoint
311
- })
312
-
313
- // CodeRabbit review on PR #390: renderErAscii's jog-row selection checked
314
- // occupancy only across [lx, rx] (the jog's own span), not the
315
- // relationship's label — which is always drawn to the right of the upper
316
- // entity's center column, regardless of which way the jog itself goes.
317
- // For a leftward jog (rx sits at the upper entity's own column), the
318
- // label span falls entirely outside that checked range.
319
- it('rejects a midpoint row whose label span (right of the jog range) is occupied', () => {
320
- const canvas = mkCanvas(30, 20)
321
- const lineX = 10 // upper entity's center column
322
- const lowerCX = 4 // lower entity's center column — left of lineX: a leftward jog
323
- const lx = Math.min(lineX, lowerCX)
324
- const rx = Math.max(lineX, lowerCX) // === lineX; the label starts past this
325
- const labelEndX = lineX + 1 + 'some label'.length
326
- // Nothing occupies [lx, rx] at the midpoint, but the label area
327
- // (lineX + 2 .. labelEndX) is already occupied by earlier content.
328
- occupyRow(canvas, 3, lineX + 2, labelEndX)
329
- // Checking only the jog's own span (the pre-fix behavior) would accept
330
- // row 3 even though the label that lands there next would collide.
331
- expect(isRowFree(canvas, 3, lx, rx, lineX)).toBe(true)
332
- // Widening the checked range to include the label span (the fix) finds
333
- // the collision and moves to a different row instead.
334
- const chosen = chooseFreeRow(
335
- canvas,
336
- 0,
337
- 6,
338
- lx,
339
- Math.max(rx, labelEndX),
340
- lineX,
341
- )
342
- expect(chosen).not.toBe(3)
343
- expect(isRowFree(canvas, chosen, lx, Math.max(rx, labelEndX), lineX)).toBe(
344
- true,
345
- )
346
- })
347
- })