@bian-womp/spark-workbench 0.2.6 → 0.2.8
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 +25 -25
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/NodeHandles.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/esm/index.js +25 -25
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/NodeHandles.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeHandles.d.ts","sourceRoot":"","sources":["../../../../src/misc/NodeHandles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,aAAa,EACb,cAAyC,EACzC,eAA0C,EAC1C,YAAY,EACZ,WAAW,EACX,cAA4F,GAC7F,EAAE;IACD,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC3B,KAAK,MAAM,GAAG,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACnB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;KACZ,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,
|
|
1
|
+
{"version":3,"file":"NodeHandles.d.ts","sourceRoot":"","sources":["../../../../src/misc/NodeHandles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,aAAa,EACb,cAAyC,EACzC,eAA0C,EAC1C,YAAY,EACZ,WAAW,EACX,cAA4F,GAC7F,EAAE;IACD,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC3B,KAAK,MAAM,GAAG,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACnB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;KACZ,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,2CA8FA;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchCanvas.d.ts","sourceRoot":"","sources":["../../../../src/misc/WorkbenchCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAiB9E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe;iBAGX,OAAO;cACV,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM;eAC3C,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO;yBACvC,CACnB,MAAM,EAAE,MAAM,KACX;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;+
|
|
1
|
+
{"version":3,"file":"WorkbenchCanvas.d.ts","sourceRoot":"","sources":["../../../../src/misc/WorkbenchCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAiB9E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe;iBAGX,OAAO;cACV,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM;eAC3C,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO;yBACvC,CACnB,MAAM,EAAE,MAAM,KACX;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;+CAyUpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchContext.provider.d.ts","sourceRoot":"","sources":["../../../../../src/misc/context/WorkbenchContext.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"WorkbenchContext.provider.d.ts","sourceRoot":"","sources":["../../../../../src/misc/context/WorkbenchContext.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,QAAQ,EAAwB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAmB,MAAM,4BAA4B,CAAC;AAiB3E,wBAAgB,iBAAiB,CAAC,EAChC,EAAE,EACF,MAAM,EACN,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,iBAAiB,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAshBA"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1286,7 +1286,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1286
1286
|
const FALLBACK_TOTAL_MS = 2 * 60 * 1000;
|
|
1287
1287
|
const [fallbackStarts, setFallbackStarts] = useState({});
|
|
1288
1288
|
// Track runs that emitted an error so we can keep progress on completion
|
|
1289
|
-
const
|
|
1289
|
+
const errorRunsRef = useRef({});
|
|
1290
1290
|
// Periodically advance fallback progress for running nodes without explicit progress
|
|
1291
1291
|
useEffect(() => {
|
|
1292
1292
|
const interval = setInterval(() => {
|
|
@@ -1449,6 +1449,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
else if (nodeError.nodeId) {
|
|
1451
1451
|
const nodeId = nodeError.nodeId;
|
|
1452
|
+
const runId = nodeError.runId;
|
|
1452
1453
|
setNodeStatus((s) => ({
|
|
1453
1454
|
...s,
|
|
1454
1455
|
[nodeId]: {
|
|
@@ -1457,11 +1458,11 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1457
1458
|
},
|
|
1458
1459
|
}));
|
|
1459
1460
|
// Mark this runId as errored
|
|
1460
|
-
if (
|
|
1461
|
-
|
|
1462
|
-
...
|
|
1463
|
-
[
|
|
1464
|
-
}
|
|
1461
|
+
if (runId) {
|
|
1462
|
+
errorRunsRef.current[nodeId] = {
|
|
1463
|
+
...errorRunsRef.current[nodeId],
|
|
1464
|
+
[runId]: true,
|
|
1465
|
+
};
|
|
1465
1466
|
}
|
|
1466
1467
|
}
|
|
1467
1468
|
return add("runner", "error")(e);
|
|
@@ -1514,38 +1515,29 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
|
|
|
1514
1515
|
setNodeStatus((prev) => {
|
|
1515
1516
|
const current = prev[id]?.activeRuns ?? 0;
|
|
1516
1517
|
const nextActive = current - 1;
|
|
1517
|
-
const hadError = !!(runId &&
|
|
1518
|
+
const hadError = !!(runId && errorRunsRef.current[id]?.[runId]);
|
|
1518
1519
|
const keepProgress = hadError || nextActive > 0;
|
|
1520
|
+
// Clear error flag for this runId
|
|
1521
|
+
if (runId && errorRunsRef.current[id]?.[runId]) {
|
|
1522
|
+
delete errorRunsRef.current[id]?.[runId];
|
|
1523
|
+
}
|
|
1519
1524
|
return {
|
|
1520
1525
|
...prev,
|
|
1521
1526
|
[id]: {
|
|
1522
1527
|
...prev[id],
|
|
1523
1528
|
activeRuns: nextActive,
|
|
1524
1529
|
progress: keepProgress ? prev[id]?.progress : 0,
|
|
1530
|
+
lastError: hadError ? prev[id]?.lastError : undefined,
|
|
1525
1531
|
},
|
|
1526
1532
|
};
|
|
1527
1533
|
});
|
|
1528
1534
|
// Clear fallback start timestamp if no more active runs
|
|
1529
1535
|
setFallbackStarts((prev) => {
|
|
1530
|
-
prev[id];
|
|
1531
1536
|
const nextPrev = { ...prev };
|
|
1532
1537
|
// If we don't know nextActive here, conservatively clear to stop animation
|
|
1533
1538
|
delete nextPrev[id];
|
|
1534
1539
|
return nextPrev;
|
|
1535
1540
|
});
|
|
1536
|
-
// Clear error flag for this runId
|
|
1537
|
-
if (runId) {
|
|
1538
|
-
setErrorRuns((prev) => {
|
|
1539
|
-
const nodeMap = { ...(prev[id] || {}) };
|
|
1540
|
-
delete nodeMap[runId];
|
|
1541
|
-
const next = { ...prev };
|
|
1542
|
-
if (Object.keys(nodeMap).length === 0)
|
|
1543
|
-
delete next[id];
|
|
1544
|
-
else
|
|
1545
|
-
next[id] = nodeMap;
|
|
1546
|
-
return next;
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
1541
|
}
|
|
1550
1542
|
else if (s.kind === "edge-start") {
|
|
1551
1543
|
const id = s.edgeId;
|
|
@@ -1964,12 +1956,20 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
1964
1956
|
const byId = React.useMemo(() => {
|
|
1965
1957
|
const m = new Map();
|
|
1966
1958
|
for (const h of layout) {
|
|
1967
|
-
|
|
1959
|
+
// Prefer namespaced key to disambiguate inputs/outputs that share id
|
|
1960
|
+
m.set(`${h.type}:${h.id}`, {
|
|
1961
|
+
position: h.position,
|
|
1962
|
+
y: h.y,
|
|
1963
|
+
type: h.type,
|
|
1964
|
+
});
|
|
1965
|
+
// Back-compat: also store by id-only if not already set
|
|
1966
|
+
if (!m.has(h.id))
|
|
1967
|
+
m.set(h.id, { position: h.position, y: h.y, type: h.type });
|
|
1968
1968
|
}
|
|
1969
1969
|
return m;
|
|
1970
1970
|
}, [layout]);
|
|
1971
1971
|
return (jsxs(Fragment, { children: [(data.inputHandles ?? []).map((h) => {
|
|
1972
|
-
const placed = byId.get(h.id);
|
|
1972
|
+
const placed = byId.get(`target:${h.id}`) ?? byId.get(h.id);
|
|
1973
1973
|
const position = placed?.position ?? Position.Left;
|
|
1974
1974
|
const y = placed?.y;
|
|
1975
1975
|
const cls = getClassName?.({ kind: "input", id: h.id, type: "target" }) ??
|
|
@@ -1982,7 +1982,7 @@ function NodeHandles({ data, isConnectable, inputClassName = "!w-2 !h-2 !bg-gray
|
|
|
1982
1982
|
textOverflow: "ellipsis",
|
|
1983
1983
|
}, children: renderLabel({ kind: "input", id: h.id }) }))] }, h.id));
|
|
1984
1984
|
}), (data.outputHandles ?? []).map((h) => {
|
|
1985
|
-
const placed = byId.get(h.id);
|
|
1985
|
+
const placed = byId.get(`source:${h.id}`) ?? byId.get(h.id);
|
|
1986
1986
|
const position = placed?.position ?? Position.Right;
|
|
1987
1987
|
const y = placed?.y;
|
|
1988
1988
|
const cls = getClassName?.({ kind: "output", id: h.id, type: "source" }) ??
|
|
@@ -2465,7 +2465,7 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement, get
|
|
|
2465
2465
|
const addNodeAt = (typeId, pos) => {
|
|
2466
2466
|
wb.addNode({ typeId, position: pos });
|
|
2467
2467
|
};
|
|
2468
|
-
return (jsx("div", { className: "w-full h-full", onContextMenu: onContextMenu, children: jsx(ReactFlowProvider, { children: jsxs(ReactFlow, { nodes: throttled.nodes, edges: throttled.edges, nodeTypes: nodeTypes,
|
|
2468
|
+
return (jsx("div", { className: "w-full h-full", onContextMenu: onContextMenu, children: jsx(ReactFlowProvider, { children: jsxs(ReactFlow, { nodes: throttled.nodes, edges: throttled.edges, nodeTypes: nodeTypes, selectionOnDrag: true, onInit: (inst) => (rfInstanceRef.current = inst), onConnect: onConnect, onEdgesChange: onEdgesChange, onEdgesDelete: onEdgesDelete, onNodesDelete: onNodesDelete, onNodesChange: onNodesChange, deleteKeyCode: ["Backspace", "Delete"], proOptions: { hideAttribution: true }, noDragClassName: "wb-nodrag", noWheelClassName: "wb-nowheel", noPanClassName: "wb-nopan", fitView: true, children: [jsx(Background, { id: "workbench-canvas-background", variant: BackgroundVariant.Dots, gap: 12, size: 1 }), jsx(MiniMap, {}), jsx(Controls, {}), jsx(DefaultContextMenu, { open: menuOpen, clientPos: menuPos, onAdd: addNodeAt, onClose: () => setMenuOpen(false) }), jsx(NodeContextMenu, { open: nodeMenuOpen, clientPos: nodeMenuPos, nodeId: nodeAtMenu, onClose: () => setNodeMenuOpen(false) })] }) }) }));
|
|
2469
2469
|
});
|
|
2470
2470
|
|
|
2471
2471
|
function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, example, onExampleChange, engine, onEngineChange, backendKind, onBackendKindChange, httpBaseUrl, onHttpBaseUrlChange, wsUrl, onWsUrlChange, debug, onDebugChange, showValues, onShowValuesChange, hideWorkbench, onHideWorkbenchChange, overrides, onInit, onChange, }) {
|