@knowvah/dot-engine 1.5.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 +16 -1
- package/dist/api/geometry.d.ts.map +1 -1
- package/dist/api.js +2 -0
- package/dist/api.js.map +2 -2
- package/dist/index.js +2 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/api/geometry.ts +17 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knowvah/dot-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Faithful TypeScript port of Graphviz (dot, neato, fdp, sfdp, circo, twopi, osage, patchwork) — no C: no native binary, no WASM. Oracle-verified against the C implementation, runs in the browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphviz",
|
package/src/api/geometry.ts
CHANGED
|
@@ -106,6 +106,12 @@ export interface NodeGeometry {
|
|
|
106
106
|
* type) still holds calloc-zero coordinates, so it is reported as absent
|
|
107
107
|
* rather than as a label at the origin.
|
|
108
108
|
*
|
|
109
|
+
* `xlabel` is the `xlabel` external label, positioned by the force-placement
|
|
110
|
+
* search rather than by spline midpoint arithmetic, so it is not derivable
|
|
111
|
+
* from `label` or `points`. It carries the same `lp->set` gate: a declared
|
|
112
|
+
* xlabel the search could not fit is reported as absent, exactly as
|
|
113
|
+
* `render()` declines to draw it.
|
|
114
|
+
*
|
|
109
115
|
* `sp`/`ep` are the arrow attachment points. When an end carries an arrow the
|
|
110
116
|
* spline is shortened to leave room for it, and the arrow spans from the
|
|
111
117
|
* terminal control point out to this point — so a consumer drawing its own
|
|
@@ -119,7 +125,8 @@ export interface NodeGeometry {
|
|
|
119
125
|
* (measured: ~1.5pt at `penwidth=1`, ~6.2pt at `penwidth=5`), so `ep` is the
|
|
120
126
|
* point to draw an arrow *to*, not a copy of the rendered polygon's tip.
|
|
121
127
|
*
|
|
122
|
-
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label
|
|
128
|
+
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label,
|
|
129
|
+
* ED_xlabel
|
|
123
130
|
* @see lib/common/types.h:bezier (sflag/eflag, sp/ep)
|
|
124
131
|
*/
|
|
125
132
|
export interface EdgeGeometry {
|
|
@@ -149,6 +156,11 @@ export interface EdgeGeometry {
|
|
|
149
156
|
* @see lib/common/types.h:ED_head_label
|
|
150
157
|
*/
|
|
151
158
|
headLabel?: { x: number; y: number };
|
|
159
|
+
/**
|
|
160
|
+
* `xlabel` (external label) position, if placed.
|
|
161
|
+
* @see lib/common/types.h:ED_xlabel
|
|
162
|
+
*/
|
|
163
|
+
xlabel?: { x: number; y: number };
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
/**
|
|
@@ -301,8 +313,8 @@ function arrowAttachPoints(
|
|
|
301
313
|
|
|
302
314
|
/**
|
|
303
315
|
* Snapshot one edge's geometry.
|
|
304
|
-
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label
|
|
305
|
-
* (textlabel_t.pos), bezier.sp/ep
|
|
316
|
+
* @see lib/common/types.h:ED_spl, ED_label, ED_tail_label, ED_head_label,
|
|
317
|
+
* ED_xlabel (textlabel_t.pos), bezier.sp/ep
|
|
306
318
|
*/
|
|
307
319
|
function snapshotEdge(edge: Edge, flipY: (y: number) => number): EdgeGeometry {
|
|
308
320
|
const geom: EdgeGeometry = {
|
|
@@ -318,6 +330,8 @@ function snapshotEdge(edge: Edge, flipY: (y: number) => number): EdgeGeometry {
|
|
|
318
330
|
if (tailLabel !== undefined) geom.tailLabel = tailLabel;
|
|
319
331
|
const headLabel = placedLabelPos(edge.info.head_label, flipY);
|
|
320
332
|
if (headLabel !== undefined) geom.headLabel = headLabel;
|
|
333
|
+
const xlabel = placedLabelPos(edge.info.xlabel, flipY);
|
|
334
|
+
if (xlabel !== undefined) geom.xlabel = xlabel;
|
|
321
335
|
const { sp, ep } = arrowAttachPoints(edge, flipY);
|
|
322
336
|
if (sp !== undefined) geom.sp = sp;
|
|
323
337
|
if (ep !== undefined) geom.ep = ep;
|