@bian-womp/spark-workbench 0.3.13 → 0.3.15

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
@@ -1385,6 +1385,13 @@ function excludeViewportFromUIState(uiState) {
1385
1385
  // Counter for generating readable runner IDs
1386
1386
  let remoteRunnerCounter = 0;
1387
1387
  class RemoteGraphRunner extends AbstractGraphRunner {
1388
+ /**
1389
+ * Generate cache key that includes io type to prevent collisions
1390
+ * between input and output handles with the same name
1391
+ */
1392
+ getCacheKey(nodeId, handle, io) {
1393
+ return `${nodeId}.${io}.${handle}`;
1394
+ }
1388
1395
  /**
1389
1396
  * Fetch full registry description from remote and register it locally.
1390
1397
  * Simplified with straightforward retry loop.
@@ -1503,14 +1510,6 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1503
1510
  if (attempt < this.MAX_REGISTRY_FETCH_ATTEMPTS) {
1504
1511
  const delayMs = this.INITIAL_RETRY_DELAY_MS * Math.pow(2, attempt - 1);
1505
1512
  console.warn(`Failed to fetch registry (attempt ${attempt}/${this.MAX_REGISTRY_FETCH_ATTEMPTS}), retrying in ${delayMs}ms...`, lastError);
1506
- // Emit error event for UI feedback
1507
- this.emit("error", {
1508
- kind: "registry",
1509
- message: `Registry fetch failed (attempt ${attempt}/${this.MAX_REGISTRY_FETCH_ATTEMPTS}), retrying...`,
1510
- err: lastError,
1511
- attempt,
1512
- maxAttempts: this.MAX_REGISTRY_FETCH_ATTEMPTS,
1513
- });
1514
1513
  // Wait before retrying
1515
1514
  await new Promise((resolve) => setTimeout(resolve, delayMs));
1516
1515
  }
@@ -1737,8 +1736,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1737
1736
  const snap = await client.api.snapshot();
1738
1737
  for (const [nodeId, map] of Object.entries(snap.inputs || {})) {
1739
1738
  for (const [handle, value] of Object.entries(map || {})) {
1740
- this.valueCache.set(`${nodeId}.${handle}`, {
1741
- io: "input",
1739
+ this.valueCache.set(this.getCacheKey(nodeId, handle, "input"), {
1742
1740
  value,
1743
1741
  });
1744
1742
  this.emit("value", { nodeId, handle, value, io: "input" });
@@ -1746,8 +1744,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1746
1744
  }
1747
1745
  for (const [nodeId, map] of Object.entries(snap.outputs || {})) {
1748
1746
  for (const [handle, value] of Object.entries(map || {})) {
1749
- this.valueCache.set(`${nodeId}.${handle}`, {
1750
- io: "output",
1747
+ this.valueCache.set(this.getCacheKey(nodeId, handle, "output"), {
1751
1748
  value,
1752
1749
  });
1753
1750
  this.emit("value", { nodeId, handle, value, io: "output" });
@@ -1768,8 +1765,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1768
1765
  const eng = client.engine;
1769
1766
  if (!this.listenersBound) {
1770
1767
  eng.on("value", (e) => {
1771
- this.valueCache.set(`${e.nodeId}.${e.handle}`, {
1772
- io: e.io,
1768
+ this.valueCache.set(this.getCacheKey(e.nodeId, e.handle, e.io), {
1773
1769
  value: e.value,
1774
1770
  runtimeTypeId: e.runtimeTypeId,
1775
1771
  });
@@ -1938,8 +1934,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1938
1934
  // Hydrate inputs
1939
1935
  for (const [nodeId, map] of Object.entries(snapshot.inputs || {})) {
1940
1936
  for (const [handle, value] of Object.entries(map || {})) {
1941
- this.valueCache.set(`${nodeId}.${handle}`, {
1942
- io: "input",
1937
+ this.valueCache.set(this.getCacheKey(nodeId, handle, "input"), {
1943
1938
  value,
1944
1939
  });
1945
1940
  this.emit("value", {
@@ -1954,8 +1949,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1954
1949
  // Hydrate outputs
1955
1950
  for (const [nodeId, map] of Object.entries(snapshot.outputs || {})) {
1956
1951
  for (const [handle, value] of Object.entries(map || {})) {
1957
- this.valueCache.set(`${nodeId}.${handle}`, {
1958
- io: "output",
1952
+ this.valueCache.set(this.getCacheKey(nodeId, handle, "output"), {
1959
1953
  value,
1960
1954
  });
1961
1955
  this.emit("value", {
@@ -2001,9 +1995,9 @@ class RemoteGraphRunner extends AbstractGraphRunner {
2001
1995
  const desc = this.registry.nodes.get(n.typeId);
2002
1996
  const handles = Object.keys(resolved ?? desc?.outputs ?? {});
2003
1997
  for (const h of handles) {
2004
- const key = `${n.nodeId}.${h}`;
1998
+ const key = this.getCacheKey(n.nodeId, h, "output");
2005
1999
  const rec = cache.get(key);
2006
- if (rec && rec.io === "output") {
2000
+ if (rec) {
2007
2001
  if (!out[n.nodeId])
2008
2002
  out[n.nodeId] = {};
2009
2003
  out[n.nodeId][h] = rec.value;
@@ -2026,8 +2020,8 @@ class RemoteGraphRunner extends AbstractGraphRunner {
2026
2020
  .filter((e) => e.target.nodeId === n.nodeId)
2027
2021
  .map((e) => e.target.handle));
2028
2022
  for (const h of handles) {
2029
- const rec = cache.get(`${n.nodeId}.${h}`);
2030
- if (rec && rec.io === "input")
2023
+ const rec = cache.get(this.getCacheKey(n.nodeId, h, "input"));
2024
+ if (rec)
2031
2025
  cur[h] = rec.value;
2032
2026
  }
2033
2027
  // Merge staged only for non-inbound handles so UI doesn't override runtime values