@metronforge/concept-map 0.2.0 → 0.3.0

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 (687) hide show
  1. package/README.md +76 -8
  2. package/css/concept-map.css +41 -0
  3. package/dist/dom/animator.d.ts +3 -1
  4. package/dist/dom/animator.d.ts.map +1 -1
  5. package/dist/dom/animator.js +39 -59
  6. package/dist/dom/animator.js.map +1 -1
  7. package/dist/dom/bindings.d.ts +2 -0
  8. package/dist/dom/bindings.d.ts.map +1 -0
  9. package/dist/dom/bindings.js +2 -0
  10. package/dist/dom/bindings.js.map +1 -0
  11. package/dist/dom/concepts.d.ts +3 -0
  12. package/dist/dom/concepts.d.ts.map +1 -0
  13. package/dist/dom/concepts.js +36 -0
  14. package/dist/dom/concepts.js.map +1 -0
  15. package/dist/dom/drawing.d.ts +5 -0
  16. package/dist/dom/drawing.d.ts.map +1 -0
  17. package/dist/dom/drawing.js +58 -0
  18. package/dist/dom/drawing.js.map +1 -0
  19. package/dist/dom/geometry.d.ts +1 -1
  20. package/dist/dom/geometry.d.ts.map +1 -1
  21. package/dist/dom/geometry.js +10 -7
  22. package/dist/dom/geometry.js.map +1 -1
  23. package/dist/dom/index.d.ts +2 -1
  24. package/dist/dom/index.d.ts.map +1 -1
  25. package/dist/dom/index.js +2 -1
  26. package/dist/dom/index.js.map +1 -1
  27. package/dist/dom/measureLabel.d.ts +4 -0
  28. package/dist/dom/measureLabel.d.ts.map +1 -1
  29. package/dist/dom/measureLabel.js +80 -0
  30. package/dist/dom/measureLabel.js.map +1 -1
  31. package/dist/dom/mount.d.ts.map +1 -1
  32. package/dist/dom/mount.js +2 -1
  33. package/dist/dom/mount.js.map +1 -1
  34. package/dist/dom/narrowLayout.d.ts +12 -0
  35. package/dist/dom/narrowLayout.d.ts.map +1 -0
  36. package/dist/dom/narrowLayout.js +37 -0
  37. package/dist/dom/narrowLayout.js.map +1 -0
  38. package/dist/dom/panelDom.d.ts +2 -0
  39. package/dist/dom/panelDom.d.ts.map +1 -1
  40. package/dist/dom/panelDom.js +16 -0
  41. package/dist/dom/panelDom.js.map +1 -1
  42. package/dist/dom/player.d.ts +9 -4
  43. package/dist/dom/player.d.ts.map +1 -1
  44. package/dist/dom/player.js +41 -47
  45. package/dist/dom/player.js.map +1 -1
  46. package/dist/dom/refine.d.ts +176 -0
  47. package/dist/dom/refine.d.ts.map +1 -0
  48. package/dist/dom/refine.js +75 -0
  49. package/dist/dom/refine.js.map +1 -0
  50. package/dist/dom/resize.d.ts +3 -0
  51. package/dist/dom/resize.d.ts.map +1 -0
  52. package/dist/dom/resize.js +10 -0
  53. package/dist/dom/resize.js.map +1 -0
  54. package/dist/dom/svgDom.d.ts +2 -0
  55. package/dist/dom/svgDom.d.ts.map +1 -1
  56. package/dist/dom/svgDom.js +13 -0
  57. package/dist/dom/svgDom.js.map +1 -1
  58. package/dist/dom/textBounds.d.ts +4 -0
  59. package/dist/dom/textBounds.d.ts.map +1 -0
  60. package/dist/dom/textBounds.js +24 -0
  61. package/dist/dom/textBounds.js.map +1 -0
  62. package/dist/dom/token.d.ts +7 -0
  63. package/dist/dom/token.d.ts.map +1 -0
  64. package/dist/dom/token.js +41 -0
  65. package/dist/dom/token.js.map +1 -0
  66. package/dist/element/element.js +2 -2
  67. package/dist/element/element.js.map +1 -1
  68. package/dist/element/input.d.ts +4 -1
  69. package/dist/element/input.d.ts.map +1 -1
  70. package/dist/element/input.js +6 -3
  71. package/dist/element/input.js.map +1 -1
  72. package/dist/element/layout.d.ts +1 -1
  73. package/dist/element/layout.d.ts.map +1 -1
  74. package/dist/element/layout.js +3 -3
  75. package/dist/element/layout.js.map +1 -1
  76. package/dist/layout/badges.d.ts.map +1 -1
  77. package/dist/layout/badges.js +14 -15
  78. package/dist/layout/badges.js.map +1 -1
  79. package/dist/layout/build-problem.d.ts +9 -0
  80. package/dist/layout/build-problem.d.ts.map +1 -0
  81. package/dist/layout/build-problem.js +54 -0
  82. package/dist/layout/build-problem.js.map +1 -0
  83. package/dist/layout/check.d.ts.map +1 -1
  84. package/dist/layout/check.js +0 -17
  85. package/dist/layout/check.js.map +1 -1
  86. package/dist/layout/dagre.d.ts.map +1 -1
  87. package/dist/layout/dagre.js +61 -34
  88. package/dist/layout/dagre.js.map +1 -1
  89. package/dist/layout/elk-graph.d.ts +72 -0
  90. package/dist/layout/elk-graph.d.ts.map +1 -0
  91. package/dist/layout/elk-graph.js +71 -0
  92. package/dist/layout/elk-graph.js.map +1 -0
  93. package/dist/layout/elk-ports.d.ts +19 -0
  94. package/dist/layout/elk-ports.d.ts.map +1 -0
  95. package/dist/layout/elk-ports.js +42 -0
  96. package/dist/layout/elk-ports.js.map +1 -0
  97. package/dist/layout/elk.d.ts.map +1 -1
  98. package/dist/layout/elk.js +73 -70
  99. package/dist/layout/elk.js.map +1 -1
  100. package/dist/layout/errors.d.ts +110 -0
  101. package/dist/layout/errors.d.ts.map +1 -0
  102. package/dist/layout/errors.js +98 -0
  103. package/dist/layout/errors.js.map +1 -0
  104. package/dist/layout/font-metrics.d.ts +0 -1
  105. package/dist/layout/font-metrics.d.ts.map +1 -1
  106. package/dist/layout/font-metrics.js +0 -1
  107. package/dist/layout/font-metrics.js.map +1 -1
  108. package/dist/layout/free-edges.d.ts +6 -0
  109. package/dist/layout/free-edges.d.ts.map +1 -0
  110. package/dist/layout/free-edges.js +17 -0
  111. package/dist/layout/free-edges.js.map +1 -0
  112. package/dist/layout/graph.d.ts +1 -3
  113. package/dist/layout/graph.d.ts.map +1 -1
  114. package/dist/layout/graph.js +6 -11
  115. package/dist/layout/graph.js.map +1 -1
  116. package/dist/layout/hints.d.ts +35 -0
  117. package/dist/layout/hints.d.ts.map +1 -0
  118. package/dist/layout/hints.js +49 -0
  119. package/dist/layout/hints.js.map +1 -0
  120. package/dist/layout/index.d.ts +12 -2
  121. package/dist/layout/index.d.ts.map +1 -1
  122. package/dist/layout/index.js +87 -12
  123. package/dist/layout/index.js.map +1 -1
  124. package/dist/layout/inspect-routes.d.ts +18 -0
  125. package/dist/layout/inspect-routes.d.ts.map +1 -0
  126. package/dist/layout/inspect-routes.js +45 -0
  127. package/dist/layout/inspect-routes.js.map +1 -0
  128. package/dist/layout/intent.d.ts +5 -0
  129. package/dist/layout/intent.d.ts.map +1 -0
  130. package/dist/layout/intent.js +48 -0
  131. package/dist/layout/intent.js.map +1 -0
  132. package/dist/layout/legacy.d.ts +6 -0
  133. package/dist/layout/legacy.d.ts.map +1 -0
  134. package/dist/layout/legacy.js +16 -0
  135. package/dist/layout/legacy.js.map +1 -0
  136. package/dist/layout/measure.d.ts +4 -0
  137. package/dist/layout/measure.d.ts.map +1 -1
  138. package/dist/layout/measure.js +13 -13
  139. package/dist/layout/measure.js.map +1 -1
  140. package/dist/layout/measured.d.ts +4 -0
  141. package/dist/layout/measured.d.ts.map +1 -0
  142. package/dist/layout/measured.js +27 -0
  143. package/dist/layout/measured.js.map +1 -0
  144. package/dist/layout/measurement.d.ts +30 -0
  145. package/dist/layout/measurement.d.ts.map +1 -0
  146. package/dist/layout/measurement.js +2 -0
  147. package/dist/layout/measurement.js.map +1 -0
  148. package/dist/layout/mono-metrics.d.ts +2 -0
  149. package/dist/layout/mono-metrics.d.ts.map +1 -0
  150. package/dist/layout/mono-metrics.js +4 -0
  151. package/dist/layout/mono-metrics.js.map +1 -0
  152. package/dist/layout/moved-routes.d.ts +7 -0
  153. package/dist/layout/moved-routes.d.ts.map +1 -0
  154. package/dist/layout/moved-routes.js +49 -0
  155. package/dist/layout/moved-routes.js.map +1 -0
  156. package/dist/layout/outcomes.d.ts +24 -0
  157. package/dist/layout/outcomes.d.ts.map +1 -0
  158. package/dist/layout/outcomes.js +7 -0
  159. package/dist/layout/outcomes.js.map +1 -0
  160. package/dist/layout/place-free.d.ts +8 -0
  161. package/dist/layout/place-free.d.ts.map +1 -0
  162. package/dist/layout/place-free.js +106 -0
  163. package/dist/layout/place-free.js.map +1 -0
  164. package/dist/layout/place-same-rank.d.ts +10 -0
  165. package/dist/layout/place-same-rank.d.ts.map +1 -0
  166. package/dist/layout/place-same-rank.js +21 -0
  167. package/dist/layout/place-same-rank.js.map +1 -0
  168. package/dist/layout/place.d.ts +6 -0
  169. package/dist/layout/place.d.ts.map +1 -0
  170. package/dist/layout/place.js +38 -0
  171. package/dist/layout/place.js.map +1 -0
  172. package/dist/layout/ports.d.ts +10 -0
  173. package/dist/layout/ports.d.ts.map +1 -0
  174. package/dist/layout/ports.js +2 -0
  175. package/dist/layout/ports.js.map +1 -0
  176. package/dist/layout/problem.d.ts +85 -0
  177. package/dist/layout/problem.d.ts.map +1 -0
  178. package/dist/layout/problem.js +2 -0
  179. package/dist/layout/problem.js.map +1 -0
  180. package/dist/layout/relations/align-lanes.d.ts +15 -0
  181. package/dist/layout/relations/align-lanes.d.ts.map +1 -0
  182. package/dist/layout/relations/align-lanes.js +64 -0
  183. package/dist/layout/relations/align-lanes.js.map +1 -0
  184. package/dist/layout/relations/align-layout.d.ts +13 -0
  185. package/dist/layout/relations/align-layout.d.ts.map +1 -0
  186. package/dist/layout/relations/align-layout.js +47 -0
  187. package/dist/layout/relations/align-layout.js.map +1 -0
  188. package/dist/layout/relations/align.d.ts +8 -0
  189. package/dist/layout/relations/align.d.ts.map +1 -0
  190. package/dist/layout/relations/align.js +20 -0
  191. package/dist/layout/relations/align.js.map +1 -0
  192. package/dist/layout/relations/apply.d.ts +16 -0
  193. package/dist/layout/relations/apply.d.ts.map +1 -0
  194. package/dist/layout/relations/apply.js +76 -0
  195. package/dist/layout/relations/apply.js.map +1 -0
  196. package/dist/layout/relations/check-derived.d.ts +10 -0
  197. package/dist/layout/relations/check-derived.d.ts.map +1 -0
  198. package/dist/layout/relations/check-derived.js +31 -0
  199. package/dist/layout/relations/check-derived.js.map +1 -0
  200. package/dist/layout/relations/check-witness.d.ts +11 -0
  201. package/dist/layout/relations/check-witness.d.ts.map +1 -0
  202. package/dist/layout/relations/check-witness.js +56 -0
  203. package/dist/layout/relations/check-witness.js.map +1 -0
  204. package/dist/layout/relations/check.d.ts +8 -0
  205. package/dist/layout/relations/check.d.ts.map +1 -0
  206. package/dist/layout/relations/check.js +41 -0
  207. package/dist/layout/relations/check.js.map +1 -0
  208. package/dist/layout/relations/cross.d.ts +6 -0
  209. package/dist/layout/relations/cross.d.ts.map +1 -0
  210. package/dist/layout/relations/cross.js +58 -0
  211. package/dist/layout/relations/cross.js.map +1 -0
  212. package/dist/layout/relations/derive.d.ts +4 -0
  213. package/dist/layout/relations/derive.d.ts.map +1 -0
  214. package/dist/layout/relations/derive.js +13 -0
  215. package/dist/layout/relations/derive.js.map +1 -0
  216. package/dist/layout/relations/derived-input.d.ts +23 -0
  217. package/dist/layout/relations/derived-input.d.ts.map +1 -0
  218. package/dist/layout/relations/derived-input.js +39 -0
  219. package/dist/layout/relations/derived-input.js.map +1 -0
  220. package/dist/layout/relations/explain.d.ts +18 -0
  221. package/dist/layout/relations/explain.d.ts.map +1 -0
  222. package/dist/layout/relations/explain.js +45 -0
  223. package/dist/layout/relations/explain.js.map +1 -0
  224. package/dist/layout/relations/lane-pins.d.ts +11 -0
  225. package/dist/layout/relations/lane-pins.d.ts.map +1 -0
  226. package/dist/layout/relations/lane-pins.js +25 -0
  227. package/dist/layout/relations/lane-pins.js.map +1 -0
  228. package/dist/layout/relations/lane-rank.d.ts +10 -0
  229. package/dist/layout/relations/lane-rank.d.ts.map +1 -0
  230. package/dist/layout/relations/lane-rank.js +63 -0
  231. package/dist/layout/relations/lane-rank.js.map +1 -0
  232. package/dist/layout/relations/normalize.d.ts +4 -0
  233. package/dist/layout/relations/normalize.d.ts.map +1 -0
  234. package/dist/layout/relations/normalize.js +87 -0
  235. package/dist/layout/relations/normalize.js.map +1 -0
  236. package/dist/layout/relations/paths.d.ts +10 -0
  237. package/dist/layout/relations/paths.d.ts.map +1 -0
  238. package/dist/layout/relations/paths.js +36 -0
  239. package/dist/layout/relations/paths.js.map +1 -0
  240. package/dist/layout/relations/pin-anchors.d.ts +6 -0
  241. package/dist/layout/relations/pin-anchors.d.ts.map +1 -0
  242. package/dist/layout/relations/pin-anchors.js +15 -0
  243. package/dist/layout/relations/pin-anchors.js.map +1 -0
  244. package/dist/layout/relations/rank.d.ts +9 -0
  245. package/dist/layout/relations/rank.d.ts.map +1 -0
  246. package/dist/layout/relations/rank.js +63 -0
  247. package/dist/layout/relations/rank.js.map +1 -0
  248. package/dist/layout/relations/result.d.ts +28 -0
  249. package/dist/layout/relations/result.d.ts.map +1 -0
  250. package/dist/layout/relations/result.js +2 -0
  251. package/dist/layout/relations/result.js.map +1 -0
  252. package/dist/layout/relations/solve.d.ts +5 -0
  253. package/dist/layout/relations/solve.d.ts.map +1 -0
  254. package/dist/layout/relations/solve.js +62 -0
  255. package/dist/layout/relations/solve.js.map +1 -0
  256. package/dist/layout/relations/types.d.ts +45 -0
  257. package/dist/layout/relations/types.d.ts.map +1 -0
  258. package/dist/layout/relations/types.js +2 -0
  259. package/dist/layout/relations/types.js.map +1 -0
  260. package/dist/layout/resolve-measured.d.ts +171 -0
  261. package/dist/layout/resolve-measured.d.ts.map +1 -0
  262. package/dist/layout/resolve-measured.js +16 -0
  263. package/dist/layout/resolve-measured.js.map +1 -0
  264. package/dist/layout/resolve.d.ts.map +1 -1
  265. package/dist/layout/resolve.js +23 -10
  266. package/dist/layout/resolve.js.map +1 -1
  267. package/dist/layout/route/channel-bends.d.ts +19 -0
  268. package/dist/layout/route/channel-bends.d.ts.map +1 -0
  269. package/dist/layout/route/channel-bends.js +64 -0
  270. package/dist/layout/route/channel-bends.js.map +1 -0
  271. package/dist/layout/route/channel-coupling.d.ts +69 -0
  272. package/dist/layout/route/channel-coupling.d.ts.map +1 -0
  273. package/dist/layout/route/channel-coupling.js +60 -0
  274. package/dist/layout/route/channel-coupling.js.map +1 -0
  275. package/dist/layout/route/channel-free.d.ts +5 -0
  276. package/dist/layout/route/channel-free.d.ts.map +1 -0
  277. package/dist/layout/route/channel-free.js +14 -0
  278. package/dist/layout/route/channel-free.js.map +1 -0
  279. package/dist/layout/route/channel-grid.d.ts +30 -0
  280. package/dist/layout/route/channel-grid.d.ts.map +1 -0
  281. package/dist/layout/route/channel-grid.js +81 -0
  282. package/dist/layout/route/channel-grid.js.map +1 -0
  283. package/dist/layout/route/channel-input.d.ts +29 -0
  284. package/dist/layout/route/channel-input.d.ts.map +1 -0
  285. package/dist/layout/route/channel-input.js +54 -0
  286. package/dist/layout/route/channel-input.js.map +1 -0
  287. package/dist/layout/route/channel-layout.d.ts +5 -0
  288. package/dist/layout/route/channel-layout.d.ts.map +1 -0
  289. package/dist/layout/route/channel-layout.js +25 -0
  290. package/dist/layout/route/channel-layout.js.map +1 -0
  291. package/dist/layout/route/channel-moved.d.ts +4 -0
  292. package/dist/layout/route/channel-moved.d.ts.map +1 -0
  293. package/dist/layout/route/channel-moved.js +31 -0
  294. package/dist/layout/route/channel-moved.js.map +1 -0
  295. package/dist/layout/route/channel-order.d.ts +48 -0
  296. package/dist/layout/route/channel-order.d.ts.map +1 -0
  297. package/dist/layout/route/channel-order.js +60 -0
  298. package/dist/layout/route/channel-order.js.map +1 -0
  299. package/dist/layout/route/channel-port.d.ts +11 -0
  300. package/dist/layout/route/channel-port.d.ts.map +1 -0
  301. package/dist/layout/route/channel-port.js +10 -0
  302. package/dist/layout/route/channel-port.js.map +1 -0
  303. package/dist/layout/route/channel-search.d.ts +7 -0
  304. package/dist/layout/route/channel-search.d.ts.map +1 -0
  305. package/dist/layout/route/channel-search.js +70 -0
  306. package/dist/layout/route/channel-search.js.map +1 -0
  307. package/dist/layout/route/channel-sides.d.ts +10 -0
  308. package/dist/layout/route/channel-sides.d.ts.map +1 -0
  309. package/dist/layout/route/channel-sides.js +22 -0
  310. package/dist/layout/route/channel-sides.js.map +1 -0
  311. package/dist/layout/route/channel-spacing-order.d.ts +51 -0
  312. package/dist/layout/route/channel-spacing-order.d.ts.map +1 -0
  313. package/dist/layout/route/channel-spacing-order.js +56 -0
  314. package/dist/layout/route/channel-spacing-order.js.map +1 -0
  315. package/dist/layout/route/channel-spacing.d.ts +33 -0
  316. package/dist/layout/route/channel-spacing.d.ts.map +1 -0
  317. package/dist/layout/route/channel-spacing.js +73 -0
  318. package/dist/layout/route/channel-spacing.js.map +1 -0
  319. package/dist/layout/route/channel-tracks.d.ts +25 -0
  320. package/dist/layout/route/channel-tracks.d.ts.map +1 -0
  321. package/dist/layout/route/channel-tracks.js +73 -0
  322. package/dist/layout/route/channel-tracks.js.map +1 -0
  323. package/dist/layout/route/channel.d.ts +24 -0
  324. package/dist/layout/route/channel.d.ts.map +1 -0
  325. package/dist/layout/route/channel.js +17 -0
  326. package/dist/layout/route/channel.js.map +1 -0
  327. package/dist/layout/route/choose-route.d.ts +6 -0
  328. package/dist/layout/route/choose-route.d.ts.map +1 -0
  329. package/dist/layout/route/choose-route.js +11 -0
  330. package/dist/layout/route/choose-route.js.map +1 -0
  331. package/dist/layout/route/exclude-rank-edges.d.ts +4 -0
  332. package/dist/layout/route/exclude-rank-edges.d.ts.map +1 -0
  333. package/dist/layout/route/exclude-rank-edges.js +8 -0
  334. package/dist/layout/route/exclude-rank-edges.js.map +1 -0
  335. package/dist/layout/route/free-edges.d.ts +10 -0
  336. package/dist/layout/route/free-edges.d.ts.map +1 -0
  337. package/dist/layout/route/free-edges.js +8 -0
  338. package/dist/layout/route/free-edges.js.map +1 -0
  339. package/dist/layout/route/route-audit.d.ts +22 -0
  340. package/dist/layout/route/route-audit.d.ts.map +1 -0
  341. package/dist/layout/route/route-audit.js +51 -0
  342. package/dist/layout/route/route-audit.js.map +1 -0
  343. package/dist/layout/routing-defects.d.ts +8 -0
  344. package/dist/layout/routing-defects.d.ts.map +1 -0
  345. package/dist/layout/routing-defects.js +38 -0
  346. package/dist/layout/routing-defects.js.map +1 -0
  347. package/dist/layout/same-rank-boundary.d.ts +10 -0
  348. package/dist/layout/same-rank-boundary.d.ts.map +1 -0
  349. package/dist/layout/same-rank-boundary.js +31 -0
  350. package/dist/layout/same-rank-boundary.js.map +1 -0
  351. package/dist/layout/same-rank-outcome.d.ts +43 -0
  352. package/dist/layout/same-rank-outcome.d.ts.map +1 -0
  353. package/dist/layout/same-rank-outcome.js +2 -0
  354. package/dist/layout/same-rank-outcome.js.map +1 -0
  355. package/dist/layout/same-rank.d.ts +9 -0
  356. package/dist/layout/same-rank.d.ts.map +1 -0
  357. package/dist/layout/same-rank.js +92 -0
  358. package/dist/layout/same-rank.js.map +1 -0
  359. package/dist/layout/self-route.d.ts +1 -1
  360. package/dist/layout/self-route.d.ts.map +1 -1
  361. package/dist/layout/self-route.js +5 -3
  362. package/dist/layout/self-route.js.map +1 -1
  363. package/dist/layout/stages/arcs.d.ts +5 -0
  364. package/dist/layout/stages/arcs.d.ts.map +1 -0
  365. package/dist/layout/stages/arcs.js +43 -0
  366. package/dist/layout/stages/arcs.js.map +1 -0
  367. package/dist/layout/stages/badge-candidates.d.ts +4 -0
  368. package/dist/layout/stages/badge-candidates.d.ts.map +1 -0
  369. package/dist/layout/stages/badge-candidates.js +10 -0
  370. package/dist/layout/stages/badge-candidates.js.map +1 -0
  371. package/dist/layout/stages/badge-placement.d.ts +7 -0
  372. package/dist/layout/stages/badge-placement.d.ts.map +1 -0
  373. package/dist/layout/stages/badge-placement.js +24 -0
  374. package/dist/layout/stages/badge-placement.js.map +1 -0
  375. package/dist/layout/stages/constraints.d.ts +4 -0
  376. package/dist/layout/stages/constraints.d.ts.map +1 -0
  377. package/dist/layout/stages/constraints.js +51 -0
  378. package/dist/layout/stages/constraints.js.map +1 -0
  379. package/dist/layout/stages/contact-inputs.d.ts +10 -0
  380. package/dist/layout/stages/contact-inputs.d.ts.map +1 -0
  381. package/dist/layout/stages/contact-inputs.js +23 -0
  382. package/dist/layout/stages/contact-inputs.js.map +1 -0
  383. package/dist/layout/stages/contact-reduction.d.ts +9 -0
  384. package/dist/layout/stages/contact-reduction.d.ts.map +1 -0
  385. package/dist/layout/stages/contact-reduction.js +36 -0
  386. package/dist/layout/stages/contact-reduction.js.map +1 -0
  387. package/dist/layout/stages/contacts.d.ts +9 -0
  388. package/dist/layout/stages/contacts.d.ts.map +1 -0
  389. package/dist/layout/stages/contacts.js +61 -0
  390. package/dist/layout/stages/contacts.js.map +1 -0
  391. package/dist/layout/stages/drawn.d.ts +37 -0
  392. package/dist/layout/stages/drawn.d.ts.map +1 -0
  393. package/dist/layout/stages/drawn.js +92 -0
  394. package/dist/layout/stages/drawn.js.map +1 -0
  395. package/dist/layout/stages/hard-check.d.ts +11 -0
  396. package/dist/layout/stages/hard-check.d.ts.map +1 -0
  397. package/dist/layout/stages/hard-check.js +35 -0
  398. package/dist/layout/stages/hard-check.js.map +1 -0
  399. package/dist/layout/stages/hints.d.ts +5 -0
  400. package/dist/layout/stages/hints.d.ts.map +1 -0
  401. package/dist/layout/stages/hints.js +58 -0
  402. package/dist/layout/stages/hints.js.map +1 -0
  403. package/dist/layout/stages/label-candidates.d.ts +8 -0
  404. package/dist/layout/stages/label-candidates.d.ts.map +1 -0
  405. package/dist/layout/stages/label-candidates.js +38 -0
  406. package/dist/layout/stages/label-candidates.js.map +1 -0
  407. package/dist/layout/stages/label-check.d.ts +9 -0
  408. package/dist/layout/stages/label-check.d.ts.map +1 -0
  409. package/dist/layout/stages/label-check.js +15 -0
  410. package/dist/layout/stages/label-check.js.map +1 -0
  411. package/dist/layout/stages/label-placement.d.ts +4 -0
  412. package/dist/layout/stages/label-placement.d.ts.map +1 -0
  413. package/dist/layout/stages/label-placement.js +106 -0
  414. package/dist/layout/stages/label-placement.js.map +1 -0
  415. package/dist/layout/stages/number-placement.d.ts +6 -0
  416. package/dist/layout/stages/number-placement.d.ts.map +1 -0
  417. package/dist/layout/stages/number-placement.js +41 -0
  418. package/dist/layout/stages/number-placement.js.map +1 -0
  419. package/dist/layout/stages/paths.d.ts +7 -0
  420. package/dist/layout/stages/paths.d.ts.map +1 -0
  421. package/dist/layout/stages/paths.js +155 -0
  422. package/dist/layout/stages/paths.js.map +1 -0
  423. package/dist/layout/stages/placement.d.ts +4 -0
  424. package/dist/layout/stages/placement.d.ts.map +1 -0
  425. package/dist/layout/stages/placement.js +7 -0
  426. package/dist/layout/stages/placement.js.map +1 -0
  427. package/dist/layout/stages/plane.d.ts +21 -0
  428. package/dist/layout/stages/plane.d.ts.map +1 -0
  429. package/dist/layout/stages/plane.js +135 -0
  430. package/dist/layout/stages/plane.js.map +1 -0
  431. package/dist/layout/stages/presentation.d.ts +23 -0
  432. package/dist/layout/stages/presentation.d.ts.map +1 -0
  433. package/dist/layout/stages/presentation.js +35 -0
  434. package/dist/layout/stages/presentation.js.map +1 -0
  435. package/dist/layout/stages/quality.d.ts +76 -0
  436. package/dist/layout/stages/quality.d.ts.map +1 -0
  437. package/dist/layout/stages/quality.js +2 -0
  438. package/dist/layout/stages/quality.js.map +1 -0
  439. package/dist/layout/stages/reading.d.ts +22 -0
  440. package/dist/layout/stages/reading.d.ts.map +1 -0
  441. package/dist/layout/stages/reading.js +67 -0
  442. package/dist/layout/stages/reading.js.map +1 -0
  443. package/dist/layout/stages/refine.d.ts +7 -0
  444. package/dist/layout/stages/refine.d.ts.map +1 -0
  445. package/dist/layout/stages/refine.js +41 -0
  446. package/dist/layout/stages/refine.js.map +1 -0
  447. package/dist/layout/stages/report.d.ts +13 -0
  448. package/dist/layout/stages/report.d.ts.map +1 -0
  449. package/dist/layout/stages/report.js +41 -0
  450. package/dist/layout/stages/report.js.map +1 -0
  451. package/dist/layout/stages/uncertainty.d.ts +5 -0
  452. package/dist/layout/stages/uncertainty.d.ts.map +1 -0
  453. package/dist/layout/stages/uncertainty.js +18 -0
  454. package/dist/layout/stages/uncertainty.js.map +1 -0
  455. package/dist/layout/stretch-route.d.ts +6 -0
  456. package/dist/layout/stretch-route.d.ts.map +1 -0
  457. package/dist/layout/stretch-route.js +31 -0
  458. package/dist/layout/stretch-route.js.map +1 -0
  459. package/dist/layout/text-size.d.ts +5 -0
  460. package/dist/layout/text-size.d.ts.map +1 -0
  461. package/dist/layout/text-size.js +14 -0
  462. package/dist/layout/text-size.js.map +1 -0
  463. package/dist/layout/types.d.ts +32 -11
  464. package/dist/layout/types.d.ts.map +1 -1
  465. package/dist/layout/width.d.ts +8 -0
  466. package/dist/layout/width.d.ts.map +1 -0
  467. package/dist/layout/width.js +15 -0
  468. package/dist/layout/width.js.map +1 -0
  469. package/dist/model/flow.d.ts +4 -0
  470. package/dist/model/flow.d.ts.map +1 -1
  471. package/dist/model/flow.js +15 -8
  472. package/dist/model/flow.js.map +1 -1
  473. package/dist/model/frame.d.ts +5 -28
  474. package/dist/model/frame.d.ts.map +1 -1
  475. package/dist/model/frame.js +7 -45
  476. package/dist/model/frame.js.map +1 -1
  477. package/dist/model/labels.d.ts +6 -0
  478. package/dist/model/labels.d.ts.map +1 -1
  479. package/dist/model/labels.js +8 -0
  480. package/dist/model/labels.js.map +1 -1
  481. package/dist/model/panel-labels.d.ts +9 -0
  482. package/dist/model/panel-labels.d.ts.map +1 -0
  483. package/dist/model/panel-labels.js +10 -0
  484. package/dist/model/panel-labels.js.map +1 -0
  485. package/dist/model/panel.d.ts +34 -0
  486. package/dist/model/panel.d.ts.map +1 -0
  487. package/dist/model/panel.js +52 -0
  488. package/dist/model/panel.js.map +1 -0
  489. package/dist/model/retarget-flow.d.ts +6 -0
  490. package/dist/model/retarget-flow.d.ts.map +1 -0
  491. package/dist/model/retarget-flow.js +39 -0
  492. package/dist/model/retarget-flow.js.map +1 -0
  493. package/dist/render/arrow-label.d.ts +4 -0
  494. package/dist/render/arrow-label.d.ts.map +1 -0
  495. package/dist/render/arrow-label.js +13 -0
  496. package/dist/render/arrow-label.js.map +1 -0
  497. package/dist/render/panel-labels.d.ts +3 -0
  498. package/dist/render/panel-labels.d.ts.map +1 -0
  499. package/dist/render/panel-labels.js +8 -0
  500. package/dist/render/panel-labels.js.map +1 -0
  501. package/dist/render/panel.d.ts.map +1 -1
  502. package/dist/render/panel.js +3 -2
  503. package/dist/render/panel.js.map +1 -1
  504. package/dist/render/positions.d.ts +15 -0
  505. package/dist/render/positions.d.ts.map +1 -0
  506. package/dist/render/positions.js +21 -0
  507. package/dist/render/positions.js.map +1 -0
  508. package/dist/render/svg.d.ts.map +1 -1
  509. package/dist/render/svg.js +21 -12
  510. package/dist/render/svg.js.map +1 -1
  511. package/dist/schema/content.d.ts +64 -64
  512. package/dist/schema/content.d.ts.map +1 -1
  513. package/dist/schema/content.js +22 -24
  514. package/dist/schema/content.js.map +1 -1
  515. package/dist/schema/hints.d.ts +45 -0
  516. package/dist/schema/hints.d.ts.map +1 -0
  517. package/dist/schema/hints.js +28 -0
  518. package/dist/schema/hints.js.map +1 -0
  519. package/dist/schema/layout.d.ts +7 -7
  520. package/dist/schema/layout.d.ts.map +1 -1
  521. package/dist/schema/layout.js +5 -2
  522. package/dist/schema/layout.js.map +1 -1
  523. package/dist/schema/measurement.d.ts +17 -0
  524. package/dist/schema/measurement.d.ts.map +1 -0
  525. package/dist/schema/measurement.js +18 -0
  526. package/dist/schema/measurement.js.map +1 -0
  527. package/dist/schema/primitives.d.ts +43 -43
  528. package/dist/schema/primitives.d.ts.map +1 -1
  529. package/dist/schema/primitives.js +22 -21
  530. package/dist/schema/primitives.js.map +1 -1
  531. package/dist/schema/references.d.ts.map +1 -1
  532. package/dist/schema/references.js +35 -2
  533. package/dist/schema/references.js.map +1 -1
  534. package/dist/schema.d.ts +583 -385
  535. package/dist/schema.d.ts.map +1 -1
  536. package/dist/schema.js +33 -29
  537. package/dist/schema.js.map +1 -1
  538. package/package.json +1 -1
  539. package/resolved-map.schema.json +228 -0
  540. package/source-map.schema.json +157 -0
  541. package/src/dom/animator.ts +41 -62
  542. package/src/dom/bindings.ts +1 -0
  543. package/src/dom/concepts.ts +51 -0
  544. package/src/dom/drawing.ts +64 -0
  545. package/src/dom/geometry.ts +22 -11
  546. package/src/dom/index.ts +2 -1
  547. package/src/dom/measureLabel.ts +97 -0
  548. package/src/dom/mount.ts +2 -1
  549. package/src/dom/narrowLayout.ts +37 -0
  550. package/src/dom/panelDom.ts +20 -0
  551. package/src/dom/player.ts +54 -58
  552. package/src/dom/refine.ts +119 -0
  553. package/src/dom/resize.ts +13 -0
  554. package/src/dom/svgDom.ts +13 -0
  555. package/src/dom/textBounds.ts +40 -0
  556. package/src/dom/token.ts +50 -0
  557. package/src/element/element.ts +2 -2
  558. package/src/element/input.ts +12 -4
  559. package/src/element/layout.ts +3 -2
  560. package/src/layout/badges.ts +19 -30
  561. package/src/layout/build-problem.ts +64 -0
  562. package/src/layout/check.ts +0 -22
  563. package/src/layout/dagre.ts +87 -41
  564. package/src/layout/elk-graph.ts +85 -0
  565. package/src/layout/elk-ports.ts +49 -0
  566. package/src/layout/elk.ts +96 -74
  567. package/src/layout/errors.ts +179 -0
  568. package/src/layout/font-metrics.ts +0 -1
  569. package/src/layout/free-edges.ts +28 -0
  570. package/src/layout/graph.ts +6 -17
  571. package/src/layout/hints.ts +56 -0
  572. package/src/layout/index.ts +177 -16
  573. package/src/layout/inspect-routes.ts +80 -0
  574. package/src/layout/intent.ts +49 -0
  575. package/src/layout/legacy.ts +20 -0
  576. package/src/layout/measure.ts +18 -15
  577. package/src/layout/measured.ts +38 -0
  578. package/src/layout/measurement.ts +27 -0
  579. package/src/layout/mono-metrics.ts +3 -0
  580. package/src/layout/moved-routes.ts +76 -0
  581. package/src/layout/outcomes.ts +35 -0
  582. package/src/layout/place-free.ts +175 -0
  583. package/src/layout/place-same-rank.ts +46 -0
  584. package/src/layout/place.ts +46 -0
  585. package/src/layout/ports.ts +11 -0
  586. package/src/layout/problem.ts +63 -0
  587. package/src/layout/relations/align-lanes.ts +90 -0
  588. package/src/layout/relations/align-layout.ts +71 -0
  589. package/src/layout/relations/align.ts +32 -0
  590. package/src/layout/relations/apply.ts +103 -0
  591. package/src/layout/relations/check-derived.ts +37 -0
  592. package/src/layout/relations/check-witness.ts +87 -0
  593. package/src/layout/relations/check.ts +61 -0
  594. package/src/layout/relations/cross.ts +78 -0
  595. package/src/layout/relations/derive.ts +18 -0
  596. package/src/layout/relations/derived-input.ts +60 -0
  597. package/src/layout/relations/explain.ts +63 -0
  598. package/src/layout/relations/lane-pins.ts +62 -0
  599. package/src/layout/relations/lane-rank.ts +158 -0
  600. package/src/layout/relations/normalize.ts +108 -0
  601. package/src/layout/relations/paths.ts +39 -0
  602. package/src/layout/relations/pin-anchors.ts +21 -0
  603. package/src/layout/relations/rank.ts +86 -0
  604. package/src/layout/relations/result.ts +27 -0
  605. package/src/layout/relations/solve.ts +67 -0
  606. package/src/layout/relations/types.ts +41 -0
  607. package/src/layout/resolve-measured.ts +30 -0
  608. package/src/layout/resolve.ts +31 -10
  609. package/src/layout/route/channel-bends.ts +79 -0
  610. package/src/layout/route/channel-coupling.ts +85 -0
  611. package/src/layout/route/channel-free.ts +21 -0
  612. package/src/layout/route/channel-grid.ts +118 -0
  613. package/src/layout/route/channel-input.ts +66 -0
  614. package/src/layout/route/channel-layout.ts +30 -0
  615. package/src/layout/route/channel-moved.ts +51 -0
  616. package/src/layout/route/channel-order.ts +74 -0
  617. package/src/layout/route/channel-port.ts +13 -0
  618. package/src/layout/route/channel-search.ts +86 -0
  619. package/src/layout/route/channel-sides.ts +31 -0
  620. package/src/layout/route/channel-spacing-order.ts +65 -0
  621. package/src/layout/route/channel-spacing.ts +112 -0
  622. package/src/layout/route/channel-tracks.ts +107 -0
  623. package/src/layout/route/channel.ts +30 -0
  624. package/src/layout/route/choose-route.ts +13 -0
  625. package/src/layout/route/exclude-rank-edges.ts +12 -0
  626. package/src/layout/route/free-edges.ts +17 -0
  627. package/src/layout/route/route-audit.ts +65 -0
  628. package/src/layout/routing-defects.ts +56 -0
  629. package/src/layout/same-rank-boundary.ts +34 -0
  630. package/src/layout/same-rank-outcome.ts +30 -0
  631. package/src/layout/same-rank.ts +157 -0
  632. package/src/layout/self-route.ts +5 -2
  633. package/src/layout/stages/arcs.ts +61 -0
  634. package/src/layout/stages/badge-candidates.ts +11 -0
  635. package/src/layout/stages/badge-placement.ts +43 -0
  636. package/src/layout/stages/constraints.ts +63 -0
  637. package/src/layout/stages/contact-inputs.ts +29 -0
  638. package/src/layout/stages/contact-reduction.ts +41 -0
  639. package/src/layout/stages/contacts.ts +96 -0
  640. package/src/layout/stages/drawn.ts +129 -0
  641. package/src/layout/stages/hard-check.ts +54 -0
  642. package/src/layout/stages/hints.ts +76 -0
  643. package/src/layout/stages/label-candidates.ts +57 -0
  644. package/src/layout/stages/label-check.ts +21 -0
  645. package/src/layout/stages/label-placement.ts +168 -0
  646. package/src/layout/stages/number-placement.ts +53 -0
  647. package/src/layout/stages/paths.ts +175 -0
  648. package/src/layout/stages/placement.ts +8 -0
  649. package/src/layout/stages/plane.ts +181 -0
  650. package/src/layout/stages/presentation.ts +71 -0
  651. package/src/layout/stages/quality.ts +63 -0
  652. package/src/layout/stages/reading.ts +102 -0
  653. package/src/layout/stages/refine.ts +47 -0
  654. package/src/layout/stages/report.ts +57 -0
  655. package/src/layout/stages/uncertainty.ts +27 -0
  656. package/src/layout/stretch-route.ts +45 -0
  657. package/src/layout/text-size.ts +26 -0
  658. package/src/layout/types.ts +32 -11
  659. package/src/layout/width.ts +22 -0
  660. package/src/model/flow.ts +19 -8
  661. package/src/model/frame.ts +12 -73
  662. package/src/model/labels.ts +13 -0
  663. package/src/model/panel-labels.ts +22 -0
  664. package/src/model/panel.ts +98 -0
  665. package/src/model/retarget-flow.ts +43 -0
  666. package/src/render/arrow-label.ts +16 -0
  667. package/src/render/panel-labels.ts +11 -0
  668. package/src/render/panel.ts +3 -2
  669. package/src/render/positions.ts +29 -0
  670. package/src/render/svg.ts +32 -12
  671. package/src/schema/content.ts +47 -44
  672. package/src/schema/hints.ts +31 -0
  673. package/src/schema/layout.ts +5 -2
  674. package/src/schema/measurement.ts +23 -0
  675. package/src/schema/primitives.ts +27 -26
  676. package/src/schema/references.ts +45 -2
  677. package/src/schema.ts +55 -44
  678. package/dist/dom/badgeDom.d.ts +0 -3
  679. package/dist/dom/badgeDom.d.ts.map +0 -1
  680. package/dist/dom/badgeDom.js +0 -23
  681. package/dist/dom/badgeDom.js.map +0 -1
  682. package/dist/model/badge-placement.d.ts +0 -10
  683. package/dist/model/badge-placement.d.ts.map +0 -1
  684. package/dist/model/badge-placement.js +0 -27
  685. package/dist/model/badge-placement.js.map +0 -1
  686. package/src/dom/badgeDom.ts +0 -32
  687. package/src/model/badge-placement.ts +0 -43
