@knowvah/dot-engine 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/api/index.d.ts +2 -2
- package/dist/api.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/gvc/anchor.d.ts.map +1 -1
- package/dist/gvc/device.d.ts +1 -1
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/index.js +226 -40
- package/dist/index.js.map +3 -3
- package/dist/layout/neato/init.d.ts.map +1 -1
- package/dist/layout/twopi/init.d.ts +0 -7
- package/dist/layout/twopi/init.d.ts.map +1 -1
- package/dist/render/index.d.ts +2 -2
- package/dist/render/map.d.ts +29 -7
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/public.d.ts +1 -1
- package/dist/render/xdot-public.d.ts +1 -1
- package/dist/render.js +226 -40
- package/dist/render.js.map +3 -3
- package/package.json +10 -9
- package/src/api/index.ts +2 -2
- package/src/common/textmeasure-factory.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/gvc/anchor.ts +10 -2
- package/src/gvc/device.ts +10 -3
- package/src/index.ts +3 -3
- package/src/layout/neato/init.ts +13 -2
- package/src/layout/twopi/init.ts +7 -2
- package/src/render/index.ts +2 -2
- package/src/render/map.ts +295 -32
- package/src/render/public.ts +1 -1
- package/src/render/svg-graph.ts +1 -1
- package/src/render/xdot-public.ts +1 -1
- package/dist/bundle.js +0 -101
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/layout/neato/init.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/layout/neato/init.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MA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AAK,GAAG,IAAI,CAQzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAyBtF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQtE;AAMD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAOrE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAI7C;AAMD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAc7C;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAS3C"}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* twopi engine initialisation: per-node/edge init, graph init, cleanup.
|
|
3
|
-
* Ports lib/twopigen/twopiinit.c: twopi_init_node_edge, twopi_init_graph,
|
|
4
|
-
* findRootNode, twopi_cleanup.
|
|
5
|
-
*
|
|
6
|
-
* @see lib/twopigen/twopiinit.c
|
|
7
|
-
*/
|
|
8
1
|
import type { Graph } from '../../model/graph.js';
|
|
9
2
|
import type { Node } from '../../model/node.js';
|
|
10
3
|
import type { Edge } from '../../model/edge.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/layout/twopi/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/layout/twopi/init.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AA6BhD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAQ3C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAI3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAchD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAO7C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAMnD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAS7C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAM3C"}
|
package/dist/render/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `@knowvah/dot-engine/render` — the output-formats + draw-ops entry point (ADR-2).
|
|
3
3
|
*
|
|
4
4
|
* Pure re-export barrel for the public render surface: the multi-format
|
|
5
5
|
* `render()` entry and the structured xdot draw-op access.
|
|
6
6
|
*
|
|
7
|
-
* Typical flow: build or `parse()` a graph (see
|
|
7
|
+
* Typical flow: build or `parse()` a graph (see `@knowvah/dot-engine/api`), then
|
|
8
8
|
* either call `render(g, format, opts?)` for a serialized output string —
|
|
9
9
|
* `format` is one of {@link OutputFormat} (`'svg'`, `'dot'`, `'xdot'`,
|
|
10
10
|
* `'json'`, `'plain'`, ...) — or call {@link getDrawOps} to skip string
|
package/dist/render/map.d.ts
CHANGED
|
@@ -31,25 +31,47 @@ export interface AnchorCtx {
|
|
|
31
31
|
target: string;
|
|
32
32
|
id: string;
|
|
33
33
|
}
|
|
34
|
-
/** Format with 5 significant figures, trailing zeros stripped
|
|
34
|
+
/** Format with 5 significant figures, trailing zeros stripped — C snprintf
|
|
35
|
+
* `%.5g`. JS toPrecision rounds exact decimal ties away from zero, but C
|
|
36
|
+
* (round-to-nearest-even FP mode) rounds them to even, and integer point
|
|
37
|
+
* coordinates land on exact .x5 inch ties (e.g. 78498pt/72 = 1090.25 →
|
|
38
|
+
* "1090.2", not "1090.3"). Round from the exact expansion instead.
|
|
39
|
+
* @see lib/common/output.c:printdouble */
|
|
35
40
|
export declare function printG5(v: number): string;
|
|
36
41
|
/** Convert points → inches (PS2INCH = 1/72) and format as %.5g. */
|
|
37
42
|
export declare function plainCoord(v: number): string;
|
|
43
|
+
/** The needs-quotes / numeral / escape state scan of `_agstrcanon`, over UTF-8
|
|
44
|
+
* BYTES (C iterates bytes: cnt counts bytes for line breaking, and non-ascii
|
|
45
|
+
* bytes are id chars). Returns the quoted buffer or the untouched input.
|
|
46
|
+
* @see lib/cgraph/write.c:_agstrcanon */
|
|
47
|
+
export declare function agstrcanonText(arg: string): string;
|
|
38
48
|
/** Resolve fill color: fillcolor attr, then color attr, then lightgrey. */
|
|
39
|
-
export declare function plainNodeFill(n: Node): string;
|
|
49
|
+
export declare function plainNodeFill(n: Node, g: Graph): string;
|
|
40
50
|
/** Read the five style attrs needed for a plain node line. */
|
|
41
|
-
export declare function plainNodeAttrs(n: Node): PlainNodeAttrs;
|
|
51
|
+
export declare function plainNodeAttrs(n: Node, g: Graph): PlainNodeAttrs;
|
|
42
52
|
/** Write one node line: `node name x y w h label style shape color fill\n` */
|
|
43
|
-
export declare function writePlainNode(n: Node, out: string[]): void;
|
|
44
|
-
/** Flatten all Bezier curves in an edge spline into a point array.
|
|
53
|
+
export declare function writePlainNode(n: Node, g: Graph, out: string[]): void;
|
|
54
|
+
/** Flatten all Bezier curves in an edge spline into a point array. Reads
|
|
55
|
+
* exactly bz.size points — routing can leave over-allocated scratch entries
|
|
56
|
+
* past size in bz.list (C sums ED_spl sizes, never the allocation).
|
|
57
|
+
* @see lib/common/output.c:write_plain (183-195) */
|
|
45
58
|
export declare function collectSplinePts(e: Edge): Point[];
|
|
46
59
|
/** Return `:name` suffix when a port name is present, else empty string. */
|
|
47
60
|
export declare function portSuffix(name: string | null): string;
|
|
48
61
|
/** Write the `edge tail head n pt...` prefix when spline data exists. */
|
|
49
62
|
export declare function writePlainEdgeHead(e: Edge, tport: string, hport: string, pts: Point[], out: string[]): void;
|
|
50
|
-
/** Write one edge — spline prefix if available,
|
|
63
|
+
/** Write one edge — spline prefix if available, then the edge label (when
|
|
64
|
+
* present), always appends `style color\n`. plain-ext ports come from the
|
|
65
|
+
* tailport/headport ATTRS (C agget), which keep any `:compass` suffix the
|
|
66
|
+
* resolved port objects have already split off.
|
|
67
|
+
* @see lib/common/output.c:write_plain (200-208) */
|
|
51
68
|
export declare function writePlainEdge(e: Edge, extend: boolean, out: string[]): void;
|
|
52
|
-
/** Write the full plain output: graph header, nodes, edges, stop.
|
|
69
|
+
/** Write the full plain output: graph header, nodes, edges, stop.
|
|
70
|
+
* Node iteration is agfstnode/agnxtnode (AGSEQ) order, not insertion-Map
|
|
71
|
+
* order; the graph line's scale is job->zoom — the size= fit factor, computed
|
|
72
|
+
* with the dot renderer's pad of 0 (render_features_dot).
|
|
73
|
+
* @see lib/common/output.c:write_plain
|
|
74
|
+
* @see plugin/core/gvrender_core_dot.c:render_features_dot */
|
|
53
75
|
export declare function writePlain(g: Graph, job: RenderJob, extend: boolean): void;
|
|
54
76
|
/** Build AnchorCtx from an ObjState, defaulting nulls to empty string. */
|
|
55
77
|
export declare function cmapxObjAnchor(obj: ObjState): AnchorCtx;
|
package/dist/render/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/render/map.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/render/map.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAOxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,kBAAkB,CAAC;AAe1B,8CAA8C;AAC9C,MAAM,WAAW,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AQ,CAAC,UAAU,QAAQ;CACtC;AAED,4EAA4E;AAC5E,qBAAa,eAAgB,SAAQ,eAAe;IAClD,QAAQ,CAAC,IAAI,cAAc;IAC3B,SAAS,CAAC,QAAQ,CAAC,OAAO,QAAQ;IAClC,SAAS,CAAC,QAAQ,CAAC,UAAU,SAAS;CACvC;AAMD,wDAAwD;AACxD,wBAAgB,mBAAmB,IAAI,cAAc,CAAgC;AAErF,4DAA4D;AAC5D,wBAAgB,sBAAsB,IAAI,cAAc,CAAmC;AAE3F,uDAAuD;AACvD,wBAAgB,kBAAkB,IAAI,cAAc,CAA+B;AAEnF,oEAAoE;AACpE,wBAAgB,oBAAoB,IAAI,cAAc,CAAiC;AAEvF,wDAAwD;AACxD,wBAAgB,mBAAmB,IAAI,cAAc,CAAgC;AAErF,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,cAAc,CAAkC"}
|
package/dist/render/public.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface RenderOptions {
|
|
|
31
31
|
* `false` — unset reproduces the pre-AD-1 raw `xlink:href="src"`
|
|
32
32
|
* passthrough byte-for-byte. When `true`, the SVG emitter consults the
|
|
33
33
|
* process-global resolver registered via `setImageResolver` (from
|
|
34
|
-
*
|
|
34
|
+
* `@knowvah/dot-engine`) for each `image=`/HTML `<IMG>` source; a hit is inlined
|
|
35
35
|
* as `data:<mime>;base64,<...>`, a miss (or no resolver registered) falls
|
|
36
36
|
* back to the raw src passthrough. Has no effect on non-SVG formats.
|
|
37
37
|
*/
|
|
@@ -71,7 +71,7 @@ export declare const DEFAULT_DRAW_ENGINE: EngineName;
|
|
|
71
71
|
* @example
|
|
72
72
|
* ```ts
|
|
73
73
|
* import { parse } from '@knowvah/dot-engine';
|
|
74
|
-
* import { getDrawOps } from '
|
|
74
|
+
* import { getDrawOps } from '@knowvah/dot-engine/render';
|
|
75
75
|
*
|
|
76
76
|
* const g = parse('digraph { a -> b; }');
|
|
77
77
|
* for (const op of getDrawOps(g)) {
|
package/dist/render.js
CHANGED
|
@@ -5056,7 +5056,7 @@ function adviseHostFaithful() {
|
|
|
5056
5056
|
if (process.env?.GV_FONT_QUIET || !process.stderr?.isTTY) return;
|
|
5057
5057
|
adviceShown = true;
|
|
5058
5058
|
process.stderr.write(
|
|
5059
|
-
"
|
|
5059
|
+
"@knowvah/dot-engine: measuring text with built-in metrics (kerning/shaping not applied). For host-faithful sizing matching the rendering font, install `canvas` and call setTextMeasurer(new CanvasTextMeasurer(createCanvas(0,0).getContext('2d'))). Silence with GV_FONT_QUIET=1.\n"
|
|
5060
5060
|
);
|
|
5061
5061
|
}
|
|
5062
5062
|
function createMeasurer() {
|
|
@@ -17766,7 +17766,7 @@ function orthoRoundedPolylines(pts, radius) {
|
|
|
17766
17766
|
// src/render/svg-graph.ts
|
|
17767
17767
|
var SVG_XML_DECL = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n';
|
|
17768
17768
|
var SVG_DOCTYPE = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"\n "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n';
|
|
17769
|
-
var SVG_GENERATOR_COMMENT = "<!-- Generated by
|
|
17769
|
+
var SVG_GENERATOR_COMMENT = "<!-- Generated by @knowvah/dot-engine -->\n";
|
|
17770
17770
|
var BGCOLOR_TRANSPARENT = "\0transparent";
|
|
17771
17771
|
function formatG(n) {
|
|
17772
17772
|
return String(parseFloat(n.toPrecision(6)));
|
|
@@ -18668,8 +18668,11 @@ function computeNodeUrlMap(n, obj, ctx) {
|
|
|
18668
18668
|
obj.urlMapPts = m.pts.map((p) => mapTransform(p, ctx));
|
|
18669
18669
|
}
|
|
18670
18670
|
function computeGraphUrlMap(obj, ctx) {
|
|
18671
|
-
const ll = { x:
|
|
18672
|
-
const ur = {
|
|
18671
|
+
const ll = { x: -ctx.pad.x, y: -ctx.pad.y };
|
|
18672
|
+
const ur = {
|
|
18673
|
+
x: ctx.bb.ur.x - ctx.bb.ll.x + ctx.pad.x,
|
|
18674
|
+
y: ctx.bb.ur.y - ctx.bb.ll.y + ctx.pad.y
|
|
18675
|
+
};
|
|
18673
18676
|
obj.urlMapShape = 0 /* Rectangle */;
|
|
18674
18677
|
obj.urlMapPts = [mapTransform(ll, ctx), mapTransform(ur, ctx)];
|
|
18675
18678
|
}
|
|
@@ -18906,7 +18909,7 @@ function walkNodesAndEdges(g, renderer, job, info) {
|
|
|
18906
18909
|
|
|
18907
18910
|
// src/gvc/device.ts
|
|
18908
18911
|
function renderClusterLabel(sg, renderer, job) {
|
|
18909
|
-
renderOneLabel(sg.info.label, renderer, job);
|
|
18912
|
+
renderOneLabel(sg.info.label, renderer, job, false);
|
|
18910
18913
|
}
|
|
18911
18914
|
function transformPoint(p, job) {
|
|
18912
18915
|
if ((job.flags & GVRENDER_DOES_TRANSFORM) !== 0) {
|
|
@@ -19013,8 +19016,9 @@ function labelSpanX(lp, just) {
|
|
|
19013
19016
|
if (just === "r") return lp.pos.x + lp.space.x / 2;
|
|
19014
19017
|
return lp.pos.x;
|
|
19015
19018
|
}
|
|
19016
|
-
function renderOneLabel(lp, renderer, job) {
|
|
19017
|
-
if (!lp
|
|
19019
|
+
function renderOneLabel(lp, renderer, job, requireSet = true) {
|
|
19020
|
+
if (!lp) return;
|
|
19021
|
+
if (requireSet && !lp.set) return;
|
|
19018
19022
|
if (lp.html) {
|
|
19019
19023
|
if (lp.u.kind === "html") {
|
|
19020
19024
|
const html = lp.u.html;
|
|
@@ -19037,7 +19041,7 @@ function renderNodeXLabel(n, renderer, job) {
|
|
|
19037
19041
|
}
|
|
19038
19042
|
function renderGraphLabel(g, renderer, job) {
|
|
19039
19043
|
setHtmlAnchorObj(svgGraphId(g, job), labelTextOf2(g.info.label), job.obj ?? void 0);
|
|
19040
|
-
renderOneLabel(g.info.label, renderer, job);
|
|
19044
|
+
renderOneLabel(g.info.label, renderer, job, false);
|
|
19041
19045
|
}
|
|
19042
19046
|
function renderClusterBox(sg, filled, renderer, job) {
|
|
19043
19047
|
const { ll, ur } = sg.info.bb;
|
|
@@ -35116,8 +35120,9 @@ function neatoInitNode(n, dim = DFLT_DIM) {
|
|
|
35116
35120
|
n.info.pos = pos;
|
|
35117
35121
|
}
|
|
35118
35122
|
if (n.info.UF_size === void 0) n.info.UF_size = 1;
|
|
35119
|
-
|
|
35120
|
-
if (!n.info.
|
|
35123
|
+
const plainShaped = n.info.shape?.name === "plain";
|
|
35124
|
+
if (!n.info.width && !plainShaped) n.info.width = 0.75;
|
|
35125
|
+
if (!n.info.height && !plainShaped) n.info.height = 0.5;
|
|
35121
35126
|
}
|
|
35122
35127
|
function userPos(n) {
|
|
35123
35128
|
const p = n.attrs.get("pos");
|
|
@@ -41717,8 +41722,9 @@ function makeRdata(INF) {
|
|
|
41717
41722
|
}
|
|
41718
41723
|
function twopiInitNode(n) {
|
|
41719
41724
|
if (!n.info.pos || n.info.pos.length < 2) n.info.pos = [0, 0];
|
|
41720
|
-
|
|
41721
|
-
if (!n.info.
|
|
41725
|
+
const plainShaped = n.info.shape?.name === "plain";
|
|
41726
|
+
if (!n.info.width && !plainShaped) n.info.width = 0.75;
|
|
41727
|
+
if (!n.info.height && !plainShaped) n.info.height = 0.5;
|
|
41722
41728
|
}
|
|
41723
41729
|
function twopiInitEdge(e) {
|
|
41724
41730
|
const wt = e.attrs.get("weight");
|
|
@@ -52085,73 +52091,253 @@ function createJsonRenderer() {
|
|
|
52085
52091
|
|
|
52086
52092
|
// src/render/map.ts
|
|
52087
52093
|
var DQ = '"';
|
|
52094
|
+
function exactDecimalDigits2(v) {
|
|
52095
|
+
const dv = new DataView(new ArrayBuffer(8));
|
|
52096
|
+
dv.setFloat64(0, Math.abs(v));
|
|
52097
|
+
const bits = dv.getBigUint64(0);
|
|
52098
|
+
const expBits = Number(bits >> 52n & 0x7ffn);
|
|
52099
|
+
const mant = bits & 0xfffffffffffffn;
|
|
52100
|
+
const m = expBits === 0 ? mant : mant | 1n << 52n;
|
|
52101
|
+
const e = (expBits === 0 ? 1 : expBits) - 1075;
|
|
52102
|
+
let intDigits;
|
|
52103
|
+
let fracLen = 0;
|
|
52104
|
+
if (e >= 0) {
|
|
52105
|
+
intDigits = (m << BigInt(e)).toString();
|
|
52106
|
+
} else {
|
|
52107
|
+
intDigits = (m * 5n ** BigInt(-e)).toString();
|
|
52108
|
+
fracLen = -e;
|
|
52109
|
+
}
|
|
52110
|
+
if (intDigits.length <= fracLen) {
|
|
52111
|
+
intDigits = "0".repeat(fracLen - intDigits.length + 1) + intDigits;
|
|
52112
|
+
}
|
|
52113
|
+
const pointPos = intDigits.length - fracLen;
|
|
52114
|
+
const firstSig = intDigits.search(/[1-9]/);
|
|
52115
|
+
return { digits: intDigits.slice(firstSig), exp10: pointPos - firstSig - 1 };
|
|
52116
|
+
}
|
|
52088
52117
|
function printG5(v) {
|
|
52089
|
-
|
|
52090
|
-
|
|
52091
|
-
|
|
52118
|
+
if (v === 0 || !Number.isFinite(v)) return String(v);
|
|
52119
|
+
const P = 5;
|
|
52120
|
+
const { digits, exp10 } = exactDecimalDigits2(v);
|
|
52121
|
+
let sig = digits.slice(0, P);
|
|
52122
|
+
if (sig.length < P) sig += "0".repeat(P - sig.length);
|
|
52123
|
+
const rest = digits.slice(P);
|
|
52124
|
+
const restNonzeroAfterFirst = /[1-9]/.test(rest.slice(1));
|
|
52125
|
+
const roundUp = rest.length > 0 && (rest[0] > "5" || rest[0] === "5" && restNonzeroAfterFirst || rest[0] === "5" && !restNonzeroAfterFirst && (sig.charCodeAt(P - 1) - 48) % 2 === 1);
|
|
52126
|
+
let exp = exp10;
|
|
52127
|
+
if (roundUp) {
|
|
52128
|
+
const n = String(BigInt(sig) + 1n);
|
|
52129
|
+
sig = n.length > P ? (exp++, n.slice(0, P)) : n;
|
|
52092
52130
|
}
|
|
52093
|
-
|
|
52131
|
+
const sign2 = v < 0 ? "-" : "";
|
|
52132
|
+
if (exp < -4 || exp >= P) {
|
|
52133
|
+
const mant = (sig[0] + "." + sig.slice(1)).replace(/\.?0+$/, "");
|
|
52134
|
+
const as = Math.abs(exp);
|
|
52135
|
+
return sign2 + mant + "e" + (exp < 0 ? "-" : "+") + (as < 10 ? "0" : "") + String(as);
|
|
52136
|
+
}
|
|
52137
|
+
let s;
|
|
52138
|
+
if (exp >= sig.length - 1) {
|
|
52139
|
+
s = sig + "0".repeat(exp - sig.length + 1);
|
|
52140
|
+
} else if (exp >= 0) {
|
|
52141
|
+
s = sig.slice(0, exp + 1) + "." + sig.slice(exp + 1);
|
|
52142
|
+
} else {
|
|
52143
|
+
s = "0." + "0".repeat(-exp - 1) + sig;
|
|
52144
|
+
}
|
|
52145
|
+
if (s.includes(".")) s = s.replace(/\.?0+$/, "");
|
|
52146
|
+
return sign2 + s;
|
|
52094
52147
|
}
|
|
52095
52148
|
function plainCoord(v) {
|
|
52096
52149
|
return printG5(v / 72);
|
|
52097
52150
|
}
|
|
52098
|
-
|
|
52099
|
-
|
|
52100
|
-
|
|
52151
|
+
var CANON_KEYWORDS = ["node", "edge", "strict", "graph", "digraph", "subgraph"];
|
|
52152
|
+
var MAX_OUTPUTLINE = 128;
|
|
52153
|
+
function isDigitByte(b) {
|
|
52154
|
+
return b >= 48 && b <= 57;
|
|
52155
|
+
}
|
|
52156
|
+
function isAlnumByte(b) {
|
|
52157
|
+
return isDigitByte(b) || b >= 65 && b <= 90 || b >= 97 && b <= 122;
|
|
52158
|
+
}
|
|
52159
|
+
function isIdCharByte(b) {
|
|
52160
|
+
return isAlnumByte(b) || b === 46 || b === 45 || b >= 128;
|
|
52161
|
+
}
|
|
52162
|
+
function isEscapeAt(bytes, i) {
|
|
52163
|
+
if (bytes[i] !== 92) return false;
|
|
52164
|
+
const c = bytes[i + 1];
|
|
52165
|
+
return c !== void 0 && 'EGHLNTlnr\\"'.includes(String.fromCharCode(c));
|
|
52166
|
+
}
|
|
52167
|
+
function agstrcanonText(arg) {
|
|
52168
|
+
if (arg.length === 0) return '""';
|
|
52169
|
+
const bytes = new TextEncoder().encode(arg);
|
|
52170
|
+
const out = [34];
|
|
52171
|
+
let needsQuotes = false;
|
|
52172
|
+
let partOfEscape = false;
|
|
52173
|
+
let backslashPending = false;
|
|
52174
|
+
let cnt = 0;
|
|
52175
|
+
let dotcnt = 0;
|
|
52176
|
+
let maybeNum = isDigitByte(bytes[0]) || bytes[0] === 46 || bytes[0] === 45;
|
|
52177
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
52178
|
+
const uc = bytes[i];
|
|
52179
|
+
if (uc === 34 && !partOfEscape) {
|
|
52180
|
+
out.push(92);
|
|
52181
|
+
needsQuotes = true;
|
|
52182
|
+
} else if (!partOfEscape && isEscapeAt(bytes, i)) {
|
|
52183
|
+
needsQuotes = true;
|
|
52184
|
+
partOfEscape = true;
|
|
52185
|
+
} else if (maybeNum) {
|
|
52186
|
+
if (uc === 45) {
|
|
52187
|
+
if (cnt) {
|
|
52188
|
+
maybeNum = false;
|
|
52189
|
+
needsQuotes = true;
|
|
52190
|
+
}
|
|
52191
|
+
} else if (uc === 46) {
|
|
52192
|
+
if (dotcnt++) {
|
|
52193
|
+
maybeNum = false;
|
|
52194
|
+
needsQuotes = true;
|
|
52195
|
+
}
|
|
52196
|
+
} else if (!isDigitByte(uc)) {
|
|
52197
|
+
maybeNum = false;
|
|
52198
|
+
needsQuotes = true;
|
|
52199
|
+
}
|
|
52200
|
+
partOfEscape = false;
|
|
52201
|
+
} else if (!(isAlnumByte(uc) || uc === 95 || uc >= 128)) {
|
|
52202
|
+
needsQuotes = true;
|
|
52203
|
+
partOfEscape = false;
|
|
52204
|
+
} else {
|
|
52205
|
+
partOfEscape = false;
|
|
52206
|
+
}
|
|
52207
|
+
out.push(uc);
|
|
52208
|
+
cnt++;
|
|
52209
|
+
const next = bytes[i + 1];
|
|
52210
|
+
if (next !== void 0) {
|
|
52211
|
+
const last = out[out.length - 1];
|
|
52212
|
+
const canBreak = !(isIdCharByte(last) || last === 92) && isIdCharByte(next);
|
|
52213
|
+
if (backslashPending && canBreak) {
|
|
52214
|
+
out.push(92, 10);
|
|
52215
|
+
needsQuotes = true;
|
|
52216
|
+
backslashPending = false;
|
|
52217
|
+
cnt = 0;
|
|
52218
|
+
} else if (cnt >= MAX_OUTPUTLINE) {
|
|
52219
|
+
if (canBreak) {
|
|
52220
|
+
out.push(92, 10);
|
|
52221
|
+
needsQuotes = true;
|
|
52222
|
+
cnt = 0;
|
|
52223
|
+
} else {
|
|
52224
|
+
backslashPending = true;
|
|
52225
|
+
}
|
|
52226
|
+
}
|
|
52227
|
+
}
|
|
52228
|
+
}
|
|
52229
|
+
out.push(34);
|
|
52230
|
+
const first = bytes[0];
|
|
52231
|
+
if (needsQuotes || cnt === 1 && (first === 46 || first === 45)) {
|
|
52232
|
+
return new TextDecoder().decode(new Uint8Array(out));
|
|
52233
|
+
}
|
|
52234
|
+
const lower = arg.toLowerCase();
|
|
52235
|
+
for (const tok of CANON_KEYWORDS) {
|
|
52236
|
+
if (tok === lower) return new TextDecoder().decode(new Uint8Array(out));
|
|
52237
|
+
}
|
|
52238
|
+
return arg;
|
|
52239
|
+
}
|
|
52240
|
+
function lateNN(v, def) {
|
|
52241
|
+
return v !== void 0 && v !== "" ? v : def;
|
|
52242
|
+
}
|
|
52243
|
+
function plainNodeFill(n, g) {
|
|
52244
|
+
const fillcolor = lateNN(nodeAttr(n, g, "fillcolor"), "");
|
|
52245
|
+
if (fillcolor !== "") return fillcolor;
|
|
52246
|
+
return lateNN(nodeAttr(n, g, "color"), "lightgrey");
|
|
52247
|
+
}
|
|
52248
|
+
function plainNodeLabel(n, g) {
|
|
52249
|
+
const lbl = n.info.label;
|
|
52250
|
+
const attr2 = nodeAttr(n, g, "label");
|
|
52251
|
+
if (lbl !== void 0 && lbl.u.kind === "html") {
|
|
52252
|
+
const a = attr2 ?? "";
|
|
52253
|
+
return "<" + (isHtmlValue(a) ? htmlValueContent(a) : a) + ">";
|
|
52254
|
+
}
|
|
52255
|
+
if (attr2 !== void 0 && isHtmlValue(attr2) && lbl !== void 0 && lbl.u.kind === "txt") {
|
|
52256
|
+
return agstrcanonText(htmlValueContent(attr2));
|
|
52257
|
+
}
|
|
52258
|
+
const shape = n.info.shape;
|
|
52259
|
+
if (shape !== void 0 && shape.kind === 2 /* SH_RECORD */) {
|
|
52260
|
+
return agstrcanonText(nodeAttr(n, g, "label") ?? "\\N");
|
|
52261
|
+
}
|
|
52262
|
+
const text = lbl !== void 0 ? lbl.text : n.attrs.get("label") ?? n.name;
|
|
52263
|
+
return agstrcanonText(text);
|
|
52101
52264
|
}
|
|
52102
|
-
function plainNodeAttrs(n) {
|
|
52265
|
+
function plainNodeAttrs(n, g) {
|
|
52266
|
+
const shapeAttr = lateNN(nodeAttr(n, g, "shape"), "ellipse");
|
|
52267
|
+
const shapefile = nodeAttr(n, g, "shapefile");
|
|
52268
|
+
const shapeName = shapefile !== void 0 && shapefile !== "" && shapeAttr !== "epsf" ? "custom" : shapeAttr;
|
|
52103
52269
|
return {
|
|
52104
|
-
label:
|
|
52105
|
-
style: n
|
|
52106
|
-
shape:
|
|
52107
|
-
color: n
|
|
52108
|
-
fill: plainNodeFill(n)
|
|
52270
|
+
label: plainNodeLabel(n, g),
|
|
52271
|
+
style: lateNN(nodeAttr(n, g, "style"), "solid"),
|
|
52272
|
+
shape: shapeName,
|
|
52273
|
+
color: lateNN(nodeAttr(n, g, "color"), "black"),
|
|
52274
|
+
fill: plainNodeFill(n, g)
|
|
52109
52275
|
};
|
|
52110
52276
|
}
|
|
52111
|
-
function writePlainNode(n, out) {
|
|
52277
|
+
function writePlainNode(n, g, out) {
|
|
52112
52278
|
const x = plainCoord(n.info.coord.x);
|
|
52113
52279
|
const y = plainCoord(n.info.coord.y);
|
|
52114
52280
|
const w = printG5(n.info.width);
|
|
52115
52281
|
const h = printG5(n.info.height);
|
|
52116
|
-
const a = plainNodeAttrs(n);
|
|
52117
|
-
out.push("node " + n.name + " " + x + " " + y + " " + w + " " + h + " " + a.label + " " + a.style + " " + a.shape + " " + a.color + " " + a.fill + "\n");
|
|
52282
|
+
const a = plainNodeAttrs(n, g);
|
|
52283
|
+
out.push("node " + agstrcanonText(n.name) + " " + x + " " + y + " " + w + " " + h + " " + a.label + " " + a.style + " " + a.shape + " " + a.color + " " + a.fill + "\n");
|
|
52118
52284
|
}
|
|
52119
52285
|
function collectSplinePts(e) {
|
|
52120
52286
|
if (!e.info.spl) return [];
|
|
52121
52287
|
const pts = [];
|
|
52122
52288
|
for (const bz of e.info.spl.list) {
|
|
52123
|
-
for (
|
|
52289
|
+
for (let i = 0; i < bz.size; i++) pts.push(bz.list[i]);
|
|
52124
52290
|
}
|
|
52125
52291
|
return pts;
|
|
52126
52292
|
}
|
|
52127
|
-
function
|
|
52128
|
-
|
|
52293
|
+
function writeNodeAndPort(n, portname, out) {
|
|
52294
|
+
let name = n.name;
|
|
52295
|
+
if (n.info.clustnode) {
|
|
52296
|
+
const i = name.indexOf(":");
|
|
52297
|
+
if (i >= 0) name = name.slice(i + 1);
|
|
52298
|
+
}
|
|
52299
|
+
out.push(" " + agstrcanonText(name));
|
|
52300
|
+
if (portname !== "") out.push(":" + agstrcanonText(portname));
|
|
52129
52301
|
}
|
|
52130
52302
|
function writePlainEdgeHead(e, tport, hport, pts, out) {
|
|
52131
|
-
out.push("edge
|
|
52303
|
+
out.push("edge");
|
|
52304
|
+
writeNodeAndPort(e.tail, tport, out);
|
|
52305
|
+
writeNodeAndPort(e.head, hport, out);
|
|
52306
|
+
out.push(" " + String(pts.length));
|
|
52132
52307
|
for (const pt of pts) {
|
|
52133
52308
|
out.push(" " + plainCoord(pt.x) + " " + plainCoord(pt.y));
|
|
52134
52309
|
}
|
|
52135
52310
|
}
|
|
52136
52311
|
function writePlainEdge(e, extend, out) {
|
|
52137
|
-
const tport = extend ?
|
|
52138
|
-
const hport = extend ?
|
|
52312
|
+
const tport = extend ? e.attrs.get("tailport") ?? "" : "";
|
|
52313
|
+
const hport = extend ? e.attrs.get("headport") ?? "" : "";
|
|
52139
52314
|
const pts = collectSplinePts(e);
|
|
52140
52315
|
if (pts.length > 0) writePlainEdgeHead(e, tport, hport, pts, out);
|
|
52141
|
-
const
|
|
52142
|
-
|
|
52316
|
+
const lbl = e.info.label;
|
|
52317
|
+
if (lbl !== void 0) {
|
|
52318
|
+
out.push(" " + agstrcanonText(lbl.text) + " " + plainCoord(lbl.pos.x) + " " + plainCoord(lbl.pos.y));
|
|
52319
|
+
}
|
|
52320
|
+
const style = lateNN(e.attrs.get("style"), "solid");
|
|
52321
|
+
const color = lateNN(e.attrs.get("color"), "black");
|
|
52143
52322
|
out.push(" " + style + " " + color + "\n");
|
|
52144
52323
|
}
|
|
52145
52324
|
function writePlain(g, job, extend) {
|
|
52146
52325
|
const w = plainCoord(g.info.bb.ur.x);
|
|
52147
52326
|
const h = plainCoord(g.info.bb.ur.y);
|
|
52148
|
-
|
|
52149
|
-
|
|
52327
|
+
const zoom = initJobViewportZoom(
|
|
52328
|
+
job.bb,
|
|
52329
|
+
parseDrawingSize(g.attrs.get("size")),
|
|
52330
|
+
{ x: 0, y: 0 }
|
|
52331
|
+
);
|
|
52332
|
+
job.write("graph " + printG5(zoom) + " " + w + " " + h + "\n");
|
|
52333
|
+
const nodes = nodesInSeq(g);
|
|
52334
|
+
for (const n of nodes) {
|
|
52335
|
+
if (n.info.clustnode) continue;
|
|
52150
52336
|
const buf = [];
|
|
52151
|
-
writePlainNode(n, buf);
|
|
52337
|
+
writePlainNode(n, g, buf);
|
|
52152
52338
|
job.write(buf.join(""));
|
|
52153
52339
|
}
|
|
52154
|
-
for (const
|
|
52340
|
+
for (const n of nodes) {
|
|
52155
52341
|
for (const e of n.outEdges(g)) {
|
|
52156
52342
|
const buf = [];
|
|
52157
52343
|
writePlainEdge(e, extend, buf);
|