@bian-womp/spark-graph 0.3.45 → 0.3.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/lib/cjs/index.cjs +14 -15
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/cjs/src/core/types.d.ts +2 -1
  4. package/lib/cjs/src/core/types.d.ts.map +1 -1
  5. package/lib/cjs/src/runtime/GraphRuntime.d.ts +1 -1
  6. package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
  7. package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
  8. package/lib/cjs/src/runtime/components/RunContextManager.d.ts +2 -1
  9. package/lib/cjs/src/runtime/components/RunContextManager.d.ts.map +1 -1
  10. package/lib/esm/index.js +14 -15
  11. package/lib/esm/index.js.map +1 -1
  12. package/lib/esm/src/core/types.d.ts +2 -1
  13. package/lib/esm/src/core/types.d.ts.map +1 -1
  14. package/lib/esm/src/runtime/GraphRuntime.d.ts +1 -1
  15. package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
  16. package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
  17. package/lib/esm/src/runtime/components/RunContextManager.d.ts +2 -1
  18. package/lib/esm/src/runtime/components/RunContextManager.d.ts.map +1 -1
  19. package/lib/src/builder/GraphBuilder.d.ts +43 -0
  20. package/lib/src/builder/GraphBuilder.d.ts.map +1 -0
  21. package/lib/src/builder/GraphBuilder.js +284 -0
  22. package/lib/src/builder/GraphBuilder.js.map +1 -0
  23. package/lib/src/builder/Registry.d.ts +93 -0
  24. package/lib/src/builder/Registry.d.ts.map +1 -0
  25. package/lib/src/builder/Registry.js +393 -0
  26. package/lib/src/builder/Registry.js.map +1 -0
  27. package/lib/src/core/categories.d.ts +22 -0
  28. package/lib/src/core/categories.d.ts.map +1 -0
  29. package/lib/src/core/categories.js +2 -0
  30. package/lib/src/core/categories.js.map +1 -0
  31. package/lib/src/core/order.d.ts +7 -0
  32. package/lib/src/core/order.d.ts.map +1 -0
  33. package/lib/src/core/order.js +66 -0
  34. package/lib/src/core/order.js.map +1 -0
  35. package/lib/src/core/type-utils.d.ts +29 -0
  36. package/lib/src/core/type-utils.d.ts.map +1 -0
  37. package/lib/src/core/type-utils.js +97 -0
  38. package/lib/src/core/type-utils.js.map +1 -0
  39. package/lib/src/core/types.d.ts +92 -0
  40. package/lib/src/core/types.d.ts.map +1 -0
  41. package/lib/src/core/types.js +2 -0
  42. package/lib/src/core/types.js.map +1 -0
  43. package/lib/src/examples/arrays.d.ts +5 -0
  44. package/lib/src/examples/arrays.d.ts.map +1 -0
  45. package/lib/src/examples/arrays.js +49 -0
  46. package/lib/src/examples/arrays.js.map +1 -0
  47. package/lib/src/examples/async.d.ts +5 -0
  48. package/lib/src/examples/async.d.ts.map +1 -0
  49. package/lib/src/examples/async.js +91 -0
  50. package/lib/src/examples/async.js.map +1 -0
  51. package/lib/src/examples/progress.d.ts +5 -0
  52. package/lib/src/examples/progress.d.ts.map +1 -0
  53. package/lib/src/examples/progress.js +51 -0
  54. package/lib/src/examples/progress.js.map +1 -0
  55. package/lib/src/examples/run.d.ts +2 -0
  56. package/lib/src/examples/run.d.ts.map +1 -0
  57. package/lib/src/examples/run.js +32 -0
  58. package/lib/src/examples/run.js.map +1 -0
  59. package/lib/src/examples/runMode.d.ts +2 -0
  60. package/lib/src/examples/runMode.d.ts.map +1 -0
  61. package/lib/src/examples/runMode.js +223 -0
  62. package/lib/src/examples/runMode.js.map +1 -0
  63. package/lib/src/examples/shared.d.ts +5 -0
  64. package/lib/src/examples/shared.d.ts.map +1 -0
  65. package/lib/src/examples/shared.js +49 -0
  66. package/lib/src/examples/shared.js.map +1 -0
  67. package/lib/src/examples/simple.d.ts +5 -0
  68. package/lib/src/examples/simple.d.ts.map +1 -0
  69. package/lib/src/examples/simple.js +79 -0
  70. package/lib/src/examples/simple.js.map +1 -0
  71. package/lib/src/examples/snapshot.d.ts +4 -0
  72. package/lib/src/examples/snapshot.d.ts.map +1 -0
  73. package/lib/src/examples/snapshot.js +58 -0
  74. package/lib/src/examples/snapshot.js.map +1 -0
  75. package/lib/src/examples/validation.d.ts +5 -0
  76. package/lib/src/examples/validation.d.ts.map +1 -0
  77. package/lib/src/examples/validation.js +105 -0
  78. package/lib/src/examples/validation.js.map +1 -0
  79. package/lib/src/index.d.ts +27 -0
  80. package/lib/src/index.d.ts.map +1 -0
  81. package/lib/src/index.js +19 -0
  82. package/lib/src/index.js.map +1 -0
  83. package/lib/src/misc/base.d.ts +51 -0
  84. package/lib/src/misc/base.d.ts.map +1 -0
  85. package/lib/src/misc/base.js +1122 -0
  86. package/lib/src/misc/base.js.map +1 -0
  87. package/lib/src/misc/utils/json.d.ts +22 -0
  88. package/lib/src/misc/utils/json.d.ts.map +1 -0
  89. package/lib/src/misc/utils/json.js +239 -0
  90. package/lib/src/misc/utils/json.js.map +1 -0
  91. package/lib/src/misc/utils/merge.d.ts +51 -0
  92. package/lib/src/misc/utils/merge.d.ts.map +1 -0
  93. package/lib/src/misc/utils/merge.js +600 -0
  94. package/lib/src/misc/utils/merge.js.map +1 -0
  95. package/lib/src/plugins/composite.d.ts +22 -0
  96. package/lib/src/plugins/composite.d.ts.map +1 -0
  97. package/lib/src/plugins/composite.js +59 -0
  98. package/lib/src/plugins/composite.js.map +1 -0
  99. package/lib/src/plugins/compute.d.ts +5 -0
  100. package/lib/src/plugins/compute.d.ts.map +1 -0
  101. package/lib/src/plugins/compute.js +39 -0
  102. package/lib/src/plugins/compute.js.map +1 -0
  103. package/lib/src/runtime/Engine.d.ts +28 -0
  104. package/lib/src/runtime/Engine.d.ts.map +1 -0
  105. package/lib/src/runtime/Engine.js +2 -0
  106. package/lib/src/runtime/Engine.js.map +1 -0
  107. package/lib/src/runtime/GraphLifecycleApi.d.ts +46 -0
  108. package/lib/src/runtime/GraphLifecycleApi.d.ts.map +1 -0
  109. package/lib/src/runtime/GraphLifecycleApi.js +2 -0
  110. package/lib/src/runtime/GraphLifecycleApi.js.map +1 -0
  111. package/lib/src/runtime/GraphRuntime.d.ts +94 -0
  112. package/lib/src/runtime/GraphRuntime.d.ts.map +1 -0
  113. package/lib/src/runtime/GraphRuntime.js +729 -0
  114. package/lib/src/runtime/GraphRuntime.js.map +1 -0
  115. package/lib/src/runtime/LocalEngine.d.ts +45 -0
  116. package/lib/src/runtime/LocalEngine.d.ts.map +1 -0
  117. package/lib/src/runtime/LocalEngine.js +89 -0
  118. package/lib/src/runtime/LocalEngine.js.map +1 -0
  119. package/lib/src/runtime/components/EdgePropagator.d.ts +101 -0
  120. package/lib/src/runtime/components/EdgePropagator.d.ts.map +1 -0
  121. package/lib/src/runtime/components/EdgePropagator.js +372 -0
  122. package/lib/src/runtime/components/EdgePropagator.js.map +1 -0
  123. package/lib/src/runtime/components/EventEmitter.d.ts +12 -0
  124. package/lib/src/runtime/components/EventEmitter.d.ts.map +1 -0
  125. package/lib/src/runtime/components/EventEmitter.js +33 -0
  126. package/lib/src/runtime/components/EventEmitter.js.map +1 -0
  127. package/lib/src/runtime/components/Graph.d.ts +211 -0
  128. package/lib/src/runtime/components/Graph.d.ts.map +1 -0
  129. package/lib/src/runtime/components/Graph.js +468 -0
  130. package/lib/src/runtime/components/Graph.js.map +1 -0
  131. package/lib/src/runtime/components/HandleResolver.d.ts +36 -0
  132. package/lib/src/runtime/components/HandleResolver.d.ts.map +1 -0
  133. package/lib/src/runtime/components/HandleResolver.js +231 -0
  134. package/lib/src/runtime/components/HandleResolver.js.map +1 -0
  135. package/lib/src/runtime/components/NodeExecutor.d.ts +110 -0
  136. package/lib/src/runtime/components/NodeExecutor.d.ts.map +1 -0
  137. package/lib/src/runtime/components/NodeExecutor.js +659 -0
  138. package/lib/src/runtime/components/NodeExecutor.js.map +1 -0
  139. package/lib/src/runtime/components/RunContextManager.d.ts +86 -0
  140. package/lib/src/runtime/components/RunContextManager.d.ts.map +1 -0
  141. package/lib/src/runtime/components/RunContextManager.js +302 -0
  142. package/lib/src/runtime/components/RunContextManager.js.map +1 -0
  143. package/lib/src/runtime/components/RuntimeValidatorManager.d.ts +31 -0
  144. package/lib/src/runtime/components/RuntimeValidatorManager.d.ts.map +1 -0
  145. package/lib/src/runtime/components/RuntimeValidatorManager.js +55 -0
  146. package/lib/src/runtime/components/RuntimeValidatorManager.js.map +1 -0
  147. package/lib/src/runtime/components/graph-utils.d.ts +33 -0
  148. package/lib/src/runtime/components/graph-utils.d.ts.map +1 -0
  149. package/lib/src/runtime/components/graph-utils.js +292 -0
  150. package/lib/src/runtime/components/graph-utils.js.map +1 -0
  151. package/lib/src/runtime/components/interfaces.d.ts +54 -0
  152. package/lib/src/runtime/components/interfaces.d.ts.map +1 -0
  153. package/lib/src/runtime/components/interfaces.js +2 -0
  154. package/lib/src/runtime/components/interfaces.js.map +1 -0
  155. package/lib/src/runtime/components/types.d.ts +55 -0
  156. package/lib/src/runtime/components/types.d.ts.map +1 -0
  157. package/lib/src/runtime/components/types.js +2 -0
  158. package/lib/src/runtime/components/types.js.map +1 -0
  159. package/lib/src/runtime/utils.d.ts +67 -0
  160. package/lib/src/runtime/utils.d.ts.map +1 -0
  161. package/lib/src/runtime/utils.js +137 -0
  162. package/lib/src/runtime/utils.js.map +1 -0
  163. package/package.json +2 -2
