@pixerate/editor 0.23.0 → 0.24.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.
Files changed (155) hide show
  1. package/README.md +96 -1
  2. package/THIRD_PARTY_NOTICES.md +51 -0
  3. package/dist/agent/index.cjs +9 -8
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +4 -3
  6. package/dist/agent/index.d.ts +4 -3
  7. package/dist/agent/index.js +3 -2
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/canvas/index.cjs +1210 -17
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.d.cts +318 -1
  12. package/dist/canvas/index.d.ts +318 -1
  13. package/dist/canvas/index.js +1199 -6
  14. package/dist/canvas/index.js.map +1 -1
  15. package/dist/{chunk-QBJ22YZR.js → chunk-3CN2WD3X.js} +1354 -206
  16. package/dist/chunk-3CN2WD3X.js.map +1 -0
  17. package/dist/{chunk-JJDLPEWL.js → chunk-3LV6RRPH.js} +2 -2
  18. package/dist/{chunk-MJZBNWG7.js → chunk-5S3Z4PPF.js} +78 -557
  19. package/dist/chunk-5S3Z4PPF.js.map +1 -0
  20. package/dist/chunk-664LQYFJ.js +115 -0
  21. package/dist/chunk-664LQYFJ.js.map +1 -0
  22. package/dist/{chunk-AA4ZEVCC.cjs → chunk-D27YFC46.cjs} +101 -580
  23. package/dist/chunk-D27YFC46.cjs.map +1 -0
  24. package/dist/chunk-D6FH2YAX.cjs +131 -0
  25. package/dist/chunk-D6FH2YAX.cjs.map +1 -0
  26. package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
  27. package/dist/chunk-FD4LPFAE.cjs.map +1 -0
  28. package/dist/chunk-FODNLX5N.js +749 -0
  29. package/dist/chunk-FODNLX5N.js.map +1 -0
  30. package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
  31. package/dist/chunk-FPENXAEJ.js.map +1 -0
  32. package/dist/chunk-HLIMTC6N.js +1 -0
  33. package/dist/chunk-HLIMTC6N.js.map +1 -0
  34. package/dist/{chunk-QGHGJ56O.js → chunk-ITBSKI26.js} +1483 -19
  35. package/dist/chunk-ITBSKI26.js.map +1 -0
  36. package/dist/{chunk-XDMXXC4Z.cjs → chunk-MA2F5KHF.cjs} +350 -227
  37. package/dist/chunk-MA2F5KHF.cjs.map +1 -0
  38. package/dist/{chunk-RIKBJLS2.cjs → chunk-MCSJFWAO.cjs} +1356 -208
  39. package/dist/chunk-MCSJFWAO.cjs.map +1 -0
  40. package/dist/chunk-MKA3AHLV.cjs +256 -0
  41. package/dist/chunk-MKA3AHLV.cjs.map +1 -0
  42. package/dist/chunk-OLZJXL4R.cjs +749 -0
  43. package/dist/chunk-OLZJXL4R.cjs.map +1 -0
  44. package/dist/chunk-OXSV64JX.js +689 -0
  45. package/dist/chunk-OXSV64JX.js.map +1 -0
  46. package/dist/chunk-P3RQ5UJE.cjs +689 -0
  47. package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
  48. package/dist/chunk-P6ODPZ4W.js +256 -0
  49. package/dist/chunk-P6ODPZ4W.js.map +1 -0
  50. package/dist/chunk-PGNZKFQS.js +685 -0
  51. package/dist/chunk-PGNZKFQS.js.map +1 -0
  52. package/dist/chunk-PL4JB3BF.cjs +1 -0
  53. package/dist/chunk-PL4JB3BF.cjs.map +1 -0
  54. package/dist/{chunk-GVSMRPHB.cjs → chunk-SBCZ6RN5.cjs} +1568 -104
  55. package/dist/chunk-SBCZ6RN5.cjs.map +1 -0
  56. package/dist/{chunk-CL37JGFW.cjs → chunk-SML64VJG.cjs} +4 -4
  57. package/dist/{chunk-CL37JGFW.cjs.map → chunk-SML64VJG.cjs.map} +1 -1
  58. package/dist/chunk-TNNJXF46.cjs +115 -0
  59. package/dist/chunk-TNNJXF46.cjs.map +1 -0
  60. package/dist/chunk-U5HZSFCS.js +131 -0
  61. package/dist/chunk-U5HZSFCS.js.map +1 -0
  62. package/dist/{chunk-K3R5NG2D.js → chunk-U5KWZU4X.js} +251 -128
  63. package/dist/chunk-U5KWZU4X.js.map +1 -0
  64. package/dist/chunk-XNORY7M6.cjs +685 -0
  65. package/dist/chunk-XNORY7M6.cjs.map +1 -0
  66. package/dist/commands/index.d.cts +5 -353
  67. package/dist/commands/index.d.ts +5 -353
  68. package/dist/comment-store-BEMgVlAA.d.cts +135 -0
  69. package/dist/comment-store-BEMgVlAA.d.ts +135 -0
  70. package/dist/compare/index.cjs +15 -0
  71. package/dist/compare/index.cjs.map +1 -0
  72. package/dist/compare/index.d.cts +58 -0
  73. package/dist/compare/index.d.ts +58 -0
  74. package/dist/compare/index.js +15 -0
  75. package/dist/compare/index.js.map +1 -0
  76. package/dist/{controller-pePCJLT1.d.cts → controller-BhLLAoi8.d.cts} +45 -4
  77. package/dist/{controller-pePCJLT1.d.ts → controller-BhLLAoi8.d.ts} +45 -4
  78. package/dist/documents-BQjzJNe2.d.ts +76 -0
  79. package/dist/documents-KRTPhvst.d.cts +76 -0
  80. package/dist/extensions/index.cjs +53 -5
  81. package/dist/extensions/index.cjs.map +1 -1
  82. package/dist/extensions/index.d.cts +7 -3
  83. package/dist/extensions/index.d.ts +7 -3
  84. package/dist/extensions/index.js +52 -4
  85. package/dist/generation/index.cjs +1373 -0
  86. package/dist/generation/index.cjs.map +1 -0
  87. package/dist/generation/index.d.cts +554 -0
  88. package/dist/generation/index.d.ts +554 -0
  89. package/dist/generation/index.js +1373 -0
  90. package/dist/generation/index.js.map +1 -0
  91. package/dist/grammar/index.cjs +48 -3
  92. package/dist/grammar/index.cjs.map +1 -1
  93. package/dist/grammar/index.d.cts +322 -100
  94. package/dist/grammar/index.d.ts +322 -100
  95. package/dist/grammar/index.js +54 -9
  96. package/dist/image-editor/index.cjs +1831 -30
  97. package/dist/image-editor/index.cjs.map +1 -1
  98. package/dist/image-editor/index.d.cts +590 -3
  99. package/dist/image-editor/index.d.ts +590 -3
  100. package/dist/image-editor/index.js +1807 -6
  101. package/dist/image-editor/index.js.map +1 -1
  102. package/dist/{index-CCr_z9kF.d.cts → index-BhJBSm2d.d.cts} +370 -4
  103. package/dist/{index-Ck6ajwXh.d.ts → index-fJrlkJCd.d.ts} +370 -4
  104. package/dist/index.cjs +162 -25
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +14 -8
  107. package/dist/index.d.ts +14 -8
  108. package/dist/index.js +174 -37
  109. package/dist/index.js.map +1 -1
  110. package/dist/migrate-iTlm3a8h.d.cts +112 -0
  111. package/dist/migrate-iTlm3a8h.d.ts +112 -0
  112. package/dist/persistence/index.cjs +676 -0
  113. package/dist/persistence/index.cjs.map +1 -0
  114. package/dist/persistence/index.d.cts +347 -0
  115. package/dist/persistence/index.d.ts +347 -0
  116. package/dist/persistence/index.js +676 -0
  117. package/dist/persistence/index.js.map +1 -0
  118. package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
  119. package/dist/registry-D32LpIc4.d.cts +354 -0
  120. package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
  121. package/dist/registry-evKTP4ls.d.ts +354 -0
  122. package/dist/schema-DYDGdYL9.d.cts +41 -0
  123. package/dist/schema-DYDGdYL9.d.ts +41 -0
  124. package/dist/serializers/index.cjs +4 -3
  125. package/dist/serializers/index.cjs.map +1 -1
  126. package/dist/serializers/index.d.cts +2 -1
  127. package/dist/serializers/index.d.ts +2 -1
  128. package/dist/serializers/index.js +3 -2
  129. package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
  130. package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
  131. package/dist/spreadsheet/index.cjs +37 -3
  132. package/dist/spreadsheet/index.cjs.map +1 -1
  133. package/dist/spreadsheet/index.d.cts +188 -17
  134. package/dist/spreadsheet/index.d.ts +188 -17
  135. package/dist/spreadsheet/index.js +43 -9
  136. package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
  137. package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
  138. package/dist/{track-changes-BSF58RK0.d.ts → track-changes-BK5sVf4_.d.cts} +18 -136
  139. package/dist/{track-changes-BSF58RK0.d.cts → track-changes-CDjCrwKe.d.ts} +18 -136
  140. package/package.json +16 -1
  141. package/dist/chunk-4SUNJZWB.cjs.map +0 -1
  142. package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
  143. package/dist/chunk-AXV2ZW34.cjs +0 -118
  144. package/dist/chunk-AXV2ZW34.cjs.map +0 -1
  145. package/dist/chunk-B2ZRLN4S.js +0 -118
  146. package/dist/chunk-B2ZRLN4S.js.map +0 -1
  147. package/dist/chunk-GVSMRPHB.cjs.map +0 -1
  148. package/dist/chunk-K3R5NG2D.js.map +0 -1
  149. package/dist/chunk-MJZBNWG7.js.map +0 -1
  150. package/dist/chunk-OYXSKQFR.js.map +0 -1
  151. package/dist/chunk-QBJ22YZR.js.map +0 -1
  152. package/dist/chunk-QGHGJ56O.js.map +0 -1
  153. package/dist/chunk-RIKBJLS2.cjs.map +0 -1
  154. package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
  155. /package/dist/{chunk-JJDLPEWL.js.map → chunk-3LV6RRPH.js.map} +0 -0
