@knowvah/dot-engine 1.2.7 → 1.4.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.
@@ -85,7 +85,28 @@ export interface NodeGeometry {
85
85
  * in order. An edge with no routed spline produces an empty `points` array.
86
86
  * `label` is present only when the edge carries a centre label.
87
87
  *
88
- * @see lib/common/types.h:ED_spl, ED_label
88
+ * `tailLabel`/`headLabel` are the `taillabel`/`headlabel` port labels. They
89
+ * are present only once the layout has actually *placed* them (C `lp->set`),
90
+ * which is the same gate `render()` applies before emitting the `<text>`:
91
+ * a declared port label that place_portlabel skipped (no spline, IGNORED edge
92
+ * type) still holds calloc-zero coordinates, so it is reported as absent
93
+ * rather than as a label at the origin.
94
+ *
95
+ * `sp`/`ep` are the arrow attachment points. When an end carries an arrow the
96
+ * spline is shortened to leave room for it, and the arrow spans from the
97
+ * terminal control point out to this point — so a consumer drawing its own
98
+ * arrowheads reads the tip here instead of extrapolating one. Each is present
99
+ * only when that end actually has an arrow (C `sflag`/`eflag`); with no arrow
100
+ * the field holds the calloc-zero point, which is not geometry.
101
+ *
102
+ * These are the *attachment* points on the node boundary, verbatim from the
103
+ * bezier — with `arrowhead=none` the spline simply ends there. Graphviz's own
104
+ * renderer insets the arrow polygon it draws by a penwidth-dependent amount
105
+ * (measured: ~1.5pt at `penwidth=1`, ~6.2pt at `penwidth=5`), so `ep` is the
106
+ * point to draw an arrow *to*, not a copy of the rendered polygon's tip.
107
+ *
108
+ * @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label
109
+ * @see lib/common/types.h:bezier (sflag/eflag, sp/ep)
89
110
  */
90
111
  export interface EdgeGeometry {
91
112
  tail: string;
@@ -95,11 +116,43 @@ export interface EdgeGeometry {
95
116
  x: number;
96
117
  y: number;
97
118
  }[];
119
+ /**
120
+ * Arrow attachment point at the tail end, if that end carries an arrow.
121
+ * @see lib/common/types.h:bezier.sp
122
+ */
123
+ sp?: {
124
+ x: number;
125
+ y: number;
126
+ };
127
+ /**
128
+ * Arrow attachment point at the head end, if that end carries an arrow.
129
+ * @see lib/common/types.h:bezier.ep
130
+ */
131
+ ep?: {
132
+ x: number;
133
+ y: number;
134
+ };
98
135
  /** Centre edge label position, if present. @see lib/common/types.h:ED_label */
99
136
  label?: {
100
137
  x: number;
101
138
  y: number;
102
139
  };
140
+ /**
141
+ * `taillabel` position, if placed.
142
+ * @see lib/common/types.h:ED_tail_label
143
+ */
144
+ tailLabel?: {
145
+ x: number;
146
+ y: number;
147
+ };
148
+ /**
149
+ * `headlabel` position, if placed.
150
+ * @see lib/common/types.h:ED_head_label
151
+ */
152
+ headLabel?: {
153
+ x: number;
154
+ y: number;
155
+ };
103
156
  }
104
157
  /**
105
158
  * Per-cluster geometry extracted after layout, in points.
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/api/geometry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS/C,+CAA+C;AAC/C,MAAM,MAAM,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;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AChE,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAqKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,cAAc,CAuB1E"}
package/dist/api.js CHANGED
@@ -686,6 +686,20 @@ function collectEdgePoints(edge, flipY) {
686
686
  }
687
687
  return pts;
688
688
  }
689
+ function placedLabelPos(lbl, flipY) {
690
+ if (lbl === void 0 || !lbl.set) return void 0;
691
+ return { x: lbl.pos.x, y: flipY(lbl.pos.y) };
692
+ }
693
+ function arrowAttachPoints(edge, flipY) {
694
+ const spl = edge.info.spl;
695
+ if (spl === void 0 || spl.size === 0) return {};
696
+ const out = {};
697
+ const first = spl.list[0];
698
+ if (first.sflag !== 0) out.sp = { x: first.sp.x, y: flipY(first.sp.y) };
699
+ const last = spl.list[spl.size - 1];
700
+ if (last.eflag !== 0) out.ep = { x: last.ep.x, y: flipY(last.ep.y) };
701
+ return out;
702
+ }
689
703
  function snapshotEdge(edge, flipY) {
690
704
  const geom = {
691
705
  tail: edge.tail.name,
@@ -696,6 +710,13 @@ function snapshotEdge(edge, flipY) {
696
710
  if (lbl !== void 0) {
697
711
  geom.label = { x: lbl.pos.x, y: flipY(lbl.pos.y) };
698
712
  }
713
+ const tailLabel = placedLabelPos(edge.info.tail_label, flipY);
714
+ if (tailLabel !== void 0) geom.tailLabel = tailLabel;
715
+ const headLabel = placedLabelPos(edge.info.head_label, flipY);
716
+ if (headLabel !== void 0) geom.headLabel = headLabel;
717
+ const { sp, ep } = arrowAttachPoints(edge, flipY);
718
+ if (sp !== void 0) geom.sp = sp;
719
+ if (ep !== void 0) geom.ep = ep;
699
720
  return geom;
700
721
  }
701
722
  function snapshotCluster(sg, yAxis, flipY) {