@statelyai/flow 0.12.0 → 0.12.1
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/README.md +8 -0
- package/dist/esm/index.js +25 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,6 +117,14 @@ geometry back to its absolute coordinate model, and applies complete routed
|
|
|
117
117
|
smaller graph before layout; fixed and pinned entities stay in the input but are
|
|
118
118
|
omitted from returned geometry.
|
|
119
119
|
|
|
120
|
+
<!-- finalized geometry policy from src/createFlow.ts applyLayout -->
|
|
121
|
+
|
|
122
|
+
`flow.layout.run()` and `flow.layout.apply()` round applied node positions,
|
|
123
|
+
edge-label positions, and route points to whole CSS pixels. Dimensions retain
|
|
124
|
+
subpixel precision. Fixed and untouched entities keep their authored coordinates;
|
|
125
|
+
manual graph edits and serialization do not round positions. The algorithm's
|
|
126
|
+
original precision remains available in `LayoutRunResult.result`.
|
|
127
|
+
|
|
120
128
|
```ts
|
|
121
129
|
await flow.layout.run(statelyLayout({ scope: { ids: candidateIds } }), {
|
|
122
130
|
scope: { parentId: 'group', depth: 1 },
|
package/dist/esm/index.js
CHANGED
|
@@ -7700,6 +7700,17 @@ function immutableConfiguration(configuration) {
|
|
|
7700
7700
|
};
|
|
7701
7701
|
return clone(configuration);
|
|
7702
7702
|
}
|
|
7703
|
+
/** Final layout positions align to whole CSS pixels. */
|
|
7704
|
+
function roundLayoutPosition(value) {
|
|
7705
|
+
const rounded = Math.round(value);
|
|
7706
|
+
return rounded === 0 ? 0 : rounded;
|
|
7707
|
+
}
|
|
7708
|
+
function roundLayoutPoint(point) {
|
|
7709
|
+
return {
|
|
7710
|
+
x: roundLayoutPosition(point.x),
|
|
7711
|
+
y: roundLayoutPosition(point.y)
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7703
7714
|
/**
|
|
7704
7715
|
* Create an owning Flow controller from an optional initial graph.
|
|
7705
7716
|
*
|
|
@@ -8149,14 +8160,14 @@ function createFlow(options = {}) {
|
|
|
8149
8160
|
const position = result.positions.get(node.id);
|
|
8150
8161
|
const size = result.nodeSizes?.get(node.id);
|
|
8151
8162
|
if (bounds) {
|
|
8152
|
-
node.x = bounds.x;
|
|
8153
|
-
node.y = bounds.y;
|
|
8163
|
+
node.x = roundLayoutPosition(bounds.x);
|
|
8164
|
+
node.y = roundLayoutPosition(bounds.y);
|
|
8154
8165
|
node.width = bounds.width;
|
|
8155
8166
|
node.height = bounds.height;
|
|
8156
8167
|
}
|
|
8157
8168
|
if (position) {
|
|
8158
|
-
node.x = position.x;
|
|
8159
|
-
node.y = position.y;
|
|
8169
|
+
node.x = roundLayoutPosition(position.x);
|
|
8170
|
+
node.y = roundLayoutPosition(position.y);
|
|
8160
8171
|
}
|
|
8161
8172
|
if (size) {
|
|
8162
8173
|
node.width = size.width;
|
|
@@ -8179,30 +8190,30 @@ function createFlow(options = {}) {
|
|
|
8179
8190
|
const route = result.edgeRoutes?.get(edge.id);
|
|
8180
8191
|
if (route || affectedNodeIds.has(edge.sourceId) || affectedNodeIds.has(edge.targetId)) invalidateAuthoritativeEdgePath(edge);
|
|
8181
8192
|
if (edge.label && labelBounds) {
|
|
8182
|
-
edge.label.x = labelBounds.x;
|
|
8183
|
-
edge.label.y = labelBounds.y;
|
|
8193
|
+
edge.label.x = roundLayoutPosition(labelBounds.x);
|
|
8194
|
+
edge.label.y = roundLayoutPosition(labelBounds.y);
|
|
8184
8195
|
edge.label.width = labelBounds.width;
|
|
8185
8196
|
edge.label.height = labelBounds.height;
|
|
8186
|
-
edge.x = labelBounds.x;
|
|
8187
|
-
edge.y = labelBounds.y;
|
|
8197
|
+
edge.x = roundLayoutPosition(labelBounds.x);
|
|
8198
|
+
edge.y = roundLayoutPosition(labelBounds.y);
|
|
8188
8199
|
edge.width = labelBounds.width;
|
|
8189
8200
|
edge.height = labelBounds.height;
|
|
8190
8201
|
}
|
|
8191
8202
|
if (edge.label && labelPosition) {
|
|
8192
|
-
edge.label.x = labelPosition.x;
|
|
8193
|
-
edge.label.y = labelPosition.y;
|
|
8194
|
-
edge.x = labelPosition.x;
|
|
8195
|
-
edge.y = labelPosition.y;
|
|
8203
|
+
edge.label.x = roundLayoutPosition(labelPosition.x);
|
|
8204
|
+
edge.label.y = roundLayoutPosition(labelPosition.y);
|
|
8205
|
+
edge.x = roundLayoutPosition(labelPosition.x);
|
|
8206
|
+
edge.y = roundLayoutPosition(labelPosition.y);
|
|
8196
8207
|
}
|
|
8197
8208
|
if (edge.label && (labelBounds || labelPosition)) {
|
|
8198
8209
|
delete edge.label.dx;
|
|
8199
8210
|
delete edge.label.dy;
|
|
8200
8211
|
}
|
|
8201
8212
|
if (route) if (hasAuthoritativeLayoutPoints(route)) {
|
|
8202
|
-
edge.points = route.points.map(
|
|
8213
|
+
edge.points = route.points.map(roundLayoutPoint);
|
|
8203
8214
|
edge.routing = route.routing ?? "polyline";
|
|
8204
8215
|
delete edge.waypoints;
|
|
8205
|
-
} else edge.waypoints = layoutWaypoints(route).map(
|
|
8216
|
+
} else edge.waypoints = layoutWaypoints(route).map(roundLayoutPoint);
|
|
8206
8217
|
}
|
|
8207
8218
|
const initialOffsets = /* @__PURE__ */ new Map();
|
|
8208
8219
|
if (animate) {
|