@pixerate/editor 0.140.4 → 0.142.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/canvasPlayback.d.cts +15 -0
- package/dist/agent/canvasPlayback.d.ts +15 -0
- package/dist/agent/index.cjs +173 -33
- package/dist/agent/index.d.cts +1 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +147 -7
- package/dist/agent/providers.d.cts +12 -1
- package/dist/agent/providers.d.ts +12 -1
- package/dist/agent/types.d.cts +3 -0
- package/dist/agent/types.d.ts +3 -0
- package/dist/animation/index.cjs +2 -2
- package/dist/animation/index.js +1 -1
- package/dist/animation/presence.d.cts +1 -75
- package/dist/animation/presence.d.ts +1 -75
- package/dist/animation-editor/index.cjs +69 -19
- package/dist/animation-editor/index.d.cts +1 -0
- package/dist/animation-editor/index.d.ts +1 -0
- package/dist/animation-editor/index.js +54 -4
- package/dist/animation-editor/playback.d.cts +10 -0
- package/dist/animation-editor/playback.d.ts +10 -0
- package/dist/bridge/cli.cjs +3 -3
- package/dist/bridge/cli.js +2 -2
- package/dist/bridge/index.cjs +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/canvas/index.cjs +336 -646
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +44 -354
- package/dist/canvas/playback.d.cts +14 -0
- package/dist/canvas/playback.d.ts +14 -0
- package/dist/chart/index.cjs +255 -171
- package/dist/chart/index.d.cts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +244 -160
- package/dist/chart/playback.d.cts +22 -0
- package/dist/chart/playback.d.ts +22 -0
- package/dist/chunk-54GVEVXS.js +408 -0
- package/dist/{chunk-E747F3D5.js → chunk-CC6WKVIH.js} +86 -5
- package/dist/chunk-DW4CV5H4.js +591 -0
- package/dist/{chunk-UMS6YFA6.js → chunk-EAQ4BGNS.js} +1 -1
- package/dist/{chunk-AGCD3EHB.cjs → chunk-ENIZYNEF.cjs} +7 -7
- package/dist/{chunk-BSGPXPTW.js → chunk-PEEP2YR7.js} +1 -1
- package/dist/{chunk-VTY64I6H.cjs → chunk-QSM3MDDJ.cjs} +85 -85
- package/dist/{chunk-2RUNJYOX.cjs → chunk-QZFEX2N4.cjs} +86 -5
- package/dist/{chunk-RB62U6MS.js → chunk-RFBFTLVN.js} +27 -5
- package/dist/chunk-UBRYHNRU.cjs +591 -0
- package/dist/{chunk-GEY73RUW.cjs → chunk-UJGAA6AK.cjs} +1 -1
- package/dist/{chunk-LMSFXRAJ.js → chunk-VGJTUCWM.js} +1 -1
- package/dist/chunk-X2HQP7DF.cjs +408 -0
- package/dist/chunk-XH32BATE.cjs +68 -0
- package/dist/{chunk-HDK3T2QS.cjs → chunk-Y4BWZB6J.cjs} +29 -7
- package/dist/chunk-Y6SGC6KO.js +68 -0
- package/dist/commands/index.cjs +37 -1
- package/dist/commands/index.js +36 -0
- package/dist/commands/registry.d.cts +11 -0
- package/dist/commands/registry.d.ts +11 -0
- package/dist/diagram/index.cjs +7 -7
- package/dist/diagram/index.js +1 -1
- package/dist/image-editor/index.cjs +108 -16
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +107 -15
- package/dist/image-editor/playback.d.cts +22 -0
- package/dist/image-editor/playback.d.ts +22 -0
- package/dist/index.cjs +7 -3
- package/dist/index.js +6 -2
- package/dist/paint-editor/index.cjs +73 -25
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +68 -20
- package/dist/paint-editor/playback.d.cts +16 -0
- package/dist/paint-editor/playback.d.ts +16 -0
- package/dist/parameters/index.cjs +32 -8
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +28 -4
- package/dist/parameters/playback.d.cts +10 -0
- package/dist/parameters/playback.d.ts +10 -0
- package/dist/spreadsheet/index.cjs +7 -3
- package/dist/spreadsheet/index.d.cts +1 -0
- package/dist/spreadsheet/index.d.ts +1 -0
- package/dist/spreadsheet/index.js +6 -2
- package/dist/spreadsheet/playback.d.cts +15 -0
- package/dist/spreadsheet/playback.d.ts +15 -0
- package/dist/tools/index.cjs +40 -3
- package/dist/tools/index.d.cts +3 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +39 -2
- package/dist/tools/playback.d.cts +205 -0
- package/dist/tools/playback.d.ts +205 -0
- package/dist/tools/presence.d.cts +82 -0
- package/dist/tools/presence.d.ts +82 -0
- package/dist/tools/registry.d.cts +45 -6
- package/dist/tools/registry.d.ts +45 -6
- package/dist/tools/script.d.cts +77 -0
- package/dist/tools/script.d.ts +77 -0
- package/dist/tools/view.d.cts +2 -4
- package/dist/tools/view.d.ts +2 -4
- package/dist/vector/index.cjs +217 -100
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +140 -23
- package/dist/vector/playback.d.cts +13 -0
- package/dist/vector/playback.d.ts +13 -0
- package/dist/video-editor/index.cjs +81 -28
- package/dist/video-editor/index.d.cts +1 -0
- package/dist/video-editor/index.d.ts +1 -0
- package/dist/video-editor/index.js +58 -5
- package/dist/video-editor/playback.d.cts +20 -0
- package/dist/video-editor/playback.d.ts +20 -0
- package/package.json +1 -1
- package/skills/pixerate-agent-tools/SKILL.md +13 -0
- package/skills/pixerate-animation-editor/SKILL.md +1 -0
- package/skills/pixerate-canvas/SKILL.md +3 -0
- package/skills/pixerate-chart/SKILL.md +1 -0
- package/skills/pixerate-image-editor/SKILL.md +2 -2
- package/skills/pixerate-paint-editor/SKILL.md +1 -0
- package/skills/pixerate-parameters/SKILL.md +1 -0
- package/skills/pixerate-spreadsheet/SKILL.md +1 -0
- package/skills/pixerate-vector/SKILL.md +5 -0
- package/skills/pixerate-video-editor/SKILL.md +1 -0
- package/dist/chunk-BTZS3KZY.js +0 -221
- package/dist/chunk-K73HMKQP.js +0 -0
- package/dist/chunk-LACYURUW.cjs +0 -1
- package/dist/chunk-MRD3NXKR.cjs +0 -221
package/dist/canvas/index.d.cts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './brushstroke.cjs';
|
|
|
31
31
|
export * from './gradient.cjs';
|
|
32
32
|
export * from './mermaid/index.cjs';
|
|
33
33
|
export * from './agent-presence.cjs';
|
|
34
|
+
export * from './playback.cjs';
|
|
34
35
|
export * from './capture.cjs';
|
|
35
36
|
export * from './effects.cjs';
|
|
36
37
|
export * from './effect-player.cjs';
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './brushstroke.js';
|
|
|
31
31
|
export * from './gradient.js';
|
|
32
32
|
export * from './mermaid/index.js';
|
|
33
33
|
export * from './agent-presence.js';
|
|
34
|
+
export * from './playback.js';
|
|
34
35
|
export * from './capture.js';
|
|
35
36
|
export * from './effects.js';
|
|
36
37
|
export * from './effect-player.js';
|
package/dist/canvas/index.js
CHANGED
|
@@ -65,17 +65,35 @@ import {
|
|
|
65
65
|
DEFAULT_NODE_HEIGHT,
|
|
66
66
|
DEFAULT_NODE_WIDTH,
|
|
67
67
|
DEFAULT_PLACEMENT_GAP,
|
|
68
|
+
LOCKED_DATA_KEY,
|
|
69
|
+
LOCKED_PREVIOUS_FLAGS_KEY,
|
|
70
|
+
alignNodes,
|
|
71
|
+
applyNodeUpdates,
|
|
68
72
|
boundsOf,
|
|
69
73
|
centerNodes,
|
|
70
74
|
centre,
|
|
75
|
+
createNodeLookup,
|
|
76
|
+
distributeNodes,
|
|
71
77
|
ensureLayout,
|
|
72
78
|
estimateNodeSize,
|
|
73
79
|
flowSide,
|
|
80
|
+
getAbsolutePosition,
|
|
74
81
|
getCenteredNodePosition,
|
|
75
82
|
getLayoutedNodes,
|
|
83
|
+
getNodeRect,
|
|
84
|
+
getNodeSize,
|
|
85
|
+
invertNodeUpdates,
|
|
86
|
+
isLocked,
|
|
87
|
+
lockNodes,
|
|
88
|
+
matchSize,
|
|
76
89
|
overlaps,
|
|
77
|
-
placeBeside
|
|
78
|
-
|
|
90
|
+
placeBeside,
|
|
91
|
+
readStyleSize,
|
|
92
|
+
reorderNodes,
|
|
93
|
+
toggleLockNodes,
|
|
94
|
+
unlockNodes,
|
|
95
|
+
withStyleSize
|
|
96
|
+
} from "../chunk-DW4CV5H4.js";
|
|
79
97
|
import {
|
|
80
98
|
DEFAULT_ARRANGE_SHORTCUTS,
|
|
81
99
|
matchArrangeShortcut
|
|
@@ -869,358 +887,6 @@ var StreamingLayoutManager = class {
|
|
|
869
887
|
}
|
|
870
888
|
};
|
|
871
889
|
|
|
872
|
-
// src/canvas/arrange.ts
|
|
873
|
-
var LOCKED_DATA_KEY = "locked";
|
|
874
|
-
var LOCKED_PREVIOUS_FLAGS_KEY = "lockedPrevious";
|
|
875
|
-
function parsePx(value) {
|
|
876
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
877
|
-
if (typeof value === "string") {
|
|
878
|
-
const match = /^\s*(-?\d+(?:\.\d+)?)(px)?\s*$/i.exec(value);
|
|
879
|
-
if (match) return Number(match[1]);
|
|
880
|
-
}
|
|
881
|
-
return void 0;
|
|
882
|
-
}
|
|
883
|
-
function readStyleSize(style) {
|
|
884
|
-
if (!style) return {};
|
|
885
|
-
if (typeof style === "object") {
|
|
886
|
-
return { width: parsePx(style.width), height: parsePx(style.height) };
|
|
887
|
-
}
|
|
888
|
-
const read = (prop) => {
|
|
889
|
-
const match = new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*([^;]+)`, "i").exec(style);
|
|
890
|
-
return match ? parsePx(match[1]) : void 0;
|
|
891
|
-
};
|
|
892
|
-
return { width: read("width"), height: read("height") };
|
|
893
|
-
}
|
|
894
|
-
function withStyleSize(style, size2) {
|
|
895
|
-
if (!style) return style ?? void 0;
|
|
896
|
-
if (typeof style === "object") {
|
|
897
|
-
const next2 = { ...style };
|
|
898
|
-
if (size2.width !== void 0 && "width" in next2) next2.width = size2.width;
|
|
899
|
-
if (size2.height !== void 0 && "height" in next2) next2.height = size2.height;
|
|
900
|
-
return next2;
|
|
901
|
-
}
|
|
902
|
-
let next = style;
|
|
903
|
-
for (const prop of ["width", "height"]) {
|
|
904
|
-
const value = size2[prop];
|
|
905
|
-
if (value === void 0) continue;
|
|
906
|
-
next = next.replace(
|
|
907
|
-
new RegExp(`((?:^|;)\\s*${prop}\\s*:\\s*)[^;]+`, "i"),
|
|
908
|
-
`$1${value}px`
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
return next;
|
|
912
|
-
}
|
|
913
|
-
function getNodeSize(node, options = {}) {
|
|
914
|
-
const styleSize = readStyleSize(node.style);
|
|
915
|
-
let width = node.measured?.width ?? node.width ?? styleSize.width;
|
|
916
|
-
let height = node.measured?.height ?? node.height ?? styleSize.height;
|
|
917
|
-
if (width === void 0 || height === void 0) {
|
|
918
|
-
const fallback = options.estimate === false ? { width: options.defaultWidth ?? 200, height: options.defaultHeight ?? 60 } : estimateNodeSize(node, options.defaultWidth, options.defaultHeight);
|
|
919
|
-
width ??= fallback.width;
|
|
920
|
-
height ??= fallback.height;
|
|
921
|
-
}
|
|
922
|
-
return { width, height };
|
|
923
|
-
}
|
|
924
|
-
function getAbsolutePosition(node, lookup) {
|
|
925
|
-
let x = node.position.x;
|
|
926
|
-
let y = node.position.y;
|
|
927
|
-
const seen = /* @__PURE__ */ new Set([node.id]);
|
|
928
|
-
let parentId = node.parentId;
|
|
929
|
-
while (parentId && !seen.has(parentId)) {
|
|
930
|
-
const parent = lookup.get(parentId);
|
|
931
|
-
if (!parent) break;
|
|
932
|
-
seen.add(parentId);
|
|
933
|
-
x += parent.position.x;
|
|
934
|
-
y += parent.position.y;
|
|
935
|
-
parentId = parent.parentId;
|
|
936
|
-
}
|
|
937
|
-
return { x, y };
|
|
938
|
-
}
|
|
939
|
-
function createNodeLookup(nodes) {
|
|
940
|
-
return new Map(nodes.map((n3) => [n3.id, n3]));
|
|
941
|
-
}
|
|
942
|
-
function getNodeRect(node, lookup, options) {
|
|
943
|
-
const { x, y } = node.parentId && lookup ? getAbsolutePosition(node, lookup) : node.position;
|
|
944
|
-
return { x, y, ...getNodeSize(node, options) };
|
|
945
|
-
}
|
|
946
|
-
function isLocked(node) {
|
|
947
|
-
return node?.data?.[LOCKED_DATA_KEY] === true;
|
|
948
|
-
}
|
|
949
|
-
function lockNodes(nodes, ids) {
|
|
950
|
-
const idSet = new Set(ids);
|
|
951
|
-
return nodes.map((node) => {
|
|
952
|
-
if (!idSet.has(node.id) || isLocked(node)) return node;
|
|
953
|
-
const previous = {};
|
|
954
|
-
if (node.draggable !== void 0) previous.draggable = node.draggable;
|
|
955
|
-
if (node.deletable !== void 0) previous.deletable = node.deletable;
|
|
956
|
-
return {
|
|
957
|
-
...node,
|
|
958
|
-
draggable: false,
|
|
959
|
-
deletable: false,
|
|
960
|
-
data: { ...node.data, [LOCKED_DATA_KEY]: true, [LOCKED_PREVIOUS_FLAGS_KEY]: previous }
|
|
961
|
-
};
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
function unlockNodes(nodes, ids) {
|
|
965
|
-
const idSet = new Set(ids);
|
|
966
|
-
return nodes.map((node) => {
|
|
967
|
-
if (!idSet.has(node.id) || !isLocked(node)) return node;
|
|
968
|
-
const {
|
|
969
|
-
[LOCKED_DATA_KEY]: _locked,
|
|
970
|
-
[LOCKED_PREVIOUS_FLAGS_KEY]: previous = {},
|
|
971
|
-
...data
|
|
972
|
-
} = node.data;
|
|
973
|
-
const next = { ...node, data };
|
|
974
|
-
delete next.draggable;
|
|
975
|
-
delete next.deletable;
|
|
976
|
-
if (previous.draggable !== void 0) next.draggable = previous.draggable;
|
|
977
|
-
if (previous.deletable !== void 0) next.deletable = previous.deletable;
|
|
978
|
-
return next;
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
function toggleLockNodes(nodes, ids) {
|
|
982
|
-
const idSet = new Set(ids);
|
|
983
|
-
const anyUnlocked = nodes.some((n3) => idSet.has(n3.id) && !isLocked(n3));
|
|
984
|
-
return anyUnlocked ? lockNodes(nodes, idSet) : unlockNodes(nodes, idSet);
|
|
985
|
-
}
|
|
986
|
-
function collect(nodes, ids, options) {
|
|
987
|
-
const lookup = createNodeLookup(nodes);
|
|
988
|
-
const items = [];
|
|
989
|
-
const seen = /* @__PURE__ */ new Set();
|
|
990
|
-
for (const id of ids) {
|
|
991
|
-
const node = lookup.get(id);
|
|
992
|
-
if (!node || seen.has(id)) continue;
|
|
993
|
-
seen.add(id);
|
|
994
|
-
items.push({ node, rect: getNodeRect(node, lookup, options), locked: isLocked(node) });
|
|
995
|
-
}
|
|
996
|
-
return { lookup, items };
|
|
997
|
-
}
|
|
998
|
-
function toPositionUpdates(lookup, targets) {
|
|
999
|
-
const updates = [];
|
|
1000
|
-
for (const [id, abs] of targets) {
|
|
1001
|
-
const node = lookup.get(id);
|
|
1002
|
-
let position = abs;
|
|
1003
|
-
if (node.parentId && lookup.has(node.parentId)) {
|
|
1004
|
-
const parent = lookup.get(node.parentId);
|
|
1005
|
-
const parentAbs = targets.get(parent.id) ?? getAbsolutePosition(parent, lookup);
|
|
1006
|
-
position = { x: abs.x - parentAbs.x, y: abs.y - parentAbs.y };
|
|
1007
|
-
}
|
|
1008
|
-
if (position.x !== node.position.x || position.y !== node.position.y) {
|
|
1009
|
-
updates.push({ id, position });
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
return updates;
|
|
1013
|
-
}
|
|
1014
|
-
function alignNodes(nodes, ids, edge, options = {}) {
|
|
1015
|
-
const { lookup, items } = collect(nodes, ids, options);
|
|
1016
|
-
const fixed = typeof options.to === "object" ? options.to : null;
|
|
1017
|
-
if (items.length === 0 || !fixed && items.length < 2) return [];
|
|
1018
|
-
const bounds = fixed ?? boundsOf(items.map((i) => i.rect));
|
|
1019
|
-
const targets = /* @__PURE__ */ new Map();
|
|
1020
|
-
for (const { node, rect: rect2, locked } of items) {
|
|
1021
|
-
if (locked) continue;
|
|
1022
|
-
let { x, y } = rect2;
|
|
1023
|
-
switch (edge) {
|
|
1024
|
-
case "left":
|
|
1025
|
-
x = bounds.x;
|
|
1026
|
-
break;
|
|
1027
|
-
case "center":
|
|
1028
|
-
x = bounds.x + bounds.width / 2 - rect2.width / 2;
|
|
1029
|
-
break;
|
|
1030
|
-
case "right":
|
|
1031
|
-
x = bounds.x + bounds.width - rect2.width;
|
|
1032
|
-
break;
|
|
1033
|
-
case "top":
|
|
1034
|
-
y = bounds.y;
|
|
1035
|
-
break;
|
|
1036
|
-
case "middle":
|
|
1037
|
-
y = bounds.y + bounds.height / 2 - rect2.height / 2;
|
|
1038
|
-
break;
|
|
1039
|
-
case "bottom":
|
|
1040
|
-
y = bounds.y + bounds.height - rect2.height;
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
targets.set(node.id, { x, y });
|
|
1044
|
-
}
|
|
1045
|
-
return toPositionUpdates(lookup, targets);
|
|
1046
|
-
}
|
|
1047
|
-
function distributeAxis(items, horizontal, mode, gapOverride, targets) {
|
|
1048
|
-
const start = (r) => horizontal ? r.x : r.y;
|
|
1049
|
-
const size2 = (r) => horizontal ? r.width : r.height;
|
|
1050
|
-
const sorted = [...items].sort(
|
|
1051
|
-
(a, b) => start(a.rect) + size2(a.rect) / 2 - (start(b.rect) + size2(b.rect) / 2)
|
|
1052
|
-
);
|
|
1053
|
-
const first = sorted[0].rect;
|
|
1054
|
-
const last = sorted[sorted.length - 1].rect;
|
|
1055
|
-
const n3 = sorted.length;
|
|
1056
|
-
const set = (item, value) => {
|
|
1057
|
-
if (item.locked) return;
|
|
1058
|
-
const current = targets.get(item.node.id) ?? { x: item.rect.x, y: item.rect.y };
|
|
1059
|
-
targets.set(item.node.id, horizontal ? { ...current, x: value } : { ...current, y: value });
|
|
1060
|
-
};
|
|
1061
|
-
if (mode === "centres") {
|
|
1062
|
-
const c0 = start(first) + size2(first) / 2;
|
|
1063
|
-
const c1 = start(last) + size2(last) / 2;
|
|
1064
|
-
const step = (c1 - c0) / (n3 - 1);
|
|
1065
|
-
sorted.forEach((item, i) => set(item, c0 + step * i - size2(item.rect) / 2));
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
const span = start(last) + size2(last) - start(first);
|
|
1069
|
-
const total = sorted.reduce((sum, item) => sum + size2(item.rect), 0);
|
|
1070
|
-
const gap = gapOverride ?? (span - total) / (n3 - 1);
|
|
1071
|
-
let cursor = start(first);
|
|
1072
|
-
for (const item of sorted) {
|
|
1073
|
-
set(item, cursor);
|
|
1074
|
-
cursor += size2(item.rect) + gap;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
function distributeNodes(nodes, ids, axis, mode = "gaps", options = {}) {
|
|
1078
|
-
const { lookup, items } = collect(nodes, ids, options);
|
|
1079
|
-
const minimum = options.gap !== void 0 && mode === "gaps" ? 2 : 3;
|
|
1080
|
-
if (items.length < minimum) return [];
|
|
1081
|
-
const targets = /* @__PURE__ */ new Map();
|
|
1082
|
-
if (axis !== "vertical") distributeAxis(items, true, mode, options.gap, targets);
|
|
1083
|
-
if (axis !== "horizontal") distributeAxis(items, false, mode, options.gap, targets);
|
|
1084
|
-
return toPositionUpdates(lookup, targets);
|
|
1085
|
-
}
|
|
1086
|
-
function matchSize(nodes, ids, dimension, options = {}) {
|
|
1087
|
-
const { items } = collect(nodes, ids, options);
|
|
1088
|
-
if (items.length < 2) return [];
|
|
1089
|
-
const reference = options.reference ?? "largest";
|
|
1090
|
-
const pick = (dim) => {
|
|
1091
|
-
if (typeof reference === "object") {
|
|
1092
|
-
const item = items.find((i) => i.node.id === reference.id);
|
|
1093
|
-
if (item) return item.rect[dim];
|
|
1094
|
-
}
|
|
1095
|
-
if (reference === "first") return items[0].rect[dim];
|
|
1096
|
-
const values = items.map((i) => i.rect[dim]);
|
|
1097
|
-
return reference === "smallest" ? Math.min(...values) : Math.max(...values);
|
|
1098
|
-
};
|
|
1099
|
-
const width = dimension !== "height" ? pick("width") : void 0;
|
|
1100
|
-
const height = dimension !== "width" ? pick("height") : void 0;
|
|
1101
|
-
const updates = [];
|
|
1102
|
-
for (const { node, rect: rect2, locked } of items) {
|
|
1103
|
-
if (locked) continue;
|
|
1104
|
-
const update = { id: node.id };
|
|
1105
|
-
if (width !== void 0 && width !== rect2.width) update.width = width;
|
|
1106
|
-
if (height !== void 0 && height !== rect2.height) update.height = height;
|
|
1107
|
-
if (update.width === void 0 && update.height === void 0) continue;
|
|
1108
|
-
if (options.keepCentre) {
|
|
1109
|
-
update.position = {
|
|
1110
|
-
x: node.position.x - ((update.width ?? rect2.width) - rect2.width) / 2,
|
|
1111
|
-
y: node.position.y - ((update.height ?? rect2.height) - rect2.height) / 2
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
updates.push(update);
|
|
1115
|
-
}
|
|
1116
|
-
return updates;
|
|
1117
|
-
}
|
|
1118
|
-
function reorderNodes(nodes, ids, operation, options = {}) {
|
|
1119
|
-
const lookup = createNodeLookup(nodes);
|
|
1120
|
-
const targetIds = new Set(
|
|
1121
|
-
[...ids].filter((id) => lookup.has(id) && !isLocked(lookup.get(id)))
|
|
1122
|
-
);
|
|
1123
|
-
if (targetIds.size === 0) return [];
|
|
1124
|
-
const groups = /* @__PURE__ */ new Map();
|
|
1125
|
-
for (const node of nodes) {
|
|
1126
|
-
const key = node.parentId ?? "";
|
|
1127
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
1128
|
-
groups.get(key).push(node);
|
|
1129
|
-
}
|
|
1130
|
-
const updates = [];
|
|
1131
|
-
for (const siblings of groups.values()) {
|
|
1132
|
-
if (!siblings.some((n3) => targetIds.has(n3.id))) continue;
|
|
1133
|
-
const order = siblings.map((node, index) => ({ node, index, z: typeof node.zIndex === "number" ? node.zIndex : 0 })).sort((a, b) => a.z - b.z || a.index - b.index).map((entry) => entry.node);
|
|
1134
|
-
const isTarget = (n3) => targetIds.has(n3.id);
|
|
1135
|
-
let next;
|
|
1136
|
-
if (operation === "bringToFront") {
|
|
1137
|
-
next = [...order.filter((n3) => !isTarget(n3)), ...order.filter(isTarget)];
|
|
1138
|
-
} else if (operation === "sendToBack") {
|
|
1139
|
-
next = [...order.filter(isTarget), ...order.filter((n3) => !isTarget(n3))];
|
|
1140
|
-
} else {
|
|
1141
|
-
next = [...order];
|
|
1142
|
-
const forward = operation === "bringForward";
|
|
1143
|
-
const rects = new Map(next.map((n3) => [n3.id, getNodeRect(n3, lookup, options)]));
|
|
1144
|
-
const intersects = (a, b) => a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
|
|
1145
|
-
const indices = next.map((_, i) => i);
|
|
1146
|
-
if (forward) indices.reverse();
|
|
1147
|
-
for (const i of indices) {
|
|
1148
|
-
const node = next[i];
|
|
1149
|
-
if (!isTarget(node)) continue;
|
|
1150
|
-
const step = forward ? 1 : -1;
|
|
1151
|
-
let j = i + step;
|
|
1152
|
-
let swapWith = -1;
|
|
1153
|
-
let firstNonTarget = -1;
|
|
1154
|
-
while (j >= 0 && j < next.length) {
|
|
1155
|
-
if (!isTarget(next[j])) {
|
|
1156
|
-
if (firstNonTarget === -1) firstNonTarget = j;
|
|
1157
|
-
if (intersects(rects.get(node.id), rects.get(next[j].id))) {
|
|
1158
|
-
swapWith = j;
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
j += step;
|
|
1163
|
-
}
|
|
1164
|
-
if (swapWith === -1) swapWith = firstNonTarget;
|
|
1165
|
-
if (swapWith === -1) continue;
|
|
1166
|
-
next.splice(i, 1);
|
|
1167
|
-
next.splice(swapWith, 0, node);
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
if (next.every((node, i) => node === order[i])) continue;
|
|
1171
|
-
next.forEach((node, rank) => {
|
|
1172
|
-
const current = typeof node.zIndex === "number" ? node.zIndex : 0;
|
|
1173
|
-
if (current !== rank) updates.push({ id: node.id, zIndex: rank });
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
return updates;
|
|
1177
|
-
}
|
|
1178
|
-
function applyNodeUpdates(nodes, updates) {
|
|
1179
|
-
if (updates.length === 0) return nodes;
|
|
1180
|
-
const byId = /* @__PURE__ */ new Map();
|
|
1181
|
-
for (const update of updates) {
|
|
1182
|
-
byId.set(update.id, { ...byId.get(update.id), ...update });
|
|
1183
|
-
}
|
|
1184
|
-
return nodes.map((node) => {
|
|
1185
|
-
const update = byId.get(node.id);
|
|
1186
|
-
if (!update) return node;
|
|
1187
|
-
const next = { ...node };
|
|
1188
|
-
if (update.position) next.position = { ...update.position };
|
|
1189
|
-
if (update.zIndex !== void 0) next.zIndex = update.zIndex;
|
|
1190
|
-
if (update.width !== void 0 || update.height !== void 0) {
|
|
1191
|
-
if (update.width !== void 0) next.width = update.width;
|
|
1192
|
-
if (update.height !== void 0) next.height = update.height;
|
|
1193
|
-
if (node.style) next.style = withStyleSize(node.style, update);
|
|
1194
|
-
if (node.measured) {
|
|
1195
|
-
next.measured = {
|
|
1196
|
-
...node.measured,
|
|
1197
|
-
...update.width !== void 0 ? { width: update.width } : {},
|
|
1198
|
-
...update.height !== void 0 ? { height: update.height } : {}
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
return next;
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
function invertNodeUpdates(nodes, updates) {
|
|
1206
|
-
const lookup = createNodeLookup(nodes);
|
|
1207
|
-
const inverse = [];
|
|
1208
|
-
for (const update of updates) {
|
|
1209
|
-
const node = lookup.get(update.id);
|
|
1210
|
-
if (!node) continue;
|
|
1211
|
-
const back = { id: node.id };
|
|
1212
|
-
if (update.position) back.position = { ...node.position };
|
|
1213
|
-
if (update.zIndex !== void 0) back.zIndex = typeof node.zIndex === "number" ? node.zIndex : 0;
|
|
1214
|
-
if (update.width !== void 0 || update.height !== void 0) {
|
|
1215
|
-
const size2 = getNodeSize(node);
|
|
1216
|
-
if (update.width !== void 0) back.width = size2.width;
|
|
1217
|
-
if (update.height !== void 0) back.height = size2.height;
|
|
1218
|
-
}
|
|
1219
|
-
inverse.push(back);
|
|
1220
|
-
}
|
|
1221
|
-
return inverse;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
890
|
// src/canvas/guides.ts
|
|
1225
891
|
function snapToGrid(value, spacing, origin = 0) {
|
|
1226
892
|
if (!(spacing > 0) || !Number.isFinite(spacing)) return value;
|
|
@@ -11513,6 +11179,29 @@ function isAgentCursor(cursor) {
|
|
|
11513
11179
|
return false;
|
|
11514
11180
|
}
|
|
11515
11181
|
|
|
11182
|
+
// src/canvas/playback.ts
|
|
11183
|
+
function createCanvasPlaybackLocator(options) {
|
|
11184
|
+
return (ref) => {
|
|
11185
|
+
const nodes = options.getNodes();
|
|
11186
|
+
const lookup = createNodeLookup(nodes);
|
|
11187
|
+
const rectOf = (id) => {
|
|
11188
|
+
const node = lookup.get(id);
|
|
11189
|
+
return node ? getNodeRect(node, lookup, options.rectOptions) : null;
|
|
11190
|
+
};
|
|
11191
|
+
if (ref.kind === "node" || ref.kind === "item") return rectOf(ref.id);
|
|
11192
|
+
if (ref.kind === "edge") {
|
|
11193
|
+
const edge = options.getEdges?.().find((e) => e.id === ref.id);
|
|
11194
|
+
const a = edge && rectOf(edge.source);
|
|
11195
|
+
const b = edge && rectOf(edge.target);
|
|
11196
|
+
if (!a || !b) return null;
|
|
11197
|
+
const x = (a.x + a.width / 2 + b.x + b.width / 2) / 2;
|
|
11198
|
+
const y = (a.y + a.height / 2 + b.y + b.height / 2) / 2;
|
|
11199
|
+
return { x: x - 12, y: y - 12, width: 24, height: 24 };
|
|
11200
|
+
}
|
|
11201
|
+
return null;
|
|
11202
|
+
};
|
|
11203
|
+
}
|
|
11204
|
+
|
|
11516
11205
|
// src/canvas/capture.ts
|
|
11517
11206
|
var CANVAS_CAPTURE_VIEWPORT_SELECTOR = ".xyflow__viewport, .react-flow__viewport, .svelte-flow__viewport";
|
|
11518
11207
|
var CANVAS_CAPTURE_CHROME_SELECTORS = [
|
|
@@ -12133,6 +11822,7 @@ export {
|
|
|
12133
11822
|
createCanvasEffectsController,
|
|
12134
11823
|
createCanvasEffectsToolProvider,
|
|
12135
11824
|
createCanvasInstance,
|
|
11825
|
+
createCanvasPlaybackLocator,
|
|
12136
11826
|
createCanvasScenesStore,
|
|
12137
11827
|
createDefaultStrokeStyle,
|
|
12138
11828
|
createFanOutTrajectory,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PlaybackRect, PlaybackRef } from '../tools/playback.cjs';
|
|
2
|
+
import { type NodeRectOptions } from './arrange.cjs';
|
|
3
|
+
import type { CanvasEdge, CanvasNode } from './types.cjs';
|
|
4
|
+
export interface CanvasPlaybackLocatorOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
5
|
+
getNodes: () => readonly TNode[];
|
|
6
|
+
getEdges?: () => readonly TEdge[];
|
|
7
|
+
/** Size resolution for unmeasured nodes. */
|
|
8
|
+
rectOptions?: NodeRectOptions;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Finds `{ kind: 'node', id }` (the node's absolute rectangle) and `{ kind: 'edge', id }` (a small
|
|
12
|
+
* box at the middle of the line between its nodes' centres) in flow coordinates.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createCanvasPlaybackLocator<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(options: CanvasPlaybackLocatorOptions<TNode, TEdge>): (ref: PlaybackRef) => PlaybackRect | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PlaybackRect, PlaybackRef } from '../tools/playback.js';
|
|
2
|
+
import { type NodeRectOptions } from './arrange.js';
|
|
3
|
+
import type { CanvasEdge, CanvasNode } from './types.js';
|
|
4
|
+
export interface CanvasPlaybackLocatorOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
5
|
+
getNodes: () => readonly TNode[];
|
|
6
|
+
getEdges?: () => readonly TEdge[];
|
|
7
|
+
/** Size resolution for unmeasured nodes. */
|
|
8
|
+
rectOptions?: NodeRectOptions;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Finds `{ kind: 'node', id }` (the node's absolute rectangle) and `{ kind: 'edge', id }` (a small
|
|
12
|
+
* box at the middle of the line between its nodes' centres) in flow coordinates.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createCanvasPlaybackLocator<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(options: CanvasPlaybackLocatorOptions<TNode, TEdge>): (ref: PlaybackRef) => PlaybackRect | null;
|