@bian-womp/spark-graph 0.2.42 → 0.2.44

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
@@ -1506,6 +1506,15 @@ class GraphRuntime {
1506
1506
  }
1507
1507
  // Precompute per-node resolved handles for updated graph (include dynamic)
1508
1508
  const resolved = GraphRuntime.computeResolvedHandleMap(def, registry, this.environment);
1509
+ // Check which handles changed and emit events for those
1510
+ const changedHandles = {};
1511
+ for (const [nodeId, newHandles] of resolved.map) {
1512
+ const oldHandles = this.resolvedByNode.get(nodeId);
1513
+ if (!oldHandles ||
1514
+ JSON.stringify(oldHandles) !== JSON.stringify(newHandles)) {
1515
+ changedHandles[nodeId] = newHandles;
1516
+ }
1517
+ }
1509
1518
  this.resolvedByNode = resolved.map;
1510
1519
  // Rebuild edges mapping with coercions
1511
1520
  this.edges = GraphRuntime.buildEdges(def, registry, this.resolvedByNode);
@@ -1613,8 +1622,16 @@ class GraphRuntime {
1613
1622
  this.arrayInputBuckets.delete(nodeId);
1614
1623
  }
1615
1624
  // Schedule async recompute for nodes that indicated Promise-based resolveHandles in this update
1616
- for (const nodeId of resolved.pending)
1625
+ // Emit event for changed handles (if any)
1626
+ if (Object.keys(changedHandles).length > 0) {
1627
+ this.emit("invalidate", {
1628
+ reason: "graph-updated",
1629
+ resolvedHandles: changedHandles,
1630
+ });
1631
+ }
1632
+ for (const nodeId of resolved.pending) {
1617
1633
  this.scheduleRecomputeHandles(nodeId);
1634
+ }
1618
1635
  }
1619
1636
  // Schedule a recomputation of dynamic handles for a node (async to avoid mutating during propagation)
1620
1637
  scheduleRecomputeHandles(nodeId) {
@@ -1667,8 +1684,11 @@ class GraphRuntime {
1667
1684
  return;
1668
1685
  this.resolvedByNode.set(nodeId, next);
1669
1686
  this.updateNodeHandles(nodeId, next, registry);
1670
- // Notify graph updated for UI parity
1671
- this.emit("invalidate", { reason: "graph-updated" });
1687
+ // Notify graph updated with the changed handles
1688
+ this.emit("invalidate", {
1689
+ reason: "graph-updated",
1690
+ resolvedHandles: { [nodeId]: next },
1691
+ });
1672
1692
  }
1673
1693
  }
1674
1694