@bian-womp/spark-graph 0.1.12 → 0.1.13
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 +20 -3
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +1 -0
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +20 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +1 -0
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -494,8 +494,11 @@ class GraphRuntime {
|
|
|
494
494
|
// Emit value event for input updates
|
|
495
495
|
this.emit("value", { nodeId, handle, value, io: "input" });
|
|
496
496
|
}
|
|
497
|
-
if (!this.paused)
|
|
498
|
-
|
|
497
|
+
if (!this.paused) {
|
|
498
|
+
// Only schedule if all inbound inputs are present (or there are none)
|
|
499
|
+
if (this.allInboundHaveValue(nodeId))
|
|
500
|
+
this.scheduleInputsChanged(nodeId);
|
|
501
|
+
}
|
|
499
502
|
}
|
|
500
503
|
getOutput(nodeId, output) {
|
|
501
504
|
const node = this.nodes.get(nodeId);
|
|
@@ -641,6 +644,20 @@ class GraphRuntime {
|
|
|
641
644
|
// switch or merge
|
|
642
645
|
startRun(rid, { ...node.inputs });
|
|
643
646
|
}
|
|
647
|
+
// Returns true if all inbound handles for the node currently have a value
|
|
648
|
+
allInboundHaveValue(nodeId) {
|
|
649
|
+
const node = this.nodes.get(nodeId);
|
|
650
|
+
if (!node)
|
|
651
|
+
return false;
|
|
652
|
+
const inbound = this.edges.filter((e) => e.target.nodeId === nodeId);
|
|
653
|
+
if (inbound.length === 0)
|
|
654
|
+
return true;
|
|
655
|
+
for (const e of inbound) {
|
|
656
|
+
if (!(e.target.handle in node.inputs))
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
644
661
|
invalidateDownstream(nodeId) {
|
|
645
662
|
// Notifies dependents; for now we propagate current outputs
|
|
646
663
|
for (const e of this.edges.filter((e) => e.source.nodeId === nodeId)) {
|
|
@@ -676,7 +693,7 @@ class GraphRuntime {
|
|
|
676
693
|
value: v,
|
|
677
694
|
io: "input",
|
|
678
695
|
});
|
|
679
|
-
if (!this.paused)
|
|
696
|
+
if (!this.paused && this.allInboundHaveValue(e.target.nodeId))
|
|
680
697
|
this.scheduleInputsChanged(e.target.nodeId);
|
|
681
698
|
};
|
|
682
699
|
if (e.convertAsync) {
|