@fragiola/flow 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/connect-session-nyEp02_P.js +375 -0
- package/dist/connect-session-nyEp02_P.js.map +1 -0
- package/dist/connection.d.ts +31 -0
- package/dist/connection.js +60 -0
- package/dist/connection.js.map +1 -0
- package/dist/core-queries-BPNbcM6k.js +452 -0
- package/dist/core-queries-BPNbcM6k.js.map +1 -0
- package/dist/document-schema-CPK5xkyO.js +369 -0
- package/dist/document-schema-CPK5xkyO.js.map +1 -0
- package/dist/drag.d.ts +19 -0
- package/dist/drag.js +175 -0
- package/dist/drag.js.map +1 -0
- package/dist/index.d.ts +876 -0
- package/dist/index.js +5711 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-links-CVaTtlZg.js +8 -0
- package/dist/keyboard-links-CVaTtlZg.js.map +1 -0
- package/dist/keyboard.d.ts +40 -0
- package/dist/keyboard.js +342 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/minimap.d.ts +26 -0
- package/dist/minimap.js +206 -0
- package/dist/minimap.js.map +1 -0
- package/dist/node-moves-DyWe-4dj.js +36 -0
- package/dist/node-moves-DyWe-4dj.js.map +1 -0
- package/dist/part-attributes-DuBltA__.js +71 -0
- package/dist/part-attributes-DuBltA__.js.map +1 -0
- package/dist/path-format-2OU7Eiyy.js +43 -0
- package/dist/path-format-2OU7Eiyy.js.map +1 -0
- package/dist/reconnection.d.ts +15 -0
- package/dist/reconnection.js +138 -0
- package/dist/reconnection.js.map +1 -0
- package/dist/rect-CmoREaR6.js +92 -0
- package/dist/rect-CmoREaR6.js.map +1 -0
- package/dist/resize.d.ts +33 -0
- package/dist/resize.js +316 -0
- package/dist/resize.js.map +1 -0
- package/dist/rules-DLOMrPBG.js +102 -0
- package/dist/rules-DLOMrPBG.js.map +1 -0
- package/dist/selection.d.ts +38 -0
- package/dist/selection.js +392 -0
- package/dist/selection.js.map +1 -0
- package/dist/subflows.d.ts +9 -0
- package/dist/subflows.js +237 -0
- package/dist/subflows.js.map +1 -0
- package/dist/types-CLHcZVCb.d.ts +2660 -0
- package/dist/viewport-math-B-9Pn2kN.js +69 -0
- package/dist/viewport-math-B-9Pn2kN.js.map +1 -0
- package/package.json +93 -3
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { c as nodeFlag, l as reconnectableEnd, s as edgeFlag } from "./rules-DLOMrPBG.js";
|
|
2
|
+
// src/state/clone-json.ts
|
|
3
|
+
/** A deep, writable copy of a JSON value (what the model stores from a payload, what it writes out). */
|
|
4
|
+
function cloneJson(value) {
|
|
5
|
+
if (Array.isArray(value)) return value.map(cloneJson);
|
|
6
|
+
if (typeof value === "object" && value !== null) {
|
|
7
|
+
const copy = {};
|
|
8
|
+
for (const [key, child] of Object.entries(value)) {
|
|
9
|
+
if (child === void 0) continue;
|
|
10
|
+
if (key === "__proto__") Object.defineProperty(copy, key, {
|
|
11
|
+
value: cloneJson(child),
|
|
12
|
+
enumerable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
configurable: true
|
|
15
|
+
});
|
|
16
|
+
else copy[key] = cloneJson(child);
|
|
17
|
+
}
|
|
18
|
+
return copy;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
// src/state/commands-to.ts
|
|
23
|
+
const NODE_FLAGS = [
|
|
24
|
+
"draggable",
|
|
25
|
+
"selectable",
|
|
26
|
+
"connectable",
|
|
27
|
+
"deletable",
|
|
28
|
+
"hidden",
|
|
29
|
+
"focusable"
|
|
30
|
+
];
|
|
31
|
+
/** A node's declared geometry: no command sets it, so a change replaces the node. */
|
|
32
|
+
const NODE_GEOMETRY = [
|
|
33
|
+
"initialWidth",
|
|
34
|
+
"initialHeight",
|
|
35
|
+
"handles",
|
|
36
|
+
"sourcePosition",
|
|
37
|
+
"targetPosition",
|
|
38
|
+
"origin"
|
|
39
|
+
];
|
|
40
|
+
const EDGE_FLAGS = [
|
|
41
|
+
"selectable",
|
|
42
|
+
"deletable",
|
|
43
|
+
"hidden",
|
|
44
|
+
"focusable",
|
|
45
|
+
"animated"
|
|
46
|
+
];
|
|
47
|
+
/** Whether `edge.reconnect` may move an edge's ends where `next` puts them. */
|
|
48
|
+
function reconnects(edge, next) {
|
|
49
|
+
const sourceMoves = next.source !== edge.source || next.sourceHandle !== edge.sourceHandle;
|
|
50
|
+
const targetMoves = next.target !== edge.target || next.targetHandle !== edge.targetHandle;
|
|
51
|
+
return (!sourceMoves || reconnectableEnd(edge, "source")) && (!targetMoves || reconnectableEnd(edge, "target"));
|
|
52
|
+
}
|
|
53
|
+
/** Two JSON values with the same content. */
|
|
54
|
+
function sameJson(a, b) {
|
|
55
|
+
if (a === b) return true;
|
|
56
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
57
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
58
|
+
const aKeys = Object.keys(a).filter((key) => a[key] !== void 0);
|
|
59
|
+
const bKeys = Object.keys(b).filter((key) => b[key] !== void 0);
|
|
60
|
+
return aKeys.length === bKeys.length && aKeys.every((key) => Object.hasOwn(b, key) && sameJson(a[key], b[key]));
|
|
61
|
+
}
|
|
62
|
+
/** The keys of `next` whose values differ from `current`'s, or undefined when a key was removed. */
|
|
63
|
+
function dataPatch(current, next) {
|
|
64
|
+
const before = current ?? {};
|
|
65
|
+
const after = next ?? {};
|
|
66
|
+
for (const key of Object.keys(before)) if (before[key] !== void 0 && after[key] === void 0) return void 0;
|
|
67
|
+
const patch = {};
|
|
68
|
+
for (const [key, value] of Object.entries(after)) if (value !== void 0 && !sameJson(before[key], value)) patch[key] = cloneJson(value);
|
|
69
|
+
return patch;
|
|
70
|
+
}
|
|
71
|
+
/** The ids `selected` says, in order. */
|
|
72
|
+
function selectedIds(list) {
|
|
73
|
+
return list.filter((entity) => entity.selected === true).flatMap((entity) => entity.id === void 0 ? [] : [entity.id]);
|
|
74
|
+
}
|
|
75
|
+
function sameIds(a, b) {
|
|
76
|
+
if (a.length !== b.length) return false;
|
|
77
|
+
const set = new Set(a);
|
|
78
|
+
return b.every((id) => set.has(id));
|
|
79
|
+
}
|
|
80
|
+
/** The commands that bring `reader`'s document to `target`; `installed` names the commands it may use. */
|
|
81
|
+
function commandsTo(reader, target, installed, defaultEdge) {
|
|
82
|
+
const nodesWanted = target.nodes;
|
|
83
|
+
const edgesWanted = defaultEdge === void 0 || target.edges === void 0 ? target.edges : target.edges.map((edge) => {
|
|
84
|
+
const held = edge.id === void 0 ? void 0 : reader.edge(edge.id);
|
|
85
|
+
return {
|
|
86
|
+
...Object.fromEntries(Object.entries(defaultEdge).filter(([key, value]) => held === void 0 || sameJson(held[key], value))),
|
|
87
|
+
...Object.fromEntries(Object.entries(edge).filter(([, value]) => value !== void 0))
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
const currentNodes = reader.nodes();
|
|
91
|
+
const currentEdges = reader.edges();
|
|
92
|
+
if ((nodesWanted === void 0 || nodesWanted === currentNodes) && (target.edges === void 0 || target.edges === currentEdges)) return [];
|
|
93
|
+
const subflows = installed.has("node.set-parent");
|
|
94
|
+
const out = [];
|
|
95
|
+
const push = (command, payload) => out.push({
|
|
96
|
+
command,
|
|
97
|
+
payload
|
|
98
|
+
});
|
|
99
|
+
const wantedNodes = /* @__PURE__ */ new Map();
|
|
100
|
+
const addedNodes = [];
|
|
101
|
+
for (const node of nodesWanted ?? []) {
|
|
102
|
+
if (node.id === void 0 || !reader.node(node.id)) addedNodes.push(node);
|
|
103
|
+
if (node.id !== void 0) wantedNodes.set(node.id, node);
|
|
104
|
+
}
|
|
105
|
+
const removedNodes = /* @__PURE__ */ new Set();
|
|
106
|
+
const replacedNodes = /* @__PURE__ */ new Set();
|
|
107
|
+
if (nodesWanted !== void 0) {
|
|
108
|
+
for (const node of currentNodes) {
|
|
109
|
+
const next = wantedNodes.get(node.id);
|
|
110
|
+
if (!next) {
|
|
111
|
+
removedNodes.add(node.id);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const resized = next.width !== node.width || next.height !== node.height;
|
|
115
|
+
if (next.type !== node.type || NODE_GEOMETRY.some((key) => !sameJson(node[key], next[key])) || dataPatch(node.data, next.data) === void 0 || resized && (next.width === void 0 || next.height === void 0)) replacedNodes.add(node.id);
|
|
116
|
+
}
|
|
117
|
+
if (subflows) {
|
|
118
|
+
let grew = true;
|
|
119
|
+
while (grew) {
|
|
120
|
+
grew = false;
|
|
121
|
+
for (const node of currentNodes) {
|
|
122
|
+
const parent = node.parentId;
|
|
123
|
+
if (parent !== void 0 && replacedNodes.has(parent) && !replacedNodes.has(node.id) && !removedNodes.has(node.id)) {
|
|
124
|
+
replacedNodes.add(node.id);
|
|
125
|
+
grew = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const goneNodes = /* @__PURE__ */ new Set([...removedNodes, ...replacedNodes]);
|
|
132
|
+
const goesWithParent = (node, going) => {
|
|
133
|
+
let parent = node.parentId;
|
|
134
|
+
const seen = /* @__PURE__ */ new Set();
|
|
135
|
+
while (parent !== void 0 && !seen.has(parent)) {
|
|
136
|
+
if (going.has(parent)) return true;
|
|
137
|
+
seen.add(parent);
|
|
138
|
+
parent = reader.node(parent)?.parentId;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
142
|
+
const wantedEdges = /* @__PURE__ */ new Map();
|
|
143
|
+
const addedEdges = [];
|
|
144
|
+
for (const edge of edgesWanted ?? []) {
|
|
145
|
+
if (edge.id === void 0 || !reader.edge(edge.id)) addedEdges.push(edge);
|
|
146
|
+
if (edge.id !== void 0) wantedEdges.set(edge.id, edge);
|
|
147
|
+
}
|
|
148
|
+
const touchesGone = (edge) => goneNodes.has(edge.source) || goneNodes.has(edge.target);
|
|
149
|
+
const removedEdges = [];
|
|
150
|
+
const replacedEdges = [];
|
|
151
|
+
const reconnected = [];
|
|
152
|
+
const updatedEdges = [];
|
|
153
|
+
for (const edge of currentEdges) {
|
|
154
|
+
const next = edgesWanted === void 0 ? edge : wantedEdges.get(edge.id);
|
|
155
|
+
if (!next) {
|
|
156
|
+
if (!touchesGone(edge)) removedEdges.push(edge.id);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const moved = next.source !== edge.source || next.target !== edge.target || next.sourceHandle !== edge.sourceHandle || next.targetHandle !== edge.targetHandle;
|
|
160
|
+
const replaced = (next.type ?? "bezier") !== (edge.type ?? "bezier") || !sameJson(edge.pathOptions ?? {}, next.pathOptions ?? {}) || dataPatch(edge.data, next.data) === void 0 || moved && (!installed.has("edge.reconnect") || !reconnects(edge, next));
|
|
161
|
+
if (touchesGone(edge)) {
|
|
162
|
+
if (edgesWanted !== void 0 || !removedNodes.has(edge.source) && !removedNodes.has(edge.target)) replacedEdges.push(next);
|
|
163
|
+
} else if (replaced) {
|
|
164
|
+
removedEdges.push(edge.id);
|
|
165
|
+
replacedEdges.push(next);
|
|
166
|
+
} else {
|
|
167
|
+
if (moved) reconnected.push(next);
|
|
168
|
+
updatedEdges.push([edge, next]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const removeEdge = (edgeId) => {
|
|
172
|
+
const edge = reader.edge(edgeId);
|
|
173
|
+
if (edge !== void 0 && !edgeFlag(edge, "deletable")) push("edge.set-flags", {
|
|
174
|
+
edgeId,
|
|
175
|
+
deletable: true
|
|
176
|
+
});
|
|
177
|
+
push("edge.remove", { edgeId });
|
|
178
|
+
};
|
|
179
|
+
const removeNode = (node) => {
|
|
180
|
+
const locked = [node, ...descendantsOf(node.id)].filter((entity) => !nodeFlag(entity, "deletable"));
|
|
181
|
+
for (const entity of locked) push("node.set-flags", {
|
|
182
|
+
nodeId: entity.id,
|
|
183
|
+
deletable: true
|
|
184
|
+
});
|
|
185
|
+
push("node.remove", { nodeId: node.id });
|
|
186
|
+
};
|
|
187
|
+
const descendantsOf = (nodeId) => {
|
|
188
|
+
if (!subflows) return [];
|
|
189
|
+
return currentNodes.filter((node) => node.parentId === nodeId).flatMap((child) => [child, ...descendantsOf(child.id)]);
|
|
190
|
+
};
|
|
191
|
+
for (const edgeId of removedEdges) removeEdge(edgeId);
|
|
192
|
+
for (const node of currentNodes) if (replacedNodes.has(node.id) && !goesWithParent(node, replacedNodes)) removeNode(node);
|
|
193
|
+
const toAdd = [...(nodesWanted ?? []).filter((node) => node.id !== void 0 && replacedNodes.has(node.id)), ...addedNodes];
|
|
194
|
+
const pending = new Set(toAdd.flatMap((node) => node.id === void 0 ? [] : [node.id]));
|
|
195
|
+
const added = /* @__PURE__ */ new Set();
|
|
196
|
+
let progress = true;
|
|
197
|
+
while (added.size < toAdd.length && progress) {
|
|
198
|
+
progress = false;
|
|
199
|
+
for (const node of toAdd) {
|
|
200
|
+
if (added.has(node)) continue;
|
|
201
|
+
const parent = node.parentId;
|
|
202
|
+
if (parent !== void 0 && pending.has(parent)) continue;
|
|
203
|
+
push("node.add", cloneJson(node));
|
|
204
|
+
added.add(node);
|
|
205
|
+
if (node.id !== void 0) pending.delete(node.id);
|
|
206
|
+
progress = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const node of toAdd) if (!added.has(node)) push("node.add", cloneJson(node));
|
|
210
|
+
if (nodesWanted !== void 0) for (const node of currentNodes) {
|
|
211
|
+
const next = wantedNodes.get(node.id);
|
|
212
|
+
if (!next || goneNodes.has(node.id)) continue;
|
|
213
|
+
const nodeId = node.id;
|
|
214
|
+
const reparented = subflows && (next.parentId !== node.parentId || !sameJson(next.extent, node.extent) || (next.expandParent ?? false) !== (node.expandParent ?? false));
|
|
215
|
+
if (reparented) push("node.set-parent", {
|
|
216
|
+
nodeId,
|
|
217
|
+
parentId: next.parentId ?? null,
|
|
218
|
+
extent: next.extent ?? null,
|
|
219
|
+
expandParent: next.expandParent ?? false
|
|
220
|
+
});
|
|
221
|
+
const flags = {};
|
|
222
|
+
for (const flag of NODE_FLAGS) {
|
|
223
|
+
const value = nodeFlag(next, flag);
|
|
224
|
+
if (value !== nodeFlag(node, flag)) flags[flag] = value;
|
|
225
|
+
}
|
|
226
|
+
const hasFlags = Object.keys(flags).length > 0;
|
|
227
|
+
const flagsFirst = flags.draggable !== false;
|
|
228
|
+
if (hasFlags && flagsFirst) push("node.set-flags", {
|
|
229
|
+
nodeId,
|
|
230
|
+
...flags
|
|
231
|
+
});
|
|
232
|
+
if (reparented && next.parentId !== node.parentId || next.position.x !== node.position.x || next.position.y !== node.position.y) {
|
|
233
|
+
const fixed = !nodeFlag(node, "draggable") && flags.draggable !== true;
|
|
234
|
+
if (fixed) push("node.set-flags", {
|
|
235
|
+
nodeId,
|
|
236
|
+
draggable: true
|
|
237
|
+
});
|
|
238
|
+
push("node.move", {
|
|
239
|
+
nodeId,
|
|
240
|
+
position: {
|
|
241
|
+
x: next.position.x,
|
|
242
|
+
y: next.position.y
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
if (fixed) push("node.set-flags", {
|
|
246
|
+
nodeId,
|
|
247
|
+
draggable: false
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (next.width !== void 0 && next.height !== void 0 && (next.width !== node.width || next.height !== node.height)) push("node.resize", {
|
|
251
|
+
nodeId,
|
|
252
|
+
width: next.width,
|
|
253
|
+
height: next.height
|
|
254
|
+
});
|
|
255
|
+
if (next.zIndex !== node.zIndex) push("node.set-z-index", {
|
|
256
|
+
nodeId,
|
|
257
|
+
zIndex: next.zIndex ?? null
|
|
258
|
+
});
|
|
259
|
+
const patch = dataPatch(node.data, next.data);
|
|
260
|
+
if (patch && Object.keys(patch).length > 0) push("node.set-data", {
|
|
261
|
+
nodeId,
|
|
262
|
+
data: patch
|
|
263
|
+
});
|
|
264
|
+
if (hasFlags && !flagsFirst) push("node.set-flags", {
|
|
265
|
+
nodeId,
|
|
266
|
+
...flags
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
for (const node of currentNodes) if (removedNodes.has(node.id) && !goesWithParent(node, goneNodes)) removeNode(node);
|
|
270
|
+
const connecting = [
|
|
271
|
+
...replacedEdges,
|
|
272
|
+
...addedEdges,
|
|
273
|
+
...reconnected
|
|
274
|
+
];
|
|
275
|
+
const unconnectable = [...new Set(connecting.flatMap((edge) => [edge.source, edge.target]))].filter((nodeId) => {
|
|
276
|
+
const node = wantedNodes.get(nodeId) ?? reader.node(nodeId);
|
|
277
|
+
return node !== void 0 && !nodeFlag(node, "connectable");
|
|
278
|
+
});
|
|
279
|
+
for (const nodeId of unconnectable) push("node.set-flags", {
|
|
280
|
+
nodeId,
|
|
281
|
+
connectable: true
|
|
282
|
+
});
|
|
283
|
+
for (const edge of [...replacedEdges, ...addedEdges]) push("edge.add", cloneJson(edge));
|
|
284
|
+
for (const next of reconnected) push("edge.reconnect", {
|
|
285
|
+
edgeId: next.id,
|
|
286
|
+
source: next.source,
|
|
287
|
+
target: next.target,
|
|
288
|
+
...next.sourceHandle === void 0 ? {} : { sourceHandle: next.sourceHandle },
|
|
289
|
+
...next.targetHandle === void 0 ? {} : { targetHandle: next.targetHandle }
|
|
290
|
+
});
|
|
291
|
+
for (const nodeId of unconnectable) push("node.set-flags", {
|
|
292
|
+
nodeId,
|
|
293
|
+
connectable: false
|
|
294
|
+
});
|
|
295
|
+
for (const [edge, next] of updatedEdges) {
|
|
296
|
+
const edgeId = edge.id;
|
|
297
|
+
const flags = {};
|
|
298
|
+
for (const flag of EDGE_FLAGS) {
|
|
299
|
+
const value = edgeFlag(next, flag);
|
|
300
|
+
if (value !== edgeFlag(edge, flag)) flags[flag] = value;
|
|
301
|
+
}
|
|
302
|
+
const reconnectable = next.reconnectable ?? true;
|
|
303
|
+
if (reconnectable !== (edge.reconnectable ?? true)) flags.reconnectable = reconnectable;
|
|
304
|
+
if (Object.keys(flags).length > 0) push("edge.set-flags", {
|
|
305
|
+
edgeId,
|
|
306
|
+
...flags
|
|
307
|
+
});
|
|
308
|
+
if (next.zIndex !== edge.zIndex) push("edge.set-z-index", {
|
|
309
|
+
edgeId,
|
|
310
|
+
zIndex: next.zIndex ?? null
|
|
311
|
+
});
|
|
312
|
+
const patch = dataPatch(edge.data, next.data);
|
|
313
|
+
if (patch && Object.keys(patch).length > 0) push("edge.set-data", {
|
|
314
|
+
edgeId,
|
|
315
|
+
data: patch
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (installed.has("selection.set")) {
|
|
319
|
+
const nodeIds = selectedIds(nodesWanted ?? currentNodes);
|
|
320
|
+
const edgeIds = selectedIds(edgesWanted ?? currentEdges);
|
|
321
|
+
if (!sameIds(nodeIds, selectedIds(currentNodes)) || !sameIds(edgeIds, selectedIds(currentEdges))) push("selection.set", {
|
|
322
|
+
nodeIds,
|
|
323
|
+
edgeIds,
|
|
324
|
+
mode: "replace"
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return out;
|
|
328
|
+
}
|
|
329
|
+
// src/state/core-queries.ts
|
|
330
|
+
/** A string field of a payload of unknown shape (a key's payload is not validated). */
|
|
331
|
+
function stringOf(payload, key) {
|
|
332
|
+
const value = typeof payload === "object" && payload !== null ? payload[key] : void 0;
|
|
333
|
+
return typeof value === "string" ? value : void 0;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* The nodes at the other end of a node's edges that end at it (`at: "target"`: its incomers) or
|
|
337
|
+
* start from it (`"source"`: its outgoers), in the document's node order, each once. A self loop
|
|
338
|
+
* makes the node its own incomer and outgoer; hidden nodes and edges count (a graph fact, not a
|
|
339
|
+
* view's).
|
|
340
|
+
*/
|
|
341
|
+
function neighbours(reader, nodeId, at) {
|
|
342
|
+
if (nodeId === void 0) return [];
|
|
343
|
+
const other = at === "target" ? "source" : "target";
|
|
344
|
+
const ids = /* @__PURE__ */ new Set();
|
|
345
|
+
for (const edge of reader.edges()) if (edge[at] === nodeId) ids.add(edge[other]);
|
|
346
|
+
return ids.size === 0 ? [] : reader.nodes().filter((node) => ids.has(node.id));
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* The edges that start or end at a node (`nodeId`), only those that start (`handleType:
|
|
350
|
+
* "source"`) or end (`"target"`) there with `handleType`, only those at `handleId` with it.
|
|
351
|
+
*/
|
|
352
|
+
function nodeEdges(reader, payload) {
|
|
353
|
+
const nodeId = stringOf(payload, "nodeId");
|
|
354
|
+
const handleType = stringOf(payload, "handleType");
|
|
355
|
+
const handleId = stringOf(payload, "handleId");
|
|
356
|
+
const at = (edge, end) => edge[end] === nodeId && (handleType === void 0 || handleType === end) && (handleId === void 0 || edge[end === "source" ? "sourceHandle" : "targetHandle"] === handleId);
|
|
357
|
+
return reader.edges().filter((edge) => at(edge, "source") || at(edge, "target"));
|
|
358
|
+
}
|
|
359
|
+
/** The core's `get` keys. */
|
|
360
|
+
const CORE_GET = {
|
|
361
|
+
"node-by": ({ reader }, payload) => {
|
|
362
|
+
const id = stringOf(payload, "id");
|
|
363
|
+
return id === void 0 ? void 0 : reader.node(id);
|
|
364
|
+
},
|
|
365
|
+
"edge-by": ({ reader }, payload) => {
|
|
366
|
+
const id = stringOf(payload, "id");
|
|
367
|
+
return id === void 0 ? void 0 : reader.edge(id);
|
|
368
|
+
},
|
|
369
|
+
"all-nodes": ({ reader }) => reader.nodes(),
|
|
370
|
+
"all-edges": ({ reader }) => reader.edges(),
|
|
371
|
+
"node-edges-by": ({ reader }, payload) => nodeEdges(reader, payload),
|
|
372
|
+
"node-connections-by": ({ reader }, payload) => nodeEdges(reader, payload).map((edge) => ({
|
|
373
|
+
edgeId: edge.id,
|
|
374
|
+
source: edge.source,
|
|
375
|
+
sourceHandle: edge.sourceHandle,
|
|
376
|
+
target: edge.target,
|
|
377
|
+
targetHandle: edge.targetHandle
|
|
378
|
+
})),
|
|
379
|
+
"nodes-data-by": ({ reader }, payload) => {
|
|
380
|
+
const list = typeof payload === "object" && payload !== null ? payload.nodeIds : void 0;
|
|
381
|
+
if (!Array.isArray(list)) return [];
|
|
382
|
+
return list.flatMap((id) => {
|
|
383
|
+
const node = typeof id === "string" ? reader.node(id) : void 0;
|
|
384
|
+
return node ? [{
|
|
385
|
+
id: node.id,
|
|
386
|
+
type: node.type,
|
|
387
|
+
data: node.data
|
|
388
|
+
}] : [];
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
"connected-edges-by": ({ reader }, payload) => {
|
|
392
|
+
const list = typeof payload === "object" && payload !== null ? payload.nodeIds : void 0;
|
|
393
|
+
const ids = new Set(Array.isArray(list) ? list.filter((id) => typeof id === "string") : []);
|
|
394
|
+
return reader.edges().filter((edge) => ids.has(edge.source) || ids.has(edge.target));
|
|
395
|
+
},
|
|
396
|
+
"incomers-by": ({ reader }, payload) => neighbours(reader, stringOf(payload, "nodeId"), "target"),
|
|
397
|
+
"outgoers-by": ({ reader }, payload) => neighbours(reader, stringOf(payload, "nodeId"), "source"),
|
|
398
|
+
"absolute-position-by": ({ reader, features }, payload) => {
|
|
399
|
+
const nodeId = stringOf(payload, "nodeId");
|
|
400
|
+
const node = nodeId === void 0 ? void 0 : reader.node(nodeId);
|
|
401
|
+
return node && features.absolutePosition(reader, node);
|
|
402
|
+
},
|
|
403
|
+
"flow-json": ({ reader }) => cloneJson({
|
|
404
|
+
version: 1,
|
|
405
|
+
nodes: [...reader.nodes()],
|
|
406
|
+
edges: [...reader.edges()]
|
|
407
|
+
}),
|
|
408
|
+
commands: ({ commands }) => commands,
|
|
409
|
+
"commands-to": (context, payload) => {
|
|
410
|
+
const { reader, commands } = context;
|
|
411
|
+
const target = typeof payload === "object" && payload !== null ? payload : {};
|
|
412
|
+
return commandsTo(reader, {
|
|
413
|
+
nodes: Array.isArray(target.nodes) ? target.nodes : void 0,
|
|
414
|
+
edges: Array.isArray(target.edges) ? target.edges : void 0
|
|
415
|
+
}, new Set(commands.map((command) => command.name)), context.defaultEdge);
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
function nodeAsks(flag) {
|
|
419
|
+
return ({ reader }, payload) => {
|
|
420
|
+
const nodeId = stringOf(payload, "nodeId");
|
|
421
|
+
const node = nodeId === void 0 ? void 0 : reader.node(nodeId);
|
|
422
|
+
return node !== void 0 && nodeFlag(node, flag);
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function edgeAsks(flag) {
|
|
426
|
+
return ({ reader }, payload) => {
|
|
427
|
+
const edgeId = stringOf(payload, "edgeId");
|
|
428
|
+
const edge = edgeId === void 0 ? void 0 : reader.edge(edgeId);
|
|
429
|
+
return edge !== void 0 && edgeFlag(edge, flag);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/** The core's `is` keys: a missing node or edge answers `false`. */
|
|
433
|
+
const CORE_IS = {
|
|
434
|
+
"node-draggable": nodeAsks("draggable"),
|
|
435
|
+
"node-selectable": nodeAsks("selectable"),
|
|
436
|
+
"node-connectable": nodeAsks("connectable"),
|
|
437
|
+
"node-deletable": nodeAsks("deletable"),
|
|
438
|
+
"node-hidden": nodeAsks("hidden"),
|
|
439
|
+
"edge-selectable": edgeAsks("selectable"),
|
|
440
|
+
"edge-deletable": edgeAsks("deletable"),
|
|
441
|
+
"edge-hidden": edgeAsks("hidden"),
|
|
442
|
+
"edge-reconnectable": ({ reader }, payload) => {
|
|
443
|
+
const edgeId = stringOf(payload, "edgeId");
|
|
444
|
+
const edge = edgeId === void 0 ? void 0 : reader.edge(edgeId);
|
|
445
|
+
if (edge === void 0) return false;
|
|
446
|
+
const end = stringOf(payload, "end");
|
|
447
|
+
return end === "source" || end === "target" ? reconnectableEnd(edge, end) : edgeFlag(edge, "reconnectable");
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
export { cloneJson as i, CORE_IS as n, stringOf as r, CORE_GET as t };
|
|
451
|
+
|
|
452
|
+
//# sourceMappingURL=core-queries-BPNbcM6k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-queries-BPNbcM6k.js","names":[],"sources":["../src/state/clone-json.ts","../src/state/commands-to.ts","../src/state/core-queries.ts"],"sourcesContent":["/** A deep, writable copy of a JSON value (what the model stores from a payload, what it writes out). */\nexport function cloneJson<V>(value: V): V {\n if (Array.isArray(value)) {\n return value.map(cloneJson) as V;\n }\n if (typeof value === \"object\" && value !== null) {\n const copy: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(value)) {\n if (child === undefined) continue;\n if (key === \"__proto__\") {\n // defined, not assigned: a `__proto__` key of parsed JSON stays a plain key\n Object.defineProperty(copy, key, {\n value: cloneJson(child),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n } else {\n copy[key] = cloneJson(child);\n }\n }\n return copy as V;\n }\n return value;\n}\n","// `get(\"commands-to\", { nodes?, edges? })`: the commands that turn the document into one with\n// these nodes and edges, the way an adapter's controlled `nodes` / `edges` props reach the model.\n// Each difference becomes the command a user's action would have run (`node.move`, `edge.add`,\n// `selection.set`, …), so middleware, listeners and undo see ordinary commands. The props are the\n// app's document, so a flag that stops a user (`draggable`, `deletable`, `connectable`) does not\n// stop them: the step is unlocked and locked again in the same batch; a middleware still vetoes.\n// Every adapter asks the core, so none re-implements the diff. What no command can express (a\n// node's type, a removed data key, a size given back to measurement, a node's declared geometry\n// (`initialWidth`, `initialHeight`, `handles`, `sourcePosition`, `targetPosition`, `origin`), an\n// edge's path options)\n// replaces the entity: removed and added again with the same id, its edges with it. The drawing order is not synced.\nimport type { BatchEntry } from \"../commands/types\";\nimport { edgeFlag, nodeFlag, reconnectableEnd } from \"../document/flags\";\nimport type {\n EdgeFlags,\n FlowEdge,\n FlowEdgeInput,\n FlowNode,\n FlowNodeInput,\n NodeFlags,\n} from \"../document/types\";\nimport type { FlowReader } from \"../features/types\";\nimport { cloneJson } from \"./clone-json\";\n\n/** What `commands-to` takes: the nodes and edges wanted (each list left out stays as it is). */\nexport interface CommandsToPayload {\n readonly nodes?: readonly FlowNodeInput[] | undefined;\n readonly edges?: readonly FlowEdgeInput[] | undefined;\n}\n\nconst NODE_FLAGS = [\n \"draggable\",\n \"selectable\",\n \"connectable\",\n \"deletable\",\n \"hidden\",\n \"focusable\",\n] as const satisfies readonly (keyof NodeFlags)[];\n\n/** A node's declared geometry: no command sets it, so a change replaces the node. */\nconst NODE_GEOMETRY = [\n \"initialWidth\",\n \"initialHeight\",\n \"handles\",\n \"sourcePosition\",\n \"targetPosition\",\n \"origin\",\n] as const satisfies readonly (keyof FlowNodeInput)[];\n\nconst EDGE_FLAGS = [\n \"selectable\",\n \"deletable\",\n \"hidden\",\n \"focusable\",\n \"animated\",\n] as const satisfies readonly (keyof EdgeFlags)[];\n\n/** Whether `edge.reconnect` may move an edge's ends where `next` puts them. */\nfunction reconnects(edge: FlowEdge, next: FlowEdgeInput): boolean {\n const sourceMoves =\n next.source !== edge.source || next.sourceHandle !== edge.sourceHandle;\n const targetMoves =\n next.target !== edge.target || next.targetHandle !== edge.targetHandle;\n return (\n (!sourceMoves || reconnectableEnd(edge, \"source\")) &&\n (!targetMoves || reconnectableEnd(edge, \"target\"))\n );\n}\n\ntype Json = Readonly<Record<string, unknown>>;\n\n/** Two JSON values with the same content. */\nfunction sameJson(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (\n typeof a !== \"object\" ||\n typeof b !== \"object\" ||\n a === null ||\n b === null\n ) {\n return false;\n }\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const aKeys = Object.keys(a).filter(\n (key) => (a as Json)[key] !== undefined,\n );\n const bKeys = Object.keys(b).filter(\n (key) => (b as Json)[key] !== undefined,\n );\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n Object.hasOwn(b, key) &&\n sameJson((a as Json)[key], (b as Json)[key]),\n )\n );\n}\n\n/** The keys of `next` whose values differ from `current`'s, or undefined when a key was removed. */\nfunction dataPatch(\n current: Json | undefined,\n next: Json | undefined,\n): Record<string, unknown> | undefined {\n const before = current ?? {};\n const after = next ?? {};\n for (const key of Object.keys(before)) {\n if (before[key] !== undefined && after[key] === undefined)\n return undefined;\n }\n const patch: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(after)) {\n if (value !== undefined && !sameJson(before[key], value))\n patch[key] = cloneJson(value);\n }\n return patch;\n}\n\n/** The ids `selected` says, in order. */\nfunction selectedIds(list: readonly { id?: string; selected?: boolean }[]) {\n return list\n .filter((entity) => entity.selected === true)\n .flatMap((entity) => (entity.id === undefined ? [] : [entity.id]));\n}\n\nfunction sameIds(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const set = new Set(a);\n return b.every((id) => set.has(id));\n}\n\n/** The commands that bring `reader`'s document to `target`; `installed` names the commands it may use. */\nexport function commandsTo(\n reader: FlowReader,\n target: CommandsToPayload,\n installed: ReadonlySet<string>,\n defaultEdge?: Readonly<Record<string, unknown>> | undefined,\n): BatchEntry[] {\n const nodesWanted = target.nodes;\n // the wanted edges as `edge.add` would store them (`defaultEdgeOptions` under what they give),\n // so an edge the defaults filled in is not synced back forever. An edge the model holds takes\n // a default only where it holds that default's value: a document edge, loaded without the\n // defaults, is not rewritten by them\n const edgesWanted =\n defaultEdge === undefined || target.edges === undefined\n ? target.edges\n : target.edges.map((edge) => {\n const held =\n edge.id === undefined ? undefined : reader.edge(edge.id);\n const filled = Object.fromEntries(\n Object.entries(defaultEdge).filter(\n ([key, value]) =>\n held === undefined ||\n sameJson(\n (held as unknown as Record<string, unknown>)[\n key\n ],\n value,\n ),\n ),\n );\n return {\n ...filled,\n ...Object.fromEntries(\n Object.entries(edge).filter(\n ([, value]) => value !== undefined,\n ),\n ),\n } as FlowEdgeInput;\n });\n const currentNodes = reader.nodes();\n const currentEdges = reader.edges();\n if (\n (nodesWanted === undefined || nodesWanted === currentNodes) &&\n (target.edges === undefined || target.edges === currentEdges)\n ) {\n return [];\n }\n const subflows = installed.has(\"node.set-parent\");\n const out: BatchEntry[] = [];\n const push = (command: string, payload: unknown) =>\n out.push({ command, payload } as BatchEntry);\n\n // ---- nodes: which are removed, added, replaced or updated\n const wantedNodes = new Map<string, FlowNodeInput>();\n const addedNodes: FlowNodeInput[] = [];\n for (const node of nodesWanted ?? []) {\n if (node.id === undefined || !reader.node(node.id))\n addedNodes.push(node);\n if (node.id !== undefined) wantedNodes.set(node.id, node);\n }\n const removedNodes = new Set<string>();\n const replacedNodes = new Set<string>();\n if (nodesWanted !== undefined) {\n for (const node of currentNodes) {\n const next = wantedNodes.get(node.id);\n if (!next) {\n removedNodes.add(node.id);\n continue;\n }\n const resized =\n next.width !== node.width || next.height !== node.height;\n if (\n next.type !== node.type ||\n NODE_GEOMETRY.some((key) => !sameJson(node[key], next[key])) ||\n dataPatch(node.data as Json, next.data as Json) === undefined ||\n (resized &&\n (next.width === undefined || next.height === undefined))\n ) {\n replacedNodes.add(node.id);\n }\n }\n // a node removed with its parent (`subflows()`) goes with it; a replaced parent takes its\n // children along, so they are added again too\n if (subflows) {\n let grew = true;\n while (grew) {\n grew = false;\n for (const node of currentNodes) {\n const parent = node.parentId;\n if (\n parent !== undefined &&\n replacedNodes.has(parent) &&\n !replacedNodes.has(node.id) &&\n !removedNodes.has(node.id)\n ) {\n replacedNodes.add(node.id);\n grew = true;\n }\n }\n }\n }\n }\n const goneNodes = new Set([...removedNodes, ...replacedNodes]);\n // whether a node goes with an ancestor of `going`\n const goesWithParent = (\n node: FlowNode,\n going: ReadonlySet<string>,\n ): boolean => {\n let parent = node.parentId;\n const seen = new Set<string>();\n while (parent !== undefined && !seen.has(parent)) {\n if (going.has(parent)) return true;\n seen.add(parent);\n parent = reader.node(parent)?.parentId;\n }\n return false;\n };\n\n // ---- edges\n const wantedEdges = new Map<string, FlowEdgeInput>();\n const addedEdges: FlowEdgeInput[] = [];\n for (const edge of edgesWanted ?? []) {\n if (edge.id === undefined || !reader.edge(edge.id))\n addedEdges.push(edge);\n if (edge.id !== undefined) wantedEdges.set(edge.id, edge);\n }\n const touchesGone = (edge: FlowEdge) =>\n goneNodes.has(edge.source) || goneNodes.has(edge.target);\n const removedEdges: string[] = [];\n const replacedEdges: FlowEdgeInput[] = [];\n const reconnected: FlowEdgeInput[] = [];\n const updatedEdges: [FlowEdge, FlowEdgeInput][] = [];\n for (const edge of currentEdges) {\n const next =\n edgesWanted === undefined ? edge : wantedEdges.get(edge.id);\n if (!next) {\n // an edge of a removed node goes with it\n if (!touchesGone(edge)) removedEdges.push(edge.id);\n continue;\n }\n const moved =\n next.source !== edge.source ||\n next.target !== edge.target ||\n next.sourceHandle !== edge.sourceHandle ||\n next.targetHandle !== edge.targetHandle;\n const replaced =\n (next.type ?? \"bezier\") !== (edge.type ?? \"bezier\") ||\n !sameJson(edge.pathOptions ?? {}, next.pathOptions ?? {}) ||\n dataPatch(edge.data as Json, next.data as Json) === undefined ||\n (moved &&\n (!installed.has(\"edge.reconnect\") || !reconnects(edge, next)));\n if (touchesGone(edge)) {\n // removed with its node: added again as it is wanted (an edge the app does not\n // control goes with a removed node, and comes back with a replaced one)\n if (\n edgesWanted !== undefined ||\n (!removedNodes.has(edge.source) &&\n !removedNodes.has(edge.target))\n )\n replacedEdges.push(next);\n } else if (replaced) {\n removedEdges.push(edge.id);\n replacedEdges.push(next);\n } else {\n if (moved) reconnected.push(next);\n updatedEdges.push([edge, next]);\n }\n }\n\n // The props are the app's document: a flag that stops a user (`deletable`, `draggable`,\n // `connectable`) does not stop them. Each command a flag would refuse is unlocked for its own\n // step and locked again after it, in the same batch.\n const removeEdge = (edgeId: string) => {\n const edge = reader.edge(edgeId);\n const locked = edge !== undefined && !edgeFlag(edge, \"deletable\");\n if (locked) push(\"edge.set-flags\", { edgeId, deletable: true });\n push(\"edge.remove\", { edgeId });\n };\n const removeNode = (node: FlowNode) => {\n // a node goes with its children: each one that is not deletable is unlocked too\n const locked = [node, ...descendantsOf(node.id)].filter(\n (entity) => !nodeFlag(entity, \"deletable\"),\n );\n for (const entity of locked)\n push(\"node.set-flags\", { nodeId: entity.id, deletable: true });\n push(\"node.remove\", { nodeId: node.id });\n };\n const descendantsOf = (nodeId: string): FlowNode[] => {\n if (!subflows) return [];\n const children = currentNodes.filter(\n (node) => node.parentId === nodeId,\n );\n return children.flatMap((child) => [child, ...descendantsOf(child.id)]);\n };\n\n // 1. edges that go, then the nodes replaced (their edges and children go with them)\n for (const edgeId of removedEdges) removeEdge(edgeId);\n for (const node of currentNodes) {\n if (replacedNodes.has(node.id) && !goesWithParent(node, replacedNodes))\n removeNode(node);\n }\n\n // 2. the nodes added (again), each parent before its children\n const toAdd = [\n ...(nodesWanted ?? []).filter(\n (node) => node.id !== undefined && replacedNodes.has(node.id),\n ),\n ...addedNodes,\n ];\n const pending = new Set(\n toAdd.flatMap((node) => (node.id === undefined ? [] : [node.id])),\n );\n const added = new Set<FlowNodeInput>();\n let progress = true;\n while (added.size < toAdd.length && progress) {\n progress = false;\n for (const node of toAdd) {\n if (added.has(node)) continue;\n const parent = node.parentId;\n if (parent !== undefined && pending.has(parent)) continue;\n push(\"node.add\", cloneJson(node));\n added.add(node);\n if (node.id !== undefined) pending.delete(node.id);\n progress = true;\n }\n }\n // a cycle of parents: added as they are, for the command to refuse\n for (const node of toAdd)\n if (!added.has(node)) push(\"node.add\", cloneJson(node));\n\n // 3. the nodes that stay: parent, flags, position, size, data\n if (nodesWanted !== undefined) {\n for (const node of currentNodes) {\n const next = wantedNodes.get(node.id);\n if (!next || goneNodes.has(node.id)) continue;\n const nodeId = node.id;\n // `node.set-parent` keeps the node's place on screen: its wanted (relative) position\n // is moved to after it\n const reparented =\n subflows &&\n (next.parentId !== node.parentId ||\n !sameJson(next.extent, node.extent) ||\n (next.expandParent ?? false) !==\n (node.expandParent ?? false));\n if (reparented) {\n push(\"node.set-parent\", {\n nodeId,\n parentId: next.parentId ?? null,\n extent: next.extent ?? null,\n expandParent: next.expandParent ?? false,\n });\n }\n const flags: Record<string, boolean> = {};\n for (const flag of NODE_FLAGS) {\n const value = nodeFlag(next, flag);\n if (value !== nodeFlag(node, flag)) flags[flag] = value;\n }\n const hasFlags = Object.keys(flags).length > 0;\n // a node made draggable moves; one made fixed moves first\n const flagsFirst = flags.draggable !== false;\n if (hasFlags && flagsFirst)\n push(\"node.set-flags\", { nodeId, ...flags });\n if (\n (reparented && next.parentId !== node.parentId) ||\n next.position.x !== node.position.x ||\n next.position.y !== node.position.y\n ) {\n // a node that stays fixed is unlocked for its move\n const fixed =\n !nodeFlag(node, \"draggable\") && flags.draggable !== true;\n if (fixed) push(\"node.set-flags\", { nodeId, draggable: true });\n push(\"node.move\", {\n nodeId,\n position: { x: next.position.x, y: next.position.y },\n });\n if (fixed) push(\"node.set-flags\", { nodeId, draggable: false });\n }\n if (\n next.width !== undefined &&\n next.height !== undefined &&\n (next.width !== node.width || next.height !== node.height)\n ) {\n push(\"node.resize\", {\n nodeId,\n width: next.width,\n height: next.height,\n });\n }\n if (next.zIndex !== node.zIndex)\n push(\"node.set-z-index\", {\n nodeId,\n zIndex: next.zIndex ?? null,\n });\n const patch = dataPatch(node.data as Json, next.data as Json);\n if (patch && Object.keys(patch).length > 0)\n push(\"node.set-data\", { nodeId, data: patch });\n if (hasFlags && !flagsFirst)\n push(\"node.set-flags\", { nodeId, ...flags });\n }\n }\n\n // 4. the nodes removed (a child goes with its parent)\n for (const node of currentNodes) {\n if (removedNodes.has(node.id) && !goesWithParent(node, goneNodes))\n removeNode(node);\n }\n\n // 5. the edges added (again), moved and updated; a node that is not connectable is unlocked\n // for them\n const connecting = [...replacedEdges, ...addedEdges, ...reconnected];\n const unconnectable = [\n ...new Set(connecting.flatMap((edge) => [edge.source, edge.target])),\n ].filter((nodeId) => {\n const node = wantedNodes.get(nodeId) ?? reader.node(nodeId);\n return node !== undefined && !nodeFlag(node, \"connectable\");\n });\n for (const nodeId of unconnectable)\n push(\"node.set-flags\", { nodeId, connectable: true });\n for (const edge of [...replacedEdges, ...addedEdges])\n push(\"edge.add\", cloneJson(edge));\n for (const next of reconnected) {\n push(\"edge.reconnect\", {\n edgeId: next.id,\n source: next.source,\n target: next.target,\n ...(next.sourceHandle === undefined\n ? {}\n : { sourceHandle: next.sourceHandle }),\n ...(next.targetHandle === undefined\n ? {}\n : { targetHandle: next.targetHandle }),\n });\n }\n for (const nodeId of unconnectable)\n push(\"node.set-flags\", { nodeId, connectable: false });\n for (const [edge, next] of updatedEdges) {\n const edgeId = edge.id;\n const flags: Record<string, boolean | string> = {};\n for (const flag of EDGE_FLAGS) {\n const value = edgeFlag(next, flag);\n if (value !== edgeFlag(edge, flag)) flags[flag] = value;\n }\n // `reconnectable` is a flag or an end's name\n const reconnectable = next.reconnectable ?? true;\n if (reconnectable !== (edge.reconnectable ?? true))\n flags.reconnectable = reconnectable;\n if (Object.keys(flags).length > 0)\n push(\"edge.set-flags\", { edgeId, ...flags });\n if (next.zIndex !== edge.zIndex)\n push(\"edge.set-z-index\", { edgeId, zIndex: next.zIndex ?? null });\n const patch = dataPatch(edge.data as Json, next.data as Json);\n if (patch && Object.keys(patch).length > 0)\n push(\"edge.set-data\", { edgeId, data: patch });\n }\n\n // 6. the selection (`selection()`), when it differs\n if (installed.has(\"selection.set\")) {\n const nodeIds = selectedIds(nodesWanted ?? currentNodes);\n const edgeIds = selectedIds(edgesWanted ?? currentEdges);\n if (\n !sameIds(nodeIds, selectedIds(currentNodes)) ||\n !sameIds(edgeIds, selectedIds(currentEdges))\n ) {\n push(\"selection.set\", { nodeIds, edgeIds, mode: \"replace\" });\n }\n }\n return out;\n}\n","// The core's `get` and `is` keys, answered from the committed document. A feature's keys are its\n// own (`FlowFeature.get` / `is`); the model asks them through its composed features.\nimport type { CommandInfo } from \"../commands/types\";\nimport { edgeFlag, nodeFlag, reconnectableEnd } from \"../document/flags\";\nimport type {\n EdgeFlags,\n FlowDocumentJson,\n FlowEdge,\n FlowNode,\n NodeFlags,\n} from \"../document/types\";\nimport type { ComposedFeatures } from \"../features/registry\";\nimport type { FlowReader } from \"../features/types\";\nimport { cloneJson } from \"./clone-json\";\nimport { type CommandsToPayload, commandsTo } from \"./commands-to\";\nimport type { NodeConnection, NodeData } from \"./queries\";\n\n/** What a key reads: the document, and the model's features and commands. */\nexport interface QueryContext {\n readonly reader: FlowReader;\n readonly features: ComposedFeatures;\n readonly commands: readonly CommandInfo[];\n /** the fields `edge.add` fills in (`defaultEdgeOptions`) */\n readonly defaultEdge?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/** A string field of a payload of unknown shape (a key's payload is not validated). */\nexport function stringOf(payload: unknown, key: string): string | undefined {\n const value =\n typeof payload === \"object\" && payload !== null\n ? (payload as Record<string, unknown>)[key]\n : undefined;\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * The nodes at the other end of a node's edges that end at it (`at: \"target\"`: its incomers) or\n * start from it (`\"source\"`: its outgoers), in the document's node order, each once. A self loop\n * makes the node its own incomer and outgoer; hidden nodes and edges count (a graph fact, not a\n * view's).\n */\nfunction neighbours(\n reader: FlowReader,\n nodeId: string | undefined,\n at: \"source\" | \"target\",\n): readonly FlowNode[] {\n if (nodeId === undefined) return [];\n const other = at === \"target\" ? \"source\" : \"target\";\n const ids = new Set<string>();\n for (const edge of reader.edges()) {\n if (edge[at] === nodeId) ids.add(edge[other]);\n }\n return ids.size === 0\n ? []\n : reader.nodes().filter((node) => ids.has(node.id));\n}\n\n/**\n * The edges that start or end at a node (`nodeId`), only those that start (`handleType:\n * \"source\"`) or end (`\"target\"`) there with `handleType`, only those at `handleId` with it.\n */\nfunction nodeEdges(reader: FlowReader, payload: unknown): readonly FlowEdge[] {\n const nodeId = stringOf(payload, \"nodeId\");\n const handleType = stringOf(payload, \"handleType\");\n const handleId = stringOf(payload, \"handleId\");\n const at = (edge: FlowEdge, end: \"source\" | \"target\") =>\n edge[end] === nodeId &&\n (handleType === undefined || handleType === end) &&\n (handleId === undefined ||\n edge[end === \"source\" ? \"sourceHandle\" : \"targetHandle\"] ===\n handleId);\n return reader\n .edges()\n .filter((edge) => at(edge, \"source\") || at(edge, \"target\"));\n}\n\n/** The core's `get` keys. */\nexport const CORE_GET: Readonly<\n Record<string, (context: QueryContext, payload: unknown) => unknown>\n> = {\n \"node-by\": ({ reader }, payload) => {\n const id = stringOf(payload, \"id\");\n return id === undefined ? undefined : reader.node(id);\n },\n \"edge-by\": ({ reader }, payload) => {\n const id = stringOf(payload, \"id\");\n return id === undefined ? undefined : reader.edge(id);\n },\n \"all-nodes\": ({ reader }) => reader.nodes(),\n \"all-edges\": ({ reader }) => reader.edges(),\n \"node-edges-by\": ({ reader }, payload) => nodeEdges(reader, payload),\n \"node-connections-by\": ({ reader }, payload): readonly NodeConnection[] =>\n nodeEdges(reader, payload).map((edge) => ({\n edgeId: edge.id,\n source: edge.source,\n sourceHandle: edge.sourceHandle,\n target: edge.target,\n targetHandle: edge.targetHandle,\n })),\n \"nodes-data-by\": ({ reader }, payload): readonly NodeData[] => {\n const list =\n typeof payload === \"object\" && payload !== null\n ? (payload as { nodeIds?: unknown }).nodeIds\n : undefined;\n if (!Array.isArray(list)) return [];\n return list.flatMap((id) => {\n const node = typeof id === \"string\" ? reader.node(id) : undefined;\n return node\n ? [{ id: node.id, type: node.type, data: node.data }]\n : [];\n });\n },\n \"connected-edges-by\": ({ reader }, payload) => {\n const list =\n typeof payload === \"object\" && payload !== null\n ? (payload as { nodeIds?: unknown }).nodeIds\n : undefined;\n const ids = new Set(\n Array.isArray(list)\n ? list.filter((id): id is string => typeof id === \"string\")\n : [],\n );\n return reader\n .edges()\n .filter((edge) => ids.has(edge.source) || ids.has(edge.target));\n },\n \"incomers-by\": ({ reader }, payload) =>\n neighbours(reader, stringOf(payload, \"nodeId\"), \"target\"),\n \"outgoers-by\": ({ reader }, payload) =>\n neighbours(reader, stringOf(payload, \"nodeId\"), \"source\"),\n \"absolute-position-by\": ({ reader, features }, payload) => {\n const nodeId = stringOf(payload, \"nodeId\");\n const node = nodeId === undefined ? undefined : reader.node(nodeId);\n return node && features.absolutePosition(reader, node);\n },\n \"flow-json\": ({ reader }): FlowDocumentJson =>\n cloneJson({\n version: 1,\n nodes: [...reader.nodes()],\n edges: [...reader.edges()],\n }),\n commands: ({ commands }) => commands,\n \"commands-to\": (context, payload) => {\n const { reader, commands } = context;\n const target = (\n typeof payload === \"object\" && payload !== null ? payload : {}\n ) as CommandsToPayload;\n return commandsTo(\n reader,\n {\n nodes: Array.isArray(target.nodes) ? target.nodes : undefined,\n edges: Array.isArray(target.edges) ? target.edges : undefined,\n },\n new Set(commands.map((command) => command.name)),\n context.defaultEdge,\n );\n },\n};\n\nfunction nodeAsks(flag: keyof NodeFlags) {\n return ({ reader }: QueryContext, payload: unknown): boolean => {\n const nodeId = stringOf(payload, \"nodeId\");\n const node = nodeId === undefined ? undefined : reader.node(nodeId);\n return node !== undefined && nodeFlag(node, flag);\n };\n}\n\nfunction edgeAsks(flag: keyof EdgeFlags) {\n return ({ reader }: QueryContext, payload: unknown): boolean => {\n const edgeId = stringOf(payload, \"edgeId\");\n const edge = edgeId === undefined ? undefined : reader.edge(edgeId);\n return edge !== undefined && edgeFlag(edge, flag);\n };\n}\n\n/** The core's `is` keys: a missing node or edge answers `false`. */\nexport const CORE_IS: Readonly<\n Record<string, (context: QueryContext, payload: unknown) => boolean>\n> = {\n \"node-draggable\": nodeAsks(\"draggable\"),\n \"node-selectable\": nodeAsks(\"selectable\"),\n \"node-connectable\": nodeAsks(\"connectable\"),\n \"node-deletable\": nodeAsks(\"deletable\"),\n \"node-hidden\": nodeAsks(\"hidden\"),\n \"edge-selectable\": edgeAsks(\"selectable\"),\n \"edge-deletable\": edgeAsks(\"deletable\"),\n \"edge-hidden\": edgeAsks(\"hidden\"),\n \"edge-reconnectable\": ({ reader }: QueryContext, payload: unknown) => {\n const edgeId = stringOf(payload, \"edgeId\");\n const edge = edgeId === undefined ? undefined : reader.edge(edgeId);\n if (edge === undefined) return false;\n const end = stringOf(payload, \"end\");\n return end === \"source\" || end === \"target\"\n ? reconnectableEnd(edge, end)\n : edgeFlag(edge, \"reconnectable\");\n },\n};\n"],"mappings":";;;AACA,SAAgB,UAAa,OAAa;CACtC,IAAI,MAAM,QAAQ,KAAK,GACnB,OAAO,MAAM,IAAI,SAAS;CAE9B,IAAI,OA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