@knowvah/dot-engine 1.4.0 → 1.6.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/api/geometry.d.ts +36 -1
- package/dist/api/geometry.d.ts.map +1 -1
- package/dist/api.js +13 -1
- package/dist/api.js.map +2 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/api/geometry.ts +48 -4
package/dist/api/geometry.d.ts
CHANGED
|
@@ -92,6 +92,12 @@ export interface NodeGeometry {
|
|
|
92
92
|
* type) still holds calloc-zero coordinates, so it is reported as absent
|
|
93
93
|
* rather than as a label at the origin.
|
|
94
94
|
*
|
|
95
|
+
* `xlabel` is the `xlabel` external label, positioned by the force-placement
|
|
96
|
+
* search rather than by spline midpoint arithmetic, so it is not derivable
|
|
97
|
+
* from `label` or `points`. It carries the same `lp->set` gate: a declared
|
|
98
|
+
* xlabel the search could not fit is reported as absent, exactly as
|
|
99
|
+
* `render()` declines to draw it.
|
|
100
|
+
*
|
|
95
101
|
* `sp`/`ep` are the arrow attachment points. When an end carries an arrow the
|
|
96
102
|
* spline is shortened to leave room for it, and the arrow spans from the
|
|
97
103
|
* terminal control point out to this point — so a consumer drawing its own
|
|
@@ -105,7 +111,8 @@ export interface NodeGeometry {
|
|
|
105
111
|
* (measured: ~1.5pt at `penwidth=1`, ~6.2pt at `penwidth=5`), so `ep` is the
|
|
106
112
|
* point to draw an arrow *to*, not a copy of the rendered polygon's tip.
|
|
107
113
|
*
|
|
108
|
-
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label
|
|
114
|
+
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label,
|
|
115
|
+
* ED_xlabel
|
|
109
116
|
* @see lib/common/types.h:bezier (sflag/eflag, sp/ep)
|
|
110
117
|
*/
|
|
111
118
|
export interface EdgeGeometry {
|
|
@@ -153,6 +160,14 @@ export interface EdgeGeometry {
|
|
|
153
160
|
x: number;
|
|
154
161
|
y: number;
|
|
155
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* `xlabel` (external label) position, if placed.
|
|
165
|
+
* @see lib/common/types.h:ED_xlabel
|
|
166
|
+
*/
|
|
167
|
+
xlabel?: {
|
|
168
|
+
x: number;
|
|
169
|
+
y: number;
|
|
170
|
+
};
|
|
156
171
|
}
|
|
157
172
|
/**
|
|
158
173
|
* Per-cluster geometry extracted after layout, in points.
|
|
@@ -167,7 +182,15 @@ export interface EdgeGeometry {
|
|
|
167
182
|
* `class="cluster"` polygon, so a consumer quantizing to SVG precision gets
|
|
168
183
|
* byte-conformant geometry.
|
|
169
184
|
*
|
|
185
|
+
* `label` is the cluster title's placed position and measured size, present
|
|
186
|
+
* only when the cluster declares a label. Unlike the edge port labels, it is
|
|
187
|
+
* *not* gated on the label's `set` flag: C draws a cluster label on existence
|
|
188
|
+
* alone (emit.c:3920 has no `->set` test, unlike emit_edge_label:2891), so an
|
|
189
|
+
* unplaced one still renders at whatever pos it holds. Gating here would hide
|
|
190
|
+
* geometry `render()` acts on.
|
|
191
|
+
*
|
|
170
192
|
* @see lib/common/types.h:GD_bb (of a cluster subgraph)
|
|
193
|
+
* @see lib/common/types.h:GD_label (textlabel_t.pos / .dimen)
|
|
171
194
|
*/
|
|
172
195
|
export interface ClusterGeometry {
|
|
173
196
|
/** Cluster subgraph name (e.g. `cluster6`); encodes nesting. */
|
|
@@ -176,6 +199,18 @@ export interface ClusterGeometry {
|
|
|
176
199
|
y: number;
|
|
177
200
|
width: number;
|
|
178
201
|
height: number;
|
|
202
|
+
/**
|
|
203
|
+
* Cluster label placement, if the cluster has one. `x`/`y` are the **centre**
|
|
204
|
+
* of the label space (matching `EdgeGeometry.label`, not the box corner
|
|
205
|
+
* `x`/`y` above); `width`/`height` are its measured size.
|
|
206
|
+
* @see lib/common/postproc.c:place_graph_label
|
|
207
|
+
*/
|
|
208
|
+
label?: {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
width: number;
|
|
212
|
+
height: number;
|
|
213
|
+
};
|
|
179
214
|
}
|
|
180
215
|
/**
|
|
181
216
|
* Plain, JSON-serializable snapshot of the graph's computed geometry.
|
|
@@ -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;AAU/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;CAChB;AAED
|
|
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;AAU/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;CAA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E;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE;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;AAsLD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,cAAc,CAuB1E"}
|
package/dist/api.js
CHANGED
|
@@ -714,6 +714,8 @@ function snapshotEdge(edge, flipY) {
|
|
|
714
714
|
if (tailLabel !== void 0) geom.tailLabel = tailLabel;
|
|
715
715
|
const headLabel = placedLabelPos(edge.info.head_label, flipY);
|
|
716
716
|
if (headLabel !== void 0) geom.headLabel = headLabel;
|
|
717
|
+
const xlabel = placedLabelPos(edge.info.xlabel, flipY);
|
|
718
|
+
if (xlabel !== void 0) geom.xlabel = xlabel;
|
|
717
719
|
const { sp, ep } = arrowAttachPoints(edge, flipY);
|
|
718
720
|
if (sp !== void 0) geom.sp = sp;
|
|
719
721
|
if (ep !== void 0) geom.ep = ep;
|
|
@@ -721,7 +723,7 @@ function snapshotEdge(edge, flipY) {
|
|
|
721
723
|
}
|
|
722
724
|
function snapshotCluster(sg, yAxis, flipY) {
|
|
723
725
|
const bb = sg.info.bb;
|
|
724
|
-
|
|
726
|
+
const geom = {
|
|
725
727
|
name: sg.name,
|
|
726
728
|
x: bb.ll.x,
|
|
727
729
|
// 'up' keeps the lower-left y; 'down' flips the upper-right y to the
|
|
@@ -730,6 +732,16 @@ function snapshotCluster(sg, yAxis, flipY) {
|
|
|
730
732
|
width: bb.ur.x - bb.ll.x,
|
|
731
733
|
height: bb.ur.y - bb.ll.y
|
|
732
734
|
};
|
|
735
|
+
const lab = sg.info.label;
|
|
736
|
+
if (lab !== void 0) {
|
|
737
|
+
geom.label = {
|
|
738
|
+
x: lab.pos.x,
|
|
739
|
+
y: flipY(lab.pos.y),
|
|
740
|
+
width: lab.dimen.x,
|
|
741
|
+
height: lab.dimen.y
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
return geom;
|
|
733
745
|
}
|
|
734
746
|
function collectClusters(sg, yAxis, flipY, out) {
|
|
735
747
|
for (const c of sg.info.clust ?? []) {
|