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,549 +0,0 @@
1
- // ============================================================================
2
- // ASCII renderer — arrow drawing (path, corners, arrowheads, box-start
3
- // junctions, labels)
4
- //
5
- // Split out of draw.ts.
6
- // ============================================================================
7
-
8
- import type {
9
- Canvas,
10
- DrawingCoord,
11
- GridCoord,
12
- Direction,
13
- AsciiGraph,
14
- AsciiEdge,
15
- AsciiEdgeStyle,
16
- AsciiNode,
17
- } from './types.ts'
18
- import {
19
- Up,
20
- Down,
21
- Left,
22
- Right,
23
- UpperLeft,
24
- UpperRight,
25
- LowerLeft,
26
- LowerRight,
27
- Middle,
28
- drawingCoordEquals,
29
- } from './types.ts'
30
- import { copyCanvas, drawText, write } from './canvas.ts'
31
- import { determineDirection, dirEquals } from './edge-routing.ts'
32
- import { displayWidth } from './display-width.ts'
33
- import { gridToDrawingCoord, lineToDrawing } from './grid.ts'
34
- import { splitLines } from './multiline-utils.ts'
35
- import { drawLine } from './draw-lines.ts'
36
-
37
- /**
38
- * Draw a complete arrow (edge) between two nodes.
39
- * Returns 6 separate canvases for layered compositing:
40
- * [path, boxStart, arrowHeadEnd, arrowHeadStart, corners, label]
41
- *
42
- * Supports bidirectional arrows via edge.hasArrowStart and edge.hasArrowEnd.
43
- */
44
- export function drawArrow(
45
- graph: AsciiGraph,
46
- edge: AsciiEdge,
47
- ): [Canvas, Canvas, Canvas, Canvas, Canvas, Canvas] {
48
- if (edge.path.length === 0) {
49
- const empty = copyCanvas(graph.canvas)
50
- return [empty, empty, empty, empty, empty, empty]
51
- }
52
-
53
- const labelCanvas = drawArrowLabel(graph, edge)
54
- const [pathCanvas, linesDrawn, lineDirs] = drawPath(
55
- graph,
56
- edge.path,
57
- edge.style,
58
- )
59
-
60
- // A routed path can collapse to zero drawn line segments when every grid
61
- // point maps to the same drawing coordinate — e.g. a routed edge whose
62
- // preferred from/to grid coordinates coincide for closely-spaced/adjacent
63
- // nodes (pathfinder.ts's getPath can legitimately return a single-point
64
- // path in that case; see #153). With no segment to anchor to, there's
65
- // nothing for a box-start connector or an end arrowhead to attach to, so
66
- // both are skipped instead of indexing into the empty linesDrawn/lineDirs
67
- // arrays.
68
- const hasSegments = linesDrawn.length > 0
69
-
70
- /*
71
- * An invisible link (`A ~~~ B`) routes and reserves space like any other
72
- * edge, but must leave no mark. drawPath already writes spaces for its
73
- * segments; the box connector and corner glyphs are drawn by separate
74
- * passes that don't consult the line character set, so they're suppressed
75
- * explicitly here. Arrowheads need no guard — `~~~` carries no `>`/`o`/`x`
76
- * marker, so hasArrowStart/hasArrowEnd are already false.
77
- */
78
- const invisible = edge.style === 'invisible'
79
-
80
- const boxStartCanvas =
81
- hasSegments && !invisible
82
- ? drawBoxStart(graph, edge.path, linesDrawn[0]!, edge.from)
83
- : copyCanvas(graph.canvas)
84
-
85
- // Draw end arrowhead only if hasArrowEnd is true (default behavior)
86
- let arrowHeadEndCanvas: Canvas
87
- if (edge.hasArrowEnd && hasSegments) {
88
- arrowHeadEndCanvas = drawArrowHead(
89
- graph,
90
- linesDrawn[linesDrawn.length - 1]!,
91
- lineDirs[lineDirs.length - 1]!,
92
- edge.endMarker,
93
- )
94
- } else {
95
- arrowHeadEndCanvas = copyCanvas(graph.canvas)
96
- }
97
-
98
- // Draw start arrowhead for bidirectional edges
99
- // The start arrowhead needs to be at the box connector position (one step back
100
- // from the first line point), pointing into the source node.
101
- let arrowHeadStartCanvas: Canvas
102
- if (edge.hasArrowStart && hasSegments) {
103
- const firstLine = linesDrawn[0]!
104
- const firstPoint = firstLine[0]!
105
- const startDir = reverseDirection(lineDirs[0]!)
106
-
107
- // Calculate the box connector position (one step back from first point)
108
- const arrowPos: DrawingCoord = { x: firstPoint.x, y: firstPoint.y }
109
- if (dirEquals(lineDirs[0]!, Right)) arrowPos.x = firstPoint.x - 1
110
- else if (dirEquals(lineDirs[0]!, Left)) arrowPos.x = firstPoint.x + 1
111
- else if (dirEquals(lineDirs[0]!, Down)) arrowPos.y = firstPoint.y - 1
112
- else if (dirEquals(lineDirs[0]!, Up)) arrowPos.y = firstPoint.y + 1
113
-
114
- // Create a synthetic line ending at the arrow position for drawArrowHead
115
- const syntheticLine: DrawingCoord[] = [firstPoint, arrowPos]
116
- arrowHeadStartCanvas = drawArrowHead(
117
- graph,
118
- syntheticLine,
119
- startDir,
120
- edge.startMarker,
121
- )
122
- } else {
123
- arrowHeadStartCanvas = copyCanvas(graph.canvas)
124
- }
125
-
126
- const cornersCanvas = invisible
127
- ? copyCanvas(graph.canvas)
128
- : drawCorners(graph, edge.path)
129
-
130
- return [
131
- pathCanvas,
132
- boxStartCanvas,
133
- arrowHeadEndCanvas,
134
- arrowHeadStartCanvas,
135
- cornersCanvas,
136
- labelCanvas,
137
- ]
138
- }
139
-
140
- /**
141
- * Reverse a direction (for bidirectional arrow start heads).
142
- */
143
- function reverseDirection(dir: Direction): Direction {
144
- if (dirEquals(dir, Up)) return Down
145
- if (dirEquals(dir, Down)) return Up
146
- if (dirEquals(dir, Left)) return Right
147
- if (dirEquals(dir, Right)) return Left
148
- if (dirEquals(dir, UpperLeft)) return LowerRight
149
- if (dirEquals(dir, UpperRight)) return LowerLeft
150
- if (dirEquals(dir, LowerLeft)) return UpperRight
151
- if (dirEquals(dir, LowerRight)) return UpperLeft
152
- return Middle
153
- }
154
-
155
- /**
156
- * Draw the path lines for an edge.
157
- * Returns the canvas, the coordinates drawn for each segment, and the direction of each segment.
158
- */
159
- function drawPath(
160
- graph: AsciiGraph,
161
- path: GridCoord[],
162
- style: AsciiEdgeStyle = 'solid',
163
- ): [Canvas, DrawingCoord[][], Direction[]] {
164
- const canvas = copyCanvas(graph.canvas)
165
- // path is non-empty: drawArrow (drawPath's sole caller) already returns
166
- // early when edge.path.length === 0.
167
- let previousCoord = path[0]!
168
- const linesDrawn: DrawingCoord[][] = []
169
- const lineDirs: Direction[] = []
170
-
171
- for (let i = 1; i < path.length; i++) {
172
- const nextCoord = path[i]!
173
- const prevDC = gridToDrawingCoord(graph, previousCoord)
174
- const nextDC = gridToDrawingCoord(graph, nextCoord)
175
-
176
- if (drawingCoordEquals(prevDC, nextDC)) {
177
- previousCoord = nextCoord
178
- continue
179
- }
180
-
181
- const dir = determineDirection(previousCoord, nextCoord)
182
- const segment = drawLine(
183
- canvas,
184
- prevDC,
185
- nextDC,
186
- 1,
187
- -1,
188
- graph.config.useAscii,
189
- style,
190
- )
191
- if (segment.length === 0) segment.push(prevDC)
192
- linesDrawn.push(segment)
193
- lineDirs.push(dir)
194
- previousCoord = nextCoord
195
- }
196
-
197
- return [canvas, linesDrawn, lineDirs]
198
- }
199
-
200
- /** Vertical box-border characters a horizontal connector can genuinely merge with. */
201
- const VERTICAL_BORDER_CHARS = new Set(['│', '┃', '║', '┆', '┊', '|', '‖'])
202
- /** Horizontal box-border characters a vertical connector can genuinely merge with. */
203
- const HORIZONTAL_BORDER_CHARS = new Set(['─', '━', '═', '╌', '┄', '-', '='])
204
-
205
- /**
206
- * Draw the junction character where an edge exits the source node's box.
207
- * Unicode mode uses shape-specific T-junction glyphs; ASCII mode uses the
208
- * same universal '+' already used for corners in draw-boxes.ts.
209
- * Skips drawing for state pseudo-states which have their own visual borders.
210
- *
211
- * A tee/junction character (┬┴├┤) is only correct when it's actually merging
212
- * with a real perpendicular border line at that exact cell — e.g. a grid
213
- * column widened by a sibling edge's label can push the computed box-start
214
- * position away from the node's actual border, landing on a blank cell with
215
- * no vertical (or horizontal) line to justify a junction. In that case fall
216
- * back to a plain line character matching the edge's own direction, instead
217
- * of fabricating a stray tee (see issue #86).
218
- */
219
- function drawBoxStart(
220
- graph: AsciiGraph,
221
- path: GridCoord[],
222
- firstLine: DrawingCoord[],
223
- sourceNode: AsciiNode,
224
- ): Canvas {
225
- const canvas = copyCanvas(graph.canvas)
226
- const useAscii = graph.config.useAscii
227
-
228
- // Skip box start connectors for state pseudo-states (they have their own bordered design)
229
- if (sourceNode.shape === 'state-start' || sourceNode.shape === 'state-end') {
230
- return canvas
231
- }
232
-
233
- // firstLine is guaranteed non-empty and path has >= 2 points: the sole
234
- // caller (drawArrow) only invokes drawBoxStart when drawPath produced at
235
- // least one line segment (see the `hasSegments` guard there), and
236
- // drawPath never pushes an empty segment into linesDrawn.
237
- const from = firstLine[0]!
238
- const dir = determineDirection(path[0]!, path[1]!)
239
- const junction = useAscii ? '+' : null
240
-
241
- // `canvas` (from copyCanvas) is a blank overlay layer — it never has
242
- // content of its own to check. Whether a genuine perpendicular border
243
- // line already occupies the target cell has to be read from
244
- // `graph.canvas`, which at this point in drawGraph already has node
245
- // boxes (and subgraph borders) merged onto it, before any edge layers.
246
- const existingOnBox = (x: number, y: number): string | undefined =>
247
- graph.canvas[x]?.[y]
248
-
249
- if (dirEquals(dir, Up)) {
250
- const x = from.x
251
- const y = from.y + 1
252
- const existing = existingOnBox(x, y)
253
- const hasBorder =
254
- existing !== undefined && HORIZONTAL_BORDER_CHARS.has(existing)
255
- write(canvas, x, y, hasBorder ? (junction ?? '┴') : useAscii ? '|' : '│')
256
- } else if (dirEquals(dir, Down)) {
257
- const x = from.x
258
- const y = from.y - 1
259
- const existing = existingOnBox(x, y)
260
- const hasBorder =
261
- existing !== undefined && HORIZONTAL_BORDER_CHARS.has(existing)
262
- write(canvas, x, y, hasBorder ? (junction ?? '┬') : useAscii ? '|' : '│')
263
- } else if (dirEquals(dir, Left) || dirEquals(dir, Right)) {
264
- // Anchor horizontal connectors to the source node's *own* rendered
265
- // border column, not to gridToDrawingCoord's grid-column-centered
266
- // position. That position is centered within the node's border grid
267
- // column using that column's *allocated* width — but a sibling edge's
268
- // label can land on that same column (its labelLine's chosen segment
269
- // just happens to pass through the node's border column on its way
270
- // elsewhere) and widen it well past the 1-character width the border
271
- // itself needs. Centering on the inflated width then drags the
272
- // connector away from the box's actual border character, which stays
273
- // put at a position that only depends on the box's own dimensions.
274
- //
275
- // Node dimensions are set before edge routing/drawing (see
276
- // createMapping in grid.ts), so drawingCoord/drawing should always be
277
- // present here — but that's a cross-module invariant the type checker
278
- // can't see, so it's validated explicitly rather than trusted silently.
279
- const dc = sourceNode.drawingCoord
280
- const drawing = sourceNode.drawing
281
- if (dc === null || drawing === null) {
282
- /* v8 ignore next */
283
- throw new Error(
284
- `drawBoxStart: node "${sourceNode.name}" has no drawingCoord/drawing assigned`,
285
- )
286
- }
287
- const boxWidth = drawing.length
288
- const x = dirEquals(dir, Left) ? dc.x : dc.x + boxWidth - 1
289
- const y = from.y
290
- const existing = existingOnBox(x, y)
291
- const hasBorder =
292
- existing !== undefined && VERTICAL_BORDER_CHARS.has(existing)
293
- write(
294
- canvas,
295
- x,
296
- y,
297
- hasBorder
298
- ? (junction ?? (dirEquals(dir, Left) ? '┤' : '├'))
299
- : useAscii
300
- ? '-'
301
- : '─',
302
- )
303
- }
304
-
305
- return canvas
306
- }
307
-
308
- /**
309
- * Fixed glyph for a `--o`/`--x` circle/cross terminator — direction-
310
- * independent, unlike the triangular arrowheads below, so callers don't
311
- * need to know which way the edge points to pick it. Returns undefined for
312
- * a plain arrowhead (no marker), so a caller can fall back to its own
313
- * directional glyph selection. Shared by drawArrowHead below (single-edge
314
- * arrowheads) and draw-bundles.ts (fan-in/fan-out bundled arrowheads) so
315
- * the glyph choice can't drift between the two. See issue #330.
316
- */
317
- export function markerArrowChar(
318
- useAscii: boolean,
319
- marker: 'circle' | 'cross' | undefined,
320
- ): string | undefined {
321
- if (marker === 'circle') return useAscii ? 'o' : '○'
322
- if (marker === 'cross') return useAscii ? 'x' : '✕'
323
- return undefined
324
- }
325
-
326
- /**
327
- * Draw the arrowhead at the end of an edge path.
328
- * Uses triangular Unicode symbols (▲▼◄►) or ASCII symbols (^v<>).
329
- *
330
- * `marker` overrides the directional triangle with a fixed circle/cross
331
- * glyph for `--o`/`--x` (flowchart) terminators — those are direction-
332
- * independent, so the direction computed below is only used to place it,
333
- * never to pick which glyph to draw. See issue #330.
334
- */
335
- function drawArrowHead(
336
- graph: AsciiGraph,
337
- lastLine: DrawingCoord[],
338
- fallbackDir: Direction,
339
- marker?: 'circle' | 'cross',
340
- ): Canvas {
341
- const canvas = copyCanvas(graph.canvas)
342
- if (lastLine.length === 0) return canvas
343
-
344
- const from = lastLine[0]!
345
- const lastPos = lastLine[lastLine.length - 1]!
346
- let dir = determineDirection(from, lastPos)
347
- if (lastLine.length === 1 || dirEquals(dir, Middle)) dir = fallbackDir
348
-
349
- let char: string
350
-
351
- const markerChar = markerArrowChar(graph.config.useAscii, marker)
352
- if (markerChar !== undefined) {
353
- char = markerChar
354
- } else if (!graph.config.useAscii) {
355
- if (dirEquals(dir, Up)) char = '▲'
356
- else if (dirEquals(dir, Down)) char = '▼'
357
- else if (dirEquals(dir, Left)) char = '◄'
358
- else if (dirEquals(dir, Right)) char = '►'
359
- else if (dirEquals(dir, UpperRight)) char = '◥'
360
- else if (dirEquals(dir, UpperLeft)) char = '◤'
361
- else if (dirEquals(dir, LowerRight)) char = '◢'
362
- else if (dirEquals(dir, LowerLeft)) char = '◣'
363
- else {
364
- // Fallback
365
- if (dirEquals(fallbackDir, Up)) char = '▲'
366
- else if (dirEquals(fallbackDir, Down)) char = '▼'
367
- else if (dirEquals(fallbackDir, Left)) char = '◄'
368
- else if (dirEquals(fallbackDir, Right)) char = '►'
369
- else if (dirEquals(fallbackDir, UpperRight)) char = '◥'
370
- else if (dirEquals(fallbackDir, UpperLeft)) char = '◤'
371
- else if (dirEquals(fallbackDir, LowerRight)) char = '◢'
372
- else if (dirEquals(fallbackDir, LowerLeft)) char = '◣'
373
- else char = '●'
374
- }
375
- } else {
376
- if (dirEquals(dir, Up)) char = '^'
377
- else if (dirEquals(dir, Down)) char = 'v'
378
- else if (dirEquals(dir, Left)) char = '<'
379
- else if (dirEquals(dir, Right)) char = '>'
380
- else {
381
- if (dirEquals(fallbackDir, Up)) char = '^'
382
- else if (dirEquals(fallbackDir, Down)) char = 'v'
383
- else if (dirEquals(fallbackDir, Left)) char = '<'
384
- else if (dirEquals(fallbackDir, Right)) char = '>'
385
- else char = '*'
386
- }
387
- }
388
-
389
- write(canvas, lastPos.x, lastPos.y, char)
390
- return canvas
391
- }
392
-
393
- /**
394
- * Draw corner characters at path bends (where the direction changes).
395
- * Uses ┌┐└┘ in Unicode mode, + in ASCII mode.
396
- */
397
- function drawCorners(graph: AsciiGraph, path: GridCoord[]): Canvas {
398
- const canvas = copyCanvas(graph.canvas)
399
-
400
- for (let idx = 1; idx < path.length - 1; idx++) {
401
- const coord = path[idx]!
402
- const dc = gridToDrawingCoord(graph, coord)
403
- const prevDir = determineDirection(path[idx - 1]!, coord)
404
- const nextDir = determineDirection(coord, path[idx + 1]!)
405
-
406
- let corner: string
407
- if (!graph.config.useAscii) {
408
- if (
409
- (dirEquals(prevDir, Right) && dirEquals(nextDir, Down)) ||
410
- (dirEquals(prevDir, Up) && dirEquals(nextDir, Left))
411
- ) {
412
- corner = '┐'
413
- } else if (
414
- (dirEquals(prevDir, Right) && dirEquals(nextDir, Up)) ||
415
- (dirEquals(prevDir, Down) && dirEquals(nextDir, Left))
416
- ) {
417
- corner = '┘'
418
- } else if (
419
- (dirEquals(prevDir, Left) && dirEquals(nextDir, Down)) ||
420
- (dirEquals(prevDir, Up) && dirEquals(nextDir, Right))
421
- ) {
422
- corner = '┌'
423
- } else if (
424
- (dirEquals(prevDir, Left) && dirEquals(nextDir, Up)) ||
425
- (dirEquals(prevDir, Down) && dirEquals(nextDir, Right))
426
- ) {
427
- corner = '└'
428
- } else {
429
- corner = '+'
430
- }
431
- } else {
432
- corner = '+'
433
- }
434
-
435
- write(canvas, dc.x, dc.y, corner)
436
- }
437
-
438
- return canvas
439
- }
440
-
441
- /**
442
- * True when `edge` has a sibling edge connecting the exact same two nodes in
443
- * the opposite direction (`A --> B` alongside `B --> A`) — a "reciprocal
444
- * pair". Node identity is compared by reference: `converter.ts` resolves
445
- * every edge's `from`/`to` from the same shared node map, so the same
446
- * logical node is always the same object across edges.
447
- */
448
- function hasReciprocalPartner(graph: AsciiGraph, edge: AsciiEdge): boolean {
449
- return graph.edges.some(
450
- (other) =>
451
- other !== edge && other.from === edge.to && other.to === edge.from,
452
- )
453
- }
454
-
455
- /** Draw edge label text centered on the widest path segment. */
456
- function drawArrowLabel(graph: AsciiGraph, edge: AsciiEdge): Canvas {
457
- const canvas = copyCanvas(graph.canvas)
458
- if (edge.text.length === 0) return canvas
459
-
460
- const drawingLine = lineToDrawing(graph, edge.labelLine)
461
-
462
- // Determine if this is an upward edge (target is above source in the path)
463
- // This is used to offset labels on bidirectional edges to prevent overlap
464
- let isUpwardEdge: boolean | undefined
465
- if (edge.path.length >= 2) {
466
- const startY = edge.path[0]!.y
467
- const endY = edge.path[edge.path.length - 1]!.y
468
- // Edge goes up if end Y is less than start Y (smaller Y = higher on screen)
469
- if (endY < startY) {
470
- isUpwardEdge = true
471
- } else if (endY > startY) {
472
- isUpwardEdge = false
473
- }
474
- // If endY === startY, it's horizontal, leave isUpwardEdge undefined
475
- }
476
-
477
- // Only a genuine reciprocal pair (A-->B alongside B-->A) needs its label
478
- // pulled toward its own target instead of its own source — see #530 and
479
- // drawTextOnLine's doc comment below. A lone vertical edge keeps the
480
- // original "precede the arrow, near the source" placement.
481
- const pullTowardTarget = hasReciprocalPartner(graph, edge)
482
-
483
- drawTextOnLine(canvas, drawingLine, edge.text, isUpwardEdge, pullTowardTarget)
484
- return canvas
485
- }
486
-
487
- /**
488
- * Draw text centered on a line segment defined by two drawing coordinates.
489
- * Supports multi-line labels.
490
- *
491
- * When isUpwardEdge is provided, offsets the label vertically to prevent
492
- * overlapping with labels from edges going the opposite direction:
493
- * - Upward edges: label placed in lower portion of segment (near its own
494
- * source), unless `pullTowardTarget` is set — see below.
495
- * - Downward edges (isUpwardEdge=false): label placed in upper portion
496
- * (near its own source), unless `pullTowardTarget` is set.
497
- * - No direction (isUpwardEdge=undefined): label centered (default)
498
- *
499
- * `pullTowardTarget` inverts both of the above, pulling the label toward
500
- * its own arrowhead (the edge's target end) instead of its source. This
501
- * only makes a visible difference for a genuine reciprocal pair sharing one
502
- * vertical channel (`A --> B` alongside `B --> A`, both routed through the
503
- * same column): pulling each label toward its own *source* there pulls it
504
- * right next to the *other* edge's arrowhead instead, since in a two-node
505
- * cycle one edge's source is the other edge's target. #530 is exactly that
506
- * bug — a same-pair bidirectional edge's two labels rendered swapped
507
- * relative to the arrowheads they sit beside. A lone edge (no reciprocal
508
- * partner) keeps the original near-source placement so its label still
509
- * reads as "preceding" its own arrow rather than crowding the arrowhead.
510
- */
511
- function drawTextOnLine(
512
- canvas: Canvas,
513
- line: DrawingCoord[],
514
- label: string,
515
- isUpwardEdge?: boolean,
516
- pullTowardTarget = false,
517
- ): void {
518
- if (line.length < 2) return
519
- const minX = Math.min(line[0]!.x, line[1]!.x)
520
- const maxX = Math.max(line[0]!.x, line[1]!.x)
521
- const minY = Math.min(line[0]!.y, line[1]!.y)
522
- const maxY = Math.max(line[0]!.y, line[1]!.y)
523
- const middleX = minX + Math.floor((maxX - minX) / 2)
524
- let middleY = minY + Math.floor((maxY - minY) / 2)
525
-
526
- // Offset label vertically to prevent overlap on bidirectional edges
527
- // For vertical segments (same X), shift based on edge direction
528
- if (isUpwardEdge !== undefined && minX === maxX) {
529
- const segmentHeight = maxY - minY
530
- const offset = Math.max(1, Math.floor(segmentHeight / 4))
531
- // XOR: pullTowardTarget flips which portion each direction lands in.
532
- const towardMinY = pullTowardTarget ? isUpwardEdge : !isUpwardEdge
533
- if (towardMinY) {
534
- middleY = middleY - offset
535
- } else {
536
- middleY = middleY + offset
537
- }
538
- }
539
-
540
- // Support multi-line labels
541
- const lines = splitLines(label)
542
- const startY = middleY - Math.floor((lines.length - 1) / 2)
543
-
544
- for (let i = 0; i < lines.length; i++) {
545
- const lineText = lines[i]!
546
- const startX = middleX - Math.floor(displayWidth(lineText) / 2)
547
- drawText(canvas, { x: startX, y: startY + i }, lineText)
548
- }
549
- }