@statelyai/flow 0.7.0 → 0.8.2
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 +28 -15
- package/dist/esm/index.d.ts +93 -12
- package/dist/esm/index.js +3533 -3058
- package/dist/esm/layout/dagre.js +1 -1
- package/dist/esm/layout/elk.js +637 -25
- package/dist/esm/shared.js +29 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,10 +105,21 @@ await flow.layout.run(
|
|
|
105
105
|
|
|
106
106
|
<!-- adapter contracts from src/layout/elk.ts src/layout/dagre.ts and src/layout/shared.ts -->
|
|
107
107
|
|
|
108
|
-
`elkLayout()` supports compound nodes, ports, edge labels, direction,
|
|
109
|
-
bounds via `getBounds`, and scoped
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
`elkLayout()` supports compound nodes, ports, edge labels, graph direction,
|
|
109
|
+
per-group child direction, measured bounds via `getBounds`, and scoped
|
|
110
|
+
incremental layout with `scope: { ids }`.
|
|
111
|
+
Results include computed node sizes and bounds, label bounds, routed interior
|
|
112
|
+
waypoints, source metadata, and diagnostics. Hierarchical ELK runs repair
|
|
113
|
+
invalid nested label positions by choosing the nearest node-free position, keep
|
|
114
|
+
intra-compound labels inside their owning group, reserve 24px of rank clearance
|
|
115
|
+
around native labels at both root and child levels, favor straight child edges, and
|
|
116
|
+
reserve sibling space for the final label-expanded derived bounds. Cross-level
|
|
117
|
+
ancestor/descendant edges force integrated hierarchy handling even when a caller's
|
|
118
|
+
general ELK options request separate child passes; their labels reserve a clear
|
|
119
|
+
lane between the group's content block and the descendant instead of being
|
|
120
|
+
pushed outside the compound. When integrated hierarchy would override a
|
|
121
|
+
conflicting per-group direction, a focused layered pass restores that group's
|
|
122
|
+
child ranks without changing the root direction. Scoped passes send only
|
|
112
123
|
the induced graph to ELK; fixed and pinned entities remain in the input but are
|
|
113
124
|
omitted from returned geometry.
|
|
114
125
|
|
|
@@ -137,7 +148,7 @@ The canonical data model is `VisualGraph` from `@statelyai/graph`. Flow extends
|
|
|
137
148
|
<!-- flow entity types from src/types.ts -->
|
|
138
149
|
|
|
139
150
|
- **`FlowNode`** — `VisualNode` + `{ kind, dx, dy, style, ports, autoSize, autoSizeAnchor, resize, hidden, selectable, draggable, connectable, deletable, resizable }` for application-defined rendering kinds, drag offsets, DOM-owned sizing, anchor policy, style overrides, resize constraints, and per-entity behavior. Keep the structural `type` equal to `"node"`; use `kind` for variants such as `state` or `annotation`.
|
|
140
|
-
- **`FlowEdge`** — `VisualEdge` + `{ label, waypoints, sourcePort, targetPort, kind, style, labelAnchor }` for edge labels, editable
|
|
151
|
+
- **`FlowEdge`** — `VisualEdge` + `{ label, waypoints, svgPath, sourcePort, targetPort, kind, style, labelAnchor }` for edge labels, editable router via-points, exact SVG geometry, port binding, and edge styling. Canonical `VisualEdge.points` plus `routing` are an authoritative precomputed route and bypass Flow routers; an optional `svgPath` controls exact SVG paint while points remain authoritative for interaction geometry. Reconnects, node geometry updates, committed drags, and layout application clear stale precomputed routes; layout-provided edge routes replace them with router waypoints. `label.autoSize` makes rendered DOM own transient label dimensions without overwriting authored fallback `width`/`height`; inherited edge `x/y/width/height` are reserved, while positioned edge content belongs on `label`.
|
|
141
152
|
- **`FlowGraph`** — `VisualGraph` with `FlowNode[]` and `FlowEdge[]`
|
|
142
153
|
- **`FlowEntityRef`** — descriptor for a node, edge, port, or block resolved by id. `FlowAddressable` is a deprecated alias.
|
|
143
154
|
|
|
@@ -361,9 +372,9 @@ durable final layout.
|
|
|
361
372
|
|
|
362
373
|
<!-- serialization API from src/serialize.ts and src/createFlow.ts -->
|
|
363
374
|
|
|
364
|
-
`flow.toJSON()` returns `{ version: 1, graph, viewport, collapsedNodeIds }`. The graph is plain persisted intent: pending node and label drag offsets are folded into `x/y`, `dx/dy` and DOM `measured` sizes are stripped, and `style.customWidth/customHeight` are kept. Selection, hover, connection state, highlights, measurements, and undo history are session state and are not serialized.
|
|
375
|
+
`flow.toJSON()` returns `{ version: 1, graph, viewport, collapsedNodeIds }`. The graph is plain persisted intent: pending node and label drag offsets are folded into `x/y`, pending edge drag offsets are folded into route waypoints, `dx/dy` and DOM `measured` sizes are stripped, and `style.customWidth/customHeight` are kept. Selection, hover, connection state, highlights, measurements, and undo history are session state and are not serialized.
|
|
365
376
|
|
|
366
|
-
Use `fromJSON(data, options?)` to create a new controller from saved data, or `flow.load(data)` to validate and replace an existing document atomically. `load()` returns `{ ok: true, value }` or `{ ok: false, error }`. User data is deep-cloned and must be JSON-safe;
|
|
377
|
+
Use `fromJSON(data, options?)` to create a new controller from saved data, or `flow.load(data)` to validate and replace an existing document atomically. `load()` returns `{ ok: true, value }` or `{ ok: false, error }`. User data is deep-cloned and must be JSON-safe; edge route points must be finite, routing must be `polyline`, `orthogonal`, or `splines`, and SVG paths accept only path commands with finite numeric parameters. Optional Standard Schema-compatible contracts can validate and migrate application data.
|
|
367
378
|
|
|
368
379
|
Use `flow.replaceGraph(graph, options?)` when another model is authoritative and
|
|
369
380
|
continuously projects its graph into Flow. It validates atomically, returns the
|
|
@@ -402,13 +413,13 @@ events.
|
|
|
402
413
|
|
|
403
414
|
### Drag lifecycle
|
|
404
415
|
|
|
405
|
-
| Event | Payload | Description
|
|
406
|
-
| ------------ | ------------------------------- |
|
|
407
|
-
| `dragStart` | `{ id }` | Begin dragging the selected entity
|
|
408
|
-
| `dragMove` | `{ dx, dy }` | Apply in-progress drag delta
|
|
409
|
-
| `dragEnd` | — | End drag gesture
|
|
410
|
-
| `commitDrag` |
|
|
411
|
-
| `moveNodes` | `{ direction: Point, factor? }` | Move selected nodes by arrow key
|
|
416
|
+
| Event | Payload | Description |
|
|
417
|
+
| ------------ | ------------------------------- | --------------------------------------------------- |
|
|
418
|
+
| `dragStart` | `{ id }` | Begin dragging the selected entity |
|
|
419
|
+
| `dragMove` | `{ dx, dy }` | Apply in-progress drag delta |
|
|
420
|
+
| `dragEnd` | — | End drag gesture |
|
|
421
|
+
| `commitDrag` | `{ snapOffset?: Point }` | Bake `dx/dy` and the visual snap into positions |
|
|
422
|
+
| `moveNodes` | `{ direction: Point, factor? }` | Move selected nodes by arrow key |
|
|
412
423
|
|
|
413
424
|
### Selection & focus
|
|
414
425
|
|
|
@@ -602,7 +613,9 @@ await animation.done;
|
|
|
602
613
|
|
|
603
614
|
<!-- edge routers from src/routing/index.ts -->
|
|
604
615
|
|
|
605
|
-
Four built-in routers. All return `PathData` (points + source/target direction). A custom router may also return `svgPath` to preserve rounded or otherwise custom SVG geometry; `points` remain required for bounds and endpoint handles, and exported `pathToSVG` safely prefers a finite,
|
|
616
|
+
Four built-in routers. All return `PathData` (points + source/target direction). A custom router may also return `svgPath` to preserve rounded or otherwise custom SVG geometry; `points` remain required for bounds and endpoint handles, and exported `pathToSVG` safely prefers a finite override containing only SVG path commands and numeric parameters. Canonical graph `edge.points` are different from `waypoints`: they are a complete authoritative endpoint-to-endpoint route, interpreted by `edge.routing` (`polyline`, `orthogonal`, or chained `splines`) and never sent through a Flow router or split around a label. An optional edge `svgPath` preserves exact SVG paint while the authoritative points drive endpoints, bounds, hit testing, culling, transient DOM updates, and export. Core endpoint-geometry mutations invalidate precomputed route fields; layout-provided edge routes replace them with router waypoints, while consumers can apply a fresh authoritative graph to restore exact geometry. Edge `waypoints` remain ordered interior router inputs passed through `EdgeRouterContext`; built-in routers honor them. Custom `EdgeRouter`s receive the full typed edge plus the exact canonical or projection `graph` currently being routed and a detached, read-only `getEntityBounds(id)` lookup for live node/edge-label geometry. The lookup never routes another edge. Use `configureBezierRouter(options)`, `configureStepRouter(options)`, and `configureAvoidRouter(options)` for customized built-in router variants. `avoidRouter` is opt-in and routes orthogonal polylines around sibling node obstacles.
|
|
617
|
+
|
|
618
|
+
Routers must be deterministic from their supplied inputs. Flow reuses paths while routing geometry and router identity are unchanged.
|
|
606
619
|
|
|
607
620
|
```ts
|
|
608
621
|
import { configureStepRouter, type EdgeRouter } from '@statelyai/flow';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExtractEvents } from "@xstate/store";
|
|
2
|
-
import { EntityRect, Graph, GraphEdge, GraphNode, GraphPort, PortDirection, VisualEdge, VisualEdge as VisualEdge$1, VisualGraph, VisualGraphConfig, VisualNode, VisualNode as VisualNode$1, VisualPort, VisualPort as VisualPort$1 } from "@statelyai/graph";
|
|
2
|
+
import { EdgeRouting, EdgeRouting as EdgeRouting$1, EntityRect, Graph, GraphEdge, GraphNode, GraphPort, PortDirection, VisualEdge, VisualEdge as VisualEdge$1, VisualGraph, VisualGraphConfig, VisualNode, VisualNode as VisualNode$1, VisualPort, VisualPort as VisualPort$1 } from "@statelyai/graph";
|
|
3
3
|
//#region src/hierarchy.d.ts
|
|
4
4
|
type GroupContentSide = 'top' | 'left' | 'bottom' | 'right';
|
|
5
5
|
type GroupInsets = {
|
|
@@ -16,6 +16,8 @@ type GroupLayout = {
|
|
|
16
16
|
padding?: number | Partial<GroupInsets>;
|
|
17
17
|
/** Minimum child-area size when the group is empty or tiny. */
|
|
18
18
|
minChildArea?: Size;
|
|
19
|
+
/** Rank direction for this group's children during hierarchical layout. */
|
|
20
|
+
direction?: EdgeDirection;
|
|
19
21
|
} | {
|
|
20
22
|
type: 'fixed';
|
|
21
23
|
content?: GroupContentSide;
|
|
@@ -29,6 +31,8 @@ type GroupLayout = {
|
|
|
29
31
|
contentSize?: Size;
|
|
30
32
|
/** Clamp child drags to the child area (default 'none'). */
|
|
31
33
|
clampChildren?: 'x' | 'y' | 'both' | 'none';
|
|
34
|
+
/** Rank direction for this group's children during hierarchical layout. */
|
|
35
|
+
direction?: EdgeDirection;
|
|
32
36
|
};
|
|
33
37
|
type GroupGeometry = {
|
|
34
38
|
/** Overall group bounds. */
|
|
@@ -202,6 +206,11 @@ type FlowEdgeAttributes<TLabelData = unknown> = {
|
|
|
202
206
|
label?: FlowEdgeLabel<TLabelData> | null;
|
|
203
207
|
labelAnchor?: LabelAnchor;
|
|
204
208
|
waypoints?: Point[];
|
|
209
|
+
/**
|
|
210
|
+
* Exact SVG rendering for authoritative `points`. Points remain the source
|
|
211
|
+
* of truth for bounds, endpoints, hit testing, and non-SVG renderers.
|
|
212
|
+
*/
|
|
213
|
+
svgPath?: string;
|
|
205
214
|
sourcePort?: string | null;
|
|
206
215
|
targetPort?: string | null;
|
|
207
216
|
kind?: string;
|
|
@@ -251,8 +260,9 @@ type FlowNode<TData = any> = VisualNode$1<TData> & FlowNodeAttributes;
|
|
|
251
260
|
* A flow edge: VisualEdge + flow attributes.
|
|
252
261
|
*
|
|
253
262
|
* `x`/`y`/`width`/`height` are inherited from the graph visual model and
|
|
254
|
-
* reserved for compatibility. Flow renderers route edges from endpoints
|
|
255
|
-
* positioned edge content
|
|
263
|
+
* reserved for compatibility. Flow renderers route edges from endpoints unless
|
|
264
|
+
* canonical `points` provide an authoritative route; positioned edge content
|
|
265
|
+
* belongs on `label`.
|
|
256
266
|
*/
|
|
257
267
|
type FlowEdge<TEdgeData = any, TLabelData = any> = Omit<VisualEdge$1<TEdgeData>, 'label'> & FlowEdgeAttributes<TLabelData>;
|
|
258
268
|
/** A flow graph: VisualGraph with FlowNode/FlowEdge */
|
|
@@ -319,6 +329,8 @@ type EntityVisualState = {
|
|
|
319
329
|
type Direction = 'top' | 'bottom' | 'left' | 'right';
|
|
320
330
|
type PathData = {
|
|
321
331
|
points: Point[];
|
|
332
|
+
/** Explicit interpretation for authoritative graph-owned points. */
|
|
333
|
+
routing?: EdgeRouting$1;
|
|
322
334
|
sourceDirection: Direction;
|
|
323
335
|
targetDirection: Direction;
|
|
324
336
|
/**
|
|
@@ -395,6 +407,10 @@ type FitViewOptions = ViewportAnimationOptions & {
|
|
|
395
407
|
frame?: Rect;
|
|
396
408
|
};
|
|
397
409
|
//#endregion
|
|
410
|
+
//#region src/marker.d.ts
|
|
411
|
+
/** Convert a marker contract value to a safe local SVG marker reference. */
|
|
412
|
+
declare function markerToSVG(marker: MarkerType | undefined, builtInPrefix: string): string | undefined;
|
|
413
|
+
//#endregion
|
|
398
414
|
//#region src/projections.d.ts
|
|
399
415
|
type GraphDecoration<TDecoration = unknown> = TDecoration | readonly TDecoration[];
|
|
400
416
|
type GraphNodeAttrs<TStyle extends object = object, TDecoration = unknown> = {
|
|
@@ -528,6 +544,13 @@ type EdgeRouterContext<TEdgeData = any, TLabelData = any, TNodeData = any> = {
|
|
|
528
544
|
*/
|
|
529
545
|
obstacles: Rect[];
|
|
530
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* Deterministic edge-routing function.
|
|
549
|
+
*
|
|
550
|
+
* Routers should depend only on the edge and supplied routing context. Do not
|
|
551
|
+
* read viewport or external mutable state; Flow may reuse a path while graph
|
|
552
|
+
* geometry and the router identity are unchanged.
|
|
553
|
+
*/
|
|
531
554
|
type EdgeRouter<TEdgeData = any, TLabelData = any, TNodeData = any> = (edge: Readonly<FlowEdge<TEdgeData, TLabelData>>, context: EdgeRouterContext<TEdgeData, TLabelData, TNodeData>) => PathData;
|
|
532
555
|
type BezierRouterOptions = {
|
|
533
556
|
curvature?: number;
|
|
@@ -572,6 +595,8 @@ interface SpacingGuide {
|
|
|
572
595
|
}
|
|
573
596
|
interface SnapResult {
|
|
574
597
|
snapLines: SnapLine[];
|
|
598
|
+
/** Exact input rect from which the snap delta was calculated */
|
|
599
|
+
sourceRect: Rect;
|
|
575
600
|
/** Adjusted rect position (size unchanged) */
|
|
576
601
|
snapRect: Rect;
|
|
577
602
|
spacingGuides?: SpacingGuide[];
|
|
@@ -684,6 +709,13 @@ type RenderableEntitiesOptions = {
|
|
|
684
709
|
type EdgePathOptions = {
|
|
685
710
|
graph?: FlowStoreContext['graph'];
|
|
686
711
|
};
|
|
712
|
+
/**
|
|
713
|
+
* Create the framework-agnostic derived-geometry and query layer for a store.
|
|
714
|
+
*
|
|
715
|
+
* The engine owns memoized graph indices, paint order, bounds, routing, and
|
|
716
|
+
* hit-testing. Returned collections are read-only views and may retain identity
|
|
717
|
+
* while their semantic inputs are unchanged.
|
|
718
|
+
*/
|
|
687
719
|
declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineOptions): {
|
|
688
720
|
store: import("@xstate/store").Store<FlowStoreContext, {
|
|
689
721
|
createNode: {
|
|
@@ -795,10 +827,12 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
|
|
|
795
827
|
};
|
|
796
828
|
dragEnd: undefined;
|
|
797
829
|
dragCancel: undefined;
|
|
798
|
-
commitDrag: {
|
|
830
|
+
commitDrag: ({
|
|
799
831
|
transactionId?: string;
|
|
800
832
|
origin?: string;
|
|
801
|
-
}
|
|
833
|
+
} & {
|
|
834
|
+
snapOffset?: Point;
|
|
835
|
+
}) | undefined;
|
|
802
836
|
select: {
|
|
803
837
|
ids: string[];
|
|
804
838
|
mode?: "single" | "multi";
|
|
@@ -1136,10 +1170,12 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
|
|
|
1136
1170
|
};
|
|
1137
1171
|
dragEnd: undefined;
|
|
1138
1172
|
dragCancel: undefined;
|
|
1139
|
-
commitDrag: {
|
|
1173
|
+
commitDrag: ({
|
|
1140
1174
|
transactionId?: string;
|
|
1141
1175
|
origin?: string;
|
|
1142
|
-
}
|
|
1176
|
+
} & {
|
|
1177
|
+
snapOffset?: Point;
|
|
1178
|
+
}) | undefined;
|
|
1143
1179
|
select: {
|
|
1144
1180
|
ids: string[];
|
|
1145
1181
|
mode?: "single" | "multi";
|
|
@@ -1516,7 +1552,6 @@ declare function keyboardNavMode(options?: {
|
|
|
1516
1552
|
declare function wheelMode(): FlowInputMode;
|
|
1517
1553
|
declare function panMode(): FlowInputMode;
|
|
1518
1554
|
declare function pinchMode(): FlowInputMode;
|
|
1519
|
-
declare function resizeMode(): FlowInputMode;
|
|
1520
1555
|
type ReparentDropContext = {
|
|
1521
1556
|
/** Top-level dragged nodes (descendants of dragged nodes excluded). */
|
|
1522
1557
|
nodes: FlowNode[];
|
|
@@ -1585,6 +1620,10 @@ type ConnectModeOptions = {
|
|
|
1585
1620
|
}, ctx: FlowInputModeContext) => boolean;
|
|
1586
1621
|
};
|
|
1587
1622
|
declare function connectMode(options?: ConnectModeOptions): FlowInputMode;
|
|
1623
|
+
/** Select/focus graph-owned ports explicitly rendered for readonly inspection. */
|
|
1624
|
+
declare function portPressMode(options?: {
|
|
1625
|
+
keymap?: Partial<FlowKeymap>;
|
|
1626
|
+
}): FlowInputMode;
|
|
1588
1627
|
type ReconnectModeOptions = {
|
|
1589
1628
|
/**
|
|
1590
1629
|
* Mutate the Flow graph after a valid drop. Disable for controlled graphs
|
|
@@ -1654,6 +1693,9 @@ type FlowInputTarget = {
|
|
|
1654
1693
|
kind: 'port';
|
|
1655
1694
|
nodeId: string;
|
|
1656
1695
|
portName: string;
|
|
1696
|
+
portId?: string;
|
|
1697
|
+
/** `inspect` addresses the port without starting a connection gesture. */
|
|
1698
|
+
interaction?: 'connect' | 'inspect';
|
|
1657
1699
|
} | {
|
|
1658
1700
|
kind: 'none';
|
|
1659
1701
|
};
|
|
@@ -2256,7 +2298,9 @@ type FlowEventPayloadMap = {
|
|
|
2256
2298
|
};
|
|
2257
2299
|
dragEnd: undefined;
|
|
2258
2300
|
dragCancel: undefined;
|
|
2259
|
-
commitDrag: TransactionMetadata
|
|
2301
|
+
commitDrag: (TransactionMetadata & {
|
|
2302
|
+
snapOffset?: Point;
|
|
2303
|
+
}) | undefined;
|
|
2260
2304
|
select: {
|
|
2261
2305
|
ids: string[];
|
|
2262
2306
|
mode?: 'single' | 'multi';
|
|
@@ -2623,7 +2667,21 @@ type FlowSerialized<TNodeData = any, TEdgeData = any, TLabelData = any> = {
|
|
|
2623
2667
|
collapsedNodeIds?: string[];
|
|
2624
2668
|
dataVersions?: FlowDataVersions;
|
|
2625
2669
|
};
|
|
2670
|
+
/**
|
|
2671
|
+
* Parse, migrate, and validate a persisted Flow document.
|
|
2672
|
+
*
|
|
2673
|
+
* Versionless documents are treated as version 0. Data migrations must be
|
|
2674
|
+
* synchronous. The returned graph is detached from `input`; invalid documents
|
|
2675
|
+
* throw `FlowGraphValidationError` with stable issue paths.
|
|
2676
|
+
*/
|
|
2626
2677
|
declare function parseFlowSerialized<TNodeData = any, TEdgeData = any, TLabelData = any>(input: unknown, schemas?: FlowDataSchemas<TNodeData, TEdgeData, TLabelData>): FlowSerialized<TNodeData, TEdgeData, TLabelData>;
|
|
2678
|
+
/**
|
|
2679
|
+
* Create a persistence-safe graph snapshot.
|
|
2680
|
+
*
|
|
2681
|
+
* Transient drag and measurement state is folded into authored coordinates or
|
|
2682
|
+
* removed. Nested geometry objects are copied so callers can mutate the result
|
|
2683
|
+
* without changing the live graph.
|
|
2684
|
+
*/
|
|
2627
2685
|
declare function serializeFlowGraph<TNodeData = any, TEdgeData = any, TLabelData = any>(graph: FlowGraph<TNodeData, TEdgeData, TLabelData>): FlowGraph<TNodeData, TEdgeData, TLabelData>;
|
|
2628
2686
|
//#endregion
|
|
2629
2687
|
//#region src/changeSet.d.ts
|
|
@@ -2979,6 +3037,7 @@ type FlowTransactionDraft<TNodeData = any, TEdgeData = any, TLabelData = any> =
|
|
|
2979
3037
|
nodes: Omit<FlowNodesApi<TNodeData>, 'collapse' | 'expand'>;
|
|
2980
3038
|
edges: FlowEdgesApi<TEdgeData, TLabelData>;
|
|
2981
3039
|
};
|
|
3040
|
+
/** Options for creating an owning Flow controller. */
|
|
2982
3041
|
interface CreateFlowOptions<TNodeData = any, TEdgeData = any, TLabelData = any> {
|
|
2983
3042
|
/** Initial graph owned by the controller. */
|
|
2984
3043
|
graph?: FlowGraph<TNodeData, TEdgeData, TLabelData>;
|
|
@@ -3008,6 +3067,13 @@ interface CreateFlowOptions<TNodeData = any, TEdgeData = any, TLabelData = any>
|
|
|
3008
3067
|
/** Optional Standard Schema-compatible contracts for application data. */
|
|
3009
3068
|
dataSchemas?: FlowDataSchemas<TNodeData, TEdgeData, TLabelData>;
|
|
3010
3069
|
}
|
|
3070
|
+
/**
|
|
3071
|
+
* Framework-neutral owner of a Flow graph and its interaction session.
|
|
3072
|
+
*
|
|
3073
|
+
* Mutations go through the domain APIs (`nodes`, `edges`, `selection`,
|
|
3074
|
+
* `viewport`) so validation, history, commit events, and cleanup stay coherent.
|
|
3075
|
+
* Call `destroy()` when the controller is no longer used.
|
|
3076
|
+
*/
|
|
3011
3077
|
interface FlowController<TNodeData = any, TEdgeData = any, TLabelData = any> {
|
|
3012
3078
|
internals: {
|
|
3013
3079
|
store: FlowStore;
|
|
@@ -3088,7 +3154,20 @@ interface FlowController<TNodeData = any, TEdgeData = any, TLabelData = any> {
|
|
|
3088
3154
|
connections: FlowConnectionsApi;
|
|
3089
3155
|
content: FlowContentApi<TNodeData, TEdgeData, TLabelData>;
|
|
3090
3156
|
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Create an owning Flow controller from an optional initial graph.
|
|
3159
|
+
*
|
|
3160
|
+
* The input graph is validated and cloned. Adapters should subscribe to this
|
|
3161
|
+
* controller and delegate behavior to its APIs instead of reimplementing graph
|
|
3162
|
+
* or viewport policy.
|
|
3163
|
+
*/
|
|
3091
3164
|
declare function createFlow<TNodeData = any, TEdgeData = any, TLabelData = any>(options?: CreateFlowOptions<TNodeData, TEdgeData, TLabelData>): FlowController<TNodeData, TEdgeData, TLabelData>;
|
|
3165
|
+
/**
|
|
3166
|
+
* Parse a persisted Flow document and create a controller from it.
|
|
3167
|
+
*
|
|
3168
|
+
* Restores graph, collapsed nodes, and viewport after applying configured data
|
|
3169
|
+
* migrations. Throws `FlowGraphValidationError` for invalid documents.
|
|
3170
|
+
*/
|
|
3092
3171
|
declare function fromJSON<TNodeData = any, TEdgeData = any, TLabelData = any>(data: unknown, options?: Omit<CreateFlowOptions<TNodeData, TEdgeData, TLabelData>, 'graph'>): FlowController<TNodeData, TEdgeData, TLabelData>;
|
|
3093
3172
|
//#endregion
|
|
3094
3173
|
//#region src/connectionPreview.d.ts
|
|
@@ -3141,7 +3220,9 @@ declare function snapPointToGrid(point: Point, gridSize: number): Point;
|
|
|
3141
3220
|
/** Normalize a box (two points) into a Rect with positive width/height */
|
|
3142
3221
|
declare function boxToRect(p1: Point, p2: Point): Rect;
|
|
3143
3222
|
/** Get bounding rect of specific entities by id */
|
|
3144
|
-
declare function getSelectionBounds(nodes: FlowNode[], edges: FlowEdge[], selection: Set<string>, measurements?: ReadonlyMap<string, Rect
|
|
3223
|
+
declare function getSelectionBounds(nodes: FlowNode[], edges: FlowEdge[], selection: Set<string>, measurements?: ReadonlyMap<string, Rect>, options?: {
|
|
3224
|
+
includeEdgePoints?: boolean;
|
|
3225
|
+
}): Rect | null;
|
|
3145
3226
|
/** Determine select mode from a pointer/keyboard event */
|
|
3146
3227
|
declare function selectMode(e: {
|
|
3147
3228
|
shiftKey?: boolean;
|
|
@@ -3338,7 +3419,7 @@ type FlowEntityChangeNotifierOptions = {
|
|
|
3338
3419
|
declare function createEntityChangeNotifier(store: FlowStore, options?: FlowEntityChangeNotifierOptions): FlowEntityChangeNotifier;
|
|
3339
3420
|
//#endregion
|
|
3340
3421
|
//#region src/config.d.ts
|
|
3341
|
-
/** Default config:
|
|
3422
|
+
/** Default config: supported editing behaviors enabled */
|
|
3342
3423
|
declare const defaultConfig: FlowConfig;
|
|
3343
3424
|
/** Readonly preset: can select and view, cannot modify */
|
|
3344
3425
|
declare const readonlyConfig: Partial<FlowConfig>;
|
|
@@ -3348,4 +3429,4 @@ declare const readonlyConfig: Partial<FlowConfig>;
|
|
|
3348
3429
|
*/
|
|
3349
3430
|
declare function resolveBehavior<TEntity, TState>(predicate: ((entity: TEntity, state: TState) => boolean) | false | undefined, entity: TEntity, state: TState, defaultValue?: boolean): boolean;
|
|
3350
3431
|
//#endregion
|
|
3351
|
-
export { type ActiveGraphProjection, type AnchorSpec, type AnchorTransform, type AnimateViewportOptions, type AutoLayoutState, type AvoidRouterOptions, type BehaviorPredicate, type BezierRouterOptions, type BoxSelectModeOptions, type BoxSelectionTest, CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, type CanvasState, type ComposedGraphProjectionAttrs, type ConnectEndTarget, type ConnectModeOptions, type ConnectionCandidate, type ConnectionCandidateOptions, type ConnectionCandidateSource, type ConnectionEndedEvent, type ConnectionPreviewData, type ConnectionPreviewGraphOptions, type ConnectionState, type ConnectionValidationContext, type ConnectionValidationResult, type CreateEdgeInput, type CreateFlowOptions, type CreateNodeInput, type Direction, type EdgeAdjacencyIndex, type EdgeDirection, type EdgePathData, type EdgePathOptions, type EdgeRouter, type EdgeRouterContext, type EdgeRouterGraph, type EdgeSourceBoundsContext, type EntityRect, type EntityVisualState, type FitViewExclusion, type FitViewExclusionSide, type FitViewOptions, type FlowAbortSignal, type FlowAddressable, type FlowAutoSizeAnchor, type FlowCapabilityCommand, type FlowCapabilityResult, type FlowChangeSet, type FlowColorMode, type FlowCommand, type FlowCommitEvent, type FlowConfig, type FlowConfiguration, type FlowConfigureOptions, type FlowConnectMovedEvent, type FlowConnectStartedEvent, type FlowConnection, type FlowConnectionMode, type FlowConnectionOptions, type FlowConnectionsApi, type FlowContent, type FlowContentApi, type FlowContentInsertResult, type FlowController, type FlowCreateIdContext, type FlowDataSchema, type FlowDataSchemas, type FlowDataVersions, type FlowDragEndedEvent, type FlowDragMovedEvent, type FlowDragStartedEvent, type FlowEdge, type FlowEdgeAttributes, type FlowEdgeLabel, type FlowEdgePatch, type FlowEdgeStyle, type FlowEdgeUpdater, type FlowEdgesApi, type FlowEngine, type FlowEngineOptions, type FlowEntitiesDeletedEvent, type FlowEntityChangeNotifier, type FlowEntityChangeNotifierOptions, type FlowEntityGestureEvent, type FlowEntityRef, type FlowEntityUpdate, type FlowErrorEvent, type FlowEventObject, type FlowGestureModifiers, type FlowGraph, type FlowGraphChangedEvent, type FlowGraphHistoryPolicy, type FlowGraphRetentionPolicy, FlowGraphValidationError, type FlowHighlightEntry, type FlowHighlights, type FlowHighlightsApi, type FlowHistoryApi, type FlowInputEffects, type FlowInputEvent, type FlowInputMode, type FlowInputModeContext, type FlowInputModifiers, type FlowInputProfile, type FlowInputReaction, type FlowInputRuntime, type FlowInputRuntimeOptions, type FlowInputSessionHandlers, type FlowInputTarget, type FlowKeyBinding, type FlowKeyInputEvent, type FlowKeymap, type FlowLayoutApi, type FlowModeDefinition, type FlowNode, type FlowNodeAttributes, type FlowNodePatch, type FlowNodeUpdater, type FlowNodesApi, type FlowOrigin, type FlowPaneGestureEvent, type FlowPatch, type FlowPinchInputEvent, type FlowPointerInputEvent, type FlowPolicies, type FlowPort, type FlowProfile, type FlowProjectionListener, type FlowProjectionsApi, type FlowReplaceGraphOptions, type FlowResizeEndedEvent, type FlowResizeStartedEvent, type FlowResolvers, type FlowResult, type FlowRules, type FlowRuntimeSettings, type FlowSelectionAlignment, type FlowSelectionApi, type FlowSelectionChangedEvent, type FlowSelectionDistribution, type FlowSelectionDuplicateResult, type FlowSerialized, type FlowSessionResult, type FlowSettings, type FlowStore, type FlowStoreContext, type FlowStoreOptions, type FlowTransactionDraft, type FlowTransactionOptions, type FlowTransition, type FlowTransitions, type FlowTriggerCommand, type FlowTriggerName, type FlowUpdateEdgeEvent, type FlowUpdateNodeEvent, type FlowValidationIssue, type FlowViewApi, type FlowViewBoundaryEndpoints, type FlowViewChangedEvent, type FlowViewEndpoint, type FlowViewEntities, type FlowViewScope, type FlowViewSelectionPolicy, type FlowViewportApi, type FlowViewportChangedEvent, type FlowWheelInputEvent, type Graph, type GraphDecoration, type GraphEdge, type GraphEdgeAttrs, type GraphNode, type GraphNodeAttrs, type GraphPort, type GraphProjection, type GraphProjectionMapper, type GroupContentSide, type GroupGeometry, type GroupInsets, type GroupLayout, type InteractionMode, type LabelAnchor, type LayoutAlgorithm, type LayoutAnimationControls, type LayoutAnimationOptions, type LayoutApplyOptions, type LayoutDiagnostic, type LayoutEdgeRoute, type LayoutPositions, type LayoutRequestedEvent, type LayoutResult, type LayoutRunOptions, type LayoutRunResult, type MarkerType, type MinimapProjection, type MinimapProjectionOptions, type PathData, type Point, type PortDirection, type ProposedConnection, type ReconnectModeOptions, type Rect, type RenderableEntitiesOptions, type ReparentDecision, type ReparentDropContext, type ReparentOptions, type ResizeConstraints, type ResizeHandle, type ResolvedFitViewExclusion, type SelectionMode, type ShapeHandler, type Side, type Size, type SnapLine, type SnapOptions, type SnapResult, type SpacingGuide, type StandardSchemaV1Like, type StepRouterOptions, type StyleOverrides, type ToolbarPlacement, type ToolbarPlacementInput, type Viewport, type ViewportAnimationCancelFrame, type ViewportAnimationControls, type ViewportAnimationFrame, type ViewportAnimationOptions, type VisualEdge, type VisualGraph, type VisualNode, type VisualPort, type WheelInteraction, type WheelInteractionOptions, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape,
|
|
3432
|
+
export { type ActiveGraphProjection, type AnchorSpec, type AnchorTransform, type AnimateViewportOptions, type AutoLayoutState, type AvoidRouterOptions, type BehaviorPredicate, type BezierRouterOptions, type BoxSelectModeOptions, type BoxSelectionTest, CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, type CanvasState, type ComposedGraphProjectionAttrs, type ConnectEndTarget, type ConnectModeOptions, type ConnectionCandidate, type ConnectionCandidateOptions, type ConnectionCandidateSource, type ConnectionEndedEvent, type ConnectionPreviewData, type ConnectionPreviewGraphOptions, type ConnectionState, type ConnectionValidationContext, type ConnectionValidationResult, type CreateEdgeInput, type CreateFlowOptions, type CreateNodeInput, type Direction, type EdgeAdjacencyIndex, type EdgeDirection, type EdgePathData, type EdgePathOptions, type EdgeRouter, type EdgeRouterContext, type EdgeRouterGraph, type EdgeRouting, type EdgeSourceBoundsContext, type EntityRect, type EntityVisualState, type FitViewExclusion, type FitViewExclusionSide, type FitViewOptions, type FlowAbortSignal, type FlowAddressable, type FlowAutoSizeAnchor, type FlowCapabilityCommand, type FlowCapabilityResult, type FlowChangeSet, type FlowColorMode, type FlowCommand, type FlowCommitEvent, type FlowConfig, type FlowConfiguration, type FlowConfigureOptions, type FlowConnectMovedEvent, type FlowConnectStartedEvent, type FlowConnection, type FlowConnectionMode, type FlowConnectionOptions, type FlowConnectionsApi, type FlowContent, type FlowContentApi, type FlowContentInsertResult, type FlowController, type FlowCreateIdContext, type FlowDataSchema, type FlowDataSchemas, type FlowDataVersions, type FlowDragEndedEvent, type FlowDragMovedEvent, type FlowDragStartedEvent, type FlowEdge, type FlowEdgeAttributes, type FlowEdgeLabel, type FlowEdgePatch, type FlowEdgeStyle, type FlowEdgeUpdater, type FlowEdgesApi, type FlowEngine, type FlowEngineOptions, type FlowEntitiesDeletedEvent, type FlowEntityChangeNotifier, type FlowEntityChangeNotifierOptions, type FlowEntityGestureEvent, type FlowEntityRef, type FlowEntityUpdate, type FlowErrorEvent, type FlowEventObject, type FlowGestureModifiers, type FlowGraph, type FlowGraphChangedEvent, type FlowGraphHistoryPolicy, type FlowGraphRetentionPolicy, FlowGraphValidationError, type FlowHighlightEntry, type FlowHighlights, type FlowHighlightsApi, type FlowHistoryApi, type FlowInputEffects, type FlowInputEvent, type FlowInputMode, type FlowInputModeContext, type FlowInputModifiers, type FlowInputProfile, type FlowInputReaction, type FlowInputRuntime, type FlowInputRuntimeOptions, type FlowInputSessionHandlers, type FlowInputTarget, type FlowKeyBinding, type FlowKeyInputEvent, type FlowKeymap, type FlowLayoutApi, type FlowModeDefinition, type FlowNode, type FlowNodeAttributes, type FlowNodePatch, type FlowNodeUpdater, type FlowNodesApi, type FlowOrigin, type FlowPaneGestureEvent, type FlowPatch, type FlowPinchInputEvent, type FlowPointerInputEvent, type FlowPolicies, type FlowPort, type FlowProfile, type FlowProjectionListener, type FlowProjectionsApi, type FlowReplaceGraphOptions, type FlowResizeEndedEvent, type FlowResizeStartedEvent, type FlowResolvers, type FlowResult, type FlowRules, type FlowRuntimeSettings, type FlowSelectionAlignment, type FlowSelectionApi, type FlowSelectionChangedEvent, type FlowSelectionDistribution, type FlowSelectionDuplicateResult, type FlowSerialized, type FlowSessionResult, type FlowSettings, type FlowStore, type FlowStoreContext, type FlowStoreOptions, type FlowTransactionDraft, type FlowTransactionOptions, type FlowTransition, type FlowTransitions, type FlowTriggerCommand, type FlowTriggerName, type FlowUpdateEdgeEvent, type FlowUpdateNodeEvent, type FlowValidationIssue, type FlowViewApi, type FlowViewBoundaryEndpoints, type FlowViewChangedEvent, type FlowViewEndpoint, type FlowViewEntities, type FlowViewScope, type FlowViewSelectionPolicy, type FlowViewportApi, type FlowViewportChangedEvent, type FlowWheelInputEvent, type Graph, type GraphDecoration, type GraphEdge, type GraphEdgeAttrs, type GraphNode, type GraphNodeAttrs, type GraphPort, type GraphProjection, type GraphProjectionMapper, type GroupContentSide, type GroupGeometry, type GroupInsets, type GroupLayout, type InteractionMode, type LabelAnchor, type LayoutAlgorithm, type LayoutAnimationControls, type LayoutAnimationOptions, type LayoutApplyOptions, type LayoutDiagnostic, type LayoutEdgeRoute, type LayoutPositions, type LayoutRequestedEvent, type LayoutResult, type LayoutRunOptions, type LayoutRunResult, type MarkerType, type MinimapProjection, type MinimapProjectionOptions, type PathData, type Point, type PortDirection, type ProposedConnection, type ReconnectModeOptions, type Rect, type RenderableEntitiesOptions, type ReparentDecision, type ReparentDropContext, type ReparentOptions, type ResizeConstraints, type ResizeHandle, type ResolvedFitViewExclusion, type SelectionMode, type ShapeHandler, type Side, type Size, type SnapLine, type SnapOptions, type SnapResult, type SpacingGuide, type StandardSchemaV1Like, type StepRouterOptions, type StyleOverrides, type ToolbarPlacement, type ToolbarPlacementInput, type Viewport, type ViewportAnimationCancelFrame, type ViewportAnimationControls, type ViewportAnimationFrame, type ViewportAnimationOptions, type VisualEdge, type VisualGraph, type VisualNode, type VisualPort, type WheelInteraction, type WheelInteractionOptions, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, markerToSVG, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, portPressMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape, resolveBehavior, resolveGroupPadding, resolveKeymap, resolvedBounds, resolvedEdgeLabelBounds, resolvedEdgeLabelSize, resolvedPosition, screenToCanvas, selectMode, serializeFlowGraph, snapPointToGrid, snapToGrid, snappedBounds, sortActiveGraphProjections, stepRouter, straightRouter, toSVGTransform, toViewBox, trigger, unionRect, validateAndCloneGraph, validateFitFrame, validateViewport, viewportCenteredOn, viewportForBounds, visualBounds, visualPosition, wheelInteraction, wheelMode, wheelZoomDelta, zoomTo };
|