@knowvah/dot-engine 1.2.2 → 1.2.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.
@@ -28,6 +28,14 @@ export declare function arrowheadPolygon(arrowTip: Point, arrowDir: Point, penwi
28
28
  /** Minimal edge shape exposing the arrow-related attributes. */
29
29
  interface ArrowAttrEdge {
30
30
  attrs: Map<string, string>;
31
+ /** Present on real edges; the curve generator needs the rankdir frame. */
32
+ tail?: {
33
+ root?: {
34
+ info?: {
35
+ rankdir?: number;
36
+ };
37
+ };
38
+ };
31
39
  }
32
40
  /** The arrowhead/arrowtail name for an edge end (default "normal"). */
33
41
  export declare function edgeArrowName(e: ArrowAttrEdge, end: 'head' | 'tail'): string;
@@ -1 +1 @@
1
- {"version":3,"file":"edge-route-arrow.d.ts","sourceRoot":"","sources":["../../../src/layout/dot/edge-route-arrow.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAIjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,gFAAgF;AAChF,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,SAAM,GAAG,KAAK,EAAE,CAe1F;AAOD,gEAAgE;AAChE,UAAU,aAAa;IAAG,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE;AAEtD,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG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,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAC/E,WAAW,EAAE,CAMf"}
@@ -109,6 +109,11 @@ export type Port = {
109
109
  * @see lib/common/geom.c:ccwrotatepf
110
110
  */
111
111
  export declare function ccwrotatepf(p: Point, ccwrot: number): Point;
112
+ /**
113
+ * Clockwise counterpart — the exact inverse of {@link ccwrotatepf} per case.
114
+ * @see lib/common/geom.c:cwrotatepf
115
+ */
116
+ export declare function cwrotatepf(p: Point, cwrot: number): Point;
112
117
  /**
113
118
  * Returns true if box `b0` completely contains box `b1`.
114
119
  *
@@ -1 +1 @@
1
- {"version":3,"file":"geom.d.ts","sourceRoot":"","sources":["../../src/model/geom.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAMH;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAM7C;;;;;;;;GAQG;AACH,MAAM,MAAM,GAAG,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAM3C;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,4CAA4C;IAC5C,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,EAAE,EAAE,KAAK,CAAC;IACV,yCAAyC;IACzC,EAAE,EAAE,KAAK,CAAC;CACX,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,E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3D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAQzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,OAAO,CAOrD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,OAAO,CAOpD;AAMD;;;;GAIG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,WAAW,MAAO,CAAC"}
package/dist/render.js CHANGED
@@ -7597,6 +7597,40 @@ function miterShape(baseLeft, P, baseRight, penwidth) {
7597
7597
  return [{ x: P1.x + l * a.cos, y: P1.y + l * a.sin }, P1, P2];
7598
7598
  }
7599
7599
 
7600
+ // src/model/geom.ts
7601
+ function ccwrotatepf(p, ccwrot) {
7602
+ switch (ccwrot) {
7603
+ case 0:
7604
+ return p;
7605
+ case 90:
7606
+ return { x: -p.y, y: p.x };
7607
+ case 180:
7608
+ return { x: p.x, y: -p.y };
7609
+ case 270:
7610
+ return { x: p.y, y: p.x };
7611
+ default:
7612
+ return p;
7613
+ }
7614
+ }
7615
+ function cwrotatepf(p, cwrot) {
7616
+ switch (cwrot) {
7617
+ case 0:
7618
+ return p;
7619
+ case 90:
7620
+ return { x: p.y, y: -p.x };
7621
+ case 180:
7622
+ return { x: p.x, y: -p.y };
7623
+ case 270:
7624
+ return { x: p.y, y: p.x };
7625
+ default:
7626
+ return p;
7627
+ }
7628
+ }
7629
+ function boxOverlap(b0, b1) {
7630
+ return b0.ur.x >= b1.ll.x && b1.ur.x >= b0.ll.x && b0.ur.y >= b1.ll.y && b1.ur.y >= b0.ll.y;
7631
+ }
7632
+ var POINTS_PER_INCH = 72;
7633
+
7600
7634
  // src/common/arrows-shapes-poly.ts
7601
7635
  var CROW_ARROWWIDTH = 0.45;
7602
7636
  function crowBasePoints(u, v, flag) {
@@ -7758,7 +7792,15 @@ function curveControlPoints(p, v, w, flag) {
7758
7792
  const AF2 = { x: p.x - 0.95 * v.x + w.x + s * w.x * (4 / 3), y: AF3.y + s * w.y * (4 / 3) };
7759
7793
  return [AF0, AF1, AF2, AF3];
7760
7794
  }
7761
- function genCurve(p0, u, _arrowsize, penwidth, flag) {
7795
+ function genCurve(p0, u, _arrowsize, penwidth, flag, rankdir = 0) {
7796
+ if (rankdir !== 0) {
7797
+ const rot = rankdir * 90;
7798
+ const fin = genCurve(ccwrotatepf(p0, rot), ccwrotatepf(u, rot), _arrowsize, penwidth, flag);
7799
+ return {
7800
+ ops: fin.ops.map((op) => "points" in op ? { ...op, points: op.points.map((pt) => cwrotatepf(pt, rot)) } : op),
7801
+ q: cwrotatepf(fin.q, rot)
7802
+ };
7803
+ }
7762
7804
  const arrowwidth = penwidth > 4 ? 0.5 * penwidth / 4 : 0.5;
7763
7805
  const noShift = flag & ARR_MOD_INV || u.x === 0 && u.y === 0;
7764
7806
  const p = noShift ? p0 : vsub(p0, backwardDelta(u, penwidth));
@@ -7973,7 +8015,7 @@ function arrowLength(comps, arrowsize, penwidth) {
7973
8015
  for (let i = 0; i < n; i++) length += arrowLengthOne(comps[i], arrowsize, penwidth);
7974
8016
  return length;
7975
8017
  }
7976
- function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
8018
+ function dispatchSimple(r, tip2, dir, arrowsize, penwidth, rankdir = 0) {
7977
8019
  const flag = arrowFlag(r);
7978
8020
  const u = componentU(dir, r.lenfact, arrowsize);
7979
8021
  switch (r.type & ARR_TYPE_MASK) {
@@ -7987,8 +8029,10 @@ function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
7987
8029
  return genDiamond(tip2, u, arrowsize, penwidth, flag);
7988
8030
  case ARR_TYPE_DOT:
7989
8031
  return genDot(tip2, u, arrowsize, penwidth, flag);
8032
+ // curve is the one generator that is not rotation-equivariant; it needs
8033
+ // the rankdir to reproduce C's render-time (final-frame) generation.
7990
8034
  case ARR_TYPE_CURVE:
7991
- return genCurve(tip2, u, arrowsize, penwidth, flag);
8035
+ return genCurve(tip2, u, arrowsize, penwidth, flag, rankdir);
7992
8036
  case ARR_TYPE_GAP:
7993
8037
  return genGap(tip2, u, arrowsize, penwidth, flag);
7994
8038
  case ARR_TYPE_NORM:
@@ -7996,14 +8040,14 @@ function dispatchSimple(r, tip2, dir, arrowsize, penwidth) {
7996
8040
  return genNormal(tip2, u, arrowsize, penwidth, flag);
7997
8041
  }
7998
8042
  }
7999
- function arrowDrawOps(comps, tip2, dir, arrowsize, penwidth) {
8043
+ function arrowDrawOps(comps, tip2, dir, arrowsize, penwidth, rankdir = 0) {
8000
8044
  const ops = [];
8001
8045
  let p = tip2;
8002
8046
  const n = Math.min(comps.length, 4);
8003
8047
  for (let i = 0; i < n; i++) {
8004
8048
  const r = comps[i];
8005
8049
  if ((r.type & ARR_TYPE_MASK) === ARR_TYPE_NONE) break;
8006
- const res = dispatchSimple(r, p, dir, arrowsize, penwidth);
8050
+ const res = dispatchSimple(r, p, dir, arrowsize, penwidth, rankdir);
8007
8051
  ops.push(...res.ops);
8008
8052
  p = res.q;
8009
8053
  }
@@ -8147,7 +8191,8 @@ function edgeArrowsize(e) {
8147
8191
  }
8148
8192
  function arrowDrawOpsForEnd(e, end, tip2, dir, penwidth) {
8149
8193
  const comps = parseArrow(edgeArrowName(e, end)).map(resolveArrowType);
8150
- return arrowDrawOps(comps, tip2, dir, edgeArrowsize(e), penwidth);
8194
+ const rankdir = (e.tail?.root?.info?.rankdir ?? 0) & 3;
8195
+ return arrowDrawOps(comps, tip2, dir, edgeArrowsize(e), penwidth, rankdir);
8151
8196
  }
8152
8197
 
8153
8198
  // src/model/layoutParams.ts
@@ -8501,26 +8546,6 @@ var RenderJob = class {
8501
8546
  }
8502
8547
  };
8503
8548
 
8504
- // src/model/geom.ts
8505
- function ccwrotatepf(p, ccwrot) {
8506
- switch (ccwrot) {
8507
- case 0:
8508
- return p;
8509
- case 90:
8510
- return { x: -p.y, y: p.x };
8511
- case 180:
8512
- return { x: p.x, y: -p.y };
8513
- case 270:
8514
- return { x: p.y, y: p.x };
8515
- default:
8516
- return p;
8517
- }
8518
- }
8519
- function boxOverlap(b0, b1) {
8520
- return b0.ur.x >= b1.ll.x && b1.ur.x >= b0.ll.x && b0.ur.y >= b1.ll.y && b1.ur.y >= b0.ll.y;
8521
- }
8522
- var POINTS_PER_INCH = 72;
8523
-
8524
8549
  // src/model/graphInfo.ts
8525
8550
  function makeGraphInfo() {
8526
8551
  return {
@@ -16663,7 +16688,7 @@ function gdRankdir(n) {
16663
16688
  function gdFlip(n) {
16664
16689
  return (gdRankdir(n) & 1) !== 0;
16665
16690
  }
16666
- function cwrotatepf(p, cwrot) {
16691
+ function cwrotatepf2(p, cwrot) {
16667
16692
  switch (cwrot) {
16668
16693
  case 90:
16669
16694
  return { x: p.y, y: -p.x };
@@ -16810,7 +16835,7 @@ function setOrder(pp, q) {
16810
16835
  pp.order = MC_SCALE * a / (2 * Math.PI) | 0;
16811
16836
  }
16812
16837
  function applyDir(pp, bp, dir, rd, definedFinal) {
16813
- const q = cwrotatepf(dir.p, 90 * rd);
16838
+ const q = cwrotatepf2(dir.p, 90 * rd);
16814
16839
  pp.p = q;
16815
16840
  pp.bp = bp;
16816
16841
  pp.side = dir.dyna ? dir.side : invflipSide(dir.side, rd);
@@ -16826,7 +16851,7 @@ function nodeInsideFn(n) {
16826
16851
  }
16827
16852
  function compassPoint(n, insideFn, yArg, xArg, rd) {
16828
16853
  let p = { x: xArg, y: yArg };
16829
- if (rd) p = cwrotatepf(p, 90 * rd);
16854
+ if (rd) p = cwrotatepf2(p, 90 * rd);
16830
16855
  const curve = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: p.x, y: p.y }, { x: p.x, y: p.y }];
16831
16856
  const ctx = { nodeCoord: n.info.coord, rw: n.info.rw, bp: null, node: n };
16832
16857
  bezierClip(ctx, insideFn, curve, true);