@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.
- package/dist/api/builder.d.ts +7 -1
- package/dist/api/builder.d.ts.map +1 -1
- package/dist/api.js +14 -7
- package/dist/api.js.map +2 -2
- package/dist/common/compass-port.d.ts.map +1 -1
- package/dist/common/edge-label-init.d.ts +26 -1
- package/dist/common/edge-label-init.d.ts.map +1 -1
- package/dist/common/graph-init.d.ts.map +1 -1
- package/dist/common/htmltable-label.d.ts.map +1 -1
- package/dist/common/htmltable-lex.d.ts +3 -1
- package/dist/common/htmltable-lex.d.ts.map +1 -1
- package/dist/common/htmltable-parse-image.d.ts +23 -0
- package/dist/common/htmltable-parse-image.d.ts.map +1 -0
- package/dist/common/htmltable-parse-state.d.ts +4 -0
- package/dist/common/htmltable-parse-state.d.ts.map +1 -1
- package/dist/common/htmltable-parse.d.ts +33 -2
- package/dist/common/htmltable-parse.d.ts.map +1 -1
- package/dist/common/nodeinit.d.ts +16 -2
- package/dist/common/nodeinit.d.ts.map +1 -1
- package/dist/common/poly-inside.d.ts.map +1 -1
- package/dist/common/splines-geom.d.ts +2 -1
- package/dist/common/splines-geom.d.ts.map +1 -1
- package/dist/common/splines-path-begin.d.ts.map +1 -1
- package/dist/common/splines-path-end.d.ts.map +1 -1
- package/dist/common/splines-routespl.d.ts +3 -0
- package/dist/common/splines-routespl.d.ts.map +1 -1
- package/dist/gvc/context.d.ts +8 -0
- package/dist/gvc/context.d.ts.map +1 -1
- package/dist/gvc/emit-gates.d.ts +5 -10
- package/dist/gvc/emit-gates.d.ts.map +1 -1
- package/dist/gvc/emit-xdot.d.ts +7 -6
- package/dist/gvc/emit-xdot.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +5 -2
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/gvc/viewport.d.ts +10 -5
- package/dist/gvc/viewport.d.ts.map +1 -1
- package/dist/index.js +21565 -21326
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/classify.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
- package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
- package/dist/layout/dot/edge-route-chain.d.ts +20 -16
- package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
- package/dist/layout/dot/edge-route.d.ts +7 -3
- package/dist/layout/dot/edge-route.d.ts.map +1 -1
- package/dist/layout/dot/fastgr.d.ts +5 -3
- package/dist/layout/dot/fastgr.d.ts.map +1 -1
- package/dist/layout/dot/flat-adj-record.d.ts +22 -0
- package/dist/layout/dot/flat-adj-record.d.ts.map +1 -0
- package/dist/layout/dot/flat.d.ts +22 -7
- package/dist/layout/dot/flat.d.ts.map +1 -1
- package/dist/layout/dot/init.d.ts +49 -9
- package/dist/layout/dot/init.d.ts.map +1 -1
- package/dist/layout/dot/mincross-build.d.ts +6 -0
- package/dist/layout/dot/mincross-build.d.ts.map +1 -1
- package/dist/layout/dot/mincross-flat.d.ts +10 -1
- package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
- package/dist/layout/dot/mincross.d.ts +6 -1
- package/dist/layout/dot/mincross.d.ts.map +1 -1
- package/dist/layout/dot/ns-subtree.d.ts +9 -6
- package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
- package/dist/layout/dot/pack-components.d.ts +4 -3
- package/dist/layout/dot/pack-components.d.ts.map +1 -1
- package/dist/layout/dot/position-aux.d.ts +69 -21
- package/dist/layout/dot/position-aux.d.ts.map +1 -1
- package/dist/layout/dot/position-bbox.d.ts.map +1 -1
- package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
- package/dist/layout/dot/position.d.ts.map +1 -1
- package/dist/layout/dot/rank-dot2.d.ts +7 -25
- package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
- package/dist/layout/dot/self-loop.d.ts +11 -4
- package/dist/layout/dot/self-loop.d.ts.map +1 -1
- package/dist/layout/dot/splines-clone.d.ts +2 -1
- package/dist/layout/dot/splines-clone.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
- package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat.d.ts +18 -0
- package/dist/layout/dot/splines-flat.d.ts.map +1 -1
- package/dist/layout/dot/splines-groups.d.ts.map +1 -1
- package/dist/layout/dot/splines-route.d.ts +6 -3
- package/dist/layout/dot/splines-route.d.ts.map +1 -1
- package/dist/layout/dot/straight-edges.d.ts.map +1 -1
- package/dist/layout/fdp/ports.d.ts.map +1 -1
- package/dist/layout/fdp/tlayout.d.ts +3 -0
- package/dist/layout/fdp/tlayout.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad.d.ts +7 -6
- package/dist/layout/neato/conjgrad.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
- package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops.d.ts +0 -6
- package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
- package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -1
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/model/cgraph-ops.d.ts +10 -2
- package/dist/model/cgraph-ops.d.ts.map +1 -1
- package/dist/model/edge.d.ts +7 -2
- package/dist/model/edge.d.ts.map +1 -1
- package/dist/model/edgeInfo.d.ts +17 -2
- package/dist/model/edgeInfo.d.ts.map +1 -1
- package/dist/model/graph.d.ts +4 -3
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/lazy-attrs.d.ts.map +1 -1
- package/dist/model/rankEntry.d.ts +3 -1
- package/dist/model/rankEntry.d.ts.map +1 -1
- package/dist/ortho/index.d.ts +0 -1
- package/dist/ortho/index.d.ts.map +1 -1
- package/dist/ortho/partition.d.ts +2 -4
- package/dist/ortho/partition.d.ts.map +1 -1
- package/dist/parser/builder.d.ts.map +1 -1
- package/dist/pathplan/route.d.ts +93 -0
- package/dist/pathplan/route.d.ts.map +1 -1
- package/dist/render/dot/agwrite.d.ts +26 -10
- package/dist/render/dot/agwrite.d.ts.map +1 -1
- package/dist/render/dot/attrs.d.ts +15 -4
- package/dist/render/dot/attrs.d.ts.map +1 -1
- package/dist/render/dot/types.d.ts +7 -2
- package/dist/render/dot/types.d.ts.map +1 -1
- package/dist/render/dot/write-back.d.ts +14 -0
- package/dist/render/dot/write-back.d.ts.map +1 -1
- package/dist/render/dot/xdot-ops.d.ts +20 -29
- package/dist/render/dot/xdot-ops.d.ts.map +1 -1
- package/dist/render/dot.d.ts +4 -2
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/json-cluster-edge.d.ts +17 -4
- package/dist/render/json-cluster-edge.d.ts.map +1 -1
- package/dist/render/json-nonfinite.d.ts +17 -0
- package/dist/render/json-nonfinite.d.ts.map +1 -0
- package/dist/render/json.d.ts +4 -0
- package/dist/render/json.d.ts.map +1 -1
- package/dist/render/map.d.ts +3 -0
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/svg-graph.d.ts.map +1 -1
- package/dist/render/svg-id.d.ts +10 -1
- package/dist/render/svg-id.d.ts.map +1 -1
- package/dist/render/svg.d.ts +3 -1
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render.js +21517 -21278
- package/dist/render.js.map +4 -4
- package/dist/util/bsd-qsort.d.ts.map +1 -1
- package/dist/util/overflow.d.ts +37 -0
- package/dist/util/overflow.d.ts.map +1 -0
- package/dist/xdot/parse.d.ts.map +1 -1
- package/dist/xdot/strtod.d.ts +23 -0
- package/dist/xdot/strtod.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/api/builder.ts +8 -2
- package/src/common/compass-port.ts +36 -20
- package/src/common/edge-label-init.ts +43 -17
- package/src/common/graph-init.ts +11 -1
- package/src/common/htmltable-label.ts +9 -4
- package/src/common/htmltable-lex.ts +5 -2
- package/src/common/htmltable-parse-image.ts +69 -0
- package/src/common/htmltable-parse-state.ts +6 -0
- package/src/common/htmltable-parse.ts +34 -44
- package/src/common/nodeinit.ts +28 -8
- package/src/common/poly-inside.ts +11 -5
- package/src/common/splines-geom.ts +24 -6
- package/src/common/splines-path-begin.ts +4 -3
- package/src/common/splines-path-end.ts +4 -3
- package/src/common/splines-routespl.ts +32 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
- package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
- package/src/gvc/context.ts +8 -0
- package/src/gvc/device.ts +6 -6
- package/src/gvc/emit-gates.ts +6 -15
- package/src/gvc/emit-xdot.ts +10 -11
- package/src/gvc/job.ts +5 -2
- package/src/gvc/viewport.ts +13 -7
- package/src/layout/dot/__fixtures__/flat-adj-aux-syms.native-16.1.json +1210 -0
- package/src/layout/dot/classify.ts +5 -2
- package/src/layout/dot/edge-route-chain-views.ts +120 -0
- package/src/layout/dot/edge-route-chain.ts +103 -117
- package/src/layout/dot/edge-route-faithful.ts +20 -5
- package/src/layout/dot/edge-route.ts +44 -49
- package/src/layout/dot/fastgr.ts +9 -3
- package/src/layout/dot/flat-adj-record.ts +68 -0
- package/src/layout/dot/flat.ts +38 -17
- package/src/layout/dot/init.ts +59 -13
- package/src/layout/dot/mincross-build.ts +14 -1
- package/src/layout/dot/mincross-flat.ts +15 -5
- package/src/layout/dot/mincross.ts +6 -2
- package/src/layout/dot/ns-subtree.ts +11 -7
- package/src/layout/dot/pack-components.ts +6 -4
- package/src/layout/dot/position-aux.ts +122 -42
- package/src/layout/dot/position-bbox.ts +14 -1
- package/src/layout/dot/position-ycoords.ts +7 -1
- package/src/layout/dot/position.ts +4 -1
- package/src/layout/dot/rank-dot2.ts +13 -94
- package/src/layout/dot/self-loop.ts +29 -11
- package/src/layout/dot/splines-clone.ts +8 -2
- package/src/layout/dot/splines-flat-labeled.ts +3 -2
- package/src/layout/dot/splines-flat-multi.ts +12 -4
- package/src/layout/dot/splines-flat.ts +9 -19
- package/src/layout/dot/splines-groups.ts +5 -3
- package/src/layout/dot/splines-route.ts +10 -11
- package/src/layout/dot/straight-edges.ts +5 -3
- package/src/layout/fdp/ports.ts +6 -2
- package/src/layout/fdp/tlayout.ts +6 -5
- package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
- package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
- package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
- package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
- package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
- package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
- package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
- package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
- package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
- package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
- package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
- package/src/layout/neato/conjgrad-mkernel.ts +6 -2
- package/src/layout/neato/conjgrad.ts +38 -35
- package/src/layout/neato/matrix-ops-dense.ts +2 -20
- package/src/layout/neato/matrix-ops.ts +0 -20
- package/src/layout/neato/quad-prog-vpsc.ts +7 -5
- package/src/layout/neato/sgd.ts +2 -1
- package/src/layout/neato/smart-ini-x.ts +15 -15
- package/src/layout/neato/stress-subspace.ts +5 -5
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
- package/src/model/cgraph-ops.ts +4 -3
- package/src/model/edge.ts +11 -4
- package/src/model/edgeInfo.ts +18 -2
- package/src/model/graph.ts +4 -3
- package/src/model/lazy-attrs.ts +3 -1
- package/src/model/rankEntry.ts +3 -1
- package/src/ortho/index.ts +0 -1
- package/src/ortho/partition.ts +10 -22
- package/src/parser/builder.ts +12 -3
- package/src/pathplan/route.ts +14 -4
- package/src/render/dot/agwrite.ts +45 -18
- package/src/render/dot/attrs.ts +18 -7
- package/src/render/dot/types.ts +7 -2
- package/src/render/dot/write-back.ts +27 -3
- package/src/render/dot/xdot-ops.ts +25 -56
- package/src/render/dot.ts +7 -5
- package/src/render/json-cluster-edge.ts +42 -5
- package/src/render/json-nonfinite.ts +51 -0
- package/src/render/json.ts +23 -26
- package/src/render/map.ts +3 -0
- package/src/render/svg-graph.ts +3 -15
- package/src/render/svg-id.ts +11 -2
- package/src/render/svg.ts +4 -1
- package/src/util/bsd-qsort.ts +2 -1
- package/src/util/overflow.ts +74 -0
- package/src/xdot/parse.ts +9 -19
- 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":"
|
|
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"}
|
package/dist/xdot/parse.d.ts.map
CHANGED
|
@@ -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;
|
|
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.
|
|
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 &&
|
|
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",
|
package/src/api/builder.ts
CHANGED
|
@@ -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
|
|
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 ===
|
|
119
|
-
if (angle ===
|
|
120
|
-
if (angle ===
|
|
121
|
-
if (angle === 0)
|
|
122
|
-
if (angle ===
|
|
123
|
-
if (angle ===
|
|
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
|
-
/**
|
|
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:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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;
|
|
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:
|
|
192
|
-
case 'e': return { ...base, p: { x: b.ur.x, y: b.ur.y }, theta:
|
|
193
|
-
case 'w': return { ...base, p: { x: b.ll.x, y: b.ur.y }, theta:
|
|
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: -
|
|
202
|
-
case 'e': return { ...base, p: { x: b.ur.x, y: b.ll.y }, theta: -
|
|
203
|
-
case 'w': return { ...base, p: { x: b.ll.x, y: b.ll.y }, theta: -
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/src/common/graph-init.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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,
|
|
51
|
+
let lbl: HtmlLabel, lexRv: number; // lexRv: clearHTMLlexer's `ctx->error ? 3 : ctx->warn`
|
|
52
52
|
try {
|
|
53
|
-
|
|
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 =
|
|
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.
|