@knowvah/dot-engine 1.8.1 → 2.0.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 +232 -30
- package/dist/api/builder.d.ts +3 -0
- package/dist/api/builder.d.ts.map +1 -1
- package/dist/api/edge-ops.d.ts +7 -0
- package/dist/api/edge-ops.d.ts.map +1 -1
- package/dist/api/geometry.d.ts +5 -2
- package/dist/api/geometry.d.ts.map +1 -1
- package/dist/api.js +159 -31
- package/dist/api.js.map +3 -3
- package/dist/async/collect.d.ts +49 -0
- package/dist/async/collect.d.ts.map +1 -0
- package/dist/async/fonts.d.ts +20 -0
- package/dist/async/fonts.d.ts.map +1 -0
- package/dist/async/render-async.d.ts +91 -0
- package/dist/async/render-async.d.ts.map +1 -0
- package/dist/async/render-into.d.ts +38 -0
- package/dist/async/render-into.d.ts.map +1 -0
- package/dist/async/sanitize.d.ts +28 -0
- package/dist/async/sanitize.d.ts.map +1 -0
- package/dist/common/css-font.d.ts +9 -0
- package/dist/common/css-font.d.ts.map +1 -0
- package/dist/common/htmltable-types.d.ts +3 -3
- package/dist/common/htmltable-types.d.ts.map +1 -1
- package/dist/common/make-label.d.ts.map +1 -1
- package/dist/common/poly-shapes.d.ts.map +1 -1
- package/dist/common/textmeasure-factory.d.ts +2 -0
- package/dist/common/textmeasure-factory.d.ts.map +1 -1
- package/dist/common/textmeasure.d.ts +11 -1
- package/dist/common/textmeasure.d.ts.map +1 -1
- package/dist/common/utils-inputscale.d.ts +19 -0
- package/dist/common/utils-inputscale.d.ts.map +1 -0
- package/dist/errors.d.ts +61 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/gvc/context.d.ts +36 -4
- package/dist/gvc/context.d.ts.map +1 -1
- package/dist/gvc/device.d.ts +5 -2
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/gvc/image-resolver.d.ts +16 -16
- package/dist/gvc/image-resolver.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +1 -9
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/gvc/usershape.d.ts +2 -12
- package/dist/gvc/usershape.d.ts.map +1 -1
- package/dist/index.d.ts +27 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7745 -5550
- package/dist/index.js.map +4 -4
- package/dist/label/index.d.ts.map +1 -1
- package/dist/label/node.d.ts +0 -6
- package/dist/label/node.d.ts.map +1 -1
- package/dist/label/rectangle.d.ts +1 -7
- package/dist/label/rectangle.d.ts.map +1 -1
- package/dist/layout/circo/circular.d.ts +8 -5
- package/dist/layout/circo/circular.d.ts.map +1 -1
- package/dist/layout/dot/pack-components.d.ts +0 -19
- package/dist/layout/dot/pack-components.d.ts.map +1 -1
- package/dist/layout/dot/position.d.ts +7 -2
- package/dist/layout/dot/position.d.ts.map +1 -1
- package/dist/layout/fdp/derive.d.ts.map +1 -1
- package/dist/layout/fdp/index.d.ts.map +1 -1
- package/dist/layout/fdp/init.d.ts.map +1 -1
- package/dist/layout/fdp/layout.d.ts.map +1 -1
- package/dist/layout/fdp/ports.d.ts +0 -10
- package/dist/layout/fdp/ports.d.ts.map +1 -1
- package/dist/layout/fdp/xlayout.d.ts +0 -16
- package/dist/layout/fdp/xlayout.d.ts.map +1 -1
- package/dist/layout/neato/adjust-info.d.ts +117 -0
- package/dist/layout/neato/adjust-info.d.ts.map +1 -0
- package/dist/layout/neato/cdt-surface.d.ts.map +1 -1
- package/dist/layout/neato/constraint-adjust.d.ts +40 -0
- package/dist/layout/neato/constraint-adjust.d.ts.map +1 -0
- package/dist/layout/neato/edge-len.d.ts +20 -0
- package/dist/layout/neato/edge-len.d.ts.map +1 -0
- package/dist/layout/neato/fdp-adjust.d.ts +32 -4
- package/dist/layout/neato/fdp-adjust.d.ts.map +1 -1
- package/dist/layout/neato/index.d.ts +9 -6
- package/dist/layout/neato/index.d.ts.map +1 -1
- package/dist/layout/neato/init.d.ts +4 -11
- package/dist/layout/neato/init.d.ts.map +1 -1
- package/dist/layout/neato/kk-paths.d.ts +50 -0
- package/dist/layout/neato/kk-paths.d.ts.map +1 -0
- package/dist/layout/neato/kk-solve.d.ts +14 -0
- package/dist/layout/neato/kk-solve.d.ts.map +1 -0
- package/dist/layout/neato/kk.d.ts +44 -0
- package/dist/layout/neato/kk.d.ts.map +1 -0
- package/dist/layout/neato/multispline-router.d.ts.map +1 -1
- package/dist/layout/neato/poly.d.ts +50 -0
- package/dist/layout/neato/poly.d.ts.map +1 -0
- package/dist/layout/neato/sgd-dijkstra.d.ts +20 -0
- package/dist/layout/neato/sgd-dijkstra.d.ts.map +1 -0
- package/dist/layout/neato/sgd.d.ts +14 -9
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/layout/neato/start.d.ts +51 -0
- package/dist/layout/neato/start.d.ts.map +1 -0
- package/dist/layout/neato/vpsc-adjust.d.ts +21 -0
- package/dist/layout/neato/vpsc-adjust.d.ts.map +1 -0
- package/dist/layout/sfdp/index.d.ts.map +1 -1
- package/dist/layout/sfdp/init.d.ts +0 -9
- package/dist/layout/sfdp/init.d.ts.map +1 -1
- package/dist/layout/sfdp/spring-driver.d.ts.map +1 -1
- package/dist/layout/twopi/circle.d.ts +0 -7
- package/dist/layout/twopi/circle.d.ts.map +1 -1
- package/dist/ortho/ortho-parallel.d.ts.map +1 -1
- package/dist/ortho/trap-query.d.ts.map +1 -1
- package/dist/parser/index.d.ts +9 -5
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/public.d.ts +9 -3
- package/dist/render/public.d.ts.map +1 -1
- package/dist/render/xdot-public.d.ts +7 -2
- package/dist/render/xdot-public.d.ts.map +1 -1
- package/dist/render.js +7548 -5588
- package/dist/render.js.map +4 -4
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/vpsc/Solver.d.ts +1 -0
- package/dist/vpsc/Solver.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api/builder.ts +73 -5
- package/src/api/edge-ops.ts +19 -0
- package/src/api/geometry.ts +22 -5
- package/src/async/collect.ts +204 -0
- package/src/async/fonts.ts +61 -0
- package/src/async/render-async.ts +205 -0
- package/src/async/render-into.ts +115 -0
- package/src/async/sanitize.ts +150 -0
- package/src/common/css-font.ts +109 -0
- package/src/common/htmltable-types.ts +4 -5
- package/src/common/make-label.ts +10 -1
- package/src/common/poly-shapes.ts +4 -1
- package/src/common/textmeasure-factory.ts +11 -0
- package/src/common/textmeasure.ts +41 -8
- package/src/common/utils-inputscale.ts +31 -0
- package/src/errors.ts +188 -5
- package/src/gvc/context.ts +96 -17
- package/src/gvc/device.ts +11 -6
- package/src/gvc/image-resolver.ts +25 -2
- package/src/gvc/job.ts +3 -1
- package/src/gvc/usershape.ts +6 -0
- package/src/index.ts +59 -43
- package/src/label/index.ts +6 -2
- package/src/label/node.ts +2 -1
- package/src/label/rectangle.ts +4 -2
- package/src/layout/circo/circular.ts +9 -6
- package/src/layout/dot/pack-components.ts +6 -2
- package/src/layout/dot/position.ts +21 -3
- package/src/layout/fdp/derive.ts +7 -6
- package/src/layout/fdp/index.ts +45 -5
- package/src/layout/fdp/init.ts +7 -6
- package/src/layout/fdp/layout.ts +2 -1
- package/src/layout/fdp/ports.ts +3 -2
- package/src/layout/fdp/xlayout.ts +3 -1
- package/src/layout/neato/adjust-info.ts +332 -0
- package/src/layout/neato/cdt-surface.ts +50 -30
- package/src/layout/neato/constraint-adjust.ts +466 -0
- package/src/layout/neato/edge-len.ts +36 -0
- package/src/layout/neato/fdp-adjust.ts +117 -12
- package/src/layout/neato/index.ts +36 -54
- package/src/layout/neato/init.ts +21 -36
- package/src/layout/neato/kk-paths.ts +146 -0
- package/src/layout/neato/kk-solve.ts +64 -0
- package/src/layout/neato/kk.ts +322 -0
- package/src/layout/neato/multispline-router.ts +4 -3
- package/src/layout/neato/poly.ts +493 -0
- package/src/layout/neato/sgd-dijkstra.ts +125 -0
- package/src/layout/neato/sgd.ts +63 -40
- package/src/layout/neato/start.ts +222 -0
- package/src/layout/neato/vpsc-adjust.ts +93 -0
- package/src/layout/sfdp/index.ts +4 -5
- package/src/layout/sfdp/init.ts +40 -4
- package/src/layout/sfdp/spring-driver.ts +30 -1
- package/src/layout/twopi/circle.ts +2 -1
- package/src/ortho/ortho-parallel.ts +2 -1
- package/src/ortho/trap-query.ts +2 -1
- package/src/parser/index.ts +11 -11
- package/src/render/index.ts +5 -0
- package/src/render/public.ts +24 -24
- package/src/render/svg.ts +1 -1
- package/src/render/xdot-public.ts +19 -18
- package/src/util/xml.ts +24 -30
- package/src/vpsc/Solver.ts +5 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource collector: the fonts and image sources the synchronous pipeline
|
|
3
|
+
* will ask for, gathered from the parsed graph before any layout runs.
|
|
4
|
+
*
|
|
5
|
+
* Each font request mirrors a measurer call site exactly (same attribute
|
|
6
|
+
* lookup, same defaults and fallbacks), so a prefetch loads the faces the
|
|
7
|
+
* measurer will actually measure.
|
|
8
|
+
*
|
|
9
|
+
* @see src/common/nodeinit.ts:initNodeXLabel / src/common/poly-init.ts:buildNodeLabel
|
|
10
|
+
* @see src/common/edge-label-init.ts (edge, xlabel, head/tail labels)
|
|
11
|
+
* @see src/layout/dot/graph-label.ts:doGraphLabel (root and cluster labels)
|
|
12
|
+
* @see src/common/htmltable.ts / htmltable-pos-runs.ts (HTML item fonts)
|
|
13
|
+
*/
|
|
14
|
+
import type { Graph } from '../model/graph.js';
|
|
15
|
+
import type { TextVariantFlags } from '../common/textmeasure.js';
|
|
16
|
+
/** One font face the measurer will be asked for. */
|
|
17
|
+
export interface FontRequest {
|
|
18
|
+
/** Graphviz `fontname` as the measurer receives it. */
|
|
19
|
+
readonly fontname: string | null;
|
|
20
|
+
/** Font size in points. */
|
|
21
|
+
readonly fontsize: number;
|
|
22
|
+
/** Bold/italic variant flags; absent for the regular face. */
|
|
23
|
+
readonly flags?: TextVariantFlags;
|
|
24
|
+
}
|
|
25
|
+
/** Everything the sync pipeline needs prefetched. */
|
|
26
|
+
export interface Resources {
|
|
27
|
+
/** Distinct font requests, deduped by their `canvasFont` string. */
|
|
28
|
+
readonly fonts: FontRequest[];
|
|
29
|
+
/** Distinct HTML `<IMG SRC>` values (dimension lookups). */
|
|
30
|
+
readonly sizeSrcs: string[];
|
|
31
|
+
/** Distinct image sources to fetch as bytes; empty unless `inlineImages`. */
|
|
32
|
+
readonly bytesSrcs: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Options for {@link collectResources}. */
|
|
35
|
+
export interface CollectOptions {
|
|
36
|
+
/** Also collect `image=` and HTML `<IMG SRC>` values as bytes sources. */
|
|
37
|
+
readonly inlineImages: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gather every font face and image source the synchronous pipeline will ask
|
|
41
|
+
* for. Pure: reads the parsed graph only; a malformed HTML label is skipped
|
|
42
|
+
* (the sync path falls back to plain text).
|
|
43
|
+
*
|
|
44
|
+
* @param g - A parsed graph (before layout).
|
|
45
|
+
* @param opts - Collection options.
|
|
46
|
+
* @returns The deduped fonts, size sources and bytes sources.
|
|
47
|
+
*/
|
|
48
|
+
export declare function collectResources(g: Graph, opts: CollectOptions): Resources;
|
|
49
|
+
//# sourceMappingURL=collect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/async/collect.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAYjE,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AA8HD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,SAAS,CAa1E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FontRequest } from './collect.js';
|
|
2
|
+
/** A font that could not be made available before measuring. */
|
|
3
|
+
export type FontIssue = {
|
|
4
|
+
face: string;
|
|
5
|
+
reason: 'failed' | 'timeout';
|
|
6
|
+
};
|
|
7
|
+
/** Structural subset of `FontFaceSet`; the real object satisfies it. */
|
|
8
|
+
export interface FontSetLike {
|
|
9
|
+
load(font: string): Promise<readonly {
|
|
10
|
+
status?: string;
|
|
11
|
+
}[]>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Loads every distinct CSS font the requests map to (in parallel, sharing one
|
|
15
|
+
* deadline) so canvas measurement sees real faces rather than fallbacks.
|
|
16
|
+
* Resolves with one {@link FontIssue} per face that failed or timed out;
|
|
17
|
+
* never rejects. An undefined `fontSet` yields `[]` immediately.
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadFonts(fontSet: FontSetLike | undefined, fonts: readonly FontRequest[], timeoutMs: number): Promise<FontIssue[]>;
|
|
20
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/async/fonts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,gEAAgE;AAChE,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC;AAEvE,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;CAC7D;AAyBD;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,EAAE,CAAC,CAetB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async render entry points (async-api ADR-1, 3, 4, 5, 7).
|
|
3
|
+
*
|
|
4
|
+
* Parse, collect the fonts and images the graph will request, await them,
|
|
5
|
+
* then run the unchanged synchronous `layout → render → freeLayout` on a fresh
|
|
6
|
+
* per-call context whose image hooks are sync closures over per-call Maps.
|
|
7
|
+
*
|
|
8
|
+
* @see src/render/public.ts:render
|
|
9
|
+
* @see src/index.ts:renderSvg
|
|
10
|
+
*/
|
|
11
|
+
import type { Graph } from '../model/graph.js';
|
|
12
|
+
import type { EngineName } from '../gvc/context.js';
|
|
13
|
+
import type { OutputFormat, RenderOptions } from '../render/public.js';
|
|
14
|
+
import type { FontIssue, FontSetLike } from './fonts.js';
|
|
15
|
+
export type { FontIssue, FontSetLike } from './fonts.js';
|
|
16
|
+
/** Default font-load deadline in milliseconds (ADR-3). */
|
|
17
|
+
export declare const DEFAULT_FONT_TIMEOUT_MS = 3000;
|
|
18
|
+
/** Result of an async image-size lookup; `null` is a miss. */
|
|
19
|
+
export type AsyncImageSize = {
|
|
20
|
+
w: number;
|
|
21
|
+
h: number;
|
|
22
|
+
} | null;
|
|
23
|
+
/** Result of an async image-bytes lookup; `null` is a miss. */
|
|
24
|
+
export type AsyncImageBytes = {
|
|
25
|
+
bytes: Uint8Array;
|
|
26
|
+
mime?: string;
|
|
27
|
+
} | Uint8Array | null;
|
|
28
|
+
/** Options for {@link renderAsync}. */
|
|
29
|
+
export interface AsyncRenderOptions extends RenderOptions {
|
|
30
|
+
/** Async HTML `<IMG>` dimension lookup; a throw/reject counts as a miss. */
|
|
31
|
+
imageSizer?: (src: string) => Promise<AsyncImageSize>;
|
|
32
|
+
/** Async image bytes lookup for `inlineImages`; a throw/reject counts as a miss. */
|
|
33
|
+
imageResolver?: (src: string) => Promise<AsyncImageBytes>;
|
|
34
|
+
/** Font-load deadline in ms, shared by all faces. Default 3000. */
|
|
35
|
+
fontTimeoutMs?: number;
|
|
36
|
+
/** FontFaceSet-like to load faces from. Default `document.fonts` when present. */
|
|
37
|
+
fontSet?: FontSetLike;
|
|
38
|
+
}
|
|
39
|
+
/** Options for {@link renderSvgAsync}: {@link AsyncRenderOptions} minus `engine`. */
|
|
40
|
+
export type AsyncSvgOptions = Omit<AsyncRenderOptions, 'engine'>;
|
|
41
|
+
/** Resolved value of {@link renderAsync}. */
|
|
42
|
+
export interface AsyncRenderResult {
|
|
43
|
+
output: string;
|
|
44
|
+
fontIssues: FontIssue[];
|
|
45
|
+
}
|
|
46
|
+
/** Resolved value of {@link renderSvgAsync}. */
|
|
47
|
+
export interface AsyncSvgResult {
|
|
48
|
+
svg: string;
|
|
49
|
+
fontIssues: FontIssue[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Render a (parsed or built) graph to the requested format after prefetching
|
|
53
|
+
* web fonts and image data, so layout measures real faces and sizes.
|
|
54
|
+
*
|
|
55
|
+
* Every failure, including usage `TypeError`s, is a promise rejection with the
|
|
56
|
+
* same classes and codes as {@link render}. Font problems never reject; they
|
|
57
|
+
* are returned in `fontIssues` (and `console.warn`ed).
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Security: for the markup formats (`svg`, `cmapx`, `imap`), treat the output
|
|
61
|
+
* as attacker-controlled when the source graph came from untrusted DOT.
|
|
62
|
+
* Attribute values are XML-escaped, but URL schemes and resource origins
|
|
63
|
+
* (`href`/`URL`/`image`/`stylesheet`) are passed through unfiltered, matching
|
|
64
|
+
* native Graphviz. Apply a Content-Security-Policy or sanitize before embedding
|
|
65
|
+
* — see the README "Security" section.
|
|
66
|
+
*
|
|
67
|
+
* @param g - graph produced by `parse(...)` or the builder API
|
|
68
|
+
* @param format - target output format
|
|
69
|
+
* @param opts - engine, `inlineImages`, async image hooks and font options
|
|
70
|
+
* @returns the rendered string and any font issues
|
|
71
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` / `ERR_INVALID_ARG_VALUE` (as rejection)
|
|
72
|
+
* @throws RenderError, InternalError (as rejection), as {@link render}
|
|
73
|
+
*/
|
|
74
|
+
export declare function renderAsync(g: Graph, format: OutputFormat, opts?: AsyncRenderOptions): Promise<AsyncRenderResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Async counterpart of `renderSvg`: parse DOT, prefetch fonts/images, render.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Security: same untrusted-input caveat as `renderSvg` and {@link renderAsync}
|
|
80
|
+
* — the returned `svg` is attacker-controlled markup for untrusted `dotSource`;
|
|
81
|
+
* apply a CSP or sanitize before embedding. See the README "Security" section.
|
|
82
|
+
*
|
|
83
|
+
* @param dotSource - DOT-language graph source
|
|
84
|
+
* @param engine - layout engine name
|
|
85
|
+
* @param opts - `inlineImages`, async image hooks and font options
|
|
86
|
+
* @returns the SVG string and any font issues
|
|
87
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` / `ERR_INVALID_ARG_VALUE` (as rejection)
|
|
88
|
+
* @throws ParseError, RenderError, InternalError (as rejection), as `renderSvg`
|
|
89
|
+
*/
|
|
90
|
+
export declare function renderSvgAsync(dotSource: string, engine: EngineName, opts?: AsyncSvgOptions): Promise<AsyncSvgResult>;
|
|
91
|
+
//# sourceMappingURL=render-async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-async.d.ts","sourceRoot":"","sources":["../../src/async/render-async.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AAE7D,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,GAAG,IAAI,CAAC;AAEvF,uCAAuC;AACvC,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,4EAA4E;IAC5E,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACtD,oFAAoF;IACpF,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1D,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAEjE,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AA6DD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,WAAW,CAC/B,CAAC,EAAE,KAAK,EACR,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAsB5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,EAClB,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,cAAc,CAAC,CAWzB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EngineName } from '../gvc/context.js';
|
|
2
|
+
import type { AsyncSvgOptions } from './render-async.js';
|
|
3
|
+
import type { FontIssue } from './fonts.js';
|
|
4
|
+
import type { SvgParserLike } from './sanitize.js';
|
|
5
|
+
/** Options for {@link renderSvgInto}. */
|
|
6
|
+
export interface RenderSvgIntoOptions extends AsyncSvgOptions {
|
|
7
|
+
/** Custom sanitizer: receives the SVG string, returns the markup to insert. */
|
|
8
|
+
sanitize?: (svg: string) => string;
|
|
9
|
+
/** Insert the SVG as rendered, with no sanitizing at all. Default false. */
|
|
10
|
+
trusted?: boolean;
|
|
11
|
+
/** Document to look up `id` in and insert into. Default `globalThis.document`. */
|
|
12
|
+
document?: Document;
|
|
13
|
+
/** Parser override (test seam). Default: the document window's `DOMParser`. */
|
|
14
|
+
domParser?: SvgParserLike;
|
|
15
|
+
}
|
|
16
|
+
/** Resolved value of {@link renderSvgInto}. */
|
|
17
|
+
export interface RenderSvgIntoResult {
|
|
18
|
+
/** The inserted (imported) root `<svg>` element. */
|
|
19
|
+
element: SVGSVGElement;
|
|
20
|
+
fontIssues: FontIssue[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Render `src` and replace the children of the element with id `id` by the
|
|
24
|
+
* resulting `<svg>`.
|
|
25
|
+
*
|
|
26
|
+
* Order (ADR-6): `trusted === true` inserts as rendered; else `sanitize(svg)`
|
|
27
|
+
* if given; else the built-in scrubber (`scrubSvgDocument`).
|
|
28
|
+
*
|
|
29
|
+
* @param id - id of the target element in the document
|
|
30
|
+
* @param src - DOT source
|
|
31
|
+
* @param engine - layout engine name
|
|
32
|
+
* @param opts - async render options plus `sanitize`, `trusted`, `document`
|
|
33
|
+
* @returns the inserted `<svg>` element and any font issues
|
|
34
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` / `ERR_INVALID_ARG_VALUE` /
|
|
35
|
+
* `ERR_INVALID_STATE` (as rejection); RenderError if the SVG does not parse
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderSvgInto(id: string, src: string, engine: EngineName, opts?: RenderSvgIntoOptions): Promise<RenderSvgIntoResult>;
|
|
38
|
+
//# sourceMappingURL=render-into.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-into.d.ts","sourceRoot":"","sources":["../../src/async/render-into.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAKnD,yCAAyC;AACzC,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAyCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,UAAU,EAClB,IAAI,CAAC,EAAE,oBAAoB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Structural subset of `DOMParser` used by {@link scrubSvgString}. */
|
|
2
|
+
export interface SvgParserLike {
|
|
3
|
+
parseFromString(source: string, mimeType: 'image/svg+xml'): Document;
|
|
4
|
+
}
|
|
5
|
+
/** Structural subset of `XMLSerializer` used by {@link scrubSvgString}. */
|
|
6
|
+
export interface SvgSerializerLike {
|
|
7
|
+
serializeToString(node: Node): string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Scrub `doc` in place: remove `script`/`foreignObject`, `href`-targeting
|
|
11
|
+
* animations, every `on*` attribute, `javascript:`/`vbscript:` hrefs, `data:`
|
|
12
|
+
* hrefs other than `data:image/*` on `<image>`, and `xml-stylesheet`
|
|
13
|
+
* processing instructions. Element, attribute and PI matching ignores case and
|
|
14
|
+
* namespace prefix.
|
|
15
|
+
*
|
|
16
|
+
* @param doc - A document parsed from SVG; mutated.
|
|
17
|
+
*/
|
|
18
|
+
export declare function scrubSvgDocument(doc: Document): void;
|
|
19
|
+
/**
|
|
20
|
+
* Parse `svg`, scrub it with {@link scrubSvgDocument} and serialize it back.
|
|
21
|
+
*
|
|
22
|
+
* @param svg - SVG source text.
|
|
23
|
+
* @param parser - A `DOMParser`-like object.
|
|
24
|
+
* @param serializer - An `XMLSerializer`-like object.
|
|
25
|
+
* @returns The scrubbed SVG text.
|
|
26
|
+
*/
|
|
27
|
+
export declare function scrubSvgString(svg: string, parser: SvgParserLike, serializer: SvgSerializerLike): string;
|
|
28
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/async/sanitize.ts"],"names":[],"mappings":"AAwCA,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,QAAQ,CAAC;CACtE;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;CACvC;AA4DD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAcpD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,iBAAiB,GAC5B,MAAM,CAIR"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextVariantFlags } from './textmeasure.js';
|
|
2
|
+
/**
|
|
3
|
+
* CSS `font` shorthand (`[style] [weight] [stretch] <size>px <families>`)
|
|
4
|
+
* naming the face svg_textspan renders `fontname` with. Pure; always
|
|
5
|
+
* syntactically valid CSS.
|
|
6
|
+
* @see plugin/core/gvrender_core_svg.c:462-500 svg_textspan (family/weight/style selection)
|
|
7
|
+
*/
|
|
8
|
+
export declare function canvasFont(fontname: string | null, fontsize: number, flags?: TextVariantFlags): string;
|
|
9
|
+
//# sourceMappingURL=css-font.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-font.d.ts","sourceRoot":"","sources":["../../src/common/css-font.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAkFzD;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,gBAAgB,GACvB,MAAM,CAMR"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @see lib/common/htmltable.h
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { DotEngineError } from '../errors.js';
|
|
7
7
|
/**
|
|
8
8
|
* Thrown when an unrecognized HTML tag is encountered during parsing.
|
|
9
9
|
*
|
|
@@ -13,12 +13,12 @@ import type { GvError } from '../errors.js';
|
|
|
13
13
|
*
|
|
14
14
|
* @see lib/common/htmllex.c:lexerror
|
|
15
15
|
*/
|
|
16
|
-
export declare class HtmlParseError extends
|
|
16
|
+
export declare class HtmlParseError extends DotEngineError {
|
|
17
17
|
readonly type = "semantic";
|
|
18
18
|
readonly code = "HTML_PARSE_ERROR";
|
|
19
19
|
readonly friendlyMessage: string;
|
|
20
20
|
readonly tag: string;
|
|
21
|
-
constructor(tag: string);
|
|
21
|
+
constructor(tag: string, options?: ErrorOptions);
|
|
22
22
|
}
|
|
23
23
|
/** @see lib/common/htmltable.h HALIGN_* flags */
|
|
24
24
|
export type HtmlAlign = 'left' | 'center' | 'right';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmltable-types.d.ts","sourceRoot":"","sources":["../../src/common/htmltable-types.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAMH,OAAO,
|
|
1
|
+
{"version":3,"file":"htmltable-types.d.ts","sourceRoot":"","sources":["../../src/common/htmltable-types.ts"],"names":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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-label.d.ts","sourceRoot":"","sources":["../../src/common/make-label.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"make-label.d.ts","sourceRoot":"","sources":["../../src/common/make-label.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,KAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,aAAa,UAAU,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,CAAC;AAqB1B,+EAA+E;AAC/E,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAoBD,wEAAwE;AACxE,UAAU,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAAE;AAK5D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAsBzD;AAoCD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,YAAY,GACrB,UAAU,CAEZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,YAAY,EACtB,GAAG,CAAC,EAAE,QAAQ,GACb,UAAU,CAkBZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poly-shapes.d.ts","sourceRoot":"","sources":["../../src/common/poly-shapes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"poly-shapes.d.ts","sourceRoot":"","sources":["../../src/common/poly-shapes.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,uBAAuB,CAAC;AAU/B,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAkCtD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GACzE,IAAI,CAeN;AAgBD,6EAA6E;AAC7E,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAUlG;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAC1D,IAAI,CASN;AAED;+CAC+C;AAC/C,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAK5E;AAED;iEACiE;AACjE,wBAAgB,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAU/F"}
|
|
@@ -24,6 +24,8 @@ import { type TextMeasurer } from './textmeasure.js';
|
|
|
24
24
|
* render (renderSvg resolves the measurer per call). Use for deterministic
|
|
25
25
|
* tests or to wire a host-faithful Node measurer (e.g. node-canvas) — see the
|
|
26
26
|
* resolution note above.
|
|
27
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` if `m` is neither undefined nor an
|
|
28
|
+
* object with a `measure` function
|
|
27
29
|
*/
|
|
28
30
|
export declare function setTextMeasurer(m: TextMeasurer | undefined): void;
|
|
29
31
|
/** The current explicit override, or undefined when auto-resolving. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textmeasure-factory.d.ts","sourceRoot":"","sources":["../../src/common/textmeasure-factory.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACsD,KAAK,YAAY,EAC7E,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"textmeasure-factory.d.ts","sourceRoot":"","sources":["../../src/common/textmeasure-factory.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACsD,KAAK,YAAY,EAC7E,MAAM,kBAAkB,CAAC;AAM1B;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,CASjE;AAED,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,YAAY,GAAG,SAAS,CAE1D;AA2BD,8EAA8E;AAC9E,wBAAgB,cAAc,IAAI,YAAY,CAgB7C"}
|
|
@@ -96,13 +96,23 @@ export declare class LutTextMeasurer implements TextMeasurer {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Canvas-based TextMeasurer via CanvasRenderingContext2D.
|
|
99
|
-
*
|
|
99
|
+
* The font is the face the SVG emitter renders with (canvasFont), so browser
|
|
100
|
+
* measurement and rendering agree. Height is fontsize (matches C behavior).
|
|
100
101
|
* @see lib/common/textspan.c:estimate_textspan_size
|
|
101
102
|
*/
|
|
102
103
|
export declare class CanvasTextMeasurer implements TextMeasurer {
|
|
103
104
|
private readonly ctx;
|
|
105
|
+
/**
|
|
106
|
+
* fontname|fontsize|bold|italic → accepted font string. Mirrors pango's
|
|
107
|
+
* font reuse (plugin/pango/gvtextlayout_pango.c:99-100).
|
|
108
|
+
*/
|
|
109
|
+
private readonly fonts;
|
|
104
110
|
constructor(ctx: CanvasRenderingContext2D);
|
|
105
111
|
measure(text: string, fontname: string, fontsize: number, flags?: TextVariantFlags): TextSize;
|
|
112
|
+
/** Cached font string; built and validated once per distinct font. */
|
|
113
|
+
private fontFor;
|
|
114
|
+
/** True when the context accepts `font` as a `ctx.font` value. */
|
|
115
|
+
private accepts;
|
|
106
116
|
}
|
|
107
117
|
/** graphviz estimate_textspan_size line spacing. @see lib/common/const.h:70 */
|
|
108
118
|
export declare const LINESPACING = 1.2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textmeasure.d.ts","sourceRoot":"","sources":["../../src/common/textmeasure.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"textmeasure.d.ts","sourceRoot":"","sources":["../../src/common/textmeasure.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAMH,qDAAqD;AACrD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,iDAAiD;AACjD,MAAM,WAAW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G;AACH,qBAAa,eAAgB,YAAW,YAAY;IAClD,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,gBAAgB,GACvB,QAAQ;CAMZ;AASD;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAOzC,OAAO,CAAC,QAAQ,CAAC,GAAG;IANhC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;gBAEtB,GAAG,EAAE,wBAAwB;IAE1D,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,gBAAgB,GACvB,QAAQ;IAMX,sEAAsE;IACtE,OAAO,CAAC,OAAO;IAaf,kEAAkE;IAClE,OAAO,CAAC,OAAO;CAQhB;AAED,+EAA+E;AAC/E,eAAO,MAAM,WAAW,MAAO,CAAC;AAEhC;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,gBAAgB,GACvB,QAAQ;CAWZ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Graph } from '../model/graph.js';
|
|
2
|
+
/**
|
|
3
|
+
* Effective inputscale for a layout run (C's PSinputscale as set by
|
|
4
|
+
* get_inputscale). The library has no CLI `-s` flag, so the "command line
|
|
5
|
+
* flag prevails" branch (`PSinputscale > 0`) is absent. Absent/unparseable
|
|
6
|
+
* gives -1 (no scaling); 0 and negatives (clamped to 0 by late_double's
|
|
7
|
+
* minimum) give 72. Callers scale only when the result is > 0.
|
|
8
|
+
* @see lib/common/utils.c:get_inputscale
|
|
9
|
+
*/
|
|
10
|
+
export declare function getInputscale(g: Graph): number;
|
|
11
|
+
/**
|
|
12
|
+
* Divisor for `x /= PSinputscale` guarded by `if (PSinputscale > 0)`:
|
|
13
|
+
* the inputscale when positive, else 1 (no scaling).
|
|
14
|
+
* @see lib/neatogen/neatoinit.c:user_pos
|
|
15
|
+
* @see lib/fdpgen/fdpinit.c:initialPositions
|
|
16
|
+
* @see lib/fdpgen/layout.c:chkPos
|
|
17
|
+
*/
|
|
18
|
+
export declare function inputscaleDivisor(g: Graph): number;
|
|
19
|
+
//# sourceMappingURL=utils-inputscale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-inputscale.d.ts","sourceRoot":"","sources":["../../src/common/utils-inputscale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM/C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,CAG9C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,CAGlD"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type GvExpectation = Expectation;
|
|
|
14
14
|
/** Coarse classification of where an error originated. */
|
|
15
15
|
export type GvErrorType = 'syntax' | 'semantic' | 'render';
|
|
16
16
|
/** Closed union of stable error codes — each is an i18n key. */
|
|
17
|
-
export type GvErrorCode = 'SYNTAX_ERROR' | 'SYNTAX_UNEXPECTED_EOF' | 'EDGE_OP_DIRECTED_IN_UNDIRECTED' | 'EDGE_OP_UNDIRECTED_IN_DIRECTED' | 'HTML_PARSE_ERROR' | 'RENDER_ERROR' | 'GENERIC_ERROR';
|
|
17
|
+
export type GvErrorCode = 'SYNTAX_ERROR' | 'SYNTAX_UNEXPECTED_EOF' | 'EDGE_OP_DIRECTED_IN_UNDIRECTED' | 'EDGE_OP_UNDIRECTED_IN_DIRECTED' | 'HTML_PARSE_ERROR' | 'RENDER_ERROR' | 'INTERNAL_ERROR' | 'UNKNOWN_LAYOUT' | 'UNSUPPORTED_FEATURE' | 'GENERIC_ERROR';
|
|
18
18
|
/** Structured error contract shared by every error source. */
|
|
19
19
|
export interface GvError {
|
|
20
20
|
type: GvErrorType;
|
|
@@ -51,13 +51,69 @@ export declare const FRIENDLY_MESSAGES: Record<GvErrorCode, string>;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function friendlyMessageFor(code: GvErrorCode): string;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* Abstract base of every library-originated error: `instanceof
|
|
55
|
+
* DotEngineError` means dot-engine failed on this input (bad input, a fatal
|
|
56
|
+
* error Graphviz itself would report, or a dot-engine bug). Each subclass
|
|
57
|
+
* sets a hard-coded `name`.
|
|
56
58
|
*/
|
|
57
|
-
export declare class
|
|
59
|
+
export declare abstract class DotEngineError extends Error implements GvError {
|
|
60
|
+
abstract readonly type: GvErrorType;
|
|
61
|
+
abstract readonly code: GvErrorCode;
|
|
62
|
+
abstract readonly friendlyMessage: string;
|
|
63
|
+
constructor(message: string, options?: ErrorOptions);
|
|
64
|
+
}
|
|
65
|
+
/** A dot-engine bug: failed assertion, broken invariant or foreign throw. */
|
|
66
|
+
export declare class InternalError extends DotEngineError {
|
|
58
67
|
readonly type = "render";
|
|
68
|
+
readonly code = "INTERNAL_ERROR";
|
|
69
|
+
readonly friendlyMessage: string;
|
|
70
|
+
constructor(message: string, options?: ErrorOptions);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Error thrown for known layout/render-stage failures. `type` is `semantic`
|
|
74
|
+
* for `UNKNOWN_LAYOUT` / `UNSUPPORTED_FEATURE`, otherwise `render`.
|
|
75
|
+
*/
|
|
76
|
+
export declare class RenderError extends DotEngineError {
|
|
77
|
+
readonly type: GvErrorType;
|
|
59
78
|
readonly code: GvErrorCode;
|
|
60
79
|
readonly friendlyMessage: string;
|
|
61
|
-
constructor(message: string, code?: GvErrorCode);
|
|
80
|
+
constructor(message: string, code?: GvErrorCode, options?: ErrorOptions);
|
|
62
81
|
}
|
|
82
|
+
/** Guard shared by every boundary: structural check, works across bundles. */
|
|
83
|
+
export declare function isGvError(e: unknown): e is GvError;
|
|
84
|
+
/** Node-style codes carried by caller-mistake errors. */
|
|
85
|
+
export type UsageErrorCode = 'ERR_INVALID_ARG_TYPE' | 'ERR_INVALID_ARG_VALUE' | 'ERR_OUT_OF_RANGE' | 'ERR_INVALID_STATE';
|
|
86
|
+
/** TypeError carrying a usage code; `name` stays `TypeError`. */
|
|
87
|
+
export declare class UsageTypeError extends TypeError {
|
|
88
|
+
readonly code: UsageErrorCode;
|
|
89
|
+
constructor(message: string, code: UsageErrorCode);
|
|
90
|
+
}
|
|
91
|
+
/** RangeError carrying a usage code; `name` stays `RangeError`. */
|
|
92
|
+
export declare class UsageRangeError extends RangeError {
|
|
93
|
+
readonly code: UsageErrorCode;
|
|
94
|
+
constructor(message: string, code: UsageErrorCode);
|
|
95
|
+
}
|
|
96
|
+
/** Error carrying a usage code; `name` stays `Error`. */
|
|
97
|
+
export declare class UsageStateError extends Error {
|
|
98
|
+
readonly code: UsageErrorCode;
|
|
99
|
+
constructor(message: string, code: UsageErrorCode);
|
|
100
|
+
}
|
|
101
|
+
/** Wrong type, `null` or a missing required argument. */
|
|
102
|
+
export declare function invalidArgType(param: string, expected: string, actual: unknown): TypeError;
|
|
103
|
+
/** Unknown engine/format name (or other enum-like value) as an argument. */
|
|
104
|
+
export declare function invalidArgValue(param: string, value: unknown, allowed: readonly string[]): TypeError;
|
|
105
|
+
/** Numeric argument outside its range. */
|
|
106
|
+
export declare function outOfRange(param: string, range: string, value: number): RangeError;
|
|
107
|
+
/** Call made in the wrong state (e.g. `getLayout` before layout). */
|
|
108
|
+
export declare function invalidState(message: string): Error;
|
|
109
|
+
/** True for errors built by the usage-error factories. */
|
|
110
|
+
export declare function isUsageError(e: unknown): boolean;
|
|
111
|
+
/** Message of any thrown value. */
|
|
112
|
+
export declare function messageOf(err: unknown): string;
|
|
113
|
+
/**
|
|
114
|
+
* Boundary `catch` (ADR-5): usage errors and {@link GvError}s re-surface
|
|
115
|
+
* unchanged; anything else is a dot-engine bug and becomes an
|
|
116
|
+
* {@link InternalError} keeping the original as `cause`.
|
|
117
|
+
*/
|
|
118
|
+
export declare function rethrowAtBoundary(err: unknown): never;
|
|
63
119
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC;AAExC,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3D,gEAAgE;AAChE,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,uBAAuB,GACvB,gCAAgC,GAChC,gCAAgC,GAChC,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB,8DAA8D;AAC9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,uBAAuB;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,eAAe,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IAC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E,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc;CAIlD;AAED,yDAAyD;AACzD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc;CAIlD;AAyBD,yDAAyD;AACzD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,SAAS,CAKX;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,CAKX;AAED,0CAA0C;AAC1C,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,UAAU,CAKZ;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAEnD;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAMhD;AAID,mCAAmC;AACnC,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAGrD"}
|
package/dist/gvc/context.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ import type { Point, Box } from '../model/geom.js';
|
|
|
20
20
|
import type { TextSpan } from '../common/emit-types.js';
|
|
21
21
|
import type { TextMeasurer } from '../common/textmeasure.js';
|
|
22
22
|
import type { DebugOptions } from '../debug.js';
|
|
23
|
+
import type { ImageSizer } from '../common/htmltable-types.js';
|
|
24
|
+
import type { ImageResolver } from './image-resolver.js';
|
|
23
25
|
import type { RenderJob } from './job.js';
|
|
24
26
|
/** @see lib/gvc/gvcjob.h:label_type */
|
|
25
27
|
export declare const enum LabelType {
|
|
@@ -141,10 +143,29 @@ export declare class GvcContext {
|
|
|
141
143
|
private readonly layouts;
|
|
142
144
|
textMeasurer: TextMeasurer;
|
|
143
145
|
readonly debug: DebugOptions | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Per-context HTML `<IMG>` sizer; takes precedence over the global
|
|
148
|
+
* `setImageSizer`. Undefined by default. @see ADR-2 (async-api)
|
|
149
|
+
*/
|
|
150
|
+
imageSizer?: ImageSizer;
|
|
151
|
+
/**
|
|
152
|
+
* Per-context image resolver for `inlineImages`; takes precedence over the
|
|
153
|
+
* global `setImageResolver`. Undefined by default. @see ADR-2 (async-api)
|
|
154
|
+
*/
|
|
155
|
+
imageResolver?: ImageResolver;
|
|
156
|
+
/**
|
|
157
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` if `measurer` has no `measure`
|
|
158
|
+
* function or `options` is neither undefined nor an object
|
|
159
|
+
*/
|
|
144
160
|
constructor(measurer: TextMeasurer, options?: {
|
|
145
161
|
debug?: DebugOptions;
|
|
146
162
|
});
|
|
147
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Register a renderer or layout engine; overload discriminated by `quality`.
|
|
165
|
+
* @throws TypeError `ERR_INVALID_ARG_TYPE` if `p` is not a renderer plugin
|
|
166
|
+
* (string `type`, numeric `quality`) or a layout engine (string `type`,
|
|
167
|
+
* `layout` and `cleanup` functions)
|
|
168
|
+
*/
|
|
148
169
|
register(p: RendererPlugin): void;
|
|
149
170
|
register(p: LayoutEngine): void;
|
|
150
171
|
/**
|
|
@@ -152,24 +173,35 @@ export declare class GvcContext {
|
|
|
152
173
|
* Because renderers are sorted quality-descending within a prefix, the first
|
|
153
174
|
* match is always the highest-quality one (last-registered wins on tie).
|
|
154
175
|
*
|
|
155
|
-
* @throws
|
|
176
|
+
* @throws TypeError (ERR_INVALID_ARG_TYPE) if format is not a string
|
|
177
|
+
* @throws TypeError (ERR_INVALID_ARG_VALUE) if no renderer is registered
|
|
178
|
+
* for format
|
|
156
179
|
* @see lib/gvc/gvplugin.c:gvplugin_find
|
|
157
180
|
*/
|
|
158
181
|
bestRenderer(format: string): RendererPlugin;
|
|
182
|
+
/** Validate the `(g, engineName)` arguments shared by layout/freeLayout. */
|
|
183
|
+
private checkLayoutArgs;
|
|
159
184
|
/**
|
|
160
185
|
* Run layout on g using engineName. Engine cleanup is deferred to
|
|
161
186
|
* freeLayout, matching C's gvLayoutJobs / gvFreeLayout split —
|
|
162
187
|
* rendering happens in between and must see the layout state
|
|
163
188
|
* (e.g. cluster arrays).
|
|
164
189
|
*
|
|
165
|
-
* @throws
|
|
190
|
+
* @throws TypeError (ERR_INVALID_ARG_TYPE / ERR_INVALID_ARG_VALUE) for a
|
|
191
|
+
* bad `g`, or an engine argument that is not registered
|
|
192
|
+
* @throws RenderError (UNKNOWN_LAYOUT) if the `layout` attribute names no
|
|
193
|
+
* registered engine
|
|
194
|
+
* @throws RenderError (RENDER_ERROR / UNSUPPORTED_FEATURE) or InternalError
|
|
195
|
+
* from the engine itself, unwrapped; a foreign throw from an engine bug
|
|
196
|
+
* also propagates unwrapped (only the public render functions wrap it)
|
|
166
197
|
* @see lib/gvc/gvlayout.c:gvLayoutJobs
|
|
167
198
|
*/
|
|
168
199
|
layout(g: Graph, engineName: EngineName): void;
|
|
169
200
|
/**
|
|
170
201
|
* Release engine layout state after rendering.
|
|
171
202
|
*
|
|
172
|
-
* @throws
|
|
203
|
+
* @throws TypeError (ERR_INVALID_ARG_TYPE / ERR_INVALID_ARG_VALUE) for a
|
|
204
|
+
* bad `g`, or an engine argument that is not registered
|
|
173
205
|
* @see lib/gvc/gvlayout.c:gvFreeLayout
|
|
174
206
|
*/
|
|
175
207
|
freeLayout(g: Graph, engineName: EngineName): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/gvc/context.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;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;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/gvc/context.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;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;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CA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