@@ -1100,6 +1100,214 @@ declare function snapNodeResize(nodes: CanvasNode[], id: string, rect: Rect, han
1100
1100
  */
1101
1101
  declare function getResizingNodeRect(node: CanvasNode, lookup: ReadonlyMap<string, CanvasNode>, options?: NodeRectOptions): Rect;
1102
1102
 
1103
+ /**
1104
+ * Figma-style auto layout for xyflow sub-flows.
1105
+ *
1106
+ * A *frame* is any node with `data.layout` (an {@link AutoLayout}); its children are the nodes
1107
+ * whose `parentId` is the frame, in node-array order. Children may carry `data.childLayout`
1108
+ * (an {@link AutoLayoutChild}) for their own sizing, min / max, absolute positioning,
1109
+ * constraints and grid cell. The functions here are pure: they return `CanvasNodeUpdate`s
1110
+ * (positions relative to the parent, sizes) for `applyNodeUpdates`.
1111
+ */
1112
+ /** Data key holding a frame's {@link AutoLayout}. */
1113
+ declare const AUTO_LAYOUT_DATA_KEY = "layout";
1114
+ /** Data key holding a child's {@link AutoLayoutChild}. */
1115
+ declare const CHILD_LAYOUT_DATA_KEY = "childLayout";
1116
+ type AutoLayoutMode = 'horizontal' | 'vertical' | 'grid';
1117
+ /** `fixed` keeps the size, `hug` fits the content (frames and text), `fill` shares the parent's free space. */
1118
+ type AutoLayoutSizing = 'fixed' | 'hug' | 'fill';
1119
+ type AutoLayoutAlignMain = 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly';
1120
+ type AutoLayoutAlignCross = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
1121
+ /** How wrapped lines share the free cross space: packed by `alignCross` (`auto`) or spread (`space-between`). */
1122
+ type AutoLayoutAlignContent = 'auto' | 'space-between';
1123
+ /** `number` (all sides), `[vertical, horizontal]`, `[top, right, bottom, left]` or per side. */
1124
+ type AutoLayoutPadding = number | [number, number] | [number, number, number, number] | {
1125
+ top?: number;
1126
+ right?: number;
1127
+ bottom?: number;
1128
+ left?: number;
1129
+ };
1130
+ interface AutoLayoutSize {
1131
+ width?: number;
1132
+ height?: number;
1133
+ }
1134
+ interface AutoLayoutSizingPair {
1135
+ width?: AutoLayoutSizing;
1136
+ height?: AutoLayoutSizing;
1137
+ }
1138
+ /** A grid track: pixels, `'hug'` (fits its content), `'2fr'` or `{ fr: 2 }` (shares the rest like CSS `fr`). */
1139
+ type AutoLayoutGridTrack = number | 'hug' | `${number}fr` | {
1140
+ fr: number;
1141
+ };
1142
+ interface AutoLayoutGrid {
1143
+ /** Column count (all `1fr`) or the column tracks (default 2 columns). */
1144
+ columns?: number | AutoLayoutGridTrack[];
1145
+ /** Minimum row count or the row tracks (default 1); rows are added to fit the children. Missing tracks are `1fr`. */
1146
+ rows?: number | AutoLayoutGridTrack[];
1147
+ }
1148
+ /** A frame's auto layout (`node.data.layout`). */
1149
+ interface AutoLayout {
1150
+ mode: AutoLayoutMode;
1151
+ /** Main-axis gap (grid: column gap). Negative gaps overlap. Default 0. */
1152
+ gap?: number;
1153
+ /** Gap between wrapped lines (grid: row gap). Default: `gap`. */
1154
+ rowGap?: number;
1155
+ /** Default 0. */
1156
+ padding?: AutoLayoutPadding;
1157
+ /** Horizontal / vertical: wrap into lines when the main axis runs out (ignored while hugging it). */
1158
+ wrap?: boolean;
1159
+ /** Default `start`. Grid: the cell alignment along x (`start`, `center`, `end`). */
1160
+ alignMain?: AutoLayoutAlignMain;
1161
+ /** Default `start`. `baseline` applies to horizontal layouts. Grid: the cell alignment along y. */
1162
+ alignCross?: AutoLayoutAlignCross;
1163
+ alignContent?: AutoLayoutAlignContent;
1164
+ /** The frame's own sizing (`childLayout.sizing` wins when both are set). Default `fixed`. */
1165
+ sizing?: AutoLayoutSizingPair;
1166
+ /** The frame's own limits (`childLayout.min` / `max` win when set). */
1167
+ min?: AutoLayoutSize;
1168
+ max?: AutoLayoutSize;
1169
+ grid?: AutoLayoutGrid;
1170
+ }
1171
+ type AutoLayoutHorizontalConstraint = 'left' | 'right' | 'leftRight' | 'center' | 'scale';
1172
+ type AutoLayoutVerticalConstraint = 'top' | 'bottom' | 'topBottom' | 'center' | 'scale';
1173
+ interface AutoLayoutConstraints {
1174
+ horizontal?: AutoLayoutHorizontalConstraint;
1175
+ vertical?: AutoLayoutVerticalConstraint;
1176
+ }
1177
+ type AutoLayoutCellAlign = 'start' | 'center' | 'end';
1178
+ /** A grid child's cell. Column / row are 0-based anchors; unanchored children flow in reading order. */
1179
+ interface AutoLayoutGridArea {
1180
+ column?: number;
1181
+ row?: number;
1182
+ columnSpan?: number;
1183
+ rowSpan?: number;
1184
+ /** The child's own alignment in its cell (wins over the frame's). */
1185
+ alignX?: AutoLayoutCellAlign;
1186
+ alignY?: AutoLayoutCellAlign;
1187
+ }
1188
+ /** A child's layout properties (`node.data.childLayout`). */
1189
+ interface AutoLayoutChild {
1190
+ sizing?: AutoLayoutSizingPair;
1191
+ min?: AutoLayoutSize;
1192
+ max?: AutoLayoutSize;
1193
+ /** Ignore auto layout: keep its place and follow `constraints` when the frame resizes. */
1194
+ absolute?: boolean;
1195
+ /** How the child follows its parent's resizes (default left / top). */
1196
+ constraints?: AutoLayoutConstraints;
1197
+ gridArea?: AutoLayoutGridArea;
1198
+ }
1199
+ /**
1200
+ * Measuring hooks. `size` defaults to `getNodeSize` (xyflow `measured` size, then `width` /
1201
+ * `height`, then style). Nodes for which `textSize` returns a size are *text-like*: they can
1202
+ * hug, and wrap (`textHeight`) when their width is set by the layout.
1203
+ */
1204
+ interface AutoLayoutMeasure {
1205
+ size?: (node: CanvasNode) => {
1206
+ width: number;
1207
+ height: number;
1208
+ } | undefined;
1209
+ /** Natural (unwrapped) size of a text-like node. */
1210
+ textSize?: (node: CanvasNode) => {
1211
+ width: number;
1212
+ height: number;
1213
+ } | undefined;
1214
+ /** Height of a text-like node wrapped at `width`. */
1215
+ textHeight?: (node: CanvasNode, width: number) => number | undefined;
1216
+ /** Distance from the node's top to its first text baseline (for `alignCross: 'baseline'`). */
1217
+ textBaseline?: (node: CanvasNode) => number | undefined;
1218
+ }
1219
+ interface AutoLayoutOptions {
1220
+ measure?: AutoLayoutMeasure;
1221
+ /** Size resolution for unmeasured nodes when `measure.size` is not given. */
1222
+ rectOptions?: NodeRectOptions;
1223
+ }
1224
+ type Axis = 'width' | 'height';
1225
+ /** Clamps a size to `[min, max]`; non-finite or negative sizes become 0 and min wins over a smaller max. */
1226
+ declare function clampLayoutSize(value: number, min?: number, max?: number): number;
1227
+ /** The node's auto layout, or `undefined` when it is not an auto layout frame. */
1228
+ declare function getAutoLayout(node: CanvasNode | undefined | null): AutoLayout | undefined;
1229
+ /** Whether the node is an auto layout frame. */
1230
+ declare function isAutoLayoutFrame(node: CanvasNode | undefined | null): boolean;
1231
+ /** The node's child layout properties (empty when unset). */
1232
+ declare function getChildLayout(node: CanvasNode | undefined | null): AutoLayoutChild;
1233
+ /** Effective sizing of a node on one axis: `childLayout.sizing`, then `layout.sizing`, then `fixed`. */
1234
+ declare function getLayoutSizing(node: CanvasNode, axis: Axis): AutoLayoutSizing;
1235
+ /** Padding as `[top, right, bottom, left]`, sanitised (non-finite and negative values become 0). */
1236
+ declare function resolvePadding(padding: AutoLayoutPadding | undefined): [number, number, number, number];
1237
+ /** A grid child's cell (0-based column / row and spans). */
1238
+ interface AutoLayoutGridCell {
1239
+ id: string;
1240
+ column: number;
1241
+ row: number;
1242
+ columnSpan: number;
1243
+ rowSpan: number;
1244
+ }
1245
+ /** A grid frame's resolved geometry (frame-local): column x ranges, row y ranges, cells and the size it wants. */
1246
+ interface AutoLayoutGridGeometry {
1247
+ columns: [number, number][];
1248
+ rows: [number, number][];
1249
+ cells: AutoLayoutGridCell[];
1250
+ width: number;
1251
+ height: number;
1252
+ }
1253
+ /**
1254
+ * Lays out one auto layout frame's children and sizes the frame when it hugs (nested frames
1255
+ * that are resized by the layout are laid out again). Returns the position / size updates.
1256
+ */
1257
+ declare function layoutFrame(nodes: CanvasNode[], frameId: string, options?: AutoLayoutOptions): CanvasNodeUpdate[];
1258
+ /** Lays out every auto layout frame, children before parents, so nested hugging settles in one pass. */
1259
+ declare function layoutAll(nodes: CanvasNode[], options?: AutoLayoutOptions): CanvasNodeUpdate[];
1260
+ /**
1261
+ * Lays out `changedId` (when it is a frame) and then each of its auto layout ancestors,
1262
+ * innermost first. Use it after a node inside a frame was added, removed, resized or moved.
1263
+ */
1264
+ declare function layoutUp(nodes: CanvasNode[], changedId: string, options?: AutoLayoutOptions): CanvasNodeUpdate[];
1265
+ /** {@link layoutUp} for several changed nodes at once (each chain once, innermost frames first). */
1266
+ declare function layoutUpMany(nodes: CanvasNode[], changedIds: Iterable<string>, options?: AutoLayoutOptions): CanvasNodeUpdate[];
1267
+ /**
1268
+ * Children of `parentId` follow their constraints after the parent was resized from
1269
+ * `previousSize` to its current size. In an auto layout frame only absolute children move
1270
+ * (the layout places the others). Returns the updates.
1271
+ */
1272
+ declare function applyConstraints(nodes: CanvasNode[], parentId: string, previousSize: {
1273
+ width: number;
1274
+ height: number;
1275
+ }, options?: AutoLayoutOptions): CanvasNodeUpdate[];
1276
+ /** The resolved grid of a grid frame (frame-local), from its children's current sizes. */
1277
+ declare function getAutoLayoutGrid(nodes: CanvasNode[], frameId: string, options?: AutoLayoutOptions): AutoLayoutGridGeometry | undefined;
1278
+ /** Ids of the children a frame places (visible, not absolute), in order. */
1279
+ declare function getFlowChildren(nodes: CanvasNode[], frameId: string): string[];
1280
+ /** The nearest auto layout frame that places `id` (its parent, when `id` is a flow child). */
1281
+ declare function getLayoutParent(nodes: CanvasNode[], id: string): CanvasNode | undefined;
1282
+ /**
1283
+ * Makes a node's sizing coherent with where it sits, and that of its children: `fill` needs an
1284
+ * auto layout parent that does not hug that axis (and a flow child), `hug` needs an auto layout
1285
+ * frame or a text-like node (see `measure.textSize`); otherwise the axis becomes `fixed`.
1286
+ * Writes `data.childLayout.sizing`. Returns a new array (unchanged nodes keep their identity).
1287
+ */
1288
+ declare function makeSizingCoherent<TNode extends CanvasNode>(nodes: TNode[], id: string, options?: AutoLayoutOptions): TNode[];
1289
+ interface AutoLayoutInsertTarget {
1290
+ frameId: string;
1291
+ /** Index among the frame's flow children, not counting the dragged node. */
1292
+ index: number;
1293
+ /** Insertion marker (absolute flow coordinates) for `<CanvasGuidesLayer>`. */
1294
+ guide: GuideLine;
1295
+ }
1296
+ /**
1297
+ * Where a node dropped at `point` (absolute flow coordinates) goes among the flow children of
1298
+ * auto layout frame `frameId`: the reading-order index of the slot under the point. `excludeId`
1299
+ * (the dragged node) is left out of the siblings.
1300
+ */
1301
+ declare function getAutoLayoutInsertTarget(nodes: CanvasNode[], frameId: string, point: XYPosition, options?: AutoLayoutOptions & {
1302
+ excludeId?: string;
1303
+ }): AutoLayoutInsertTarget | undefined;
1304
+ /**
1305
+ * Moves child `childId` of an auto layout frame to flow index `index` (among its flow siblings)
1306
+ * by reordering the node array; parents still precede their children. Returns a new array
1307
+ * (the same array when nothing moves).
1308
+ */
1309
+ declare function moveLayoutChild<TNode extends CanvasNode>(nodes: TNode[], childId: string, index: number): TNode[];
1310
+
1103
1311
  /** Minimal history surface (`HistoryManager` satisfies it). */
1104
1312
  interface ArrangeHistoryTarget {
1105
1313
  execute(command: Command): void;
@@ -1129,6 +1337,11 @@ interface CanvasArrangeControllerOptions<TNode extends CanvasNode = CanvasNode>
1129
1337
  rectOptions?: NodeRectOptions;
1130
1338
  /** Called whenever the guide segments change (set while dragging, cleared on drop). */
1131
1339
  onGuidesChange?: (guides: GuideLine[]) => void;
1340
+ /**
1341
+ * Re-run auto layout (`data.layout` frames) around the nodes an arrange action moves or
1342
+ * resizes, in the same undoable step. `true` uses the default measuring.
1343
+ */
1344
+ autoLayout?: boolean | AutoLayoutOptions;
1132
1345
  }
1133
1346
  /**
1134
1347
  * A React Flow / SvelteFlow style node change; only `position` changes are inspected.
@@ -1370,4 +1583,108 @@ declare function fitPathData(ring: readonly Point[], options?: FitPathDataOption
1370
1583
  */
1371
1584
  declare function fitFreehandPath(points: readonly Point[], options?: Omit<FitPathDataOptions, 'closed'>): string;
1372
1585
 
1373
- export { AlignEdge, AlignNodesOptions, type ArrangeHistoryTarget, CONNECTION_LINE_TYPES, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, CanvasClipboardPayload, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasViewport, type Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type EllipseShape, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, IncrementalLayoutOptions, ManualClock, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MultiNodeTransitionOptions, type MultiPolygon, NodeRectOptions, NodeTransition, type PathCommand, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SerializedCanvasScenes, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, ZOrderOperation, applyShapeCombination, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canvasHeight, centerNodes, centre, collectDescendantIds, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, createBezierTrajectory, createCanvasArrangeController, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, defaultEasing, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, findConnectorSnap, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatNumber, getCenteredNodePosition, getLayoutedNodes, getNodeShape, getResizingNodeRect, getShapeRenderData, getShapeSvg, handlePoint, inferResizeHandle, intersectPolygons, isEventFromTextInput, isMeasureModifierHeld, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutBounds, linearPositionTrajectory, linearTrajectory, measureBetween, measureLabel, measureSelection, measureToLine, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, oppositePosition, overlaps, pageHidden, parseCanvasClipboardData, parseCanvasScenes, parseSvgPath, placeBeside, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, realClock, remapPastedNodes, repositionNodesTo, resizeHandleAxes, revertShapeCombination, ringSignedArea, runMultiNodeTransition, serializeCanvasNodes, shapeNodeToPolygon, shapeToPolygon, sideToPosition, simplifyRing, snapNodeDrag, snapNodeResize, snapResize, snapToGrid, subtractPolygons, unionPolygons, withStyleOpacity, xorPolygons };
1586
+ interface CanvasAutoLayoutControllerOptions<TNode extends CanvasNode = CanvasNode> extends AutoLayoutOptions {
1587
+ getNodes: () => TNode[];
1588
+ setNodes: (nodes: TNode[]) => void;
1589
+ /** When set, controller actions (add / remove / resize / reorder / apply) are one undoable step each. */
1590
+ history?: ArrangeHistoryTarget;
1591
+ /** Turns automatic relayout off (explicit `applyAutoLayout` still works). Default `true`. */
1592
+ enabled?: boolean;
1593
+ /** Reorder flow children by dragging them inside their frame (default `true`). */
1594
+ dragReorder?: boolean;
1595
+ /** Called when the drop marker of a reorder drag changes (empty when none). */
1596
+ onGuidesChange?: (guides: GuideLine[]) => void;
1597
+ }
1598
+ /**
1599
+ * Merges the updates of several layout passes (later ones win per field).
1600
+ */
1601
+ declare function mergeNodeUpdates(...lists: CanvasNodeUpdate[][]): CanvasNodeUpdate[];
1602
+ /**
1603
+ * Updates that re-run auto layout around `ids` after a change: each id's own layout (if a
1604
+ * frame) and its auto layout ancestors, plus the frames that lost removed children
1605
+ * (`parentIds`). Pure helper used by the controllers.
1606
+ */
1607
+ declare function relayoutUpdates(nodes: CanvasNode[], ids: Iterable<string>, options?: AutoLayoutOptions): CanvasNodeUpdate[];
1608
+ /**
1609
+ * Framework-agnostic auto layout controller shared by the React hook and the Svelte rune.
1610
+ * Applies auto layout to frames (`data.layout`) after nodes inside them are added, removed,
1611
+ * resized or reordered, either through its own (undoable) actions or by watching the flow's
1612
+ * node changes (`noteChanges` + `flush`), and reorders flow children dragged within a frame.
1613
+ */
1614
+ declare function createCanvasAutoLayoutController<TNode extends CanvasNode = CanvasNode>(options: CanvasAutoLayoutControllerOptions<TNode>): {
1615
+ /** Drop marker of the active reorder drag (flow coordinates); empty otherwise. */
1616
+ readonly guides: GuideLine[];
1617
+ /**
1618
+ * Lays out frame `frameId` and its auto layout ancestors (default: every frame) as one
1619
+ * (optionally undoable) step. Returns the updates.
1620
+ */
1621
+ applyAutoLayout(frameId?: string): CanvasNodeUpdate[];
1622
+ /** Updates that relayout around `ids` on the current nodes, without applying them. */
1623
+ layoutUpdates(ids: Iterable<string>): CanvasNodeUpdate[];
1624
+ /**
1625
+ * Applies the relayout around `ids` (frames, or nodes inside frames) directly, not
1626
+ * recorded in history: auto layout is derived state, re-run after any change.
1627
+ */
1628
+ relayout(ids: Iterable<string>): CanvasNodeUpdate[];
1629
+ /**
1630
+ * Adds `node` (into the frame named by its `parentId`, at flow `index` when given) and
1631
+ * lays out its frame, as one step.
1632
+ */
1633
+ addNode(node: TNode, addOptions?: {
1634
+ index?: number;
1635
+ }): CanvasNodeUpdate[];
1636
+ /** Removes nodes (and their descendants) and lays out the frames they leave, as one step. */
1637
+ removeNodes(ids: Iterable<string>): CanvasNodeUpdate[];
1638
+ /**
1639
+ * Resizes node `id` (its children follow their constraints) and lays out around it,
1640
+ * as one step.
1641
+ */
1642
+ resizeNode(id: string, size: {
1643
+ width?: number;
1644
+ height?: number;
1645
+ }): CanvasNodeUpdate[];
1646
+ /** Moves flow child `childId` to flow index `index` in its frame and lays it out, as one step. */
1647
+ moveChild(childId: string, index: number): CanvasNodeUpdate[];
1648
+ /** Where flow child `id` would drop if released at `point` (default: its centre). */
1649
+ getInsertTarget(id: string, point?: XYPosition): AutoLayoutInsertTarget | undefined;
1650
+ /** Records the start position of a reorder drag. Optional: `dragReorder` records it lazily. */
1651
+ beginReorderDrag(id: string): void;
1652
+ /**
1653
+ * While flow child `id` is dragged (as currently positioned in `getNodes()`): updates the
1654
+ * drop marker. Returns the insert target.
1655
+ */
1656
+ dragReorder(id: string, point?: XYPosition): AutoLayoutInsertTarget | undefined;
1657
+ /**
1658
+ * Ends a reorder drag: moves `id` to the slot under `point` (default: its centre) and lays
1659
+ * the frame out, as one undoable step whose undo puts the node back where the drag began.
1660
+ */
1661
+ endReorderDrag(id: string, point?: XYPosition): CanvasNodeUpdate[];
1662
+ /**
1663
+ * Notes a batch of React Flow / SvelteFlow style node changes (before or after they are
1664
+ * applied) so `flush` can relayout: dimension changes (measured sizes, resize ends),
1665
+ * added and removed nodes, and position changes of flow children (reorder drags).
1666
+ * Returns the changes unchanged.
1667
+ */
1668
+ noteChanges<TChange extends PositionChangeLike>(changes: TChange[]): TChange[];
1669
+ /**
1670
+ * Notes nodes that were already removed (e.g. SvelteFlow's `ondelete`), so `flush`
1671
+ * relayouts the frames they left. The nodes must still carry their `parentId`.
1672
+ */
1673
+ noteRemoved(removed: Iterable<{
1674
+ id: string;
1675
+ parentId?: string;
1676
+ }>): void;
1677
+ /** Whether `noteChanges` left work for `flush`. */
1678
+ readonly hasPending: boolean;
1679
+ /**
1680
+ * Applies the work noted by `noteChanges` to the current nodes: drop markers while
1681
+ * dragging, committed reorders on drop (undoable), and a relayout (not recorded) for
1682
+ * size, add and remove changes. Call it once the changes are applied.
1683
+ */
1684
+ flush(): CanvasNodeUpdate[];
1685
+ /** Whether `id` is an auto layout frame. */
1686
+ isFrame: (id: string) => boolean;
1687
+ };
1688
+ type CanvasAutoLayoutController<TNode extends CanvasNode = CanvasNode> = ReturnType<typeof createCanvasAutoLayoutController<TNode>>;
1689
+
1690
+ export { AUTO_LAYOUT_DATA_KEY, AlignEdge, AlignNodesOptions, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, CHILD_LAYOUT_DATA_KEY, CONNECTION_LINE_TYPES, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasViewport, type Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type EllipseShape, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, IncrementalLayoutOptions, ManualClock, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MultiNodeTransitionOptions, type MultiPolygon, NodeRectOptions, NodeTransition, type PathCommand, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SerializedCanvasScenes, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, ZOrderOperation, applyConstraints, applyShapeCombination, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canvasHeight, centerNodes, centre, clampLayoutSize, collectDescendantIds, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, createBezierTrajectory, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, defaultEasing, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, findConnectorSnap, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatNumber, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getCenteredNodePosition, getChildLayout, getFlowChildren, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNodeShape, getResizingNodeRect, getShapeRenderData, getShapeSvg, handlePoint, inferResizeHandle, intersectPolygons, isAutoLayoutFrame, isEventFromTextInput, isMeasureModifierHeld, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, oppositePosition, overlaps, pageHidden, parseCanvasClipboardData, parseCanvasScenes, parseSvgPath, placeBeside, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, realClock, relayoutUpdates, remapPastedNodes, repositionNodesTo, resizeHandleAxes, resolvePadding, revertShapeCombination, ringSignedArea, runMultiNodeTransition, serializeCanvasNodes, shapeNodeToPolygon, shapeToPolygon, sideToPosition, simplifyRing, snapNodeDrag, snapNodeResize, snapResize, snapToGrid, subtractPolygons, unionPolygons, withStyleOpacity, xorPolygons };