@knowvah/dot-engine 1.4.0 → 1.5.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.
@@ -167,7 +167,15 @@ export interface EdgeGeometry {
167
167
  * `class="cluster"` polygon, so a consumer quantizing to SVG precision gets
168
168
  * byte-conformant geometry.
169
169
  *
170
+ * `label` is the cluster title's placed position and measured size, present
171
+ * only when the cluster declares a label. Unlike the edge port labels, it is
172
+ * *not* gated on the label's `set` flag: C draws a cluster label on existence
173
+ * alone (emit.c:3920 has no `->set` test, unlike emit_edge_label:2891), so an
174
+ * unplaced one still renders at whatever pos it holds. Gating here would hide
175
+ * geometry `render()` acts on.
176
+ *
170
177
  * @see lib/common/types.h:GD_bb (of a cluster subgraph)
178
+ * @see lib/common/types.h:GD_label (textlabel_t.pos / .dimen)
171
179
  */
172
180
  export interface ClusterGeometry {
173
181
  /** Cluster subgraph name (e.g. `cluster6`); encodes nesting. */
@@ -176,6 +184,18 @@ export interface ClusterGeometry {
176
184
  y: number;
177
185
  width: number;
178
186
  height: number;
187
+ /**
188
+ * Cluster label placement, if the cluster has one. `x`/`y` are the **centre**
189
+ * of the label space (matching `EdgeGeometry.label`, not the box corner
190
+ * `x`/`y` above); `width`/`height` are its measured size.
191
+ * @see lib/common/postproc.c:place_graph_label
192
+ */
193
+ label?: {
194
+ x: number;
195
+ y: number;
196
+ width: number;
197
+ height: number;
198
+ };
179
199
  }
180
200
  /**
181
201
  * 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,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AA;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;AAoLD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,cAAc,CAuB1E"}
package/dist/api.js CHANGED
@@ -721,7 +721,7 @@ function snapshotEdge(edge, flipY) {
721
721
  }
722
722
  function snapshotCluster(sg, yAxis, flipY) {
723
723
  const bb = sg.info.bb;
724
- return {
724
+ const geom = {
725
725
  name: sg.name,
726
726
  x: bb.ll.x,
727
727
  // 'up' keeps the lower-left y; 'down' flips the upper-right y to the
@@ -730,6 +730,16 @@ function snapshotCluster(sg, yAxis, flipY) {
730
730
  width: bb.ur.x - bb.ll.x,
731
731
  height: bb.ur.y - bb.ll.y
732
732
  };
733
+ const lab = sg.info.label;
734
+ if (lab !== void 0) {
735
+ geom.label = {
736
+ x: lab.pos.x,
737
+ y: flipY(lab.pos.y),
738
+ width: lab.dimen.x,
739
+ height: lab.dimen.y
740
+ };
741
+ }
742
+ return geom;
733
743
  }
734
744
  function collectClusters(sg, yAxis, flipY, out) {
735
745
  for (const c of sg.info.clust ?? []) {