@pixerate/editor-react 0.108.0 → 0.110.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.
@@ -681,9 +681,9 @@ function useCanvasDocking(options = {}) {
681
681
  }
682
682
 
683
683
  // src/canvas/useCanvasExplosion.ts
684
- import { useCallback as useCallback6, useRef as useRef5 } from "react";
684
+ import { useCallback as useCallback6, useEffect as useEffect3, useRef as useRef5, useState as useState2 } from "react";
685
685
  import {
686
- calculateDirectionalDisplacement,
686
+ computeCanvasExplosionLayout,
687
687
  createFanOutTrajectory,
688
688
  linearPositionTrajectory,
689
689
  runMultiNodeTransition
@@ -693,75 +693,89 @@ function mergeById(base, updated) {
693
693
  const byId = new Map(updated.map((n) => [n.id, n]));
694
694
  return base.map((n) => byId.get(n.id) ?? n);
695
695
  }
696
- function useCanvasExplosion(target) {
696
+ function useCanvasExplosion(target, hookOptions = {}) {
697
697
  const snapshotsRef = useRef5(/* @__PURE__ */ new Map());
698
+ const cancelRef = useRef5(null);
699
+ const [explodedNodeIds, setExplodedNodeIds] = useState2([]);
700
+ const optionsRef = useRef5(hookOptions);
701
+ optionsRef.current = hookOptions;
702
+ useEffect3(() => () => cancelRef.current?.(), []);
703
+ const run = (transitions, base, duration, onComplete) => {
704
+ cancelRef.current?.();
705
+ cancelRef.current = runMultiNodeTransition(transitions, {
706
+ styleFormat: "object",
707
+ defaultDuration: duration,
708
+ onUpdate: (updated) => target.setNodes(mergeById(base, updated)),
709
+ onComplete: () => {
710
+ cancelRef.current = null;
711
+ onComplete();
712
+ }
713
+ });
714
+ };
698
715
  const explodeNode = useCallback6(
699
716
  (parentNodeId, options) => {
700
717
  const { nodes, edges, setNodes, setEdges } = target;
718
+ if (snapshotsRef.current.has(parentNodeId)) return false;
701
719
  const parent = nodes.find((n) => n.id === parentNodeId);
702
- if (!parent || options.childNodes.length === 0) return;
703
- const originPos = { ...parent.position };
704
- const displacedMap = options.displacementStrategy === "directional" ? calculateDirectionalDisplacement({
720
+ if (!parent || options.childNodes.length === 0) return false;
721
+ const {
722
+ connectParentToChildren = "all",
723
+ displacementStrategy = "directional",
724
+ duration = 500,
725
+ staggerDelay = 20,
726
+ easing
727
+ } = options;
728
+ const layout = computeCanvasExplosionLayout({
705
729
  existingNodes: nodes,
730
+ existingEdges: edges,
706
731
  originNode: parent,
707
732
  childNodes: options.childNodes,
708
- options: options.directionalOptions
709
- }) : /* @__PURE__ */ new Map();
710
- const snapshot = {
733
+ childEdges: options.childEdges,
734
+ strategy: displacementStrategy,
735
+ options: options.directionalOptions,
736
+ reflowOptions: options.reflowOptions,
737
+ connectParentToChildren,
738
+ createEdge: target.createEdge,
739
+ getNodesBounds: optionsRef.current.getNodesBounds
740
+ });
741
+ snapshotsRef.current.set(parentNodeId, {
711
742
  parentId: parentNodeId,
712
- childNodeIds: options.childNodes.map((c) => c.id),
713
- childEdgeIds: (options.childEdges ?? []).map((e) => e.id),
714
- displacedNodes: Array.from(displacedMap.entries()).map(([id]) => {
715
- const node = nodes.find((n) => n.id === id);
716
- return { id, originalPosition: { ...node.position } };
717
- }),
743
+ childNodeIds: layout.childNodes.map((c) => c.id),
744
+ childEdgeIds: layout.childEdges.map((e) => e.id),
745
+ displacedNodes: [...layout.originalPositions].map(([id, originalPosition]) => ({ id, originalPosition })),
718
746
  timestamp: Date.now()
719
- };
720
- snapshotsRef.current.set(parentNodeId, snapshot);
721
- const initialChildren = options.childNodes.map((child) => ({
722
- ...child,
723
- position: { ...originPos }
724
- }));
747
+ });
748
+ const originPos = { ...parent.position };
749
+ const initialChildren = layout.childNodes.map((child) => ({ ...child, position: { ...originPos } }));
725
750
  const mergedNodes = [...nodes, ...initialChildren];
726
751
  setNodes(mergedNodes);
727
- if (options.childEdges && options.childEdges.length > 0) {
728
- setEdges((prev) => [...prev, ...options.childEdges]);
729
- }
730
- const trajectory = options.trajectory ?? createFanOutTrajectory();
752
+ if (layout.childEdges.length > 0) setEdges((prev) => [...prev, ...layout.childEdges]);
753
+ const trajectory = options.trajectory ?? createFanOutTrajectory({ curvature: 0.35 });
754
+ const stagger = duration === 0 ? 0 : staggerDelay;
731
755
  const transitions = [];
732
- options.childNodes.forEach((child, index) => {
733
- const liveChild = mergedNodes.find((n) => n.id === child.id);
734
- if (liveChild) {
735
- transitions.push({
736
- node: liveChild,
737
- from: originPos,
738
- to: child.position,
739
- trajectory,
740
- index,
741
- total: options.childNodes.length,
742
- duration: options.duration ?? 400,
743
- easing: options.easing
744
- });
745
- }
756
+ layout.childNodes.forEach((child, index) => {
757
+ transitions.push({
758
+ node: initialChildren[index],
759
+ from: originPos,
760
+ to: child.position,
761
+ trajectory,
762
+ delay: index * stagger,
763
+ index,
764
+ total: layout.childNodes.length,
765
+ duration,
766
+ easing
767
+ });
746
768
  });
747
- displacedMap.forEach((targetPos, nodeId) => {
769
+ layout.displacedPositions.forEach((to, nodeId) => {
748
770
  const node = mergedNodes.find((n) => n.id === nodeId);
749
- if (node) {
750
- transitions.push({
751
- node,
752
- from: { ...node.position },
753
- to: targetPos,
754
- trajectory: linearPositionTrajectory,
755
- duration: options.duration ?? 400,
756
- easing: options.easing
757
- });
758
- }
771
+ if (node) transitions.push({ node, from: { ...node.position }, to, trajectory: linearPositionTrajectory, duration, easing });
759
772
  });
760
- runMultiNodeTransition(transitions, {
761
- styleFormat: "object",
762
- onUpdate: (updated) => setNodes(mergeById(mergedNodes, updated)),
763
- onComplete: () => options.onComplete?.()
773
+ run(transitions, mergedNodes, duration, () => {
774
+ setExplodedNodeIds((prev) => prev.includes(parentNodeId) ? prev : [...prev, parentNodeId]);
775
+ optionsRef.current.onSave?.();
776
+ options.onComplete?.();
764
777
  });
778
+ return true;
765
779
  },
766
780
  [target]
767
781
  );
@@ -769,71 +783,124 @@ function useCanvasExplosion(target) {
769
783
  (parentNodeId, options = {}) => {
770
784
  const { nodes, setNodes, setEdges } = target;
771
785
  const snapshot = snapshotsRef.current.get(parentNodeId);
772
- if (!snapshot) return;
786
+ if (!snapshot) return false;
773
787
  const parent = nodes.find((n) => n.id === parentNodeId);
774
788
  const originPos = parent ? { ...parent.position } : { x: 0, y: 0 };
775
789
  const childIdSet = new Set(snapshot.childNodeIds);
776
790
  const edgeIdSet = new Set(snapshot.childEdgeIds);
777
- const transitions = [];
778
- nodes.forEach((node) => {
779
- if (childIdSet.has(node.id)) {
780
- transitions.push({
781
- node,
782
- from: { ...node.position },
783
- to: originPos,
784
- duration: options.duration ?? 300,
785
- easing: options.easing,
786
- trajectory: options.trajectory
787
- });
788
- }
789
- });
791
+ const { duration = 400, staggerDelay = 15, easing } = options;
792
+ const trajectory = options.trajectory ?? createFanOutTrajectory({ curvature: 0.2, startScale: 1, endScale: 0, startOpacity: 1, endOpacity: 0 });
793
+ const stagger = duration === 0 ? 0 : staggerDelay;
794
+ const children = nodes.filter((n) => childIdSet.has(n.id));
795
+ const transitions = children.map((node, i) => ({
796
+ node,
797
+ from: { ...node.position },
798
+ to: originPos,
799
+ trajectory,
800
+ delay: (children.length - 1 - i) * stagger,
801
+ index: i,
802
+ total: children.length,
803
+ duration,
804
+ easing
805
+ }));
790
806
  snapshot.displacedNodes.forEach((disp) => {
791
807
  const node = nodes.find((n) => n.id === disp.id);
792
808
  if (node) {
793
- transitions.push({
794
- node,
795
- from: { ...node.position },
796
- to: disp.originalPosition,
797
- duration: options.duration ?? 300,
798
- easing: options.easing,
799
- trajectory: linearPositionTrajectory
800
- });
809
+ transitions.push({ node, from: { ...node.position }, to: disp.originalPosition, trajectory: linearPositionTrajectory, duration, easing });
801
810
  }
802
811
  });
803
- runMultiNodeTransition(transitions, {
804
- styleFormat: "object",
805
- onUpdate: (updated) => setNodes(mergeById(nodes, updated)),
806
- onComplete: () => {
807
- setNodes((prev) => prev.filter((n) => !childIdSet.has(n.id)));
808
- setEdges((prev) => prev.filter((e) => !edgeIdSet.has(e.id)));
809
- snapshotsRef.current.delete(parentNodeId);
810
- options.onComplete?.();
811
- }
812
+ run(transitions, nodes, duration, () => {
813
+ const restore = new Map(snapshot.displacedNodes.map((d) => [d.id, d.originalPosition]));
814
+ setNodes(
815
+ (prev) => prev.filter((n) => !childIdSet.has(n.id)).map((n) => restore.has(n.id) ? { ...n, position: { ...restore.get(n.id) } } : n)
816
+ );
817
+ setEdges((prev) => prev.filter((e) => !edgeIdSet.has(e.id)));
818
+ snapshotsRef.current.delete(parentNodeId);
819
+ setExplodedNodeIds((prev) => prev.filter((id) => id !== parentNodeId));
820
+ optionsRef.current.onSave?.();
821
+ options.onComplete?.();
812
822
  });
823
+ return true;
813
824
  },
814
825
  [target]
815
826
  );
827
+ const toggleExplode = useCallback6(
828
+ (parentNodeId, explodeOptions, collapseOptions) => snapshotsRef.current.has(parentNodeId) ? collapseNode(parentNodeId, collapseOptions) : explodeNode(parentNodeId, explodeOptions),
829
+ [explodeNode, collapseNode]
830
+ );
816
831
  return {
832
+ /** Ids of nodes whose explosion animation has finished (and not yet collapsed). */
833
+ explodedNodeIds,
817
834
  explodeNode,
818
835
  collapseNode,
819
- isExploded: (parentNodeId) => snapshotsRef.current.has(parentNodeId),
836
+ toggleExplode,
837
+ /** True once the node's explosion has finished, until a collapse finishes. */
838
+ isExploded: (parentNodeId) => explodedNodeIds.includes(parentNodeId),
820
839
  getSnapshot: (parentNodeId) => snapshotsRef.current.get(parentNodeId)
821
840
  };
822
841
  }
823
842
 
843
+ // src/canvas/useCanvasExplosionState.ts
844
+ import { useEffect as useEffect4, useMemo as useMemo2, useRef as useRef6, useSyncExternalStore } from "react";
845
+ import {
846
+ createCanvasExplosionStateController
847
+ } from "@pixerate/editor/canvas";
848
+ function useCanvasExplosionState(options = {}) {
849
+ const optionsRef = useRef6(options);
850
+ optionsRef.current = options;
851
+ const controllerRef = useRef6(null);
852
+ if (controllerRef.current === null) {
853
+ controllerRef.current = createCanvasExplosionStateController({
854
+ collapseDurationMs: options.collapseDurationMs,
855
+ initialActiveId: options.initialActiveId,
856
+ onExplode: (id) => optionsRef.current.onExplode?.(id),
857
+ onCollapse: (id) => optionsRef.current.onCollapse?.(id)
858
+ });
859
+ }
860
+ const controller = controllerRef.current;
861
+ useEffect4(() => () => controller.finishCollapse(), [controller]);
862
+ const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
863
+ return useMemo2(
864
+ () => ({
865
+ controller,
866
+ activeId: snapshot.activeId,
867
+ collapsingId: snapshot.collapsingId,
868
+ isExplodingOrCollapsing: snapshot.activeId !== null || snapshot.collapsingId !== null,
869
+ isExploded: (nodeId) => snapshot.activeId === nodeId,
870
+ isCollapsing: (nodeId) => snapshot.collapsingId === nodeId,
871
+ shouldRenderChildren: (nodeId) => snapshot.activeId === nodeId || snapshot.collapsingId === nodeId,
872
+ explode: (nodeId) => controller.explode(nodeId),
873
+ collapse: (nodeId) => controller.collapse(nodeId),
874
+ toggle: (nodeId) => controller.toggle(nodeId),
875
+ finishCollapse: () => controller.finishCollapse(),
876
+ destroy: () => controller.destroy()
877
+ }),
878
+ [controller, snapshot]
879
+ );
880
+ }
881
+
882
+ // src/canvas/index.ts
883
+ import {
884
+ computeCanvasExplosionLayout as computeCanvasExplosionLayout2,
885
+ explosionEdgeId,
886
+ createCanvasExplosionStateController as createCanvasExplosionStateController2,
887
+ createCanvasExplosionToolProvider,
888
+ canvasExplosionToolTarget
889
+ } from "@pixerate/editor/canvas";
890
+
824
891
  // src/canvas/useCanvasArrange.ts
825
- import { useEffect as useEffect3, useMemo as useMemo2, useRef as useRef6, useState as useState2 } from "react";
892
+ import { useEffect as useEffect5, useMemo as useMemo3, useRef as useRef7, useState as useState3 } from "react";
826
893
  import {
827
894
  createCanvasArrangeController,
828
895
  matchArrangeShortcut
829
896
  } from "@pixerate/editor/canvas";
830
897
  function useCanvasArrange(options) {
831
- const [guides, setGuides] = useState2([]);
832
- const nodesRef = useRef6(options.nodes);
898
+ const [guides, setGuides] = useState3([]);
899
+ const nodesRef = useRef7(options.nodes);
833
900
  nodesRef.current = options.nodes;
834
- const optionsRef = useRef6(options);
901
+ const optionsRef = useRef7(options);
835
902
  optionsRef.current = options;
836
- const controller = useMemo2(
903
+ const controller = useMemo3(
837
904
  () => createCanvasArrangeController({
838
905
  getNodes: () => nodesRef.current,
839
906
  setNodes: (next) => {
@@ -861,13 +928,13 @@ function useCanvasArrange(options) {
861
928
  }),
862
929
  []
863
930
  );
864
- return useMemo2(() => ({ ...controller, guides }), [controller, guides]);
931
+ return useMemo3(() => ({ ...controller, guides }), [controller, guides]);
865
932
  }
866
933
  function useCanvasArrangeShortcuts(options) {
867
- const optionsRef = useRef6(options);
934
+ const optionsRef = useRef7(options);
868
935
  optionsRef.current = options;
869
936
  const { targetElement, enabled = true } = options;
870
- useEffect3(() => {
937
+ useEffect5(() => {
871
938
  if (!enabled) return;
872
939
  const target = targetElement ?? (typeof window !== "undefined" ? window : null);
873
940
  if (!target) return;
@@ -892,24 +959,24 @@ function useCanvasArrangeShortcuts(options) {
892
959
  }
893
960
 
894
961
  // src/canvas/useCanvasScenes.ts
895
- import { useMemo as useMemo3, useRef as useRef7, useSyncExternalStore } from "react";
962
+ import { useMemo as useMemo4, useRef as useRef8, useSyncExternalStore as useSyncExternalStore2 } from "react";
896
963
  import {
897
964
  CanvasScenesStore,
898
965
  fitViewportToNodes,
899
966
  transitionCanvasView
900
967
  } from "@pixerate/editor/canvas";
901
968
  function useCanvasScenes(options = {}) {
902
- const optionsRef = useRef7(options);
969
+ const optionsRef = useRef8(options);
903
970
  optionsRef.current = options;
904
- const storeRef = useRef7(null);
971
+ const storeRef = useRef8(null);
905
972
  if (!storeRef.current) storeRef.current = options.store ?? new CanvasScenesStore(options);
906
973
  const store = storeRef.current;
907
- const state = useSyncExternalStore(
974
+ const state = useSyncExternalStore2(
908
975
  (listener) => store.subscribe(listener),
909
976
  () => store.getState(),
910
977
  () => store.getState()
911
978
  );
912
- const actions = useMemo3(() => {
979
+ const actions = useMemo4(() => {
913
980
  const show = (scene) => {
914
981
  if (!scene) return scene;
915
982
  const o = optionsRef.current;
@@ -962,16 +1029,16 @@ function useCanvasScenes(options = {}) {
962
1029
  }
963
1030
 
964
1031
  // src/canvas/useCanvasCapture.ts
965
- import { useMemo as useMemo4, useRef as useRef8 } from "react";
1032
+ import { useMemo as useMemo5, useRef as useRef9 } from "react";
966
1033
  import {
967
1034
  canvasNodeCaptureRect,
968
1035
  createCanvasCaptureToolProvider
969
1036
  } from "@pixerate/editor/canvas";
970
1037
  import { rasterizeElement } from "@pixerate/editor/tools";
971
1038
  function useCanvasCapture(options) {
972
- const optionsRef = useRef8(options);
1039
+ const optionsRef = useRef9(options);
973
1040
  optionsRef.current = options;
974
- return useMemo4(() => {
1041
+ return useMemo5(() => {
975
1042
  const latest = () => optionsRef.current;
976
1043
  return createCanvasCaptureToolProvider({
977
1044
  ...options,
@@ -990,7 +1057,7 @@ function useCanvasCapture(options) {
990
1057
  }
991
1058
 
992
1059
  // src/canvas/useCanvasEditorDocument.ts
993
- import { useEffect as useEffect4, useMemo as useMemo5, useRef as useRef9 } from "react";
1060
+ import { useEffect as useEffect6, useMemo as useMemo6, useRef as useRef10 } from "react";
994
1061
  import {
995
1062
  createCanvasEditorDocument
996
1063
  } from "@pixerate/editor/canvas";
@@ -999,10 +1066,10 @@ var contentKey = (nodes, edges) => JSON.stringify([
999
1066
  edges.map(({ selected: _s, ...rest }) => rest)
1000
1067
  ]);
1001
1068
  function useCanvasEditorDocument(options) {
1002
- const latest = useRef9(options);
1069
+ const latest = useRef10(options);
1003
1070
  latest.current = options;
1004
- const listeners = useRef9(/* @__PURE__ */ new Set());
1005
- const doc = useMemo5(
1071
+ const listeners = useRef10(/* @__PURE__ */ new Set());
1072
+ const doc = useMemo6(
1006
1073
  () => createCanvasEditorDocument({
1007
1074
  getNodes: () => latest.current.nodes,
1008
1075
  setNodes: (nodes) => latest.current.setNodes(nodes),
@@ -1019,9 +1086,9 @@ function useCanvasEditorDocument(options) {
1019
1086
  // eslint-disable-next-line react-hooks/exhaustive-deps
1020
1087
  [options.history, options.scenes]
1021
1088
  );
1022
- useEffect4(() => () => doc.destroy(), [doc]);
1023
- const lastKey = useRef9(null);
1024
- useEffect4(() => {
1089
+ useEffect6(() => () => doc.destroy(), [doc]);
1090
+ const lastKey = useRef10(null);
1091
+ useEffect6(() => {
1025
1092
  if (options.nodes.some((n) => n.dragging)) return;
1026
1093
  const key = contentKey(options.nodes, options.edges);
1027
1094
  if (lastKey.current !== null && key !== lastKey.current) listeners.current.forEach((listener) => listener());
@@ -1114,18 +1181,18 @@ function CanvasGuidesLayer({
1114
1181
  }
1115
1182
 
1116
1183
  // src/canvas/useCanvasDraw.ts
1117
- import { useEffect as useEffect5, useMemo as useMemo6, useRef as useRef10, useState as useState3 } from "react";
1184
+ import { useEffect as useEffect7, useMemo as useMemo7, useRef as useRef11, useState as useState4 } from "react";
1118
1185
  import {
1119
1186
  createCanvasDrawController
1120
1187
  } from "@pixerate/editor/canvas";
1121
1188
  function useCanvasDraw(options) {
1122
- const nodesRef = useRef10(options.nodes);
1189
+ const nodesRef = useRef11(options.nodes);
1123
1190
  nodesRef.current = options.nodes;
1124
- const optionsRef = useRef10(options);
1191
+ const optionsRef = useRef11(options);
1125
1192
  optionsRef.current = options;
1126
- const [tool, setToolState] = useState3(options.initialTool ?? "select");
1127
- const [activeStroke, setActiveStroke] = useState3(null);
1128
- const controller = useMemo6(
1193
+ const [tool, setToolState] = useState4(options.initialTool ?? "select");
1194
+ const [activeStroke, setActiveStroke] = useState4(null);
1195
+ const controller = useMemo7(
1129
1196
  () => createCanvasDrawController({
1130
1197
  getNodes: () => nodesRef.current,
1131
1198
  setNodes: (next) => {
@@ -1147,13 +1214,13 @@ function useCanvasDraw(options) {
1147
1214
  }),
1148
1215
  []
1149
1216
  );
1150
- const [style, setStyleState] = useState3(controller.style);
1151
- useEffect5(() => {
1217
+ const [style, setStyleState] = useState4(controller.style);
1218
+ useEffect7(() => {
1152
1219
  if (options.initialTool && options.initialTool !== controller.tool) {
1153
1220
  controller.setTool(options.initialTool);
1154
1221
  }
1155
1222
  }, [options.initialTool, controller]);
1156
- return useMemo6(
1223
+ return useMemo7(
1157
1224
  () => ({
1158
1225
  tool,
1159
1226
  style,
@@ -1174,7 +1241,7 @@ function useCanvasDraw(options) {
1174
1241
  }
1175
1242
 
1176
1243
  // src/canvas/CanvasDrawLayer.tsx
1177
- import { useCallback as useCallback7, useEffect as useEffect6, useRef as useRef11, useState as useState4 } from "react";
1244
+ import { useCallback as useCallback7, useEffect as useEffect8, useRef as useRef12, useState as useState5 } from "react";
1178
1245
  import {
1179
1246
  pointerPenSample,
1180
1247
  strokePointsToPathData,
@@ -1191,10 +1258,10 @@ function CanvasDrawLayer({
1191
1258
  cursor,
1192
1259
  eraserRadius = 12
1193
1260
  }) {
1194
- const svgRef = useRef11(null);
1195
- const [spaceHeld, setSpaceHeld] = useState4(false);
1196
- const [eraserPos, setEraserPos] = useState4(null);
1197
- useEffect6(() => {
1261
+ const svgRef = useRef12(null);
1262
+ const [spaceHeld, setSpaceHeld] = useState5(false);
1263
+ const [eraserPos, setEraserPos] = useState5(null);
1264
+ useEffect8(() => {
1198
1265
  function onKeyDown(e) {
1199
1266
  if (e.code === "Space" && !e.repeat) {
1200
1267
  const tag = e.target?.tagName;
@@ -1331,7 +1398,7 @@ function CanvasDrawLayer({
1331
1398
  }
1332
1399
 
1333
1400
  // src/canvas/useCanvasMeasure.ts
1334
- import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo7, useRef as useRef12, useState as useState5 } from "react";
1401
+ import { useCallback as useCallback8, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef13, useState as useState6 } from "react";
1335
1402
  import {
1336
1403
  isMeasureModifierHeld,
1337
1404
  measureSelection
@@ -1339,11 +1406,11 @@ import {
1339
1406
  var EMPTY = { guides: [], target: null, selection: null };
1340
1407
  function useCanvasMeasure(options) {
1341
1408
  const { nodes, enabled = true, requireModifier = true, targetElement, rectOptions } = options;
1342
- const [hoveredId, setHoveredId] = useState5(null);
1343
- const [modifier, setModifier] = useState5(false);
1344
- const optionsRef = useRef12(options);
1409
+ const [hoveredId, setHoveredId] = useState6(null);
1410
+ const [modifier, setModifier] = useState6(false);
1411
+ const optionsRef = useRef13(options);
1345
1412
  optionsRef.current = options;
1346
- useEffect7(() => {
1413
+ useEffect9(() => {
1347
1414
  if (!enabled) return;
1348
1415
  const target = targetElement ?? (typeof window !== "undefined" ? window : null);
1349
1416
  if (!target) return;
@@ -1360,7 +1427,7 @@ function useCanvasMeasure(options) {
1360
1427
  };
1361
1428
  }, [enabled, targetElement]);
1362
1429
  const active = enabled && (!requireModifier || modifier);
1363
- const result = useMemo7(() => {
1430
+ const result = useMemo8(() => {
1364
1431
  if (!active) return EMPTY;
1365
1432
  const ids = optionsRef.current.getSelectedIds?.() ?? nodes.filter((n) => n.selected).map((n) => n.id);
1366
1433
  return measureSelection(nodes, ids, hoveredId, rectOptions);
@@ -1450,7 +1517,7 @@ import {
1450
1517
  import { getShapeRenderData, isShapeDescription as isShapeDescription2 } from "@pixerate/editor/canvas";
1451
1518
 
1452
1519
  // src/canvas/useShapeBrushstroke.tsx
1453
- import { createContext, useContext, useEffect as useEffect8, useMemo as useMemo8, useState as useState6 } from "react";
1520
+ import { createContext, useContext, useEffect as useEffect10, useMemo as useMemo9, useState as useState7 } from "react";
1454
1521
  import {
1455
1522
  brushstrokeScaleBucket,
1456
1523
  isBrushedShape,
@@ -1474,8 +1541,8 @@ function useShapeBrushstroke(shape, width, height, position) {
1474
1541
  const unit = vb && width && vb[2] > 0 ? width / vb[2] : 1;
1475
1542
  const ox = Math.round((position?.x ?? 0) - (vb?.[0] ?? 0) * unit);
1476
1543
  const oy = Math.round((position?.y ?? 0) - (vb?.[1] ?? 0) * unit);
1477
- const [image, setImage] = useState6(null);
1478
- useEffect8(() => {
1544
+ const [image, setImage] = useState7(null);
1545
+ useEffect10(() => {
1479
1546
  if (!brushed) {
1480
1547
  setImage(null);
1481
1548
  return;
@@ -1496,9 +1563,9 @@ function useShapeBrushstroke(shape, width, height, position) {
1496
1563
  return image;
1497
1564
  }
1498
1565
  function useCanvasBrushes(options = {}) {
1499
- const [state, setState] = useState6({ brushes: [], loading: true, error: null });
1566
+ const [state, setState] = useState7({ brushes: [], loading: true, error: null });
1500
1567
  const swatches = options.swatches ? JSON.stringify(options.swatches) : "";
1501
- useEffect8(() => {
1568
+ useEffect10(() => {
1502
1569
  let live = true;
1503
1570
  const opts = swatches ? JSON.parse(swatches) : null;
1504
1571
  listCanvasBrushes().then(async (list) => opts ? Promise.all(list.map(async (b) => ({ ...b, swatch: await renderCanvasBrushSwatch(b.id, opts) }))) : list).then(
@@ -1509,11 +1576,11 @@ function useCanvasBrushes(options = {}) {
1509
1576
  live = false;
1510
1577
  };
1511
1578
  }, [swatches]);
1512
- return useMemo8(() => state, [state]);
1579
+ return useMemo9(() => state, [state]);
1513
1580
  }
1514
1581
 
1515
1582
  // src/canvas/CanvasEffects.tsx
1516
- import { createContext as createContext2, useContext as useContext2, useEffect as useEffect9, useMemo as useMemo9, useRef as useRef13, useState as useState7 } from "react";
1583
+ import { createContext as createContext2, useContext as useContext2, useEffect as useEffect11, useMemo as useMemo10, useRef as useRef14, useState as useState8 } from "react";
1517
1584
  import {
1518
1585
  createCanvasEffectsController,
1519
1586
  createCanvasEffectsToolProvider,
@@ -1528,20 +1595,20 @@ function CanvasEffectsProvider({ provider, children }) {
1528
1595
  var useCanvasEffectsProviderContext = () => useContext2(ProviderContext);
1529
1596
  function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform }) {
1530
1597
  const provider = useCanvasEffectsProviderContext();
1531
- const ref = useRef13(null);
1532
- const [failed, setFailed] = useState7(false);
1598
+ const ref = useRef14(null);
1599
+ const [failed, setFailed] = useState8(false);
1533
1600
  const dpr = typeof window !== "undefined" ? Math.min(2, window.devicePixelRatio || 1) : 1;
1534
1601
  const pw = Math.max(1, Math.round(width * dpr));
1535
1602
  const ph = Math.max(1, Math.round(height * dpr));
1536
1603
  const key = JSON.stringify(effect);
1537
- useEffect9(() => {
1604
+ useEffect11(() => {
1538
1605
  const canvas2 = ref.current;
1539
1606
  if (!provider || !canvas2) return;
1540
1607
  setFailed(false);
1541
1608
  const run = runCanvasNodeEffect({ provider, effect, target: canvas2, onError: () => setFailed(true) });
1542
1609
  return () => run.stop();
1543
1610
  }, [provider, key, pw, ph]);
1544
- const clipId = useMemo9(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
1611
+ const clipId = useMemo10(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
1545
1612
  if (!provider || failed || !(width > 0 && height > 0)) return null;
1546
1613
  const style = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: effect.opacity ?? 1 };
1547
1614
  const canvas = /* @__PURE__ */ jsx5("canvas", { ref, width: pw, height: ph, style: { width: "100%", height: "100%", display: "block" }, "data-canvas-effect": effect.effect });
@@ -1552,9 +1619,9 @@ function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform
1552
1619
  ] });
1553
1620
  }
1554
1621
  function useCanvasEffects(options) {
1555
- const opts = useRef13(options);
1622
+ const opts = useRef14(options);
1556
1623
  opts.current = options;
1557
- const controller = useMemo9(
1624
+ const controller = useMemo10(
1558
1625
  () => createCanvasEffectsController({
1559
1626
  getNodes: () => opts.current.getNodes(),
1560
1627
  setNodes: (n) => opts.current.setNodes(n),
@@ -1565,7 +1632,7 @@ function useCanvasEffects(options) {
1565
1632
  }),
1566
1633
  []
1567
1634
  );
1568
- useEffect9(() => {
1635
+ useEffect11(() => {
1569
1636
  if (!options.effects) return;
1570
1637
  return controller.useEffects(options.effects);
1571
1638
  }, [controller, options.effects]);
@@ -1573,7 +1640,7 @@ function useCanvasEffects(options) {
1573
1640
  }
1574
1641
  function useCanvasEffectsTools(registry, controller, options = {}) {
1575
1642
  const { id, namespace, readOnly, subscribe } = options;
1576
- useEffect9(() => {
1643
+ useEffect11(() => {
1577
1644
  if (!registry) return;
1578
1645
  return registry.register(createCanvasEffectsToolProvider(controller, { id, namespace, readOnly, subscribe }));
1579
1646
  }, [registry, controller, id, namespace, readOnly, subscribe]);
@@ -1581,7 +1648,7 @@ function useCanvasEffectsTools(registry, controller, options = {}) {
1581
1648
  var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
1582
1649
  function Controls({ controller, nodeId, effect }) {
1583
1650
  const { description, error } = useEffectDescription(controller.effectsProvider, effect.effect);
1584
- const [message, setMessage] = useState7(null);
1651
+ const [message, setMessage] = useState8(null);
1585
1652
  const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
1586
1653
  if (error) return /* @__PURE__ */ jsx5("p", { className: "text-[11px] text-amber-500", children: error });
1587
1654
  if (!description) return /* @__PURE__ */ jsx5("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
@@ -1600,11 +1667,11 @@ function Controls({ controller, nodeId, effect }) {
1600
1667
  ] });
1601
1668
  }
1602
1669
  function CanvasEffectsPanel({ controller, nodeId, shape, sceneId, className = "" }) {
1603
- const [, setTick] = useState7(0);
1604
- useEffect9(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
1670
+ const [, setTick] = useState8(0);
1671
+ useEffect11(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
1605
1672
  const provider = controller.effectsProvider;
1606
- const [browse, setBrowse] = useState7(null);
1607
- const [message, setMessage] = useState7(null);
1673
+ const [browse, setBrowse] = useState8(null);
1674
+ const [message, setMessage] = useState8(null);
1608
1675
  const run = (work) => {
1609
1676
  setMessage(null);
1610
1677
  Promise.resolve().then(work).then(() => setTick((n) => n + 1), (e) => setMessage(e instanceof Error ? e.message : String(e)));
@@ -1809,7 +1876,9 @@ import {
1809
1876
  runMultiNodeTransition as runMultiNodeTransition2,
1810
1877
  defaultEasing,
1811
1878
  computeNodesBoundingBox,
1812
- calculateDirectionalDisplacement as calculateDirectionalDisplacement2,
1879
+ nodeSizeOf,
1880
+ calculateDirectionalDisplacement,
1881
+ calculateReflowDisplacement,
1813
1882
  calculateDagreReflowDisplacement,
1814
1883
  isEventFromTextInput as isEventFromTextInput3,
1815
1884
  isValidCanvasNode,
@@ -1852,17 +1921,17 @@ import {
1852
1921
  } from "@pixerate/editor/canvas";
1853
1922
 
1854
1923
  // src/canvas/useCanvasAutoLayout.ts
1855
- import { useLayoutEffect, useMemo as useMemo10, useRef as useRef14, useState as useState8 } from "react";
1924
+ import { useLayoutEffect, useMemo as useMemo11, useRef as useRef15, useState as useState9 } from "react";
1856
1925
  import {
1857
1926
  createCanvasAutoLayoutController
1858
1927
  } from "@pixerate/editor/canvas";
1859
1928
  function useCanvasAutoLayout(options) {
1860
- const [guides, setGuides] = useState8([]);
1861
- const nodesRef = useRef14(options.nodes);
1929
+ const [guides, setGuides] = useState9([]);
1930
+ const nodesRef = useRef15(options.nodes);
1862
1931
  nodesRef.current = options.nodes;
1863
- const optionsRef = useRef14(options);
1932
+ const optionsRef = useRef15(options);
1864
1933
  optionsRef.current = options;
1865
- const controller = useMemo10(
1934
+ const controller = useMemo11(
1866
1935
  () => createCanvasAutoLayoutController({
1867
1936
  getNodes: () => nodesRef.current,
1868
1937
  setNodes: (next) => {
@@ -1891,7 +1960,7 @@ function useCanvasAutoLayout(options) {
1891
1960
  useLayoutEffect(() => {
1892
1961
  if (controller.hasPending) controller.flush();
1893
1962
  }, [options.nodes, controller]);
1894
- return useMemo10(
1963
+ return useMemo11(
1895
1964
  () => ({
1896
1965
  ...controller,
1897
1966
  /** Drop marker of the active reorder drag (flow coordinates). */
@@ -1905,7 +1974,7 @@ function useCanvasAutoLayout(options) {
1905
1974
  }
1906
1975
 
1907
1976
  // src/canvas/useCanvasTokens.ts
1908
- import { useCallback as useCallback9, useEffect as useEffect10, useRef as useRef15, useSyncExternalStore as useSyncExternalStore2 } from "react";
1977
+ import { useCallback as useCallback9, useEffect as useEffect12, useRef as useRef16, useSyncExternalStore as useSyncExternalStore3 } from "react";
1909
1978
  import {
1910
1979
  bindCanvasToken,
1911
1980
  detachTokenBindings,
@@ -1915,11 +1984,11 @@ import {
1915
1984
  } from "@pixerate/editor/canvas";
1916
1985
  function useCanvasTokens(options) {
1917
1986
  const { store, nodes, setNodes, modes, properties } = options;
1918
- const state = useSyncExternalStore2(store.subscribe, store.getState, store.getState);
1919
- const latest = useRef15({ nodes, setNodes, modes, properties });
1987
+ const state = useSyncExternalStore3(store.subscribe, store.getState, store.getState);
1988
+ const latest = useRef16({ nodes, setNodes, modes, properties });
1920
1989
  latest.current = { nodes, setNodes, modes, properties };
1921
1990
  const opts = () => ({ modes: latest.current.modes, properties: latest.current.properties });
1922
- useEffect10(
1991
+ useEffect12(
1923
1992
  () => store.subscribe((event) => {
1924
1993
  if (event.deletedVariableIds.length === 0) return;
1925
1994
  latest.current.setNodes((prev) => detachTokenBindings(prev, event.previous, event.deletedVariableIds, opts()));
@@ -1928,7 +1997,7 @@ function useCanvasTokens(options) {
1928
1997
  [store]
1929
1998
  );
1930
1999
  const modesKey = JSON.stringify(modes ?? {});
1931
- useEffect10(() => {
2000
+ useEffect12(() => {
1932
2001
  const next = resolveCanvasTokens(nodes, state, opts());
1933
2002
  if (next !== nodes) setNodes(next);
1934
2003
  }, [nodes, state, modesKey, properties]);
@@ -2099,16 +2168,16 @@ import {
2099
2168
  } from "@pixerate/editor/canvas";
2100
2169
 
2101
2170
  // src/canvas/useCanvasAnimation.ts
2102
- import { useEffect as useEffect11, useMemo as useMemo11, useRef as useRef16, useSyncExternalStore as useSyncExternalStore3 } from "react";
2171
+ import { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef17, useSyncExternalStore as useSyncExternalStore4 } from "react";
2103
2172
  import {
2104
2173
  createCanvasAnimationController
2105
2174
  } from "@pixerate/editor/canvas";
2106
2175
  function useCanvasAnimation(options) {
2107
- const nodesRef = useRef16(options.nodes);
2176
+ const nodesRef = useRef17(options.nodes);
2108
2177
  nodesRef.current = options.nodes;
2109
- const optionsRef = useRef16(options);
2178
+ const optionsRef = useRef17(options);
2110
2179
  optionsRef.current = options;
2111
- const controller = useMemo11(
2180
+ const controller = useMemo12(
2112
2181
  () => createCanvasAnimationController({
2113
2182
  getNodes: () => nodesRef.current,
2114
2183
  setNodes: (next) => {
@@ -2135,26 +2204,26 @@ function useCanvasAnimation(options) {
2135
2204
  }),
2136
2205
  []
2137
2206
  );
2138
- useEffect11(() => () => controller.destroy(), [controller]);
2139
- useEffect11(() => {
2207
+ useEffect13(() => () => controller.destroy(), [controller]);
2208
+ useEffect13(() => {
2140
2209
  if (options.loop !== void 0) controller.setLoop(options.loop);
2141
2210
  }, [controller, options.loop]);
2142
- useEffect11(() => {
2211
+ useEffect13(() => {
2143
2212
  if (options.playbackRate !== void 0) controller.setPlaybackRate(options.playbackRate);
2144
2213
  }, [controller, options.playbackRate]);
2145
- useEffect11(() => {
2214
+ useEffect13(() => {
2146
2215
  if (options.recording !== void 0) controller.setRecording(options.recording);
2147
2216
  }, [controller, options.recording]);
2148
- const state = useSyncExternalStore3(
2217
+ const state = useSyncExternalStore4(
2149
2218
  (listener) => controller.subscribe(listener),
2150
2219
  () => controller.getState(),
2151
2220
  () => controller.getState()
2152
2221
  );
2153
- useEffect11(() => {
2222
+ useEffect13(() => {
2154
2223
  controller.refresh();
2155
2224
  }, [controller, options.nodes]);
2156
- const displayNodes = useMemo11(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
2157
- return useMemo11(
2225
+ const displayNodes = useMemo12(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
2226
+ return useMemo12(
2158
2227
  () => ({
2159
2228
  ...controller,
2160
2229
  state,
@@ -2175,7 +2244,7 @@ function useCanvasAnimation(options) {
2175
2244
  }
2176
2245
 
2177
2246
  // src/canvas/AnimationTimeline.tsx
2178
- import { useEffect as useEffect12, useRef as useRef17 } from "react";
2247
+ import { useEffect as useEffect14, useRef as useRef18 } from "react";
2179
2248
  import {
2180
2249
  ANIMATION_EASING_LABELS,
2181
2250
  ANIMATION_EASING_PRESETS,
@@ -2198,8 +2267,8 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
2198
2267
  for (const row of rows) for (const k of row.keyframes) if (k.selected && k.ref.property === first.property && k.ref.nodeId === first.nodeId) return easingValue(k.easing);
2199
2268
  return "";
2200
2269
  })();
2201
- const dragRef = useRef17(null);
2202
- useEffect12(() => {
2270
+ const dragRef = useRef18(null);
2271
+ useEffect14(() => {
2203
2272
  const onKey = (event) => {
2204
2273
  if (event.key === "Escape" && dragRef.current) {
2205
2274
  dragRef.current = null;
@@ -2437,16 +2506,16 @@ import {
2437
2506
  } from "@pixerate/editor/canvas";
2438
2507
 
2439
2508
  // src/canvas/useCanvasComponents.ts
2440
- import { useLayoutEffect as useLayoutEffect2, useMemo as useMemo12, useRef as useRef18 } from "react";
2509
+ import { useLayoutEffect as useLayoutEffect2, useMemo as useMemo13, useRef as useRef19 } from "react";
2441
2510
  import {
2442
2511
  createCanvasComponentsController
2443
2512
  } from "@pixerate/editor/canvas";
2444
2513
  function useCanvasComponents(options) {
2445
- const nodesRef = useRef18(options.nodes);
2514
+ const nodesRef = useRef19(options.nodes);
2446
2515
  nodesRef.current = options.nodes;
2447
- const optionsRef = useRef18(options);
2516
+ const optionsRef = useRef19(options);
2448
2517
  optionsRef.current = options;
2449
- const controller = useMemo12(
2518
+ const controller = useMemo13(
2450
2519
  () => createCanvasComponentsController({
2451
2520
  getNodes: () => nodesRef.current,
2452
2521
  setNodes: (next) => {
@@ -2482,7 +2551,7 @@ function useCanvasComponents(options) {
2482
2551
  }
2483
2552
 
2484
2553
  // src/canvas/CanvasComponentsPanel.tsx
2485
- import { useState as useState9 } from "react";
2554
+ import { useState as useState10 } from "react";
2486
2555
  import {
2487
2556
  CANVAS_COMPONENT_DRAG_TYPE,
2488
2557
  inspectCanvasInstance,
@@ -2521,10 +2590,10 @@ function CanvasComponentsPanel({
2521
2590
  search = true,
2522
2591
  className = ""
2523
2592
  }) {
2524
- const [query, setQuery] = useState9("");
2525
- const [propsOpen, setPropsOpen] = useState9(null);
2526
- const [menuFor, setMenuFor] = useState9(null);
2527
- const [editing, setEditing] = useState9(null);
2593
+ const [query, setQuery] = useState10("");
2594
+ const [propsOpen, setPropsOpen] = useState10(null);
2595
+ const [menuFor, setMenuFor] = useState10(null);
2596
+ const [editing, setEditing] = useState10(null);
2528
2597
  const { components: all, sets } = listCanvasComponents(nodes);
2529
2598
  const q = query.trim().toLowerCase();
2530
2599
  const match = (name) => !q || name.toLowerCase().includes(q);
@@ -3043,7 +3112,7 @@ function MermaidFamilyScene({
3043
3112
  }
3044
3113
 
3045
3114
  // src/canvas/useMermaidDiagram.ts
3046
- import { useEffect as useEffect13, useMemo as useMemo13, useRef as useRef19, useState as useState10, useSyncExternalStore as useSyncExternalStore4 } from "react";
3115
+ import { useEffect as useEffect15, useMemo as useMemo14, useRef as useRef20, useState as useState11, useSyncExternalStore as useSyncExternalStore5 } from "react";
3047
3116
  import {
3048
3117
  DiagramController,
3049
3118
  createDiagramEditorDocument
@@ -3059,10 +3128,10 @@ import {
3059
3128
  mermaidToCanvas
3060
3129
  } from "@pixerate/editor/canvas";
3061
3130
  function useDiagramState(controller) {
3062
- return useSyncExternalStore4(controller.subscribe, controller.getState, controller.getState);
3131
+ return useSyncExternalStore5(controller.subscribe, controller.getState, controller.getState);
3063
3132
  }
3064
3133
  function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
3065
- const own = useRef19(null);
3134
+ const own = useRef20(null);
3066
3135
  let controller;
3067
3136
  if (controllerOrOptions instanceof DiagramController) controller = controllerOrOptions;
3068
3137
  else {
@@ -3072,21 +3141,21 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
3072
3141
  const layoutOptions = (controllerOrOptions instanceof DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
3073
3142
  const sceneTheme = (controllerOrOptions instanceof DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
3074
3143
  const state = useDiagramState(controller);
3075
- const editorDocument = useMemo13(() => createDiagramEditorDocument(controller), [controller]);
3076
- useEffect13(() => () => editorDocument.destroy(), [editorDocument]);
3077
- const canvas = useMemo13(
3144
+ const editorDocument = useMemo14(() => createDiagramEditorDocument(controller), [controller]);
3145
+ useEffect15(() => () => editorDocument.destroy(), [editorDocument]);
3146
+ const canvas = useMemo14(
3078
3147
  () => mermaidToCanvas(state.document, { ...layoutOptions, editable: state.editable }),
3079
3148
  // eslint-disable-next-line react-hooks/exhaustive-deps
3080
3149
  [state.document, state.editable]
3081
3150
  );
3082
- const scene = useMemo13(
3151
+ const scene = useMemo14(
3083
3152
  () => state.document.tier === "editable" ? familySceneFromLayout(state.document.family, state.document.graph, canvas.layout, { theme: { ...CSS_VARIABLE_DIAGRAM_SCENE_THEME, ...sceneTheme }, selection: state.selection }) : null,
3084
3153
  // eslint-disable-next-line react-hooks/exhaustive-deps
3085
3154
  [state.document, canvas.layout, state.selection]
3086
3155
  );
3087
- const layoutRef = useRef19(canvas.layout);
3156
+ const layoutRef = useRef20(canvas.layout);
3088
3157
  layoutRef.current = canvas.layout;
3089
- const actions = useMemo13(
3158
+ const actions = useMemo14(
3090
3159
  () => ({
3091
3160
  apply: (ops, label) => controller.apply(ops, label),
3092
3161
  load: (source, options) => controller.load(source, options),
@@ -3123,13 +3192,13 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
3123
3192
  }
3124
3193
  function useMermaidStream(source, options = {}) {
3125
3194
  const { complete = false, duration = 300, ...layoutOptions } = options;
3126
- const stream = useRef19(null);
3195
+ const stream = useRef20(null);
3127
3196
  if (!stream.current) stream.current = new DiagramStream(layoutOptions);
3128
- const result = useMemo13(() => stream.current.update(source, complete), [source, complete]);
3129
- const [shown, setShown] = useState10({ layout: result.layout, settled: true });
3130
- const shownRef = useRef19(shown.layout);
3197
+ const result = useMemo14(() => stream.current.update(source, complete), [source, complete]);
3198
+ const [shown, setShown] = useState11({ layout: result.layout, settled: true });
3199
+ const shownRef = useRef20(shown.layout);
3131
3200
  shownRef.current = shown.layout;
3132
- useEffect13(() => {
3201
+ useEffect15(() => {
3133
3202
  const target = result.layout;
3134
3203
  if (!target) return setShown({ layout: null, settled: true });
3135
3204
  const from = shownRef.current;
@@ -3146,7 +3215,7 @@ function useMermaidStream(source, options = {}) {
3146
3215
  return () => cancelAnimationFrame(frame);
3147
3216
  }, [result.layout, duration]);
3148
3217
  const doc = result.document.tier === "editable" ? result.document : null;
3149
- const canvas = useMemo13(() => {
3218
+ const canvas = useMemo14(() => {
3150
3219
  if (!doc || !shown.layout) return { nodes: [], edges: [] };
3151
3220
  const placed = new Set(Object.keys(shown.layout.positions));
3152
3221
  const graph = {
@@ -3222,14 +3291,14 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
3222
3291
  }
3223
3292
 
3224
3293
  // src/canvas/MermaidThumbnail.tsx
3225
- import { useMemo as useMemo14 } from "react";
3294
+ import { useMemo as useMemo15 } from "react";
3226
3295
  import { parseMermaid } from "@pixerate/editor/diagram";
3227
3296
  import { mermaidThumbnailSvg } from "@pixerate/editor/canvas";
3228
3297
  import { Fragment as Fragment3, jsx as jsx12 } from "react/jsx-runtime";
3229
3298
  function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
3230
- const doc = useMemo14(() => typeof source === "string" ? parseMermaid(source) : source, [source]);
3299
+ const doc = useMemo15(() => typeof source === "string" ? parseMermaid(source) : source, [source]);
3231
3300
  const key = JSON.stringify(options);
3232
- const drawn = useMemo14(
3301
+ const drawn = useMemo15(
3233
3302
  () => doc.tier === "editable" && doc.graph.nodes.length ? mermaidThumbnailSvg(doc, options) : null,
3234
3303
  // eslint-disable-next-line react-hooks/exhaustive-deps
3235
3304
  [doc, key]
@@ -3239,12 +3308,12 @@ function MermaidThumbnail({ source, className = "", fallback = null, ...options
3239
3308
  }
3240
3309
 
3241
3310
  // src/canvas/useDiagramDirector.ts
3242
- import { useRef as useRef20, useSyncExternalStore as useSyncExternalStore5 } from "react";
3311
+ import { useRef as useRef21, useSyncExternalStore as useSyncExternalStore6 } from "react";
3243
3312
  import { DiagramDirector, PresenceStore } from "@pixerate/editor/diagram";
3244
3313
  function useDiagramDirector(controller, options) {
3245
- const placement = useRef20(options.placement);
3314
+ const placement = useRef21(options.placement);
3246
3315
  placement.current = options.placement;
3247
- const ref = useRef20(null);
3316
+ const ref = useRef21(null);
3248
3317
  if (!ref.current) {
3249
3318
  const presence = new PresenceStore();
3250
3319
  ref.current = {
@@ -3255,7 +3324,7 @@ function useDiagramDirector(controller, options) {
3255
3324
  return ref.current;
3256
3325
  }
3257
3326
  function usePresenceState(presence) {
3258
- return useSyncExternalStore5(presence.subscribe, presence.getState, presence.getState);
3327
+ return useSyncExternalStore6(presence.subscribe, presence.getState, presence.getState);
3259
3328
  }
3260
3329
 
3261
3330
  // src/canvas/DiagramPresenceLayer.tsx
@@ -3339,10 +3408,12 @@ export {
3339
3408
  brushstrokeScaleBucket2 as brushstrokeScaleBucket,
3340
3409
  brushstrokeSeed,
3341
3410
  calculateDagreReflowDisplacement,
3342
- calculateDirectionalDisplacement2 as calculateDirectionalDisplacement,
3411
+ calculateDirectionalDisplacement,
3412
+ calculateReflowDisplacement,
3343
3413
  canCombineShapeNodes,
3344
3414
  canOffsetShapeNodes,
3345
3415
  canOutlineShapeNodeStrokes,
3416
+ canvasExplosionToolTarget,
3346
3417
  canvasHeight,
3347
3418
  centerNodes2 as centerNodes,
3348
3419
  centre,
@@ -3350,6 +3421,7 @@ export {
3350
3421
  clampLayoutSize,
3351
3422
  combineCanvasComponentsAsVariants,
3352
3423
  combineShapeNodes,
3424
+ computeCanvasExplosionLayout2 as computeCanvasExplosionLayout,
3353
3425
  computeNodesBoundingBox,
3354
3426
  computeSnapGuides,
3355
3427
  connectedOnly,
@@ -3362,6 +3434,8 @@ export {
3362
3434
  createCanvasComponent,
3363
3435
  createCanvasComponentsController2 as createCanvasComponentsController,
3364
3436
  createCanvasDrawController2 as createCanvasDrawController,
3437
+ createCanvasExplosionStateController2 as createCanvasExplosionStateController,
3438
+ createCanvasExplosionToolProvider,
3365
3439
  createCanvasInstance,
3366
3440
  createCanvasScenesStore,
3367
3441
  createDefaultStrokeStyle,
@@ -3390,6 +3464,7 @@ export {
3390
3464
  evaluateEasing,
3391
3465
  evaluateTrack,
3392
3466
  excludePaths,
3467
+ explosionEdgeId,
3393
3468
  exportCssAnimation,
3394
3469
  findConnectorSnap,
3395
3470
  findStrokesAtPoint,
@@ -3499,6 +3574,7 @@ export {
3499
3574
  multiPolygonArea,
3500
3575
  multiPolygonBounds,
3501
3576
  nearestHandlePositions,
3577
+ nodeSizeOf,
3502
3578
  normalizeBezierPath,
3503
3579
  normalizeKeyframes,
3504
3580
  offsetPath,
@@ -3615,6 +3691,7 @@ export {
3615
3691
  useCanvasEffectsProviderContext,
3616
3692
  useCanvasEffectsTools,
3617
3693
  useCanvasExplosion,
3694
+ useCanvasExplosionState,
3618
3695
  useCanvasGraph,
3619
3696
  useCanvasLayout,
3620
3697
  useCanvasMeasure,