@statelyai/flow 0.6.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.
@@ -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 belongs on `label`.
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
  /**
@@ -364,6 +376,13 @@ type ViewportSpringOptions = {
364
376
  type ViewportAnimationOptions = {
365
377
  duration?: number;
366
378
  easing?: (t: number) => number;
379
+ /**
380
+ * Exponential smoothing factor in `(0, 1]`. Each nominal 60 Hz frame lerps
381
+ * the current x, y, and zoom toward the target by this amount; actual frame
382
+ * deltas are normalized so the motion is refresh-rate independent. When set,
383
+ * this takes precedence over `duration` and `easing`.
384
+ */
385
+ lerp?: number;
367
386
  /**
368
387
  * Screen-space point to keep visually fixed during the animation (the focal
369
388
  * anchor of the zoom). Defaults to the target viewport's frame of reference,
@@ -388,6 +407,10 @@ type FitViewOptions = ViewportAnimationOptions & {
388
407
  frame?: Rect;
389
408
  };
390
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
391
414
  //#region src/projections.d.ts
392
415
  type GraphDecoration<TDecoration = unknown> = TDecoration | readonly TDecoration[];
393
416
  type GraphNodeAttrs<TStyle extends object = object, TDecoration = unknown> = {
@@ -521,6 +544,13 @@ type EdgeRouterContext<TEdgeData = any, TLabelData = any, TNodeData = any> = {
521
544
  */
522
545
  obstacles: Rect[];
523
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
+ */
524
554
  type EdgeRouter<TEdgeData = any, TLabelData = any, TNodeData = any> = (edge: Readonly<FlowEdge<TEdgeData, TLabelData>>, context: EdgeRouterContext<TEdgeData, TLabelData, TNodeData>) => PathData;
