@bian-womp/spark-graph 0.2.26 → 0.2.28
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/lib/cjs/index.cjs
CHANGED
|
@@ -1220,11 +1220,26 @@ class GraphRuntime {
|
|
|
1220
1220
|
this.paused = true;
|
|
1221
1221
|
try {
|
|
1222
1222
|
const ins = payload?.inputs || {};
|
|
1223
|
+
const outsPayload = payload?.outputs || {};
|
|
1223
1224
|
for (const [nodeId, map] of Object.entries(ins)) {
|
|
1224
1225
|
const node = this.nodes.get(nodeId);
|
|
1225
1226
|
if (!node)
|
|
1226
1227
|
continue;
|
|
1227
1228
|
for (const [h, v] of Object.entries(map || {})) {
|
|
1229
|
+
// If this handle has inbound wiring, prefer upstream outputs from snapshot to populate it.
|
|
1230
|
+
// Fallback: if not all upstream output values are present in the snapshot, hydrate the saved input
|
|
1231
|
+
// so the initial view matches last saved state (important for array inputs with multiple edges).
|
|
1232
|
+
const inboundEdges = this.edges.filter((e) => e.target.nodeId === nodeId && e.target.handle === h);
|
|
1233
|
+
if (inboundEdges.length > 0) {
|
|
1234
|
+
// Check if ALL upstream outputs exist in snapshot (required for correct array input restoration)
|
|
1235
|
+
const allUpstreamOutputsExist = inboundEdges.every((e) => {
|
|
1236
|
+
const srcMap = outsPayload[e.source.nodeId] || {};
|
|
1237
|
+
return Object.prototype.hasOwnProperty.call(srcMap, e.source.handle);
|
|
1238
|
+
});
|
|
1239
|
+
// Only skip input hydration if all upstream outputs are present (re-emit will populate correctly)
|
|
1240
|
+
if (allUpstreamOutputsExist)
|
|
1241
|
+
continue;
|
|
1242
|
+
}
|
|
1228
1243
|
node.inputs[h] =
|
|
1229
1244
|
typeof structuredClone === "function"
|
|
1230
1245
|
? structuredClone(v)
|