@@ -0,0 +1,63 @@
1
+ import type { SourceMap, ResolvedMap } from "../../schema.js";
2
+ import type { ConstraintVerdict } from "../problem.js";
3
+ import { checkHints } from "./hints.js";
4
+
5
+ type Box = readonly [number, number, number, number];
6
+ function laneBox(resolved: ResolvedMap, id: string): Box | undefined {
7
+ const lane = resolved.lanes[id];
8
+ return (
9
+ lane && [lane.x ?? 6, lane.y, lane.w ?? resolved.viewBox[0] - 12, lane.h]
10
+ );
11
+ }
12
+ function inside(box: Box, lane: Box): boolean {
13
+ return (
14
+ box[0] >= lane[0] &&
15
+ box[1] >= lane[1] &&
16
+ box[0] + box[2] <= lane[0] + lane[2] + 1e-6 &&
17
+ box[1] + box[3] <= lane[1] + lane[3] + 1e-6
18
+ );
19
+ }
20
+ /** Recompute every required rule from source intent and resolved geometry.
21
+ * Direction is preferred: its existing reading report remains descriptive. */
22
+ function checkLanes(
23
+ source: SourceMap | ResolvedMap,
24
+ resolved: ResolvedMap,
25
+ ): ConstraintVerdict[] {
26
+ const ids = Object.keys(source.lanes);
27
+ const messages: string[] = [];
28
+ const axis = source.direction === "right" ? 0 : 1;
29
+ for (const [id, node] of Object.entries(source.nodes)) {
30
+ if (!node.lane) continue;
31
+ const box = resolved.nodes[id]?.box;
32
+ const lane = laneBox(resolved, node.lane);
33
+ if (!box || !lane || !inside(box, lane))
34
+ messages.push(`layout.nodes.${id}: outside lane “${node.lane}”`);
35
+ }
36
+ ids.forEach((id, i) => {
37
+ const box = laneBox(resolved, id);
38
+ if (!box) messages.push(`layout.lanes: missing id “${id}”`);
39
+ if (!i || !box) return;
40
+ const prev = laneBox(resolved, ids[i - 1]);
41
+ if (prev && box[axis] < prev[axis] + prev[axis + 2])
42
+ messages.push(`layout.lanes.${id}: lanes must be ordered and disjoint`);
43
+ });
44
+ return ids.length
45
+ ? [
46
+ {
47
+ kind: "lanes",
48
+ strength: "required",
49
+ holds: !messages.length,
50
+ message:
51
+ messages.join("; ") ||
52
+ "Lanes are ordered, disjoint and contain their nodes",
53
+ },
54
+ ]
55
+ : [];
56
+ }
57
+
58
+ export function checkConstraints(
59
+ source: SourceMap | ResolvedMap,
60
+ resolved: ResolvedMap,
61
+ ): ConstraintVerdict[] {
62
+ return [...checkLanes(source, resolved), ...checkHints(source, resolved)];
63
+ }
@@ -0,0 +1,29 @@
1
+ import type { ResolvedMap, SourceMap } from "../../schema.js";
2
+ import { measureMono } from "../text-size.js";
3
+ import { drawn, TEXT } from "./drawn.js";
4
+ import type { CheckOptions } from "./quality.js";
5
+ import { judgeContacts } from "./uncertainty.js";
6
+
7
+ /** Shapes and the contact judge shared by the full check and the label check. */
8
+ export function contactInputs(
9
+ source: SourceMap | ResolvedMap,
10
+ resolved: ResolvedMap,
11
+ options: CheckOptions,
12
+ ) {
13
+ const size = options.textSize ?? TEXT;
14
+ const margin = (options.margin ?? 0.25) * size;
15
+ const tolerance = (options.tolerance ?? 0.1) * size;
16
+ const input = options.measureLabel;
17
+ const measure = !input
18
+ ? measureMono
19
+ : typeof input === "function"
20
+ ? input
21
+ : input.measure.bind(input);
22
+ const shapes = drawn(source, resolved, size, measure);
23
+ return {
24
+ size,
25
+ tolerance,
26
+ shapes,
27
+ judge: judgeContacts(shapes, size, margin, tolerance),
28
+ };
29
+ }
@@ -0,0 +1,41 @@
1
+ import type { LayoutBox } from "../types.js";
2
+ import { rectGap, segmentRectGap } from "./plane.js";
3
+ import type { Segment } from "./label-candidates.js";
4
+
5
+ type Gap = (box: LayoutBox) => number;
6
+ const margin = 1 / 64;
7
+
8
+ /** Cache fixed route bounds; exact distances are needed only nearby. */
9
+ export function lineGaps(lines: Segment[]): Gap[] {
10
+ return lines.map(([a, b]) => {
11
+ const bounds: LayoutBox = [
12
+ Math.min(a[0], b[0]),
13
+ Math.min(a[1], b[1]),
14
+ Math.abs(b[0] - a[0]),
15
+ Math.abs(b[1] - a[1]),
16
+ ];
17
+ return (box) =>
18
+ rectGap(box, bounds) >= margin ? margin : segmentRectGap(a, b, box);
19
+ });
20
+ }
21
+
22
+ // Count penetration in finite units so gradual repairs cannot oscillate.
23
+ const penetration = (gap: number) =>
24
+ Math.max(0, Math.ceil((margin - gap) / margin));
25
+
26
+ /** A move must reduce penetration and never introduce or deepen a contact. */
27
+ export function contactReduction(origin: LayoutBox, gaps: Gap[]) {
28
+ const previous = gaps.map((gap) => Math.min(margin, gap(origin)));
29
+ if (previous.every((gap) => gap >= 0)) return undefined;
30
+ const initial = previous.reduce((sum, gap) => sum + penetration(gap), 0);
31
+ return (box: LayoutBox) => {
32
+ let remaining = 0;
33
+ for (let i = 0; i < gaps.length; i++) {
34
+ const gap = gaps[i](box);
35
+ if (gap < previous[i]) return Infinity;
36
+ remaining += penetration(gap);
37
+ if (remaining >= initial) return Infinity;
38
+ }
39
+ return remaining;
40
+ };
41
+ }
@@ -0,0 +1,96 @@
1
+ import type { Contact, LayoutReport } from "./quality.js";
2
+ import type { Drawn } from "./drawn.js";
3
+ import {
4
+ circleGap,
5
+ circleRectGap,
6
+ crossings,
7
+ rectGap,
8
+ segmentRectGap,
9
+ type Rect,
10
+ type Vec,
11
+ } from "./plane.js";
12
+
13
+ /** Records a contact when the gap is below the margin. */
14
+ export type Judge = (
15
+ list: Contact[],
16
+ a: string,
17
+ b: string,
18
+ gap: number,
19
+ ) => void;
20
+
21
+ export function crossingPairs({ edges }: Drawn): LayoutReport["crossings"] {
22
+ const result: LayoutReport["crossings"] = { count: 0, pairs: [] };
23
+ edges.forEach((e, i) => {
24
+ for (const other of edges.slice(i + 1)) {
25
+ let count = 0;
26
+ for (const a of e.lines)
27
+ for (const b of other.lines) count += crossings(a, b).length;
28
+ if (!count) continue;
29
+ result.count += count;
30
+ result.pairs.push([e.id, other.id]);
31
+ }
32
+ });
33
+ return result;
34
+ }
35
+
36
+ export function labelContacts(d: Drawn, judge: Judge): LayoutReport["labels"] {
37
+ const out: LayoutReport["labels"] = { labels: [], lines: [], boxes: [] };
38
+ d.labels.forEach((label, i) => {
39
+ const a = `label:${label.id}`;
40
+ for (const other of d.labels.slice(i + 1))
41
+ judge(out.labels, a, `label:${other.id}`, rectGap(label.box, other.box));
42
+ for (const e of d.edges)
43
+ judge(out.lines, a, `line:${e.id}`, lineGap(e.lines, label.box));
44
+ for (const n of d.nodes)
45
+ judge(out.boxes, a, `node:${n.id}`, rectGap(label.box, n.box));
46
+ });
47
+ return out;
48
+ }
49
+
50
+ export function stepContacts(d: Drawn, judge: Judge): LayoutReport["steps"] {
51
+ const out: LayoutReport["steps"] = { labels: [], boxes: [], steps: [] };
52
+ const r = d.radius;
53
+ [...d.steps, ...d.nodeSteps].forEach((step) => {
54
+ for (const label of d.labels)
55
+ judge(
56
+ out.labels,
57
+ `label:${label.id}`,
58
+ step.id,
59
+ circleRectGap(step.at, r, label.box),
60
+ );
61
+ });
62
+ d.steps.forEach((step, i) => {
63
+ for (const n of d.nodes)
64
+ judge(
65
+ out.boxes,
66
+ `node:${n.id}`,
67
+ step.id,
68
+ circleRectGap(step.at, r, n.box),
69
+ );
70
+ for (const other of d.steps.slice(i + 1))
71
+ judge(out.steps, step.id, other.id, circleGap(step.at, r, other.at, r));
72
+ });
73
+ return out;
74
+ }
75
+
76
+ export function lineContacts(d: Drawn, judge: Judge): LayoutReport["lines"] {
77
+ const out: LayoutReport["lines"] = { boxes: [] };
78
+ for (const e of d.edges)
79
+ for (const n of d.nodes)
80
+ if (n.id !== e.from && n.id !== e.to)
81
+ judge(
82
+ out.boxes,
83
+ `node:${n.id}`,
84
+ `line:${e.id}`,
85
+ lineGap(e.lines, n.box),
86
+ );
87
+ return out;
88
+ }
89
+
90
+ function lineGap(lines: Vec[][], box: Rect): number {
91
+ let gap = Infinity;
92
+ for (const line of lines)
93
+ for (let k = 1; k < line.length; k++)
94
+ gap = Math.min(gap, segmentRectGap(line[k - 1], line[k], box));
95
+ return gap;
96
+ }
@@ -0,0 +1,129 @@
1
+ import type { ResolvedMap, SourceMap } from "../../schema.js";
2
+ import type { LabelMeasurer } from "../types.js";
3
+ import { measured } from "../measured.js";
4
+ import { polylines } from "./paths.js";
5
+ import type { Rect, Vec } from "./plane.js";
6
+
7
+ /** Arrow-label size used by layout and rendering. */
8
+ export const TEXT = 10.5;
9
+ /** Rendered step-number radius at that size. */
10
+ const STEP_RADIUS = 8;
11
+
12
+ /** What a resolved map draws, as plain shapes. */
13
+ export interface Drawn {
14
+ nodes: { id: string; box: Rect }[];
15
+ edges: { id: string; from: string; to: string; lines: Vec[][] }[];
16
+ labels: { id: string; box: Rect; uncertainty: number }[];
17
+ steps: { id: string; at: Vec }[];
18
+ nodeSteps: { id: string; at: Vec }[];
19
+ radius: number;
20
+ }
21
+
22
+ /** Shapes of a resolved map, with text measured at `size`. */
23
+ export function drawn(
24
+ source: SourceMap | ResolvedMap,
25
+ resolved: ResolvedMap,
26
+ size: number,
27
+ measure: LabelMeasurer,
28
+ ): Drawn {
29
+ sameStructure(source, resolved);
30
+ const edges = Object.entries(resolved.edges);
31
+ return {
32
+ nodes: Object.entries(resolved.nodes).map(([id, n]) => ({
33
+ id,
34
+ box: n.box,
35
+ })),
36
+ edges: edges.map(([id, e]) => ({
37
+ id,
38
+ from: source.edges[id].from,
39
+ to: source.edges[id].to,
40
+ lines: polylines(e.path),
41
+ })),
42
+ labels: labels(resolved, size, measure),
43
+ steps: steps(resolved),
44
+ nodeSteps: nodeSteps(resolved, size),
45
+ radius: (STEP_RADIUS / TEXT) * size,
46
+ };
47
+ }
48
+
49
+ function labels(
50
+ resolved: ResolvedMap,
51
+ size: number,
52
+ measure: LabelMeasurer,
53
+ ): Drawn["labels"] {
54
+ return Object.entries(resolved.edges).flatMap(([id, e]) => {
55
+ if (!e.label?.text) return [];
56
+ const m = measured(measure, e.label.text, {
57
+ fontSize: size,
58
+ mono: true,
59
+ edge: id,
60
+ });
61
+ // Text is drawn from its left baseline; the baseline sits a third of the
62
+ // line height below the centre.
63
+ const [x, y] = e.label.at;
64
+ return [
65
+ {
66
+ id,
67
+ uncertainty: m.uncertainty ?? 0,
68
+ box: [
69
+ x + (m.left ?? 0),
70
+ y - (m.ascent ?? (m.height * 5) / 6),
71
+ m.width,
72
+ m.height,
73
+ ] as Rect,
74
+ },
75
+ ];
76
+ });
77
+ }
78
+
79
+ /** Arrow numbers and the numbers of repeated passes. */
80
+ function steps(resolved: ResolvedMap): Drawn["steps"] {
81
+ return [
82
+ ...Object.entries(resolved.edges).flatMap(([id, e]) =>
83
+ e.badge ? [{ id: `step:${id}`, at: e.badge }] : [],
84
+ ),
85
+ ...resolved.scenarios.flatMap((s, i) =>
86
+ (s.repeatBadges ?? []).map((b) => ({
87
+ id: `repeat:${i}:${b.step}`,
88
+ at: b.at,
89
+ })),
90
+ ),
91
+ ];
92
+ }
93
+
94
+ function sameStructure(source: SourceMap | ResolvedMap, resolved: ResolvedMap) {
95
+ for (const field of ["nodes", "edges"] as const)
96
+ if (
97
+ Object.keys(source[field]).sort().join() !==
98
+ Object.keys(resolved[field]).sort().join()
99
+ )
100
+ throw new Error(
101
+ `check: the resolved map has different ${field} from the source map`,
102
+ );
103
+ for (const [id, e] of Object.entries(source.edges)) {
104
+ const r = resolved.edges[id];
105
+ if (r.from !== e.from || r.to !== e.to)
106
+ throw new Error(
107
+ `check: edge “${id}” connects different nodes in the resolved map`,
108
+ );
109
+ }
110
+ }
111
+
112
+ /** Node step numbers intentionally sit on their box, but must not cover labels. */
113
+ export function nodeSteps(map: ResolvedMap, size: number): Drawn["nodeSteps"] {
114
+ const inset = (2 * size) / TEXT;
115
+ return map.scenarios.flatMap((scenario, i) =>
116
+ !scenario.display.nodeBadges
117
+ ? []
118
+ : scenario.steps.flatMap((step) => {
119
+ if (step.edges.length || !step.current.length) return [];
120
+ const [x, y, w] = map.nodes[step.current[0]].box;
121
+ return [
122
+ {
123
+ id: `node-step:${i}:${step.id}`,
124
+ at: [x + w - inset, y + inset] as Vec,
125
+ },
126
+ ];
127
+ }),
128
+ );
129
+ }
@@ -0,0 +1,54 @@
1
+ import type { ResolvedMap, SourceMap } from "../../schema.js";
2
+ import { checkConstraints } from "./constraints.js";
3
+ import { contactInputs } from "./contact-inputs.js";
4
+ import { labelContacts, lineContacts, stepContacts } from "./contacts.js";
5
+ import type { CheckOptions, LayoutReport } from "./quality.js";
6
+
7
+ type HardReport = Pick<
8
+ LayoutReport,
9
+ "hard" | "constraints" | "labels" | "steps" | "lines"
10
+ >;
11
+
12
+ /** The complete hard-defect check without descriptive crossing/reading metrics. */
13
+ export function checkHard(
14
+ source: SourceMap | ResolvedMap,
15
+ resolved: ResolvedMap,
16
+ options: CheckOptions = {},
17
+ ): HardReport {
18
+ return hardReport(source, resolved, contactInputs(source, resolved, options));
19
+ }
20
+
21
+ export function hardReport(
22
+ source: SourceMap | ResolvedMap,
23
+ resolved: ResolvedMap,
24
+ { shapes, judge }: Pick<ReturnType<typeof contactInputs>, "shapes" | "judge">,
25
+ ): HardReport {
26
+ const report: HardReport = {
27
+ hard: 0,
28
+ constraints: checkConstraints(source, resolved),
29
+ labels: labelContacts(shapes, judge),
30
+ steps: stepContacts(shapes, judge),
31
+ lines: lineContacts(shapes, judge),
32
+ };
33
+ report.hard =
34
+ contactLists(report)
35
+ .flat()
36
+ .filter((c) => c.band === "defect").length +
37
+ report.constraints.filter(
38
+ (c) => c.strength === "required" && c.holds === false,
39
+ ).length;
40
+ return report;
41
+ }
42
+
43
+ /** Contact groups in the order used by full-report diagnostics. */
44
+ export function contactLists(report: HardReport) {
45
+ return [
46
+ report.labels.labels,
47
+ report.labels.lines,
48
+ report.labels.boxes,
49
+ report.steps.labels,
50
+ report.steps.boxes,
51
+ report.steps.steps,
52
+ report.lines.boxes,
53
+ ];
54
+ }
@@ -0,0 +1,76 @@
1
+ import type { SourceMap, ResolvedMap } from "../../schema.js";
2
+ import { statedHints, constraintName } from "../hints.js";
3
+ import type { ConstraintVerdict } from "../problem.js";
4
+ import type { StatedHint } from "../types.js";
5
+ import { polylines } from "./paths.js";
6
+
7
+ function sideHolds(
8
+ hint: Extract<StatedHint, { kind: "side" }>,
9
+ source: SourceMap | ResolvedMap,
10
+ resolved: ResolvedMap,
11
+ ): boolean {
12
+ const edge = source.edges[hint.edge];
13
+ const box = edge && resolved.nodes[edge[hint.end]]?.box;
14
+ const path = resolved.edges[hint.edge]?.path;
15
+ if (!box || !path) return false;
16
+ const lines = polylines(path, true);
17
+ if (lines.length !== 1) return false;
18
+ const point = hint.end === "from" ? lines[0][0] : lines[0].at(-1)!;
19
+ const axis = hint.side === "left" || hint.side === "right" ? 0 : 1;
20
+ const other = 1 - axis;
21
+ const boundary =
22
+ box[axis] +
23
+ (hint.side === "right" || hint.side === "bottom" ? box[axis + 2] : 0);
24
+ // Permit only floating-point roundoff, not a visible gap from the box.
25
+ const epsilon = (a: number) =>
26
+ Number.EPSILON *
27
+ 8 *
28
+ Math.max(Math.abs(box[a]), box[a + 2], Math.abs(point[a]));
29
+ return (
30
+ Math.abs(point[axis] - boundary) <= epsilon(axis) &&
31
+ point[other] >= box[other] - epsilon(other) &&
32
+ point[other] <= box[other] + box[other + 2] + epsilon(other)
33
+ );
34
+ }
35
+
36
+ /** Geometry is authoritative; rank exclusion cannot be inferred from it. */
37
+ export function checkHints(
38
+ source: SourceMap | ResolvedMap,
39
+ resolved: ResolvedMap,
40
+ ): ConstraintVerdict[] {
41
+ const axis = source.direction === "right" ? 0 : 1;
42
+ return statedHints(source).map((hint): ConstraintVerdict => {
43
+ if (hint.kind === "pin") {
44
+ const box = resolved.nodes[hint.node]?.box;
45
+ const distance = box
46
+ ? Math.hypot(
47
+ box[0] + box[2] / 2 - hint.at[0],
48
+ box[1] + box[3] / 2 - hint.at[1],
49
+ )
50
+ : Infinity;
51
+ const message = `${hint.path}: pin (${hint.node}): ${distance} units from box centre`;
52
+ return hint.strength === "required"
53
+ ? { ...hint, holds: distance <= 1e-6, message }
54
+ : { ...hint, holds: null, message };
55
+ }
56
+ if (hint.kind === "free")
57
+ return {
58
+ ...hint,
59
+ holds: null,
60
+ message: `${constraintName(hint)}: not verifiable from the drawing`,
61
+ };
62
+ const positions =
63
+ hint.kind === "sameRank"
64
+ ? hint.nodes.map((id) => resolved.nodes[id]?.box[axis])
65
+ : [];
66
+ const holds =
67
+ hint.kind === "side"
68
+ ? sideHolds(hint, source, resolved)
69
+ : positions.every((p) => p !== undefined && p === positions[0]);
70
+ return {
71
+ ...hint,
72
+ holds,
73
+ message: `${constraintName(hint)}: ${holds ? "honoured" : "not honoured"}`,
74
+ };
75
+ });
76
+ }
@@ -0,0 +1,57 @@
1
+ import type { LayoutBox, LayoutPoint } from "../types.js";
2
+ import type { Vec } from "./plane.js";
3
+ import { badgeCandidates } from "./badge-candidates.js";
4
+ import { segmentRectGap } from "./plane.js";
5
+
6
+ export type Segment = readonly [Vec, Vec];
7
+
8
+ /** A bounded set beside each part of the label's own route. */
9
+ export function* labelCandidates(
10
+ box: LayoutBox,
11
+ route: Segment[],
12
+ limit: number,
13
+ obstacles: LayoutBox[],
14
+ ) {
15
+ for (const [a, b] of route)
16
+ for (let part = 0; part <= 16; part++) {
17
+ const x = a[0] + ((b[0] - a[0]) * part) / 16;
18
+ const y = a[1] + ((b[1] - a[1]) * part) / 16;
19
+ for (const dx of [-box[2] - 4, -box[2] / 2, 4])
20
+ for (const dy of [-box[3] - 4, -box[3] / 2, 4])
21
+ yield [x + dx, y + dy] as LayoutPoint;
22
+ }
23
+ yield* badgeCandidates([box[0], box[1]], limit);
24
+ yield* obstacleCandidates(box, obstacles);
25
+ }
26
+
27
+ /** Sample narrow slots that regular route and radial intervals can miss. */
28
+ function* obstacleCandidates(box: LayoutBox, obstacles: LayoutBox[]) {
29
+ const boundaries = (axis: 0 | 1) => [
30
+ box[axis],
31
+ ...obstacles.flatMap((other) => [
32
+ other[axis] - box[axis + 2] - 1 / 64,
33
+ other[axis] + other[axis + 2] + 1 / 64,
34
+ ]),
35
+ ];
36
+ const xs = boundaries(0),
37
+ ys = boundaries(1);
38
+ for (const x of xs) for (const y of ys) yield [x, y] as LayoutPoint;
39
+ }
40
+
41
+ /** Prefer the own route over unrelated arrows, then the smallest move. */
42
+ export function labelCost(
43
+ box: LayoutBox,
44
+ origin: LayoutBox,
45
+ own: Segment[],
46
+ other: Segment[],
47
+ limit: number,
48
+ ) {
49
+ const gap = (segments: Segment[]) =>
50
+ Math.min(...segments.map(([a, b]) => segmentRectGap(a, b, box)));
51
+ const distance = gap(own);
52
+ return (
53
+ (gap(other) < distance ? 4 * limit : 0) +
54
+ distance +
55
+ Math.hypot(box[0] - origin[0], box[1] - origin[1])
56
+ );
57
+ }
@@ -0,0 +1,21 @@
1
+ import type { ResolvedMap, SourceMap } from "../../schema.js";
2
+ import { contactInputs } from "./contact-inputs.js";
3
+ import { labelContacts, stepContacts } from "./contacts.js";
4
+ import type { CheckOptions, LayoutReport } from "./quality.js";
5
+
6
+ /**
7
+ * The part of `check` that concerns text: arrow labels and step numbers. Same
8
+ * shapes, thresholds and bands as `check`, without lanes, crossings or reading
9
+ * direction, so a browser that only decides where labels go stays small.
10
+ */
11
+ export function checkLabels(
12
+ source: SourceMap | ResolvedMap,
13
+ resolved: ResolvedMap,
14
+ options: CheckOptions = {},
15
+ ): Pick<LayoutReport, "labels" | "steps"> {
16
+ const { shapes, judge } = contactInputs(source, resolved, options);
17
+ return {
18
+ labels: labelContacts(shapes, judge),
19
+ steps: stepContacts(shapes, judge),
20
+ };
21
+ }