@@ -0,0 +1,600 @@
1
+ import { generateId } from "../base";
2
+ import { parseJsonPath, setValueAtPath, findMatchingPaths } from "./json";
3
+ import { isTyped, unwrapTypeId, unwrapValue, typed, } from "../../core/type-utils";
4
+ function mergeGraphDefinitions(target, source) {
5
+ const existingNodeIds = new Set(target.nodes.map((n) => n.nodeId));
6
+ const existingEdgeIds = new Set(target.edges.map((e) => e.id));
7
+ const nodeIdMap = {};
8
+ const targetInputDefaults = {};
9
+ const sourceInputDefaults = {};
10
+ for (const node of target.nodes) {
11
+ if (node.resolvedHandles?.inputDefaults) {
12
+ targetInputDefaults[node.nodeId] = {
13
+ ...node.resolvedHandles.inputDefaults,
14
+ };
15
+ }
16
+ }
17
+ const importedNodes = source.nodes.map((n) => {
18
+ let newId = n.nodeId;
19
+ const isExistingNode = existingNodeIds.has(newId);
20
+ if (isExistingNode) {
21
+ newId = generateId("n", existingNodeIds);
22
+ }
23
+ else {
24
+ existingNodeIds.add(newId);
25
+ }
26
+ nodeIdMap[n.nodeId] = newId;
27
+ if (n.resolvedHandles?.inputDefaults) {
28
+ sourceInputDefaults[n.nodeId] = { ...n.resolvedHandles.inputDefaults };
29
+ }
30
+ return {
31
+ ...n,
32
+ nodeId: newId,
33
+ resolvedHandles: n.resolvedHandles
34
+ ? {
35
+ ...n.resolvedHandles,
36
+ inputDefaults: undefined,
37
+ }
38
+ : undefined,
39
+ };
40
+ });
41
+ const importedEdges = source.edges.map((e) => {
42
+ let newEdgeId = e.id;
43
+ if (existingEdgeIds.has(newEdgeId)) {
44
+ newEdgeId = generateId("e", existingEdgeIds);
45
+ }
46
+ else {
47
+ existingEdgeIds.add(newEdgeId);
48
+ }
49
+ const sourceNodeId = nodeIdMap[e.source.nodeId] ?? e.source.nodeId;
50
+ const targetNodeId = nodeIdMap[e.target.nodeId] ?? e.target.nodeId;
51
+ return {
52
+ ...e,
53
+ id: newEdgeId,
54
+ source: {
55
+ ...e.source,
56
+ nodeId: sourceNodeId,
57
+ },
58
+ target: {
59
+ ...e.target,
60
+ nodeId: targetNodeId,
61
+ },
62
+ };
63
+ });
64
+ return {
65
+ merged: {
66
+ nodes: [...target.nodes, ...importedNodes],
67
+ edges: [...target.edges, ...importedEdges],
68
+ },
69
+ nodeIdMap,
70
+ targetInputDefaults,
71
+ sourceInputDefaults,
72
+ };
73
+ }
74
+ /**
75
+ * Compute the center point of a graph based on node positions.
76
+ */
77
+ export function computeGraphCenter(positions, nodeIds) {
78
+ const validPositions = nodeIds
79
+ .map((id) => positions[id])
80
+ .filter((pos) => pos !== undefined);
81
+ if (validPositions.length === 0) {
82
+ return { x: 0, y: 0 };
83
+ }
84
+ const minX = Math.min(...validPositions.map((p) => p.x));
85
+ const maxX = Math.max(...validPositions.map((p) => p.x));
86
+ const minY = Math.min(...validPositions.map((p) => p.y));
87
+ const maxY = Math.max(...validPositions.map((p) => p.y));
88
+ return {
89
+ x: (minX + maxX) / 2,
90
+ y: (minY + maxY) / 2,
91
+ };
92
+ }
93
+ /**
94
+ * Offset positions of imported nodes based on an anchor point.
95
+ * Preserves relative layout of imported nodes while positioning them at the anchor.
96
+ */
97
+ export function offsetImportedPositions(targetPositions, sourcePositions, sourceDef, nodeIdMap, anchorPos) {
98
+ const sourceNodeIds = sourceDef.nodes.map((n) => n.nodeId);
99
+ const sourceCenter = computeGraphCenter(sourcePositions, sourceNodeIds);
100
+ const dx = anchorPos.x - sourceCenter.x;
101
+ const dy = anchorPos.y - sourceCenter.y;
102
+ const newPositions = {
103
+ ...targetPositions,
104
+ };
105
+ for (const node of sourceDef.nodes) {
106
+ const oldId = node.nodeId;
107
+ const newId = nodeIdMap[oldId];
108
+ const srcPos = sourcePositions[oldId] ?? { x: 0, y: 0 };
109
+ newPositions[newId] = {
110
+ x: srcPos.x + dx,
111
+ y: srcPos.y + dy,
112
+ };
113
+ }
114
+ return newPositions;
115
+ }
116
+ function buildTypeMaps(def) {
117
+ const nodeTypeMap = new Map();
118
+ const inputHandleTypeMap = new Map();
119
+ const outputHandleTypeMap = new Map();
120
+ for (const node of def.nodes) {
121
+ nodeTypeMap.set(node.nodeId, node.typeId);
122
+ const nodeInputTypes = new Map();
123
+ const nodeOutputTypes = new Map();
124
+ if (node.resolvedHandles?.inputs) {
125
+ for (const [handleId, handleDesc] of Object.entries(node.resolvedHandles.inputs)) {
126
+ let typeId;
127
+ if (typeof handleDesc === "string") {
128
+ typeId = handleDesc;
129
+ }
130
+ else if (Array.isArray(handleDesc)) {
131
+ typeId = handleDesc[0]; // Use first type for type map (backward compat)
132
+ }
133
+ else {
134
+ const descTypeId = handleDesc.typeId;
135
+ typeId = Array.isArray(descTypeId) ? descTypeId[0] : descTypeId;
136
+ }
137
+ if (typeId)
138
+ nodeInputTypes.set(handleId, typeId);
139
+ }
140
+ }
141
+ if (node.resolvedHandles?.outputs) {
142
+ for (const [handleId, handleDesc] of Object.entries(node.resolvedHandles.outputs)) {
143
+ const typeId = typeof handleDesc === "string"
144
+ ? handleDesc
145
+ : Array.isArray(handleDesc)
146
+ ? handleDesc[0]
147
+ : undefined;
148
+ if (typeId)
149
+ nodeOutputTypes.set(handleId, typeId);
150
+ }
151
+ }
152
+ // Also include handles from inputDefaults - they share handle IDs with inputs
153
+ if (node.resolvedHandles?.inputDefaults) {
154
+ for (const handleId of Object.keys(node.resolvedHandles.inputDefaults)) {
155
+ // If not already in map, try to get type from input handles
156
+ if (!nodeInputTypes.has(handleId) && node.resolvedHandles?.inputs) {
157
+ const inputDesc = node.resolvedHandles.inputs[handleId];
158
+ if (inputDesc) {
159
+ let typeId;
160
+ if (typeof inputDesc === "string") {
161
+ typeId = inputDesc;
162
+ }
163
+ else if (Array.isArray(inputDesc)) {
164
+ typeId = inputDesc[0]; // Use first type for type map (backward compat)
165
+ }
166
+ else {
167
+ const descTypeId = inputDesc.typeId;
168
+ typeId = Array.isArray(descTypeId) ? descTypeId[0] : descTypeId;
169
+ }
170
+ if (typeId)
171
+ nodeInputTypes.set(handleId, typeId);
172
+ }
173
+ }
174
+ }
175
+ }
176
+ if (nodeInputTypes.size > 0) {
177
+ inputHandleTypeMap.set(node.nodeId, nodeInputTypes);
178
+ }
179
+ if (nodeOutputTypes.size > 0) {
180
+ outputHandleTypeMap.set(node.nodeId, nodeOutputTypes);
181
+ }
182
+ }
183
+ return { nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap };
184
+ }
185
+ function applyConversion(items, values, converter, type) {
186
+ for (const item of items) {
187
+ const convertedValue = converter({
188
+ nodeId: item.nodeId,
189
+ handleId: item.handleId,
190
+ value: item.value,
191
+ type,
192
+ nodeTypeId: item.nodeTypeId,
193
+ handleDataType: item.handleDataType,
194
+ runtimeTypeId: item.runtimeTypeId,
195
+ });
196
+ if (convertedValue === null) {
197
+ delete values[item.nodeId]?.[item.handleId];
198
+ if (values[item.nodeId] &&
199
+ Object.keys(values[item.nodeId]).length === 0) {
200
+ delete values[item.nodeId];
201
+ }
202
+ }
203
+ else {
204
+ if (!values[item.nodeId]) {
205
+ values[item.nodeId] = {};
206
+ }
207
+ values[item.nodeId][item.handleId] = convertedValue;
208
+ }
209
+ }
210
+ }
211
+ function collectValuesToConvert(values, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap, type) {
212
+ const converted = {};
213
+ const toConvert = [];
214
+ const handleTypeMap = type === "output" ? outputHandleTypeMap : inputHandleTypeMap;
215
+ for (const [nodeId, nodeValues] of Object.entries(values)) {
216
+ converted[nodeId] = { ...nodeValues };
217
+ const nodeTypeId = nodeTypeMap.get(nodeId);
218
+ for (const [handleId, value] of Object.entries(nodeValues)) {
219
+ const handleDataType = handleTypeMap.get(nodeId)?.get(handleId);
220
+ const runtimeTypeId = isTyped(value) ? unwrapTypeId(value) : undefined;
221
+ toConvert.push({
222
+ nodeId,
223
+ originalNodeId: nodeId,
224
+ handleId,
225
+ value,
226
+ nodeTypeId,
227
+ handleDataType,
228
+ runtimeTypeId,
229
+ });
230
+ }
231
+ }
232
+ return { converted, toConvert };
233
+ }
234
+ export function convertSnapshot(snapshot, converter) {
235
+ const def = snapshot.def ?? { nodes: [], edges: [] };
236
+ const { nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap } = buildTypeMaps(def);
237
+ const inputDefaults = {};
238
+ for (const node of def.nodes) {
239
+ if (node.resolvedHandles?.inputDefaults) {
240
+ inputDefaults[node.nodeId] = { ...node.resolvedHandles.inputDefaults };
241
+ }
242
+ }
243
+ const { converted: convertedInputs, toConvert: inputsToConvert } = collectValuesToConvert(snapshot.inputs ?? {}, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap, "input");
244
+ const { converted: convertedOutputs, toConvert: outputsToConvert } = collectValuesToConvert(snapshot.outputs ?? {}, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap, "output");
245
+ const { converted: convertedInputDefaults, toConvert: inputDefaultsToConvert, } = collectValuesToConvert(inputDefaults, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap, "inputDefault");
246
+ applyConversion(inputsToConvert, convertedInputs, converter, "input");
247
+ applyConversion(outputsToConvert, convertedOutputs, converter, "output");
248
+ applyConversion(inputDefaultsToConvert, convertedInputDefaults, converter, "inputDefault");
249
+ const updatedNodes = def.nodes.map((node) => {
250
+ const defaults = convertedInputDefaults[node.nodeId];
251
+ if (!defaults || Object.keys(defaults).length === 0) {
252
+ if (node.resolvedHandles?.inputDefaults) {
253
+ const { inputDefaults, ...restHandles } = node.resolvedHandles;
254
+ return {
255
+ ...node,
256
+ resolvedHandles: Object.keys(restHandles).length > 0 ? restHandles : undefined,
257
+ };
258
+ }
259
+ return node;
260
+ }
261
+ return {
262
+ ...node,
263
+ resolvedHandles: {
264
+ ...node.resolvedHandles,
265
+ inputDefaults: defaults,
266
+ },
267
+ };
268
+ });
269
+ return {
270
+ ...snapshot,
271
+ def: { ...def, nodes: updatedNodes },
272
+ inputs: convertedInputs,
273
+ outputs: convertedOutputs,
274
+ };
275
+ }
276
+ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOutputs, targetInputDefaults, sourceInputDefaults, nodeIdMap, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap) {
277
+ const mergedInputs = { ...targetInputs };
278
+ const mergedOutputs = { ...targetOutputs };
279
+ const mergedInputDefaults = { ...targetInputDefaults };
280
+ const inputsToConvert = [];
281
+ const outputsToConvert = [];
282
+ const inputDefaultsToConvert = [];
283
+ for (const [oldId, inputs] of Object.entries(sourceInputs)) {
284
+ const newId = nodeIdMap[oldId];
285
+ if (newId) {
286
+ if (!mergedInputs[newId]) {
287
+ mergedInputs[newId] = {};
288
+ }
289
+ const nodeTypeId = nodeTypeMap?.get(oldId);
290
+ for (const [handleId, value] of Object.entries(inputs)) {
291
+ const handleDataType = inputHandleTypeMap?.get(oldId)?.get(handleId);
292
+ inputsToConvert.push({
293
+ nodeId: newId,
294
+ originalNodeId: oldId,
295
+ handleId,
296
+ value,
297
+ nodeTypeId,
298
+ handleDataType,
299
+ });
300
+ mergedInputs[newId][handleId] = value;
301
+ }
302
+ }
303
+ }
304
+ for (const [oldId, outputs] of Object.entries(sourceOutputs)) {
305
+ const newId = nodeIdMap[oldId];
306
+ if (newId) {
307
+ if (!mergedOutputs[newId]) {
308
+ mergedOutputs[newId] = {};
309
+ }
310
+ const nodeTypeId = nodeTypeMap?.get(oldId);
311
+ for (const [handleId, value] of Object.entries(outputs)) {
312
+ const handleDataType = outputHandleTypeMap?.get(oldId)?.get(handleId);
313
+ const runtimeTypeId = isTyped(value) ? unwrapTypeId(value) : undefined;
314
+ outputsToConvert.push({
315
+ nodeId: newId,
316
+ originalNodeId: oldId,
317
+ handleId,
318
+ value,
319
+ nodeTypeId,
320
+ handleDataType,
321
+ runtimeTypeId,
322
+ });
323
+ mergedOutputs[newId][handleId] = value;
324
+ }
325
+ }
326
+ }
327
+ for (const [oldId, defaults] of Object.entries(sourceInputDefaults)) {
328
+ const newId = nodeIdMap[oldId];
329
+ if (newId) {
330
+ if (!mergedInputDefaults[newId]) {
331
+ mergedInputDefaults[newId] = {};
332
+ }
333
+ const nodeTypeId = nodeTypeMap?.get(oldId);
334
+ for (const [handleId, value] of Object.entries(defaults)) {
335
+ const handleDataType = inputHandleTypeMap?.get(oldId)?.get(handleId);
336
+ inputDefaultsToConvert.push({
337
+ nodeId: newId,
338
+ originalNodeId: oldId,
339
+ handleId,
340
+ value,
341
+ nodeTypeId,
342
+ handleDataType,
343
+ });
344
+ mergedInputDefaults[newId][handleId] = value;
345
+ }
346
+ }
347
+ }
348
+ return {
349
+ mergedInputs,
350
+ mergedOutputs,
351
+ mergedInputDefaults,
352
+ inputsToConvert,
353
+ outputsToConvert,
354
+ inputDefaultsToConvert,
355
+ };
356
+ }
357
+ function mergeSnapshotData(targetSnapshot, sourceSnapshot, targetInputDefaults, sourceInputDefaults, nodeIdMap) {
358
+ const sourceDef = sourceSnapshot.def ?? { nodes: [], edges: [] };
359
+ const { nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap } = buildTypeMaps(sourceDef);
360
+ return mergeInputsOutputs(targetSnapshot.inputs ?? {}, targetSnapshot.outputs ?? {}, sourceSnapshot.inputs ?? {}, sourceSnapshot.outputs ?? {}, targetInputDefaults, sourceInputDefaults, nodeIdMap, nodeTypeMap, inputHandleTypeMap, outputHandleTypeMap);
361
+ }
362
+ export function mergeSnapshots(targetSnapshot, sourceSnapshot, converter) {
363
+ const targetDef = targetSnapshot.def ?? { nodes: [], edges: [] };
364
+ const sourceDef = sourceSnapshot.def ?? { nodes: [], edges: [] };
365
+ const { merged, nodeIdMap, targetInputDefaults, sourceInputDefaults } = mergeGraphDefinitions(targetDef, sourceDef);
366
+ const { mergedInputs, mergedOutputs, mergedInputDefaults, inputsToConvert, outputsToConvert, inputDefaultsToConvert, } = mergeSnapshotData(targetSnapshot, sourceSnapshot, targetInputDefaults, sourceInputDefaults, nodeIdMap);
367
+ if (converter) {
368
+ applyConversion(inputDefaultsToConvert, mergedInputDefaults, converter, "inputDefault");
369
+ applyConversion(inputsToConvert, mergedInputs, converter, "input");
370
+ applyConversion(outputsToConvert, mergedOutputs, converter, "output");
371
+ }
372
+ const nodeMap = new Map(merged.nodes.map((n) => [n.nodeId, n]));
373
+ for (const nodeId in mergedInputDefaults) {
374
+ const node = nodeMap.get(nodeId);
375
+ if (node && Object.keys(mergedInputDefaults[nodeId]).length > 0) {
376
+ if (!node.resolvedHandles) {
377
+ node.resolvedHandles = {};
378
+ }
379
+ node.resolvedHandles.inputDefaults = mergedInputDefaults[nodeId];
380
+ }
381
+ }
382
+ return {
383
+ merged: {
384
+ def: merged,
385
+ inputs: mergedInputs,
386
+ outputs: mergedOutputs,
387
+ environment: {
388
+ ...targetSnapshot.environment,
389
+ ...sourceSnapshot.environment,
390
+ },
391
+ extData: { ...targetSnapshot.extData, ...sourceSnapshot.extData },
392
+ },
393
+ nodeIdMap,
394
+ };
395
+ }
396
+ /**
397
+ * Merge runtime metadata from source into target, remapping node IDs using nodeIdMap.
398
+ * Preserves target metadata and adds/updates source metadata with remapped IDs.
399
+ */
400
+ export function mergeRuntimeState(targetRuntime, sourceRuntime, nodeIdMap) {
401
+ const result = {
402
+ nodes: { ...(targetRuntime?.nodes || {}) },
403
+ };
404
+ if (!sourceRuntime?.nodes)
405
+ return result;
406
+ // Remap source node IDs to new merged node IDs
407
+ for (const [sourceNodeId, newNodeId] of Object.entries(nodeIdMap)) {
408
+ const sourceNodeMeta = sourceRuntime.nodes[sourceNodeId];
409
+ if (sourceNodeMeta) {
410
+ result.nodes[newNodeId] = { ...sourceNodeMeta };
411
+ }
412
+ }
413
+ return result;
414
+ }
415
+ function matchesPattern(value, pattern) {
416
+ if (!pattern)
417
+ return true;
418
+ if (typeof pattern === "string") {
419
+ return value === pattern;
420
+ }
421
+ return pattern.test(value);
422
+ }
423
+ /**
424
+ * Build a converter function from a configuration that maps values based on handle/node matching.
425
+ * The converter will replace values when:
426
+ * - handleId matches (if specified)
427
+ * - nodeId matches (if specified)
428
+ * - nodeTypeId matches (if specified)
429
+ * - handleDataType matches (if specified)
430
+ * - runtimeTypeId matches (if specified, for typed outputs)
431
+ * - value exists in valueMap
432
+ */
433
+ export function buildValueConverter(config) {
434
+ return (converterConfig) => {
435
+ const { nodeId, handleId, value, type, nodeTypeId, handleDataType, runtimeTypeId, } = converterConfig;
436
+ const isValueTyped = isTyped(value);
437
+ for (const mapping of config.mappings) {
438
+ if (mapping.type && mapping.type !== type)
439
+ continue;
440
+ if (mapping.handleId && !matchesPattern(handleId, mapping.handleId))
441
+ continue;
442
+ if (mapping.nodeId && !matchesPattern(nodeId, mapping.nodeId))
443
+ continue;
444
+ if (mapping.nodeTypeId && nodeTypeId) {
445
+ if (!matchesPattern(nodeTypeId, mapping.nodeTypeId))
446
+ continue;
447
+ }
448
+ if (mapping.handleDataType && handleDataType) {
449
+ if (!matchesPattern(handleDataType, mapping.handleDataType))
450
+ continue;
451
+ }
452
+ if (mapping.runtimeTypeId && runtimeTypeId) {
453
+ if (!matchesPattern(runtimeTypeId, mapping.runtimeTypeId))
454
+ continue;
455
+ }
456
+ if (mapping.transformTypedValue && isValueTyped) {
457
+ const innerValue = unwrapValue(value);
458
+ const typedTypeId = unwrapTypeId(value);
459
+ if (!typedTypeId)
460
+ continue;
461
+ if (mapping.path !== undefined) {
462
+ const pathSegments = parseJsonPath(mapping.path);
463
+ const matches = findMatchingPaths(innerValue, pathSegments);
464
+ if (matches.length > 0) {
465
+ const transformedInner = JSON.parse(JSON.stringify(innerValue));
466
+ let changed = false;
467
+ for (const match of matches) {
468
+ const matchValue = match.value;
469
+ if (matchValue !== null && matchValue !== undefined) {
470
+ let newValue = matchValue;
471
+ if (mapping.valueMap instanceof Map) {
472
+ if (mapping.valueMap.has(matchValue)) {
473
+ newValue = mapping.valueMap.get(matchValue);
474
+ changed = true;
475
+ }
476
+ }
477
+ else {
478
+ if (typeof matchValue === "string" ||
479
+ typeof matchValue === "number") {
480
+ const key = String(matchValue);
481
+ if (key in mapping.valueMap) {
482
+ newValue = mapping.valueMap[key];
483
+ changed = true;
484
+ }
485
+ }
486
+ }
487
+ if (changed && newValue !== matchValue) {
488
+ // If mapped to null, set null at the path (which may delete nested property)
489
+ setValueAtPath(transformedInner, match.path, newValue);
490
+ }
491
+ }
492
+ }
493
+ // If the entire typed output should be deleted (all paths mapped to null),
494
+ // we'd need to check if the whole inner value is null/empty, but for now
495
+ // we'll return the transformed value or original
496
+ return changed ? typed(typedTypeId, transformedInner) : value;
497
+ }
498
+ }
499
+ else {
500
+ if (innerValue !== null && innerValue !== undefined) {
501
+ let newValue = innerValue;
502
+ if (mapping.valueMap instanceof Map) {
503
+ if (mapping.valueMap.has(innerValue)) {
504
+ newValue = mapping.valueMap.get(innerValue);
505
+ // If mapped to null, return null to delete the output
506
+ if (newValue === null) {
507
+ return null;
508
+ }
509
+ return typed(typedTypeId, newValue);
510
+ }
511
+ }
512
+ else {
513
+ if (typeof innerValue === "string" ||
514
+ typeof innerValue === "number") {
515
+ const key = String(innerValue);
516
+ if (key in mapping.valueMap) {
517
+ newValue = mapping.valueMap[key];
518
+ // If mapped to null, return null to delete the output
519
+ if (newValue === null) {
520
+ return null;
521
+ }
522
+ return typed(typedTypeId, newValue);
523
+ }
524
+ }
525
+ }
526
+ }
527
+ }
528
+ continue;
529
+ }
530
+ if (mapping.path !== undefined) {
531
+ let pathSegments = parseJsonPath(mapping.path);
532
+ if (isValueTyped) {
533
+ const typedTypeId = unwrapTypeId(value);
534
+ if (typedTypeId) {
535
+ const firstSegment = pathSegments[0];
536
+ const firstSegmentStr = typeof firstSegment === "string"
537
+ ? firstSegment
538
+ : firstSegment instanceof RegExp
539
+ ? null
540
+ : String(firstSegment);
541
+ if (firstSegmentStr !== "__spark_value" &&
542
+ firstSegmentStr !== "__spark_type") {
543
+ pathSegments = ["__spark_value", ...pathSegments];
544
+ }
545
+ }
546
+ }
547
+ const matches = findMatchingPaths(value, pathSegments);
548
+ if (matches.length > 0) {
549
+ const transformedValue = JSON.parse(JSON.stringify(value));
550
+ let changed = false;
551
+ for (const match of matches) {
552
+ const matchValue = match.value;
553
+ if (matchValue !== null && matchValue !== undefined) {
554
+ let newValue = matchValue;
555
+ if (mapping.valueMap instanceof Map) {
556
+ if (mapping.valueMap.has(matchValue)) {
557
+ newValue = mapping.valueMap.get(matchValue);
558
+ changed = true;
559
+ }
560
+ }
561
+ else {
562
+ if (typeof matchValue === "string" ||
563
+ typeof matchValue === "number") {
564
+ const key = String(matchValue);
565
+ if (key in mapping.valueMap) {
566
+ newValue = mapping.valueMap[key];
567
+ changed = true;
568
+ }
569
+ }
570
+ }
571
+ if (changed && newValue !== matchValue) {
572
+ setValueAtPath(transformedValue, match.path, newValue);
573
+ }
574
+ }
575
+ }
576
+ return changed ? transformedValue : value;
577
+ }
578
+ }
579
+ else {
580
+ if (value !== null && value !== undefined) {
581
+ if (mapping.valueMap instanceof Map) {
582
+ if (mapping.valueMap.has(value)) {
583
+ return mapping.valueMap.get(value);
584
+ }
585
+ }
586
+ else {
587
+ if (typeof value === "string" || typeof value === "number") {
588
+ const key = String(value);
589
+ if (key in mapping.valueMap) {
590
+ return mapping.valueMap[key];
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }
597
+ return value;
598
+ };
599
+ }
600
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../src/misc/utils/merge.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,KAAK,GACN,MAAM,uBAAuB,CAAC;AAc/B,SAAS,qBAAqB,CAC5B,MAAuB,EACvB,MAAuB;IAOvB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/D,MAAM,SAAS,GAA2B,EAAE,CAAC;IAC7C,MAAM,mBAAmB,GAAe,EAAE,CAAC;IAC3C,MAAM,mBAAmB,GAAe,EAAE,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,eAAe,EAAE,aAAa,EAAE,CAAC;YACxC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;gBACjC,GAAG,IAAI,CAAC,eAAe,C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gB,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;4BACzD,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,OAAO,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC5C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC1C,IAAI,OAAO,CAAC,QAAQ,YAAY,GAAG,EAAE,CAAC;wBACpC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAkC,CAAC,EAAE,CAAC;4BAC7D,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAkC,CAAC,CAAC;wBAClE,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;4BAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC1B,IAAI,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gCAC5B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAC/B,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { GraphDefinition } from "@bian-womp/spark-protocol";
2
+ import type { NodeCategoryDescriptor } from "../core/categories";
3
+ import { Registry } from "../builder/Registry";
4
+ import { GraphRuntime } from "../runtime/GraphRuntime";
5
+ export interface CompositeImpl {
6
+ def: GraphDefinition;
7
+ exposure: {
8
+ inputs: Record<string, {
9
+ nodeId: string;
10
+ handle: string;
11
+ }>;
12
+ outputs: Record<string, {
13
+ nodeId: string;
14
+ handle: string;
15
+ }>;
16
+ };
17
+ }
18
+ export declare const CompositeCategory: (registry: Registry) => NodeCategoryDescriptor<CompositeImpl, {
19
+ inner?: GraphRuntime;
20
+ unsub?: () => void;
21
+ }>;
22
+ //# sourceMappingURL=composite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite.d.ts","sourceRoot":"","sources":["../../../src/plugins/composite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,eAAe,CAAC;IACrB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC3D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7D,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,KACjB,sBAAsB,CACvB,aAAa,EACb;IAAE,KAAK,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAsD5C,CAAC"}