@bian-womp/spark-graph 0.3.72 → 0.3.73
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 +32 -36
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +7 -6
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/EdgePropagator.d.ts +2 -7
- package/lib/cjs/src/runtime/components/EdgePropagator.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/interfaces.d.ts +2 -1
- package/lib/cjs/src/runtime/components/interfaces.d.ts.map +1 -1
- package/lib/esm/index.js +32 -36
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +7 -6
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/EdgePropagator.d.ts +2 -7
- package/lib/esm/src/runtime/components/EdgePropagator.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/interfaces.d.ts +2 -1
- package/lib/esm/src/runtime/components/interfaces.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -2523,11 +2523,10 @@ class HandleResolver {
|
|
|
2523
2523
|
* EdgePropagator component - handles value propagation through edges
|
|
2524
2524
|
*/
|
|
2525
2525
|
class EdgePropagator {
|
|
2526
|
-
constructor(graph, eventEmitter, runContextManager,
|
|
2526
|
+
constructor(graph, eventEmitter, runContextManager, nodeExecutor, runtime) {
|
|
2527
2527
|
this.graph = graph;
|
|
2528
2528
|
this.eventEmitter = eventEmitter;
|
|
2529
2529
|
this.runContextManager = runContextManager;
|
|
2530
|
-
this.handleResolver = handleResolver;
|
|
2531
2530
|
this.nodeExecutor = nodeExecutor;
|
|
2532
2531
|
this.runtime = runtime;
|
|
2533
2532
|
this.arrayInputBuckets = new Map();
|
|
@@ -2716,7 +2715,7 @@ class EdgePropagator {
|
|
|
2716
2715
|
// Set input value (respecting skipPropagateValues)
|
|
2717
2716
|
const shouldSetValue = this.shouldSetInputValue(effectiveRunContexts);
|
|
2718
2717
|
if (shouldSetValue && valueChanged) {
|
|
2719
|
-
this.setTargetInput(edge, processedValue);
|
|
2718
|
+
this.runtime.setTargetInput(edge, processedValue, "applyToTarget");
|
|
2720
2719
|
}
|
|
2721
2720
|
else if (shouldSetValue && !valueChanged) {
|
|
2722
2721
|
// Even if value didn't change, update timestamp if we're forcing execution
|
|
@@ -2772,13 +2771,6 @@ class EdgePropagator {
|
|
|
2772
2771
|
}
|
|
2773
2772
|
return true;
|
|
2774
2773
|
}
|
|
2775
|
-
/**
|
|
2776
|
-
* Set target input value and emit event
|
|
2777
|
-
*/
|
|
2778
|
-
setTargetInput(edge, value) {
|
|
2779
|
-
this.graph.updateNodeInput(edge.target.nodeId, edge.target.handle, value);
|
|
2780
|
-
this.handleResolver.scheduleRecomputeHandles(edge.target.nodeId);
|
|
2781
|
-
}
|
|
2782
2774
|
/**
|
|
2783
2775
|
* Execute downstream if conditions are met
|
|
2784
2776
|
*/
|
|
@@ -3622,7 +3614,7 @@ class GraphRuntime {
|
|
|
3622
3614
|
this.graph = new Graph(this.eventEmitter);
|
|
3623
3615
|
this.runContextManager = new RunContextManager(this.graph, "warn");
|
|
3624
3616
|
this.handleResolver = new HandleResolver(this.graph, this.eventEmitter, this.runContextManager, this);
|
|
3625
|
-
this.edgePropagator = new EdgePropagator(this.graph, this.eventEmitter, this.runContextManager, this
|
|
3617
|
+
this.edgePropagator = new EdgePropagator(this.graph, this.eventEmitter, this.runContextManager, this, this);
|
|
3626
3618
|
// Create NodeExecutor with EdgePropagator and HandleResolver
|
|
3627
3619
|
this.nodeExecutor = new NodeExecutor(this.graph, this.eventEmitter, this.runContextManager, this.handleResolver, this, this);
|
|
3628
3620
|
// Create RuntimeValidatorManager
|
|
@@ -3711,6 +3703,30 @@ class GraphRuntime {
|
|
|
3711
3703
|
on(event, handler) {
|
|
3712
3704
|
return this.eventEmitter.on(event, handler);
|
|
3713
3705
|
}
|
|
3706
|
+
/**
|
|
3707
|
+
* Check if an event is an invalidate event that should trigger re-execution
|
|
3708
|
+
*/
|
|
3709
|
+
isInvalidateEvent(event) {
|
|
3710
|
+
if (!event || typeof event !== "object")
|
|
3711
|
+
return false;
|
|
3712
|
+
// Check if event has action === "invalidate"
|
|
3713
|
+
const e = event;
|
|
3714
|
+
return e.action === "invalidate";
|
|
3715
|
+
}
|
|
3716
|
+
executeNodeAutoRun(nodeId, opts) {
|
|
3717
|
+
const node = this.graph.getNode(nodeId);
|
|
3718
|
+
const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
|
|
3719
|
+
let runContextIdsToUse = undefined;
|
|
3720
|
+
if (this.runMode === "manual") {
|
|
3721
|
+
runContextIdsToUse = new Set([this.runContextManager.createRunContext(nodeId, { propagate: false })]);
|
|
3722
|
+
}
|
|
3723
|
+
if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
|
|
3724
|
+
this.execute(nodeId, {
|
|
3725
|
+
runContextIds: runContextIdsToUse,
|
|
3726
|
+
reason: opts?.reason ?? "executeNodeAutoRun",
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3714
3730
|
setInputs(nodeId, inputs) {
|
|
3715
3731
|
const node = this.graph.getNode(nodeId);
|
|
3716
3732
|
if (!node)
|
|
@@ -3766,8 +3782,6 @@ class GraphRuntime {
|
|
|
3766
3782
|
const same = valuesEqual(prev, value);
|
|
3767
3783
|
if (!same) {
|
|
3768
3784
|
this.graph.updateNodeInput(nodeId, handle, value);
|
|
3769
|
-
// Emit value event for input updates
|
|
3770
|
-
this.eventEmitter.emit("value", { nodeId, handle, value, io: "input" });
|
|
3771
3785
|
anyChanged = true;
|
|
3772
3786
|
}
|
|
3773
3787
|
}
|
|
@@ -3819,16 +3833,6 @@ class GraphRuntime {
|
|
|
3819
3833
|
// Forward event to node's onExternalEvent handler for custom actions
|
|
3820
3834
|
node.runtime.onExternalEvent?.(event, node.state);
|
|
3821
3835
|
}
|
|
3822
|
-
/**
|
|
3823
|
-
* Check if an event is an invalidate event that should trigger re-execution
|
|
3824
|
-
*/
|
|
3825
|
-
isInvalidateEvent(event) {
|
|
3826
|
-
if (!event || typeof event !== "object")
|
|
3827
|
-
return false;
|
|
3828
|
-
// Check if event has action === "invalidate"
|
|
3829
|
-
const e = event;
|
|
3830
|
-
return e.action === "invalidate";
|
|
3831
|
-
}
|
|
3832
3836
|
cancelNodeRuns(nodeIds) {
|
|
3833
3837
|
this.nodeExecutor.cancelNodeRuns(nodeIds);
|
|
3834
3838
|
}
|
|
@@ -3856,6 +3860,7 @@ class GraphRuntime {
|
|
|
3856
3860
|
this.nodeExecutor.setEnvironment(this.environment);
|
|
3857
3861
|
for (const nodeId of this.graph.getNodeIds()) {
|
|
3858
3862
|
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
3863
|
+
this.executeNodeAutoRun(nodeId, { reason: "setEnvironment" });
|
|
3859
3864
|
}
|
|
3860
3865
|
}
|
|
3861
3866
|
setCustomNodeData(customNodeData) {
|
|
@@ -4003,19 +4008,10 @@ class GraphRuntime {
|
|
|
4003
4008
|
}
|
|
4004
4009
|
}
|
|
4005
4010
|
}
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
if (this.runMode === "manual") {
|
|
4011
|
-
runContextIdsToUse = new Set([this.runContextManager.createRunContext(nodeId, { propagate: false })]);
|
|
4012
|
-
}
|
|
4013
|
-
if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
|
|
4014
|
-
this.execute(nodeId, {
|
|
4015
|
-
runContextIds: runContextIdsToUse,
|
|
4016
|
-
reason: opts?.reason ?? "executeNodeAutoRun",
|
|
4017
|
-
});
|
|
4018
|
-
}
|
|
4011
|
+
setTargetInput(edge, value, reason) {
|
|
4012
|
+
this.graph.updateNodeInput(edge.target.nodeId, edge.target.handle, value);
|
|
4013
|
+
this.handleResolver.scheduleRecomputeHandles(edge.target.nodeId);
|
|
4014
|
+
this.executeNodeAutoRun(edge.target.nodeId, { reason });
|
|
4019
4015
|
}
|
|
4020
4016
|
copyOutputs(fromNodeId, toNodeId, options) {
|
|
4021
4017
|
const fromNode = this.getNodeData(fromNodeId);
|