@knowvah/dot-engine 2.12.1 → 2.12.3

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 (308) hide show
  1. package/dist/api/builder.d.ts +7 -1
  2. package/dist/api/builder.d.ts.map +1 -1
  3. package/dist/api.js +14 -7
  4. package/dist/api.js.map +2 -2
  5. package/dist/common/compass-port.d.ts.map +1 -1
  6. package/dist/common/edge-label-init.d.ts +26 -1
  7. package/dist/common/edge-label-init.d.ts.map +1 -1
  8. package/dist/common/graph-init.d.ts.map +1 -1
  9. package/dist/common/htmltable-label.d.ts.map +1 -1
  10. package/dist/common/htmltable-lex.d.ts +3 -1
  11. package/dist/common/htmltable-lex.d.ts.map +1 -1
  12. package/dist/common/htmltable-parse-image.d.ts +23 -0
  13. package/dist/common/htmltable-parse-image.d.ts.map +1 -0
  14. package/dist/common/htmltable-parse-state.d.ts +4 -0
  15. package/dist/common/htmltable-parse-state.d.ts.map +1 -1
  16. package/dist/common/htmltable-parse.d.ts +33 -2
  17. package/dist/common/htmltable-parse.d.ts.map +1 -1
  18. package/dist/common/nodeinit.d.ts +16 -2
  19. package/dist/common/nodeinit.d.ts.map +1 -1
  20. package/dist/common/poly-inside.d.ts.map +1 -1
  21. package/dist/common/splines-geom.d.ts +2 -1
  22. package/dist/common/splines-geom.d.ts.map +1 -1
  23. package/dist/common/splines-path-begin.d.ts.map +1 -1
  24. package/dist/common/splines-path-end.d.ts.map +1 -1
  25. package/dist/common/splines-routespl.d.ts +3 -0
  26. package/dist/common/splines-routespl.d.ts.map +1 -1
  27. package/dist/gvc/context.d.ts +8 -0
  28. package/dist/gvc/context.d.ts.map +1 -1
  29. package/dist/gvc/emit-gates.d.ts +5 -10
  30. package/dist/gvc/emit-gates.d.ts.map +1 -1
  31. package/dist/gvc/emit-xdot.d.ts +7 -6
  32. package/dist/gvc/emit-xdot.d.ts.map +1 -1
  33. package/dist/gvc/job.d.ts +5 -2
  34. package/dist/gvc/job.d.ts.map +1 -1
  35. package/dist/gvc/viewport.d.ts +10 -5
  36. package/dist/gvc/viewport.d.ts.map +1 -1
  37. package/dist/index.js +21565 -21326
  38. package/dist/index.js.map +4 -4
  39. package/dist/layout/dot/classify.d.ts.map +1 -1
  40. package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
  41. package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
  42. package/dist/layout/dot/edge-route-chain.d.ts +20 -16
  43. package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
  44. package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
  45. package/dist/layout/dot/edge-route.d.ts +7 -3
  46. package/dist/layout/dot/edge-route.d.ts.map +1 -1
  47. package/dist/layout/dot/fastgr.d.ts +5 -3
  48. package/dist/layout/dot/fastgr.d.ts.map +1 -1
  49. package/dist/layout/dot/flat-adj-record.d.ts +22 -0
  50. package/dist/layout/dot/flat-adj-record.d.ts.map +1 -0
  51. package/dist/layout/dot/flat.d.ts +22 -7
  52. package/dist/layout/dot/flat.d.ts.map +1 -1
  53. package/dist/layout/dot/init.d.ts +49 -9
  54. package/dist/layout/dot/init.d.ts.map +1 -1
  55. package/dist/layout/dot/mincross-build.d.ts +6 -0
  56. package/dist/layout/dot/mincross-build.d.ts.map +1 -1
  57. package/dist/layout/dot/mincross-flat.d.ts +10 -1
  58. package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
  59. package/dist/layout/dot/mincross.d.ts +6 -1
  60. package/dist/layout/dot/mincross.d.ts.map +1 -1
  61. package/dist/layout/dot/ns-subtree.d.ts +9 -6
  62. package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
  63. package/dist/layout/dot/pack-components.d.ts +4 -3
  64. package/dist/layout/dot/pack-components.d.ts.map +1 -1
  65. package/dist/layout/dot/position-aux.d.ts +69 -21
  66. package/dist/layout/dot/position-aux.d.ts.map +1 -1
  67. package/dist/layout/dot/position-bbox.d.ts.map +1 -1
  68. package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
  69. package/dist/layout/dot/position.d.ts.map +1 -1
  70. package/dist/layout/dot/rank-dot2.d.ts +7 -25
  71. package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
  72. package/dist/layout/dot/self-loop.d.ts +11 -4
  73. package/dist/layout/dot/self-loop.d.ts.map +1 -1
  74. package/dist/layout/dot/splines-clone.d.ts +2 -1
  75. package/dist/layout/dot/splines-clone.d.ts.map +1 -1
  76. package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
  77. package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
  78. package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
  79. package/dist/layout/dot/splines-flat.d.ts +18 -0
  80. package/dist/layout/dot/splines-flat.d.ts.map +1 -1
  81. package/dist/layout/dot/splines-groups.d.ts.map +1 -1
  82. package/dist/layout/dot/splines-route.d.ts +6 -3
  83. package/dist/layout/dot/splines-route.d.ts.map +1 -1
  84. package/dist/layout/dot/straight-edges.d.ts.map +1 -1
  85. package/dist/layout/fdp/ports.d.ts.map +1 -1
  86. package/dist/layout/fdp/tlayout.d.ts +3 -0
  87. package/dist/layout/fdp/tlayout.d.ts.map +1 -1
  88. package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
  89. package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
  90. package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
  91. package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
  92. package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
  93. package/dist/layout/neato/conjgrad.d.ts +7 -6
  94. package/dist/layout/neato/conjgrad.d.ts.map +1 -1
  95. package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
  96. package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
  97. package/dist/layout/neato/matrix-ops.d.ts +0 -6
  98. package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
  99. package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -1
  100. package/dist/layout/neato/sgd.d.ts.map +1 -1
  101. package/dist/model/cgraph-ops.d.ts +10 -2
  102. package/dist/model/cgraph-ops.d.ts.map +1 -1
  103. package/dist/model/edge.d.ts +7 -2
  104. package/dist/model/edge.d.ts.map +1 -1
  105. package/dist/model/edgeInfo.d.ts +17 -2
  106. package/dist/model/edgeInfo.d.ts.map +1 -1
  107. package/dist/model/graph.d.ts +4 -3
  108. package/dist/model/graph.d.ts.map +1 -1
  109. package/dist/model/lazy-attrs.d.ts.map +1 -1
  110. package/dist/model/rankEntry.d.ts +3 -1
  111. package/dist/model/rankEntry.d.ts.map +1 -1
  112. package/dist/ortho/index.d.ts +0 -1
  113. package/dist/ortho/index.d.ts.map +1 -1
  114. package/dist/ortho/partition.d.ts +2 -4
  115. package/dist/ortho/partition.d.ts.map +1 -1
  116. package/dist/parser/builder.d.ts.map +1 -1
  117. package/dist/pathplan/route.d.ts +93 -0
  118. package/dist/pathplan/route.d.ts.map +1 -1
  119. package/dist/render/dot/agwrite.d.ts +26 -10
  120. package/dist/render/dot/agwrite.d.ts.map +1 -1
  121. package/dist/render/dot/attrs.d.ts +15 -4
  122. package/dist/render/dot/attrs.d.ts.map +1 -1
  123. package/dist/render/dot/types.d.ts +7 -2
  124. package/dist/render/dot/types.d.ts.map +1 -1
  125. package/dist/render/dot/write-back.d.ts +14 -0
  126. package/dist/render/dot/write-back.d.ts.map +1 -1
  127. package/dist/render/dot/xdot-ops.d.ts +20 -29
  128. package/dist/render/dot/xdot-ops.d.ts.map +1 -1
  129. package/dist/render/dot.d.ts +4 -2
  130. package/dist/render/dot.d.ts.map +1 -1
  131. package/dist/render/json-cluster-edge.d.ts +17 -4
  132. package/dist/render/json-cluster-edge.d.ts.map +1 -1
  133. package/dist/render/json-nonfinite.d.ts +17 -0
  134. package/dist/render/json-nonfinite.d.ts.map +1 -0
  135. package/dist/render/json.d.ts +4 -0
  136. package/dist/render/json.d.ts.map +1 -1
  137. package/dist/render/map.d.ts +3 -0
  138. package/dist/render/map.d.ts.map +1 -1
  139. package/dist/render/svg-graph.d.ts.map +1 -1
  140. package/dist/render/svg-id.d.ts +10 -1
  141. package/dist/render/svg-id.d.ts.map +1 -1
  142. package/dist/render/svg.d.ts +3 -1
  143. package/dist/render/svg.d.ts.map +1 -1
  144. package/dist/render.js +21517 -21278
  145. package/dist/render.js.map +4 -4
  146. package/dist/util/bsd-qsort.d.ts.map +1 -1
  147. package/dist/util/overflow.d.ts +37 -0
  148. package/dist/util/overflow.d.ts.map +1 -0
  149. package/dist/xdot/parse.d.ts.map +1 -1
  150. package/dist/xdot/strtod.d.ts +23 -0
  151. package/dist/xdot/strtod.d.ts.map +1 -0
  152. package/package.json +3 -2
  153. package/src/api/builder.ts +8 -2
  154. package/src/common/compass-port.ts +36 -20
  155. package/src/common/edge-label-init.ts +43 -17
  156. package/src/common/graph-init.ts +11 -1
  157. package/src/common/htmltable-label.ts +9 -4
  158. package/src/common/htmltable-lex.ts +5 -2
  159. package/src/common/htmltable-parse-image.ts +69 -0
  160. package/src/common/htmltable-parse-state.ts +6 -0
  161. package/src/common/htmltable-parse.ts +34 -44
  162. package/src/common/nodeinit.ts +28 -8
  163. package/src/common/poly-inside.ts +11 -5
  164. package/src/common/splines-geom.ts +24 -6
  165. package/src/common/splines-path-begin.ts +4 -3
  166. package/src/common/splines-path-end.ts +4 -3
  167. package/src/common/splines-routespl.ts +32 -0
  168. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
  169. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
  170. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
  171. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
  172. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
  173. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
  174. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
  175. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
  176. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
  177. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
  178. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
  179. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
  180. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
  181. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
  182. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
  183. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
  184. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
  185. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
  186. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
  187. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
  188. package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
  189. package/src/gvc/context.ts +8 -0
  190. package/src/gvc/device.ts +6 -6
  191. package/src/gvc/emit-gates.ts +6 -15
  192. package/src/gvc/emit-xdot.ts +10 -11
  193. package/src/gvc/job.ts +5 -2
  194. package/src/gvc/viewport.ts +13 -7
  195. package/src/layout/dot/__fixtures__/flat-adj-aux-syms.native-16.1.json +1210 -0
  196. package/src/layout/dot/classify.ts +5 -2
  197. package/src/layout/dot/edge-route-chain-views.ts +120 -0
  198. package/src/layout/dot/edge-route-chain.ts +103 -117
  199. package/src/layout/dot/edge-route-faithful.ts +20 -5
  200. package/src/layout/dot/edge-route.ts +44 -49
  201. package/src/layout/dot/fastgr.ts +9 -3
  202. package/src/layout/dot/flat-adj-record.ts +68 -0
  203. package/src/layout/dot/flat.ts +38 -17
  204. package/src/layout/dot/init.ts +59 -13
  205. package/src/layout/dot/mincross-build.ts +14 -1
  206. package/src/layout/dot/mincross-flat.ts +15 -5
  207. package/src/layout/dot/mincross.ts +6 -2
  208. package/src/layout/dot/ns-subtree.ts +11 -7
  209. package/src/layout/dot/pack-components.ts +6 -4
  210. package/src/layout/dot/position-aux.ts +122 -42
  211. package/src/layout/dot/position-bbox.ts +14 -1
  212. package/src/layout/dot/position-ycoords.ts +7 -1
  213. package/src/layout/dot/position.ts +4 -1
  214. package/src/layout/dot/rank-dot2.ts +13 -94
  215. package/src/layout/dot/self-loop.ts +29 -11
  216. package/src/layout/dot/splines-clone.ts +8 -2
  217. package/src/layout/dot/splines-flat-labeled.ts +3 -2
  218. package/src/layout/dot/splines-flat-multi.ts +12 -4
  219. package/src/layout/dot/splines-flat.ts +9 -19
  220. package/src/layout/dot/splines-groups.ts +5 -3
  221. package/src/layout/dot/splines-route.ts +10 -11
  222. package/src/layout/dot/straight-edges.ts +5 -3
  223. package/src/layout/fdp/ports.ts +6 -2
  224. package/src/layout/fdp/tlayout.ts +6 -5
  225. package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
  226. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
  227. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
  228. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
  229. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
  230. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
  231. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
  232. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
  233. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
  234. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
  235. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
  236. package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
  237. package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
  238. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
  239. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
  240. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
  241. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
  242. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
  243. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
  244. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
  245. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
  246. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
  247. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
  248. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
  249. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
  250. package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
  251. package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
  252. package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
  253. package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
  254. package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
  255. package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
  256. package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
  257. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
  258. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
  259. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
  260. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
  261. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
  262. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
  263. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
  264. package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
  265. package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
  266. package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
  267. package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
  268. package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
  269. package/src/layout/neato/conjgrad-mkernel.ts +6 -2
  270. package/src/layout/neato/conjgrad.ts +38 -35
  271. package/src/layout/neato/matrix-ops-dense.ts +2 -20
  272. package/src/layout/neato/matrix-ops.ts +0 -20
  273. package/src/layout/neato/quad-prog-vpsc.ts +7 -5
  274. package/src/layout/neato/sgd.ts +2 -1
  275. package/src/layout/neato/smart-ini-x.ts +15 -15
  276. package/src/layout/neato/stress-subspace.ts +5 -5
  277. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
  278. package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
  279. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
  280. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
  281. package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
  282. package/src/model/cgraph-ops.ts +4 -3
  283. package/src/model/edge.ts +11 -4
  284. package/src/model/edgeInfo.ts +18 -2
  285. package/src/model/graph.ts +4 -3
  286. package/src/model/lazy-attrs.ts +3 -1
  287. package/src/model/rankEntry.ts +3 -1
  288. package/src/ortho/index.ts +0 -1
  289. package/src/ortho/partition.ts +10 -22
  290. package/src/parser/builder.ts +12 -3
  291. package/src/pathplan/route.ts +14 -4
  292. package/src/render/dot/agwrite.ts +45 -18
  293. package/src/render/dot/attrs.ts +18 -7
  294. package/src/render/dot/types.ts +7 -2
  295. package/src/render/dot/write-back.ts +27 -3
  296. package/src/render/dot/xdot-ops.ts +25 -56
  297. package/src/render/dot.ts +7 -5
  298. package/src/render/json-cluster-edge.ts +42 -5
  299. package/src/render/json-nonfinite.ts +51 -0
  300. package/src/render/json.ts +23 -26
  301. package/src/render/map.ts +3 -0
  302. package/src/render/svg-graph.ts +3 -15
  303. package/src/render/svg-id.ts +11 -2
  304. package/src/render/svg.ts +4 -1
  305. package/src/util/bsd-qsort.ts +2 -1
  306. package/src/util/overflow.ts +74 -0
  307. package/src/xdot/parse.ts +9 -19
  308. package/src/xdot/strtod.ts +167 -0