525
555
  type BezierRouterOptions = {
526
556
  curvature?: number;
@@ -565,6 +595,8 @@ interface SpacingGuide {
565
595
  }
566
596
  interface SnapResult {
567
597
  snapLines: SnapLine[];
598
+ /** Exact input rect from which the snap delta was calculated */
599
+ sourceRect: Rect;
568
600
  /** Adjusted rect position (size unchanged) */
569
601
  snapRect: Rect;
570
602
  spacingGuides?: SpacingGuide[];
@@ -677,6 +709,13 @@ type RenderableEntitiesOptions = {
677
709
  type EdgePathOptions = {
678
710
  graph?: FlowStoreContext['graph'];
679
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
+ */
680
719
  declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineOptions): {
681
720
  store: import("@xstate/store").Store<FlowStoreContext, {
682
721
  createNode: {
@@ -788,10 +827,12 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
788
827
  };
789
828
  dragEnd: undefined;
790
829
  dragCancel: undefined;
791
- commitDrag: {
830
+ commitDrag: ({
792
831
  transactionId?: string;
793
832
  origin?: string;
794
- } | undefined;
833
+ } & {
834
+ snapOffset?: Point;
835
+ }) | undefined;
795
836
  select: {
796
837
  ids: string[];
797
838
  mode?: "single" | "multi";
@@ -842,6 +883,7 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
842
883
  setViewport: Viewport;
843
884
  setFitFrame: {
844
885
  frame: Rect | null;
886
+ preserveCenter?: boolean;
845
887
  };
846
888
  panBy: Point;
847
889
  zoomTo: {
@@ -875,7 +917,9 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
875
917
  setNodeExtent: {
876
918
  extent: [Point, Point] | null;
877
919
  };
878
- updateViewportSize: Size;
920
+ updateViewportSize: Size & {
921
+ preserveCenter?: boolean;
922
+ };
879
923
  fitView: FitViewOptions | undefined;
880
924
  pushViewport: undefined;
881
925
  popViewport: undefined;
@@ -1126,10 +1170,12 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
1126
1170
  };
1127
1171
  dragEnd: undefined;
1128
1172
  dragCancel: undefined;
1129
- commitDrag: {
1173
+ commitDrag: ({
1130
1174
  transactionId?: string;
1131
1175
  origin?: string;
1132
- } | undefined;
1176
+ } & {
1177
+ snapOffset?: Point;
1178
+ }) | undefined;
1133
1179
  select: {
1134
1180
  ids: string[];
1135
1181
  mode?: "single" | "multi";
@@ -1180,6 +1226,7 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
1180
1226
  setViewport: Viewport;
1181
1227
  setFitFrame: {
1182
1228
  frame: Rect | null;
1229
+ preserveCenter?: boolean;
1183
1230
  };
1184
1231
  panBy: Point;
1185
1232
  zoomTo: {
@@ -1213,7 +1260,9 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
1213
1260
  setNodeExtent: {
1214
1261
  extent: [Point, Point] | null;
1215
1262
  };
1216
- updateViewportSize: Size;
1263
+ updateViewportSize: Size & {
1264
+ preserveCenter?: boolean;
1265
+ };
1217
1266
  fitView: FitViewOptions | undefined;
1218
1267
  pushViewport: undefined;
1219
1268
  popViewport: undefined;
@@ -1503,7 +1552,6 @@ declare function keyboardNavMode(options?: {
1503
1552
  declare function wheelMode(): FlowInputMode;
1504
1553
  declare function panMode(): FlowInputMode;
1505
1554
  declare function pinchMode(): FlowInputMode;
1506
- declare function resizeMode(): FlowInputMode;
1507
1555
  type ReparentDropContext = {
1508
1556
  /** Top-level dragged nodes (descendants of dragged nodes excluded). */
1509
1557
  nodes: FlowNode[];
@@ -1572,6 +1620,10 @@ type ConnectModeOptions = {
1572
1620
  }, ctx: FlowInputModeContext) => boolean;
1573
1621
  };
1574
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;
1575
1627
  type ReconnectModeOptions = {
1576
1628
  /**
1577
1629
  * Mutate the Flow graph after a valid drop. Disable for controlled graphs
@@ -1641,6 +1693,9 @@ type FlowInputTarget = {
1641
1693
  kind: 'port';
1642
1694
  nodeId: string;
1643
1695
  portName: string;
1696
+ portId?: string;
1697
+ /** `inspect` addresses the port without starting a connection gesture. */
1698
+ interaction?: 'connect' | 'inspect';
1644
1699
  } | {
1645
1700
  kind: 'none';
1646
1701
  };
@@ -1985,7 +2040,7 @@ type FlowStoreContext = {
1985
2040
  autoLayout: AutoLayoutState;
1986
2041
  /** Transient visual offsets for an in-flight layout animation. */
1987
2042
  layoutAnimation: {
1988
- status: "idle" | "running";
2043
+ status: 'idle' | 'running';
1989
2044
  offsets: Map<string, Point>;
1990
2045
  };
1991
2046
  colorMode: FlowColorMode;
@@ -2006,7 +2061,7 @@ type FlowStoreContext = {
2006
2061
  */
2007
2062
  configRevision: number;
2008
2063
  };
2009
- type FlowColorMode = "light" | "dark" | "system";
2064
+ type FlowColorMode = 'light' | 'dark' | 'system';
2010
2065
  /** kind → (entity id → metadata) */
2011
2066
  type FlowHighlights = Map<string, Map<string, unknown>>;
2012
2067
  type FlowHighlightEntry = {
@@ -2054,31 +2109,31 @@ type FlowStoreOptions = {
2054
2109
  * - 'retarget': edges connected to deleted node become self-loops on the other endpoint
2055
2110
  * - function: custom logic — receives graph + node ids to delete, returns { nodes, edges } to keep
2056
2111
  */
2057
- onDeleteNodes?: "cascade" | "retarget" | ((graph: FlowGraph, nodeIds: Set<string>) => {
2112
+ onDeleteNodes?: 'cascade' | 'retarget' | ((graph: FlowGraph, nodeIds: Set<string>) => {
2058
2113
  nodes: FlowNode[];
2059
2114
  edges: FlowEdge[];
2060
2115
  });
2061
2116
  };
2062
- type FlowRuntimeSettings = Pick<FlowStoreOptions, "dragThreshold" | "constrainNodeMovement" | "autoPanOnDrag" | "autoPanThreshold" | "autoPanSpeed" | "enableSnapLines" | "snapThreshold" | "enableSpacingGuides" | "boxSelectionTest" | "labelAnchor">;
2117
+ type FlowRuntimeSettings = Pick<FlowStoreOptions, 'dragThreshold' | 'constrainNodeMovement' | 'autoPanOnDrag' | 'autoPanThreshold' | 'autoPanSpeed' | 'enableSnapLines' | 'snapThreshold' | 'enableSpacingGuides' | 'boxSelectionTest' | 'labelAnchor'>;
2063
2118
  type LayoutRequestedEvent = {
2064
2119
  algorithm: string;
2065
2120
  graph: FlowGraph;
2066
2121
  };
2067
2122
  type ConnectEndTarget = {
2068
- kind: "node";
2123
+ kind: 'node';
2069
2124
  nodeId: string;
2070
2125
  port: string | null;
2071
2126
  } | {
2072
- kind: "edge";
2127
+ kind: 'edge';
2073
2128
  edgeId: string;
2074
2129
  } | {
2075
- kind: "canvas";
2130
+ kind: 'canvas';
2076
2131
  position: Point;
2077
2132
  } | {
2078
- kind: "none";
2133
+ kind: 'none';
2079
2134
  };
2080
2135
  type ConnectionEndedEvent = {
2081
- status: "connected" | "cancelled" | "invalid";
2136
+ status: 'connected' | 'cancelled' | 'invalid';
2082
2137
  source: {
2083
2138
  nodeId: string;
2084
2139
  port: string | null;
@@ -2243,16 +2298,18 @@ type FlowEventPayloadMap = {
2243
2298
  };
2244
2299
  dragEnd: undefined;
2245
2300
  dragCancel: undefined;
2246
- commitDrag: TransactionMetadata | undefined;
2301
+ commitDrag: (TransactionMetadata & {
2302
+ snapOffset?: Point;
2303
+ }) | undefined;
2247
2304
  select: {
2248
2305
  ids: string[];
2249
- mode?: "single" | "multi";
2306
+ mode?: 'single' | 'multi';
2250
2307
  };
2251
2308
  selectAll: undefined;
2252
2309
  clearSelection: undefined;
2253
2310
  selectionBoxStart: {
2254
2311
  point: Point;
2255
- mode?: "single" | "multi";
2312
+ mode?: 'single' | 'multi';
2256
2313
  };
2257
2314
  selectionBoxMove: {
2258
2315
  point: Point;
@@ -2295,6 +2352,7 @@ type FlowEventPayloadMap = {
2295
2352
  setViewport: Viewport;
2296
2353
  setFitFrame: {
2297
2354
  frame: Rect | null;
2355
+ preserveCenter?: boolean;
2298
2356
  };
2299
2357
  panBy: Point;
2300
2358
  zoomTo: {
@@ -2328,7 +2386,9 @@ type FlowEventPayloadMap = {
2328
2386
  setNodeExtent: {
2329
2387
  extent: [Point, Point] | null;
2330
2388
  };
2331
- updateViewportSize: Size;
2389
+ updateViewportSize: Size & {
2390
+ preserveCenter?: boolean;
2391
+ };
2332
2392
  fitView: FitViewOptions | undefined;
2333
2393
  pushViewport: undefined;
2334
2394
  popViewport: undefined;
@@ -2345,7 +2405,7 @@ type FlowEventPayloadMap = {
2345
2405
  position: Point;
2346
2406
  active?: boolean;
2347
2407
  reconnectingEdgeId?: string | null;
2348
- reconnectingEnd?: "source" | "target" | null;
2408
+ reconnectingEnd?: 'source' | 'target' | null;
2349
2409
  preview?: boolean;
2350
2410
  };
2351
2411
  connectionMove: {
@@ -2430,8 +2490,8 @@ type FlowEventPayloadMap = {
2430
2490
  } & TransactionMetadata;
2431
2491
  reportError: FlowErrorEvent;
2432
2492
  };
2433
- type FlowNodePatch = Partial<Omit<FlowNode, "id" | "type" | "parentId">>;
2434
- type FlowEdgePatch = Partial<Omit<FlowEdge, "id" | "type" | "sourceId" | "targetId" | "sourcePort" | "targetPort">>;
2493
+ type FlowNodePatch = Partial<Omit<FlowNode, 'id' | 'type' | 'parentId'>>;
2494
+ type FlowEdgePatch = Partial<Omit<FlowEdge, 'id' | 'type' | 'sourceId' | 'targetId' | 'sourcePort' | 'targetPort'>>;
2435
2495
  type FlowNodeUpdater = (node: FlowNode) => FlowNode;
2436
2496
  type FlowEdgeUpdater = (edge: FlowEdge) => FlowEdge;
2437
2497
  type FlowUpdateNodeEvent = {
@@ -2448,8 +2508,8 @@ type TransactionMetadata = {
2448
2508
  transactionId?: string;
2449
2509
  origin?: string;
2450
2510
  };
2451
- type FlowGraphRetentionPolicy = "preserve" | "reset";
2452
- type FlowGraphHistoryPolicy = "reset" | "ignore" | "record";
2511
+ type FlowGraphRetentionPolicy = 'preserve' | 'reset';
2512
+ type FlowGraphHistoryPolicy = 'reset' | 'ignore' | 'record';
2453
2513
  type ReplaceGraphMetadata = TransactionMetadata & {
2454
2514
  retention?: FlowGraphRetentionPolicy;
2455
2515
  history?: FlowGraphHistoryPolicy;
@@ -2491,6 +2551,18 @@ type AnimateViewportOptions = ViewportAnimationOptions & {
2491
2551
  declare function animateViewport(store: FlowStore, target: Viewport, options?: AnimateViewportOptions): ViewportAnimationControls;
2492
2552
  //#endregion
2493
2553
  //#region src/viewport/index.d.ts
2554
+ type FitViewExclusionSide = 'top' | 'right' | 'bottom' | 'left' | 'nearest';
2555
+ type FitViewExclusion = {
2556
+ /** Read the current exclusion in viewport-local screen pixels. */
2557
+ getRect: () => Rect | null;
2558
+ /** Edge whose band this overlay occupies. Defaults to the nearest edge. */
2559
+ side?: FitViewExclusionSide;
2560
+ /** Additional screen-pixel clearance beyond the measured overlay. */
2561
+ gap?: number;
2562
+ };
2563
+ type ResolvedFitViewExclusion = Omit<FitViewExclusion, 'getRect'> & {
2564
+ rect: Rect;
2565
+ };
2494
2566
  /** Create a default viewport (origin, no zoom) */
2495
2567
  declare function createViewport(x?: number, y?: number, zoom?: number): Viewport;
2496
2568
  /**
@@ -2528,6 +2600,11 @@ declare function clampZoom(zoom: number, minZoom: number, maxZoom: number): numb
2528
2600
  declare function viewportCenteredOn(center: Point, size: Size, zoom: number, frame?: Rect): Viewport;
2529
2601
  /** Validate and clone a positive finite screen-space fit frame. */
2530
2602
  declare function validateFitFrame(frame: Rect): Rect;
2603
+ /**
2604
+ * Reduce a fit frame by measured floating overlays. Each overlay reserves the
2605
+ * band between itself and its assigned (or nearest) frame edge.
2606
+ */
2607
+ declare function fitFrameAroundExclusions(frame: Rect, exclusions: Iterable<ResolvedFitViewExclusion>): Rect;
2531
2608
  //#endregion
2532
2609
  //#region src/validation.d.ts
2533
2610
  type FlowResult<T, TError = FlowGraphValidationError> = {
@@ -2590,7 +2667,21 @@ type FlowSerialized<TNodeData = any, TEdgeData = any, TLabelData = any> = {
2590
2667
  collapsedNodeIds?: string[];
2591
2668
  dataVersions?: FlowDataVersions;
2592
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
+ */
2593
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
+ */
2594
2685
  declare function serializeFlowGraph<TNodeData = any, TEdgeData = any, TLabelData = any>(graph: FlowGraph<TNodeData, TEdgeData, TLabelData>): FlowGraph<TNodeData, TEdgeData, TLabelData>;
2595
2686
  //#endregion
2596
2687
  //#region src/changeSet.d.ts
@@ -2843,7 +2934,11 @@ type FlowViewportApi = {
2843
2934
  frame?: Rect;
2844
2935
  }) => ViewportAnimationControls;
2845
2936
  getFitFrame: () => Readonly<Rect>;
2846
- setFitFrame: (frame: Rect | null) => void;
2937
+ setFitFrame: (frame: Rect | null, options?: {
2938
+ preserveCenter?: boolean;
2939
+ }) => void;
2940
+ /** Register a measured screen-space overlay that fit/center commands avoid. */
2941
+ registerFitExclusion: (exclusion: FitViewExclusion) => () => void;
2847
2942
  };
2848
2943
  type FlowLayoutApi<TNodeData = any, TEdgeData = any, TLabelData = any> = {
2849
2944
  run: (layout?: LayoutAlgorithm<TNodeData, TEdgeData, TLabelData>, options?: LayoutRunOptions) => Promise<LayoutRunResult>;
@@ -2942,6 +3037,7 @@ type FlowTransactionDraft<TNodeData = any, TEdgeData = any, TLabelData = any> =
2942
3037
  nodes: Omit<FlowNodesApi<TNodeData>, 'collapse' | 'expand'>;
2943
3038
  edges: FlowEdgesApi<TEdgeData, TLabelData>;
2944
3039
  };
3040
+ /** Options for creating an owning Flow controller. */
2945
3041
  interface CreateFlowOptions<TNodeData = any, TEdgeData = any, TLabelData = any> {
2946
3042
  /** Initial graph owned by the controller. */
2947
3043
  graph?: FlowGraph<TNodeData, TEdgeData, TLabelData>;
@@ -2971,6 +3067,13 @@ interface CreateFlowOptions<TNodeData = any, TEdgeData = any, TLabelData = any>
2971
3067
  /** Optional Standard Schema-compatible contracts for application data. */
2972
3068
  dataSchemas?: FlowDataSchemas<TNodeData, TEdgeData, TLabelData>;
2973
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
+ */
2974
3077
  interface FlowController<TNodeData = any, TEdgeData = any, TLabelData = any> {
2975
3078
  internals: {
2976
3079
  store: FlowStore;
@@ -3051,7 +3154,20 @@ interface FlowController<TNodeData = any, TEdgeData = any, TLabelData = any> {
3051
3154
  connections: FlowConnectionsApi;
3052
3155
  content: FlowContentApi<TNodeData, TEdgeData, TLabelData>;
3053
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
+ */
3054
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
+ */
3055
3171
  declare function fromJSON<TNodeData = any, TEdgeData = any, TLabelData = any>(data: unknown, options?: Omit<CreateFlowOptions<TNodeData, TEdgeData, TLabelData>, 'graph'>): FlowController<TNodeData, TEdgeData, TLabelData>;
3056
3172
  //#endregion
3057
3173
  //#region src/connectionPreview.d.ts
@@ -3104,7 +3220,9 @@ declare function snapPointToGrid(point: Point, gridSize: number): Point;
3104
3220
  /** Normalize a box (two points) into a Rect with positive width/height */
3105
3221
  declare function boxToRect(p1: Point, p2: Point): Rect;
3106
3222
  /** Get bounding rect of specific entities by id */
3107
- declare function getSelectionBounds(nodes: FlowNode[], edges: FlowEdge[], selection: Set<string>, measurements?: ReadonlyMap<string, Rect>): Rect | null;
3223
+ declare function getSelectionBounds(nodes: FlowNode[], edges: FlowEdge[], selection: Set<string>, measurements?: ReadonlyMap<string, Rect>, options?: {
3224
+ includeEdgePoints?: boolean;
3225
+ }): Rect | null;
3108
3226
  /** Determine select mode from a pointer/keyboard event */
3109
3227
  declare function selectMode(e: {
3110
3228
  shiftKey?: boolean;
@@ -3301,7 +3419,7 @@ type FlowEntityChangeNotifierOptions = {
3301
3419
  declare function createEntityChangeNotifier(store: FlowStore, options?: FlowEntityChangeNotifierOptions): FlowEntityChangeNotifier;
3302
3420
  //#endregion
3303
3421
  //#region src/config.d.ts
3304
- /** Default config: everything enabled */
3422
+ /** Default config: supported editing behaviors enabled */
3305
3423
  declare const defaultConfig: FlowConfig;
3306
3424
  /** Readonly preset: can select and view, cannot modify */
3307
3425
  declare const readonlyConfig: Partial<FlowConfig>;
@@ -3311,4 +3429,4 @@ declare const readonlyConfig: Partial<FlowConfig>;
3311
3429
  */
3312
3430
  declare function resolveBehavior<TEntity, TState>(predicate: ((entity: TEntity, state: TState) => boolean) | false | undefined, entity: TEntity, state: TState, defaultValue?: boolean): boolean;
3313
3431
  //#endregion
3314
- 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 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 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, 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, resizeMode, 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 };
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 };