@bian-womp/spark-workbench 0.1.25 → 0.1.27
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 +44 -15
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/lib/esm/index.js +45 -16
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -1911,7 +1911,6 @@ function NodeContextMenu({ open, clientPos, nodeId, onClose, }) {
|
|
|
1911
1911
|
|
|
1912
1912
|
const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement }, ref) => {
|
|
1913
1913
|
const { wb, registry, inputsMap, outputsMap, valuesTick, nodeStatus, edgeStatus, validationByNode, validationByEdge, } = useWorkbenchContext();
|
|
1914
|
-
const ioValues = { inputs: inputsMap, outputs: outputsMap };
|
|
1915
1914
|
const nodeValidation = validationByNode;
|
|
1916
1915
|
const edgeValidation = validationByEdge.errors;
|
|
1917
1916
|
// Expose imperative API
|
|
@@ -1924,7 +1923,7 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement }, r
|
|
|
1924
1923
|
catch { }
|
|
1925
1924
|
},
|
|
1926
1925
|
}));
|
|
1927
|
-
const { onConnect, onNodesChange, onEdgesChange, onEdgesDelete, onNodesDelete, onSelectionChange, } = useWorkbenchBridge(wb);
|
|
1926
|
+
const { onConnect, onNodesChange: wbOnNodesChange, onEdgesChange: wbOnEdgesChange, onEdgesDelete, onNodesDelete, onSelectionChange, } = useWorkbenchBridge(wb);
|
|
1928
1927
|
const { nodeTypes, resolveNodeType } = React.useMemo(() => {
|
|
1929
1928
|
// Build nodeTypes map using UI extension registry
|
|
1930
1929
|
const ui = wb.getUI();
|
|
@@ -1945,13 +1944,13 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement }, r
|
|
|
1945
1944
|
return { nodeTypes: types, resolveNodeType: resolver };
|
|
1946
1945
|
// registry is stable; ui renderers expected to be set up before mount
|
|
1947
1946
|
}, [wb, registry]);
|
|
1948
|
-
const { nodes, edges } = React.useMemo(() => {
|
|
1947
|
+
const { nodes: computedNodes, edges: computedEdges } = React.useMemo(() => {
|
|
1949
1948
|
const def = wb.export();
|
|
1950
1949
|
const sel = wb.getSelection();
|
|
1951
|
-
|
|
1950
|
+
const out = toReactFlow(def, wb.getPositions(), registry, {
|
|
1952
1951
|
showValues,
|
|
1953
|
-
inputs:
|
|
1954
|
-
outputs:
|
|
1952
|
+
inputs: inputsMap,
|
|
1953
|
+
outputs: outputsMap,
|
|
1955
1954
|
resolveNodeType,
|
|
1956
1955
|
toString,
|
|
1957
1956
|
toElement,
|
|
@@ -1962,9 +1961,12 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement }, r
|
|
|
1962
1961
|
selectedNodeIds: new Set(sel.nodes),
|
|
1963
1962
|
selectedEdgeIds: new Set(sel.edges),
|
|
1964
1963
|
});
|
|
1964
|
+
console.info(nodeTypes, out);
|
|
1965
|
+
return out;
|
|
1965
1966
|
}, [
|
|
1966
1967
|
showValues,
|
|
1967
|
-
|
|
1968
|
+
inputsMap,
|
|
1969
|
+
outputsMap,
|
|
1968
1970
|
valuesTick,
|
|
1969
1971
|
toString,
|
|
1970
1972
|
toElement,
|
|
@@ -1972,7 +1974,28 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement }, r
|
|
|
1972
1974
|
edgeStatus,
|
|
1973
1975
|
nodeValidation,
|
|
1974
1976
|
edgeValidation,
|
|
1977
|
+
nodeTypes,
|
|
1978
|
+
resolveNodeType,
|
|
1975
1979
|
]);
|
|
1980
|
+
// Local controlled state per requested pattern
|
|
1981
|
+
const [nodes, setNodes] = React.useState(computedNodes);
|
|
1982
|
+
const [edges, setEdges] = React.useState(computedEdges);
|
|
1983
|
+
// Sync from computed graph to local state when source changes
|
|
1984
|
+
React.useEffect(() => {
|
|
1985
|
+
setNodes(computedNodes);
|
|
1986
|
+
}, [computedNodes]);
|
|
1987
|
+
React.useEffect(() => {
|
|
1988
|
+
setEdges(computedEdges);
|
|
1989
|
+
}, [computedEdges]);
|
|
1990
|
+
// Bridge RF changes to both local state and workbench
|
|
1991
|
+
const onNodesChange = React.useCallback((changes) => {
|
|
1992
|
+
setNodes((nds) => ReactFlow.applyNodeChanges(changes, nds));
|
|
1993
|
+
wbOnNodesChange(changes);
|
|
1994
|
+
}, [wbOnNodesChange]);
|
|
1995
|
+
const onEdgesChange = React.useCallback((changes) => {
|
|
1996
|
+
setEdges((eds) => ReactFlow.applyEdgeChanges(changes, eds));
|
|
1997
|
+
wbOnEdgesChange(changes);
|
|
1998
|
+
}, [wbOnEdgesChange]);
|
|
1976
1999
|
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
1977
2000
|
const [menuPos, setMenuPos] = React.useState(null);
|
|
1978
2001
|
const [nodeMenuOpen, setNodeMenuOpen] = React.useState(false);
|
|
@@ -2125,7 +2148,9 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
2125
2148
|
const downloadGraph = React.useCallback(() => {
|
|
2126
2149
|
try {
|
|
2127
2150
|
const def = wb.export();
|
|
2128
|
-
const
|
|
2151
|
+
const inputs = runner.getInputs(def);
|
|
2152
|
+
const payload = { def, inputs };
|
|
2153
|
+
const pretty = JSON.stringify(payload, null, 2);
|
|
2129
2154
|
const blob = new Blob([pretty], { type: "application/json" });
|
|
2130
2155
|
const url = URL.createObjectURL(blob);
|
|
2131
2156
|
const a = document.createElement("a");
|
|
@@ -2142,7 +2167,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
2142
2167
|
catch (err) {
|
|
2143
2168
|
alert(String(err?.message ?? err));
|
|
2144
2169
|
}
|
|
2145
|
-
}, [wb]);
|
|
2170
|
+
}, [wb, runner]);
|
|
2146
2171
|
const hydrateFromBackend = React.useCallback(async (kind, base) => {
|
|
2147
2172
|
try {
|
|
2148
2173
|
const transport = kind === "remote-http"
|
|
@@ -2292,20 +2317,24 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
2292
2317
|
value = Number.isFinite(n) ? n : 0;
|
|
2293
2318
|
break;
|
|
2294
2319
|
}
|
|
2320
|
+
case "base.float[]": {
|
|
2321
|
+
value = parseArray(String(raw), (x) => Number(x));
|
|
2322
|
+
break;
|
|
2323
|
+
}
|
|
2295
2324
|
case "base.bool": {
|
|
2296
2325
|
value = raw === "true" || raw === "1" ? true : false;
|
|
2297
2326
|
break;
|
|
2298
2327
|
}
|
|
2299
|
-
case "base.
|
|
2300
|
-
value = String(raw);
|
|
2328
|
+
case "base.bool[]": {
|
|
2329
|
+
value = parseArray(String(raw), (x) => /^(true|1)$/i.test(x));
|
|
2301
2330
|
break;
|
|
2302
2331
|
}
|
|
2303
|
-
case "base.
|
|
2304
|
-
value =
|
|
2332
|
+
case "base.string": {
|
|
2333
|
+
value = String(raw);
|
|
2305
2334
|
break;
|
|
2306
2335
|
}
|
|
2307
|
-
case "base.
|
|
2308
|
-
value = parseArray(String(raw), (x) =>
|
|
2336
|
+
case "base.string[]": {
|
|
2337
|
+
value = parseArray(String(raw), (x) => String(x));
|
|
2309
2338
|
break;
|
|
2310
2339
|
}
|
|
2311
2340
|
case "base.vec3": {
|