@bian-womp/spark-graph 0.3.6 → 0.3.7

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
@@ -2157,8 +2157,27 @@ class GraphRuntime {
2157
2157
  const node = this.graph.getNode(nodeId);
2158
2158
  if (!node)
2159
2159
  return;
2160
+ // If event is an invalidate event, re-run the node with same inputs
2161
+ if (this.isInvalidateEvent(event)) {
2162
+ // Check if node has all inbound inputs (required for execution)
2163
+ if (this.graph.allInboundHaveValue(nodeId)) {
2164
+ this.execute(nodeId);
2165
+ }
2166
+ return;
2167
+ }
2168
+ // Forward event to node's onExternalEvent handler for custom actions
2160
2169
  node.runtime.onExternalEvent?.(event, node.state);
2161
2170
  }
2171
+ /**
2172
+ * Check if an event is an invalidate event that should trigger re-execution
2173
+ */
2174
+ isInvalidateEvent(event) {
2175
+ if (!event || typeof event !== "object")
2176
+ return false;
2177
+ // Check if event has action === "invalidate"
2178
+ const e = event;
2179
+ return e.action === "invalidate";
2180
+ }
2162
2181
  cancelNodeRuns(nodeIds) {
2163
2182
  this.nodeExecutor.cancelNodeRuns(nodeIds);
2164
2183
  }