@knowvah/dot-engine 2.11.0 → 2.12.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/dist/common/agerr.d.ts +12 -0
- package/dist/common/agerr.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -15
- package/dist/index.js.map +3 -3
- package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/render.js +63 -15
- package/dist/render.js.map +3 -3
- package/package.json +1 -1
- package/src/common/agerr.ts +49 -1
- package/src/index.ts +4 -0
- package/src/layout/dot/edge-route-chain.ts +79 -7
- package/src/layout/dot/splines.ts +2 -2
- package/src/layout/fdp/index.ts +2 -2
- package/src/layout/neato/sgd.ts +3 -9
package/dist/common/agerr.d.ts
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
export type AgerrLevel = 'error' | 'warning' | 'prev';
|
|
3
3
|
/** The console channel a line goes to. */
|
|
4
4
|
export type AgerrChannel = 'warn' | 'error';
|
|
5
|
+
/**
|
|
6
|
+
* C's `agusererrf`: called with each piece of a message as `out` writes it.
|
|
7
|
+
* The return value is ignored, as C ignores it.
|
|
8
|
+
* @see lib/cgraph/cgraph.h:agusererrf
|
|
9
|
+
*/
|
|
10
|
+
export type AgUserErrF = (message: string) => number | void;
|
|
11
|
+
/**
|
|
12
|
+
* Set the function that receives engine messages in place of the console;
|
|
13
|
+
* null restores the console. Returns the previous function.
|
|
14
|
+
* @see lib/cgraph/agerror.c:agseterrf
|
|
15
|
+
*/
|
|
16
|
+
export declare function agseterrf(newf: AgUserErrF | null): AgUserErrF | null;
|
|
5
17
|
/**
|
|
6
18
|
* `default_usererrf`: every character that `gv_iscntrl(c) && !gv_isspace(c)`
|
|
7
19
|
* (0x00-0x1F except `\t\n\v\f\r`, and 0x7F) is written as `\ooo`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agerr.d.ts","sourceRoot":"","sources":["../../src/common/agerr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agerr.d.ts","sourceRoot":"","sources":["../../src/common/agerr.ts"],"names":[],"mappings":"AAuBA,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtD,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAwB5C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;AAS5D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,GAAG,IAAI,CAIpE;AAOD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASrD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGrE;AA8DD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAEzF;AAED,yCAAyC;AACzC,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,UAAU,YAAY,KAAG,IAAoC,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,EAAE,UAAU,YAAY,KAAG,IACjC,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAExE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export { parse } from './parser/index.js';
|
|
|
54
54
|
export { ParseError } from './parser/index.js';
|
|
55
55
|
export { DotEngineError, InternalError, RenderError, isGvError } from './errors.js';
|
|
56
56
|
export type { GvError, UsageErrorCode, GvErrorType, GvErrorCode, GvExpectation, RenderResult, } from './errors.js';
|
|
57
|
+
export { agseterrf } from './common/agerr.js';
|
|
58
|
+
export type { AgUserErrF } from './common/agerr.js';
|
|
57
59
|
export { setImageSizer } from './gvc/usershape.js';
|
|
58
60
|
export type { ImageSizer } from './common/htmltable-types.js';
|
|
59
61
|
export { setImageResolver } from './gvc/image-resolver.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAoCnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAgBvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,YAAY,CAShF;AAED,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpF,YAAY,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":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CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMlE,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAU9D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,12 @@ var OCTAL_WIDTH = 3;
|
|
|
18
18
|
var OCTAL_RADIX = 8;
|
|
19
19
|
var lastLevel = "warning";
|
|
20
20
|
var pending = { line: null, channel: "warn" };
|
|
21
|
+
var usererrf = null;
|
|
22
|
+
function agseterrf(newf) {
|
|
23
|
+
const oldf = usererrf;
|
|
24
|
+
usererrf = newf;
|
|
25
|
+
return oldf;
|
|
26
|
+
}
|
|
21
27
|
registerRenderState(() => {
|
|
22
28
|
flushPending();
|
|
23
29
|
lastLevel = "warning";
|
|
@@ -43,7 +49,9 @@ function flushPending() {
|
|
|
43
49
|
writeLine(channel, line);
|
|
44
50
|
}
|
|
45
51
|
function writeLine(channel, line) {
|
|
46
|
-
if (
|
|
52
|
+
if (usererrf !== null) usererrf(`${line}
|
|
53
|
+
`);
|
|
54
|
+
else if (channel === "warn") console.warn(escapeControl(line));
|
|
47
55
|
else console.error(escapeControl(line));
|
|
48
56
|
}
|
|
49
57
|
function assemble(level, msg) {
|
|
@@ -51,6 +59,13 @@ function assemble(level, msg) {
|
|
|
51
59
|
const prefix = level === "error" ? PREFIX_ERROR : PREFIX_WARNING;
|
|
52
60
|
return `${prefix}${PREFIX_SEP}${msg}`;
|
|
53
61
|
}
|
|
62
|
+
function outToUser(errf, level, msg) {
|
|
63
|
+
if (level !== "prev") {
|
|
64
|
+
errf(level === "error" ? PREFIX_ERROR : PREFIX_WARNING);
|
|
65
|
+
errf(PREFIX_SEP);
|
|
66
|
+
}
|
|
67
|
+
errf(msg);
|
|
68
|
+
}
|
|
54
69
|
function channelOf(level) {
|
|
55
70
|
const eff = level === "prev" ? lastLevel : level;
|
|
56
71
|
return eff === "warning" ? "warn" : "error";
|
|
@@ -58,6 +73,12 @@ function channelOf(level) {
|
|
|
58
73
|
function emit(level, msg, channel, hold) {
|
|
59
74
|
const target = channel ?? channelOf(level);
|
|
60
75
|
if (level !== "prev") lastLevel = level;
|
|
76
|
+
if (usererrf !== null) {
|
|
77
|
+
flushPending();
|
|
78
|
+
outToUser(usererrf, level, hold ? msg : `${msg}
|
|
79
|
+
`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
61
82
|
const text = assemble(level, msg);
|
|
62
83
|
if (pending.line === null) {
|
|
63
84
|
pending.channel = target;
|
|
@@ -34636,10 +34657,46 @@ function routeChainSegmented(g, beginEdge, endEdge, segs) {
|
|
|
34636
34657
|
}
|
|
34637
34658
|
return finishChain(w, endEdge, segs[ei], segFirst, segs) ? w.pts : null;
|
|
34638
34659
|
}
|
|
34639
|
-
function
|
|
34660
|
+
function copyPort2(p) {
|
|
34661
|
+
return { ...p, p: { ...p.p } };
|
|
34662
|
+
}
|
|
34663
|
+
function hackflagBeginView(e, back, firstVnode) {
|
|
34664
|
+
const tailPort = back ? e.info.head_port : e.info.tail_port;
|
|
34665
|
+
return {
|
|
34666
|
+
...e,
|
|
34667
|
+
tail: back ? e.head : e.tail,
|
|
34668
|
+
head: firstVnode,
|
|
34669
|
+
info: {
|
|
34670
|
+
...e.info,
|
|
34671
|
+
tail_port: copyPort2(tailPort),
|
|
34672
|
+
head_port: { ...copyPort2(e.info.head_port), defined: false, p: { x: 0, y: 0 } },
|
|
34673
|
+
edge_type: VIRTUAL,
|
|
34674
|
+
to_orig: e
|
|
34675
|
+
}
|
|
34676
|
+
};
|
|
34677
|
+
}
|
|
34678
|
+
function hackflagEndView(e, back) {
|
|
34679
|
+
if (back) return makeFwdEdge(e);
|
|
34680
|
+
return {
|
|
34681
|
+
...e,
|
|
34682
|
+
info: { ...e.info, tail_port: copyPort2(e.info.tail_port), head_port: copyPort2(e.info.head_port) }
|
|
34683
|
+
};
|
|
34684
|
+
}
|
|
34685
|
+
function chainEnds(e, segs) {
|
|
34686
|
+
const first = segs[0];
|
|
34687
|
+
const last = segs[segs.length - 1];
|
|
34688
|
+
const orig = resolveOrigEdge(e);
|
|
34689
|
+
if (resolveOrigEdge(first) === orig) return [first, last];
|
|
34690
|
+
const back = (orig.head.info.rank ?? 0) < (orig.tail.info.rank ?? 0);
|
|
34691
|
+
return [hackflagBeginView(orig, back, first.head), hackflagEndView(orig, back)];
|
|
34692
|
+
}
|
|
34693
|
+
function spansRanksForward(g, e) {
|
|
34640
34694
|
const r = e.tail.info.rank;
|
|
34641
34695
|
const rh = e.head.info.rank;
|
|
34642
|
-
|
|
34696
|
+
return g.info.rank !== void 0 && r !== void 0 && rh !== void 0 && rh > r + 1;
|
|
34697
|
+
}
|
|
34698
|
+
function routeMultiRankEdgeFaithful(g, e) {
|
|
34699
|
+
if (!spansRanksForward(g, e)) return null;
|
|
34643
34700
|
const et = edgeType(g);
|
|
34644
34701
|
if (et === EDGETYPE_LINE) {
|
|
34645
34702
|
const line = makeLineEdge(g, e);
|
|
@@ -34647,7 +34704,8 @@ function routeMultiRankEdgeFaithful(g, e) {
|
|
|
34647
34704
|
}
|
|
34648
34705
|
const segs = chainSegments(e);
|
|
34649
34706
|
if (segs.length === 0 || segs[segs.length - 1].head !== e.head) return null;
|
|
34650
|
-
|
|
34707
|
+
const [beginEdge, endEdge] = chainEnds(e, segs);
|
|
34708
|
+
return routeChainSegmented(g, beginEdge, endEdge, segs) ?? "lost";
|
|
34651
34709
|
}
|
|
34652
34710
|
function entryRunSegments(e) {
|
|
34653
34711
|
const segs = [e];
|
|
@@ -34718,7 +34776,8 @@ function routeBackEdge(e, _tailBox, _headBox, g) {
|
|
|
34718
34776
|
const segs = backChainSegments(e);
|
|
34719
34777
|
if (segs.length < 2 || segs[segs.length - 1].head !== e.tail) return;
|
|
34720
34778
|
const fwdEdge = makeFwdEdge(e);
|
|
34721
|
-
const
|
|
34779
|
+
const [beginEdge, endEdge] = chainEnds(e, segs);
|
|
34780
|
+
const fwd = routeChainSegmented(g, beginEdge, endEdge, segs);
|
|
34722
34781
|
if (fwd === null) {
|
|
34723
34782
|
e.info.lost = true;
|
|
34724
34783
|
return;
|
|
@@ -40830,7 +40889,7 @@ function orthoDispatch(g) {
|
|
|
40830
40889
|
function curvedTop(g) {
|
|
40831
40890
|
resetRW(g);
|
|
40832
40891
|
if (((g.root.info.has_labels ?? 0) & EDGE_LABEL) !== 0) {
|
|
40833
|
-
|
|
40892
|
+
agwarningf("edge labels with splines=curved not supported in dot - use xlabels");
|
|
40834
40893
|
}
|
|
40835
40894
|
}
|
|
40836
40895
|
function finalizeSplines(g, et, normalize) {
|
|
@@ -43423,17 +43482,11 @@ function buildUnfixed(g, n) {
|
|
|
43423
43482
|
}
|
|
43424
43483
|
function resolveModel(model) {
|
|
43425
43484
|
if (model === MODEL_CIRCUIT) {
|
|
43426
|
-
|
|
43427
|
-
"warn",
|
|
43428
|
-
"circuit model not yet supported in Gmode=sgd, reverting to shortpath model"
|
|
43429
|
-
);
|
|
43485
|
+
agwarningf("circuit model not yet supported in Gmode=sgd, reverting to shortpath model");
|
|
43430
43486
|
return MODEL_SHORTPATH;
|
|
43431
43487
|
}
|
|
43432
43488
|
if (model === MODEL_MDS) {
|
|
43433
|
-
|
|
43434
|
-
"warn",
|
|
43435
|
-
"mds model not yet supported in Gmode=sgd, reverting to shortpath model"
|
|
43436
|
-
);
|
|
43489
|
+
agwarningf("mds model not yet supported in Gmode=sgd, reverting to shortpath model");
|
|
43437
43490
|
return MODEL_SHORTPATH;
|
|
43438
43491
|
}
|
|
43439
43492
|
return model;
|
|
@@ -56986,7 +57039,7 @@ function fdpSplines(g) {
|
|
|
56986
57039
|
);
|
|
56987
57040
|
}
|
|
56988
57041
|
if (g.info.n_cluster_edges) {
|
|
56989
|
-
|
|
57042
|
+
agwarningf(CLUSTER_EDGE_WARNING);
|
|
56990
57043
|
et = EDGETYPE_LINE;
|
|
56991
57044
|
} else {
|
|
56992
57045
|
splineEdges1(g, et);
|
|
@@ -62875,6 +62928,7 @@ export {
|
|
|
62875
62928
|
ParseError,
|
|
62876
62929
|
RenderError,
|
|
62877
62930
|
addEdge4 as addEdge,
|
|
62931
|
+
agseterrf,
|
|
62878
62932
|
createGraph,
|
|
62879
62933
|
getDrawOps,
|
|
62880
62934
|
getLayout,
|