@@ -1 +1 @@
1
- {"version":3,"file":"bsd-qsort.d.ts","sourceRoot":"","sources":["../../src/util/bsd-qsort.ts"],"names":[],"mappings":"AA+KA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAQ9F;AAyCD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAOrE"}
1
+ {"version":3,"file":"bsd-qsort.d.ts","sourceRoot":"","sources":["../../src/util/bsd-qsort.ts"],"names":[],"mappings":"AAgLA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAQ9F;AAyCD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAOrE"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Overflow-checked arithmetic helpers.
3
+ *
4
+ * @see lib/util/overflow.h
5
+ */
6
+ /**
7
+ * Add two integers, clamping to lower and upper type bounds.
8
+ *
9
+ * Returns the sum `a + b`, or `INT_MAX`/`INT_MIN` on overflow/underflow. C's
10
+ * operands are `int`; the port applies the same three branches to its numbers
11
+ * as they are, with no int32 wrap of the inputs.
12
+ * @see lib/util/overflow.h:sadd_saturate
13
+ */
14
+ export declare function saddSaturate(a: number, b: number): number;
15
+ /**
16
+ * Divide two double floating-point values, checking for overflow.
17
+ *
18
+ * Returns the quotient `n / d`, or `null` where C returns `true` and leaves
19
+ * `*res` as it was: the quotient is not finite (a zero or subnormal divisor,
20
+ * a non-finite operand, or a result past `DBL_MAX`). A call site writes C's
21
+ * "assign the fallback, then overwrite on success" as `fdivOverflow(n, d) ??
22
+ * fallback`; a zero quotient is a result, and `??` keeps it.
23
+ * @see lib/util/overflow.h:fdiv_overflow
24
+ */
25
+ export declare function fdivOverflow(n: number, d: number): number | null;
26
+ /**
27
+ * Divide two floating-point values, checking for overflow.
28
+ *
29
+ * The `float` twin of {@link fdivOverflow}. C's parameters and quotient are
30
+ * `float`, so the operands and the quotient are rounded to float32: a
31
+ * quotient past `FLT_MAX` is an overflow here though it is finite as a
32
+ * double. Dividing two float32 values in double and rounding once gives
33
+ * IEEE single division's result (53 >= 2 * 24 + 2 bits).
34
+ * @see lib/util/overflow.h:fdivf_overflow
35
+ */
36
+ export declare function fdivfOverflow(n: number, d: number): number | null;
37
+ //# sourceMappingURL=overflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../src/util/overflow.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAMH;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/xdot/parse.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,IAAI,EAAU,QAAQ,EAAE,YAAY,EACf,SAAS,EACC,WAAW,EAC3C,MAAM,YAAY,CAAC;AAMpB,KAAK,EAAE,CAAC,CAAC,IAAI;IAAE,GAAG,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AA+U5C,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAyC;AACxG,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,CAA6C;AACpH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAA2C;AAC1G,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,CAAgD;AACvH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAE5G;AACD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1F;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAoC;AACrF,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAyC"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/xdot/parse.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,IAAI,EAAU,QAAQ,EAAE,YAAY,EACf,SAAS,EACC,WAAW,EAC3C,MAAM,YAAY,CAAC;AAOpB,KAAK,EAAE,CAAC,CAAC,IAAI;IAAE,GAAG,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AAoU5C,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAyC;AACxG,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,CAA6C;AACpH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAA2C;AAC1G,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,CAAgD;AACvH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAE5G;AACD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1F;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAoC;AACrF,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAyC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The number scan C's xdot parser gets from libc strtod. parseReal, parseRect
3
+ * and parsePolyline all read their doubles with strtod, so an xdot string may
4
+ * hold anything strtod accepts: a decimal, a hexadecimal float, `inf` or
5
+ * `infinity`, and `nan` or `nan(...)`. The grammar is the oracle platform's
6
+ * (macOS libc), which takes any characters between `nan(` and the first `)`.
7
+ * @see lib/xdot/xdot.c:parseReal
8
+ */
9
+ /** A scanned number and the offset just past it, or null when none starts here. */
10
+ export type Scan = {
11
+ val: number;
12
+ pos: number;
13
+ } | null;
14
+ /** @see lib/util/gv_ctype.h:gv_isspace */
15
+ export declare function isSpace(c: string): boolean;
16
+ /**
17
+ * strtod(s + pos, &end): skips whitespace, takes an optional sign, then the
18
+ * longest number strtod accepts. Null when no conversion is possible, which
19
+ * is C's `end == s`.
20
+ * @see lib/xdot/xdot.c:parseReal
21
+ */
22
+ export declare function scanStrtod(s: string, pos: number): Scan;
23
+ //# sourceMappingURL=strtod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strtod.d.ts","sourceRoot":"","sources":["../../src/xdot/strtod.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,mFAAmF;AACnF,MAAM,MAAM,IAAI,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AAgBvD,0CAA0C;AAC1C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE1C;AA2HD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAOvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowvah/dot-engine",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "description": "Faithful TypeScript port of Graphviz (dot, neato, fdp, sfdp, circo, twopi, osage, patchwork) — no C: no native binary, no WASM. Oracle-verified against the C implementation, runs in the browser.",
5
5
  "keywords": [
6
6
  "graphviz",
@@ -65,9 +65,10 @@
65
65
  "typecheck": "tsc --noEmit --stableTypeOrdering",
66
66
  "pretypecheck:ts7": "npm run parser:regen",
67
67
  "typecheck:ts7": "tsgo --noEmit",
68
+ "codeql:gate": "bash test/tools/codeql-gate.sh",
68
69
  "parser:regen": "peggy --format es --dts src/parser/dot.pegjs -o src/parser/dot.js",
69
70
  "survey:setup": "sh test/corpus/gen-headless-gvbindir.sh",
70
- "survey": "npm run survey:setup && GVBINDIR=${GVBINDIR:-/tmp/ghl} PARITY_OUT=parity-rules.json tsx test/corpus/survey.ts",
71
+ "survey": "npm run survey:setup && PARITY_OUT=parity-rules.json tsx test/corpus/survey.ts",
71
72
  "survey:fast": "SURVEY_MAX_PORT_MS=${SURVEY_MAX_PORT_MS:-60000} npm run survey",
72
73
  "survey:gate": "tsx test/corpus/rules-gate.ts",
73
74
  "survey:dashboard": "tsx test/corpus/dashboard.ts",
@@ -26,6 +26,8 @@ import { HTML_STRING_MARK } from '../common/html-string.js';
26
26
  export interface CreateGraphOptions {
27
27
  directed?: boolean;
28
28
  strict?: boolean;
29
+ /** The graph's name. Omitted: the graph is anonymous, as `agopen(NULL)` is
30
+ * (written `digraph {`). An explicit `''` is a name (written `digraph "" {`). */
29
31
  name?: string;
30
32
  }
31
33
 
@@ -331,15 +333,19 @@ function resolveKind(opts: CreateGraphOptions | undefined): GraphKind {
331
333
  * Create a new programmatic graph builder.
332
334
  *
333
335
  * The builder's `.graph` is a fresh Graph ready for handoff to layout/render.
334
- * Defaults: directed=true, strict=false, name=''.
336
+ * Defaults: directed=true, strict=false, no name. A graph created without a
337
+ * `name` is anonymous, as `agopen(NULL)` is: `graph.name` reads `''` and dot
338
+ * output starts `digraph {`. An explicit `name: ''` is a name, as `agopen("")`
339
+ * is, and prints `digraph "" {`.
335
340
  *
336
341
  * @throws TypeError `ERR_INVALID_ARG_TYPE` if `opts` or one of its fields has
337
342
  * the wrong type. Builder and handle methods throw the same for wrong
338
343
  * argument types, and `InternalError` if node/subgraph creation fails.
339
344
  * @see lib/cgraph/graph.c:agopen
345
+ * @see lib/cgraph/id.c:agmapnametoid
340
346
  */
341
347
  export function createGraph(opts?: CreateGraphOptions): GvGraphBuilder {
342
348
  requireGraphOptions(opts);
343
- const g = new Graph(opts?.name ?? '', resolveKind(opts));
349
+ const g = new Graph(opts?.name ?? '', resolveKind(opts), opts?.name === undefined);
344
350
  return new GraphBuilder(g, g);
345
351
  }
@@ -111,27 +111,40 @@ function invflipSide(side: number, rankdir: number): number {
111
111
 
112
112
  // ---------------------------------------------------------------------------
113
113
  // invflipAngle helpers
114
- // @see lib/common/shapes.c:invflip_angle (line 2606)
114
+ // @see lib/common/shapes.c:invflip_angle (line 2607)
115
115
  // ---------------------------------------------------------------------------
116
116
 
117
+ /** The RANKDIR_RL arm of invflip_angle, on ¼×π units; no match leaves the angle unchanged. */
117
118
  function invflipAngleRL(angle: number): number {
118
- if (angle === Math.PI) return -0.5 * Math.PI;
119
- if (angle === Math.PI * 0.75) return -0.25 * Math.PI;
120
- if (angle === Math.PI * 0.5) return 0;
121
- if (angle === 0) return Math.PI * 0.5;
122
- if (angle === Math.PI * -0.25) return Math.PI * 0.75;
123
- if (angle === Math.PI * -0.5) return Math.PI;
119
+ if (angle === 4) return -2;
120
+ if (angle === 3) return -1;
121
+ if (angle === 2) return 0;
122
+ if (angle === 0) return 2;
123
+ if (angle === -1) return 3;
124
+ if (angle === -2) return 4;
124
125
  return angle;
125
126
  }
126
127
 
127
- /** Adjust theta for rankdir. @see lib/common/shapes.c:invflip_angle (line 2606) */
128
+ /**
129
+ * Adjust theta for rankdir.
130
+ * @param angle Angle in units of ¼×π (C's `int`)
131
+ * @returns Computed angle in radians
132
+ * @see lib/common/shapes.c:invflip_angle (line 2607)
133
+ */
128
134
  function invflipAngle(angle: number, rankdir: number): number {
135
+ let a = angle;
129
136
  switch (rankdir) {
130
- case RANKDIR_BT: return -angle;
131
- case RANKDIR_LR: return angle - Math.PI * 0.5;
132
- case RANKDIR_RL: return invflipAngleRL(angle);
133
- default: return angle; // RANKDIR_TB: identity
137
+ case RANKDIR_BT:
138
+ // C: `angle *= -1` on an int, where 0 stays 0. In JS `-a` and `a * -1`
139
+ // turn 0 into -0, which would survive the conversion below; `0 - a`
140
+ // keeps it +0.
141
+ a = 0 - a;
142
+ break;
143
+ case RANKDIR_LR: a -= 2; break;
144
+ case RANKDIR_RL: a = invflipAngleRL(a); break;
145
+ default: break; // RANKDIR_TB: identity
134
146
  }
147
+ return a * 0.25 * Math.PI;
135
148
  }
136
149
 
137
150
  // ---------------------------------------------------------------------------
@@ -165,7 +178,10 @@ function compassBbox(n: Node, bp: Box | null): BboxResult {
165
178
  // ---------------------------------------------------------------------------
166
179
 
167
180
  type DirectionResult = {
168
- p: Point; theta: number; side: number;
181
+ p: Point;
182
+ /** C's `int theta`, in units of ¼×π; invflipAngle converts it to radians. */
183
+ theta: number;
184
+ side: number;
169
185
  constrain: boolean; clip: boolean; dyna: boolean;
170
186
  defined: boolean; rv: number;
171
187
  };
@@ -188,9 +204,9 @@ function dirUnrecognized(p: Point): DirectionResult {
188
204
  function dirN(rest: string, b: Box, ctr: Point, sides: number): DirectionResult {
189
205
  const base = { constrain: true, clip: false, dyna: false };
190
206
  switch (rest) {
191
- case '': return { ...base, p: { x: ctr.x, y: b.ur.y }, theta: Math.PI * 0.5, side: sides & TOP, defined: true, rv: 0 };
192
- case 'e': return { ...base, p: { x: b.ur.x, y: b.ur.y }, theta: Math.PI * 0.25, side: sides & (TOP | RIGHT), defined: true, rv: 0 };
193
- case 'w': return { ...base, p: { x: b.ll.x, y: b.ur.y }, theta: Math.PI * 0.75, side: sides & (TOP | LEFT), defined: true, rv: 0 };
207
+ case '': return { ...base, p: { x: ctr.x, y: b.ur.y }, theta: 2, side: sides & TOP, defined: true, rv: 0 };
208
+ case 'e': return { ...base, p: { x: b.ur.x, y: b.ur.y }, theta: 1, side: sides & (TOP | RIGHT), defined: true, rv: 0 };
209
+ case 'w': return { ...base, p: { x: b.ll.x, y: b.ur.y }, theta: 3, side: sides & (TOP | LEFT), defined: true, rv: 0 };
194
210
  default: return dirUnrecognized({ x: ctr.x, y: ctr.y });
195
211
  }
196
212
  }
@@ -198,9 +214,9 @@ function dirN(rest: string, b: Box, ctr: Point, sides: number): DirectionResult
198
214
  function dirS(rest: string, b: Box, ctr: Point, sides: number): DirectionResult {
199
215
  const base = { constrain: true, clip: false, dyna: false };
200
216
  switch (rest) {
201
- case '': return { ...base, p: { x: ctr.x, y: b.ll.y }, theta: -Math.PI * 0.5, side: sides & BOTTOM, defined: true, rv: 0 };
202
- case 'e': return { ...base, p: { x: b.ur.x, y: b.ll.y }, theta: -Math.PI * 0.25, side: sides & (BOTTOM | RIGHT), defined: true, rv: 0 };
203
- case 'w': return { ...base, p: { x: b.ll.x, y: b.ll.y }, theta: -Math.PI * 0.75, side: sides & (BOTTOM | LEFT), defined: true, rv: 0 };
217
+ case '': return { ...base, p: { x: ctr.x, y: b.ll.y }, theta: -2, side: sides & BOTTOM, defined: true, rv: 0 };
218
+ case 'e': return { ...base, p: { x: b.ur.x, y: b.ll.y }, theta: -1, side: sides & (BOTTOM | RIGHT), defined: true, rv: 0 };
219
+ case 'w': return { ...base, p: { x: b.ll.x, y: b.ll.y }, theta: -3, side: sides & (BOTTOM | LEFT), defined: true, rv: 0 };
204
220
  default: return dirUnrecognized({ x: ctr.x, y: ctr.y });
205
221
  }
206
222
  }
@@ -212,7 +228,7 @@ function dirE(rest: string, b: Box, ctr: Point, sides: number): DirectionResult
212
228
 
213
229
  function dirW(rest: string, b: Box, ctr: Point, sides: number): DirectionResult {
214
230
  if (rest.length > 0) return dirUnrecognized(ctr);
215
- return { p: { x: b.ll.x, y: ctr.y }, theta: Math.PI, side: sides & LEFT, constrain: true, clip: false, dyna: false, defined: true, rv: 0 };
231
+ return { p: { x: b.ll.x, y: ctr.y }, theta: 4, side: sides & LEFT, constrain: true, clip: false, dyna: false, defined: true, rv: 0 };
216
232
  }
217
233
 
218
234
  // ---------------------------------------------------------------------------
@@ -220,12 +220,32 @@ function applyTailLabel(e: Edge, g: Graph, lfi: FontInfo, measurer: TextMeasurer
220
220
  // @see lib/common/utils.c:509-545
221
221
  // ---------------------------------------------------------------------------
222
222
 
223
+ /**
224
+ * Which of common_init_edge's guarded label symbols are bound. C tests each
225
+ * global before reading it (`E_xlabel && (str = agxget(e, E_xlabel)) && str[0]`),
226
+ * and make_flat_adj_edges' setState nulls these three for the aux layout, so an
227
+ * aux edge's copied `xlabel`, `headlabel` and `taillabel` are never read: no
228
+ * label is made and no GD_has_labels bit is set. E_label is rebound from the
229
+ * aux graph instead, so it has no entry here.
230
+ * @see lib/common/utils.c:common_init_edge (525, 533, 539)
231
+ * @see lib/dotgen/dotsplines.c:setState
232
+ */
233
+ export interface EdgeLabelSyms {
234
+ readonly headlabel: boolean;
235
+ readonly taillabel: boolean;
236
+ readonly xlabel: boolean;
237
+ }
238
+
239
+ /** Every symbol bound, as graph_init leaves them. @see lib/common/input.c:graph_init */
240
+ export const BOUND_EDGE_LABEL_SYMS: EdgeLabelSyms = { headlabel: true, taillabel: true, xlabel: true };
241
+
223
242
  /**
224
243
  * Apply label and xlabel with lazy fi init mirroring C's NULL-guard pattern.
225
- * fi is initialized at most once and reused for xlabel.
244
+ * fi is initialized at most once and reused for xlabel. An unbound E_xlabel
245
+ * fails C's guard before the attribute is read.
226
246
  * @see lib/common/utils.c:common_init_edge (lines 515-531)
227
247
  */
228
- function applyMainLabels(e: Edge, g: Graph, measurer: TextMeasurer): void {
248
+ function applyMainLabels(e: Edge, g: Graph, measurer: TextMeasurer, syms: EdgeLabelSyms): void {
229
249
  // C: fi.fontname = NULL; init on first need, reuse for xlabel.
230
250
  let fi: FontInfo | null = null;
231
251
  const labelStr = e.attrs.get('label');
@@ -233,29 +253,25 @@ function applyMainLabels(e: Edge, g: Graph, measurer: TextMeasurer): void {
233
253
  fi = initFontEdgeAttr(e);
234
254
  applyLabel(e, g, fi, measurer);
235
255
  }
236
- const xlabelStr = e.attrs.get('xlabel');
256
+ // utils.c:525 — E_xlabel && (str = agxget(e, E_xlabel)) && str[0]
257
+ const xlabelStr = syms.xlabel ? e.attrs.get('xlabel') : undefined;
237
258
  if (xlabelStr) {
238
259
  applyXLabel(e, g, fi ?? initFontEdgeAttr(e), measurer);
239
260
  }
240
261
  }
241
262
 
242
263
  /**
243
- * Apply headlabel and taillabel using the labelfont* chain.
264
+ * Apply headlabel and taillabel using the labelfont* chain. An unbound
265
+ * E_headlabel or E_taillabel fails C's guard before the attribute is read.
244
266
  * @see lib/common/utils.c:common_init_edge (lines 533-545)
245
267
  */
246
- function applyEndLabels(e: Edge, g: Graph, measurer: TextMeasurer): void {
268
+ function applyEndLabels(e: Edge, g: Graph, measurer: TextMeasurer, syms: EdgeLabelSyms): void {
269
+ if (!syms.headlabel && !syms.taillabel) return;
247
270
  const lfi = getLabelFontInfo(e);
248
- applyHeadLabel(e, g, lfi, measurer);
249
- applyTailLabel(e, g, lfi, measurer);
271
+ if (syms.headlabel) applyHeadLabel(e, g, lfi, measurer); // utils.c:533
272
+ if (syms.taillabel) applyTailLabel(e, g, lfi, measurer); // utils.c:539
250
273
  }
251
274
 
252
- /**
253
- * Creates label, xlabel, head_label, and tail_label TextlabelT objects on the
254
- * edge, mirroring common_init_edge in C. C statement order is preserved:
255
- * label → xlabel → headlabel → taillabel.
256
- *
257
- * @see lib/common/utils.c:common_init_edge (lines 509-545)
258
- */
259
275
  /** Shape portfn: aiming point + slope for a named/compass port. */
260
276
  type PortFn = (n: unknown, portname: string, compass: string) => Port;
261
277
 
@@ -307,11 +323,21 @@ export function initEdgePorts(e: Edge): void {
307
323
  if (isClipDisabled(e.attrs.get('headclip'))) e.info.head_port.clip = false;
308
324
  }
309
325
 
310
- export function initEdgeLabels(e: Edge, g: Graph, measurer: TextMeasurer): void {
326
+ /**
327
+ * Creates label, xlabel, head_label, and tail_label TextlabelT objects on the
328
+ * edge, mirroring common_init_edge in C. C statement order is preserved:
329
+ * label → xlabel → headlabel → taillabel. `syms` stands for the global symbol
330
+ * state the three guarded reads test (unbound inside make_flat_adj_edges).
331
+ *
332
+ * @see lib/common/utils.c:common_init_edge (lines 509-545)
333
+ */
334
+ export function initEdgeLabels(
335
+ e: Edge, g: Graph, measurer: TextMeasurer, syms: EdgeLabelSyms = BOUND_EDGE_LABEL_SYMS,
336
+ ): void {
311
337
  initEdgePorts(e); // port block runs for every edge, before the label short-circuit
312
338
  const hasMain = e.attrs.has('label') || e.attrs.has('xlabel');
313
339
  const hasEnd = e.attrs.has('headlabel') || e.attrs.has('taillabel');
314
340
  if (!hasMain && !hasEnd) return;
315
- if (hasMain) applyMainLabels(e, g, measurer);
316
- if (hasEnd) applyEndLabels(e, g, measurer);
341
+ if (hasMain) applyMainLabels(e, g, measurer, syms);
342
+ if (hasEnd) applyEndLabels(e, g, measurer, syms);
317
343
  }
@@ -29,6 +29,7 @@ import type { RatioKind } from '../model/layoutParams.js';
29
29
  import { doGraphLabel } from '../layout/dot/graph-label.js';
30
30
  import { mapbool, setClType, LOCAL, GLOBAL, NOCLUST } from '../layout/dot/rank.js';
31
31
  import { cround } from './arith.js';
32
+ import { d2i } from '../util/math.js';
32
33
  import { agwarningf } from './agerr.js';
33
34
  import { setImageHooks, setImagePath } from './safefile.js';
34
35
 
@@ -119,10 +120,19 @@ function maptoken(p: string | undefined, names: string[], vals: number[]): numbe
119
120
  * `nodesep` is a plain late_double; `ranksep` additionally honours the
120
121
  * `equally` keyword (→ exact_ranksep) and a bare number that may be followed
121
122
  * by text. Absent attrs yield POINTS(DEFAULT_*) = 18 / 36.
123
+ *
124
+ * GD_nodesep is an `int` (types.h), and POINTS is `(int)(f + .5)`: past
125
+ * INT_MAX that conversion is undefined in C, and the oracle's arm64 build
126
+ * saturates it (scalar fcvtzs). `d2i` is that saturation. Evidence: corpus
127
+ * 2758 (`nodesep=40000000`, 2.88e9 pt) makes native 16.1.1 report an aux
128
+ * edge of `2147483701.000000`, INT_MAX plus two 27-pt half widths (issue
129
+ * #162). Only nodesep is saturated here: the other POINTS sites (ranksep,
130
+ * size, page) have no such evidence.
122
131
  * @see lib/common/input.c:665-681
123
132
  */
124
133
  function parseSepAttrs(g: Graph): void {
125
- g.info.nodesep = points(lateDouble(g.attrs.get('nodesep'), DEFAULT_NODESEP, MIN_NODESEP));
134
+ // `points` already rounded, so d2i's truncation changes nothing below INT_MAX.
135
+ g.info.nodesep = d2i(points(lateDouble(g.attrs.get('nodesep'), DEFAULT_NODESEP, MIN_NODESEP)));
126
136
  const p = g.attrs.get('ranksep');
127
137
  let xf = DEFAULT_RANKSEP;
128
138
  if (p !== undefined && p !== '') {
@@ -19,7 +19,7 @@ import { HtmlLexError } from './htmltable-lex.js';
19
19
  import { labelStderr, type StderrLines } from './htmltable-attr-warn.js';
20
20
  import { posHtmlLabel, type HtmlFontInfo, type PlacedHtml } from './htmltable-pos.js';
21
21
 
22
- /** parseHTML's rv for a label that failed to parse (`ctx->error`). */
22
+ /** parseHTML's rv once htmlerror or the lexer printed an error (`ctx->error`), with or without a label. */
23
23
  const HTML_PARSE_FATAL = 3;
24
24
 
25
25
  /** A built HTML label plus make_html_label's "problem" return value. */
@@ -48,9 +48,14 @@ export function makeHtmlLabelTo(
48
48
  stderr: StderrLines,
49
49
  ): HtmlLabelResult {
50
50
  const { fontname, fontsize, fontcolor, imageSizer, imageResolver, imageDpi, pencolor } = finfo;
51
- let lbl: HtmlLabel, lexWarn: boolean; // lexWarn: htmllex.c's ctx->warn, rv bit 1
51
+ let lbl: HtmlLabel, lexRv: number; // lexRv: clearHTMLlexer's `ctx->error ? 3 : ctx->warn`
52
52
  try {
53
- ({ label: lbl, warn: lexWarn } = parseHtmlLabelRv(content, stderr));
53
+ const parsed = parseHtmlLabelRv(content, stderr);
54
+ lbl = parsed.label;
55
+ // An error a rule reported without YYABORT (the image rule's) leaves the
56
+ // label: it is sized and drawn, and rv 3 makes make_label name the object.
57
+ // @see lib/common/htmllex.c:clearHTMLlexer
58
+ lexRv = parsed.error ? HTML_PARSE_FATAL : Number(parsed.warn);
54
59
  } catch (e) {
55
60
  // C aborts the HTML parse on a syntax error (YYABORT): parseHTML returns
56
61
  // rv 3 (ctx->error) with no label, and make_html_label returns it with
@@ -63,7 +68,7 @@ export function makeHtmlLabelTo(
63
68
  // which then flows table->cell->nested-table.
64
69
  // @see lib/common/htmltable.c:1911 (getPenColor), :1406/:1556 (inheritance)
65
70
  if (lbl.kind === 'table') inheritTablePenColor(lbl.table, pencolor);
66
- const rv = Number(lexWarn) | sizeHtmlLabel(lbl, measurer, {
71
+ const rv = lexRv | sizeHtmlLabel(lbl, measurer, {
67
72
  fontsize, fontname, imageSizer, imageResolver, imageDpi, stderr,
68
73
  });
69
74
  const placed = posHtmlLabel(lbl, { fontname, fontsize, fontcolor }, measurer);
@@ -161,11 +161,14 @@ const SYNTAX_ERROR = 'syntax error';
161
161
  */
162
162
  export class HtmlLexError extends HtmlParseError {
163
163
  readonly diagnostics: readonly string[];
164
+ /** Printed by `lexerror`, which unlike htmlerror and the expat path prints even when `ctx->error` is set. */
165
+ readonly unguarded: boolean;
164
166
 
165
- constructor(tag: string, message: string, diagnostics: readonly string[]) {
167
+ constructor(tag: string, message: string, diagnostics: readonly string[], unguarded = false) {
166
168
  super(tag);
167
169
  this.message = message;
168
170
  this.diagnostics = diagnostics;
171
+ this.unguarded = unguarded;
169
172
  }
170
173
  }
171
174
 
@@ -260,7 +263,7 @@ function checkTagToken(site: TokenSite): void {
260
263
  }
261
264
  if (KNOWN_TAGS.has(tag.name.toUpperCase())) return;
262
265
  const text = `Unknown HTML element <${tag.name}> on line ${lineAt(src, tok.start)} `;
263
- throw new HtmlLexError(tag.name.toUpperCase(), text, [`Error: ${text}`]);
266
+ throw new HtmlLexError(tag.name.toUpperCase(), text, [`Error: ${text}`], true);
264
267
  }
265
268
 
266
269
  /** The tokens one expat event gives the parser, after the errors C would hit. */
@@ -0,0 +1,69 @@
1
+ // SPDX-License-Identifier: EPL-2.0
2
+ /**
3
+ * The `image` rule of an HTML-like label's cell. Strings may stand before and
4
+ * after `<IMG>`: blank ones are ignored, and one with a non-space character is
5
+ * reported through `htmlerror` without `YYABORT`, so the parse goes on and the
6
+ * label keeps its image (parseHTML's rv is 3 with a label).
7
+ *
8
+ * @see lib/common/htmlparse.y:338-356
9
+ * @see lib/common/htmllex.c:52-59
10
+ */
11
+
12
+ import type { HtmlCellContent, HtmlImage, OpenToken, Token } from './htmltable-types.js';
13
+ import type { ParseState } from './htmltable-parse-state.js';
14
+ import { consume, consumedTag, emitWarnings, peek } from './htmltable-parse-state.js';
15
+ import { htmlErrorAtToken } from './htmltable-lex.js';
16
+ import type { CellScan } from './htmltable-parse.js';
17
+ import { MSG_SYNTAX_ERROR, consumeClose, parseError, skipStrings } from './htmltable-parse.js';
18
+
19
+ /** @see lib/common/htmlparse.y:340 (image rule, mid-rule action) */
20
+ const MSG_TEXT_BEFORE_IMG = 'Syntax error: non-space string used before <IMG>';
21
+ /** @see lib/common/htmlparse.y:343 (image rule, final action) */
22
+ const MSG_TEXT_AFTER_IMG = 'Syntax error: non-space string used after <IMG>';
23
+
24
+ /**
25
+ * `htmlerror` called from a rule action that does not abort: with `tok` the
26
+ * lookahead the lexer last returned, print the message and its context unless
27
+ * an error was printed before, and set `ctx->error`. The lexer ran for `tok`
28
+ * first, so that token's warnings come out ahead of the message. Without a
29
+ * lookahead the lexer failed fetching it and set `ctx->error` itself, so its
30
+ * own error is the one reported.
31
+ * @see lib/common/htmllex.c:htmlerror
32
+ */
33
+ const softError = (s: ParseState, tok: Token | undefined, message: string): void => {
34
+ if (tok === undefined) throw parseError(s, tok, message);
35
+ emitWarnings(s, tok);
36
+ if (s.error === true) return;
37
+ s.error = true;
38
+ for (const line of htmlErrorAtToken(message, tok)?.diagnostics ?? []) s.stderr?.write(`${line}\n`);
39
+ };
40
+
41
+ /** `T_img T_end_img` or `T_IMG`: the element itself. */
42
+ const parseImgContent = (s: ParseState, t: OpenToken): HtmlImage => {
43
+ consume(s);
44
+ const img: HtmlImage = {
45
+ kind: 'image',
46
+ src: t.attrs['src'] ?? '',
47
+ scale: t.attrs['scale'],
48
+ };
49
+ consumeClose(s, 'IMG');
50
+ return img;
51
+ };
52
+
53
+ /**
54
+ * `image : opt_space T_IMG opt_space` as the cell's only child, entered at the
55
+ * IMG token. The leading `opt_space` is strings alone, so an IMG that follows
56
+ * a tag is a syntax error. Its nonSpace check runs with the IMG as lookahead.
57
+ * The trailing `opt_space` reduces at whatever token follows the strings, and
58
+ * the rule's final action runs there by default reduction: its check is
59
+ * reported at that token even when the token then fails the cell rule.
60
+ * @see lib/common/htmlparse.y:338-356
61
+ */
62
+ export const scanCellImage = (s: ParseState, t: OpenToken, st: CellScan): HtmlCellContent[] => {
63
+ if (consumedTag(s, st.start)) throw parseError(s, t, MSG_SYNTAX_ERROR);
64
+ if (st.textNonSpace) softError(s, t, MSG_TEXT_BEFORE_IMG);
65
+ st.kind = 'image';
66
+ const img = parseImgContent(s, t);
67
+ if (skipStrings(s)) softError(s, peek(s), MSG_TEXT_AFTER_IMG);
68
+ return [img];
69
+ };
@@ -25,10 +25,16 @@ export interface ParseState {
25
25
  warn?: boolean;
26
26
  /** What the lexer wrote after its last token, printed when the parser asks for more. */
27
27
  eof?: LexerOutput;
28
+ /** `ctx->error`: htmlerror printed from a rule that went on parsing; the label's rv is 3. */
29
+ error?: boolean;
28
30
  }
29
31
 
30
32
  export const peek = (s: ParseState): Token | undefined => s.tokens[s.pos];
31
33
 
34
+ /** True when a tag, not only strings, was consumed since `start` (an `opt_space` is strings alone). */
35
+ export const consumedTag = (s: ParseState, start: number): boolean =>
36
+ s.tokens.slice(start, s.pos).some((t) => t.type !== 'text');
37
+
32
38
  /**
33
39
  * Print what the C lexer wrote while lexing `tok`, once, and fold its `warn`
34
40
  * into the label's rv.