@bian-womp/spark-workbench 0.3.20 → 0.3.21

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
@@ -1215,7 +1215,7 @@ class LocalGraphRunner extends AbstractGraphRunner {
1215
1215
  this.engine.on("error", (e) => this.emit("error", e));
1216
1216
  this.engine.on("invalidate", (e) => this.emit("invalidate", e));
1217
1217
  this.engine.on("stats", (e) => this.emit("stats", e));
1218
- this.engine.launch(opts?.invalidate);
1218
+ this.engine.launch(opts?.invalidate, opts?.runMode, opts?.startPaused);
1219
1219
  const runMode = opts?.runMode ?? "manual";
1220
1220
  this.emit("status", { running: true, runMode });
1221
1221
  for (const [nodeId, map] of Object.entries(this.stagedInputs)) {
@@ -1363,6 +1363,26 @@ class LocalGraphRunner extends AbstractGraphRunner {
1363
1363
  await this.setExtData(payload.extData);
1364
1364
  }
1365
1365
  }
1366
+ async convertSnapshot(converterConfig, options) {
1367
+ const snapshot = await this.snapshotFull();
1368
+ const converter = sparkGraph.buildValueConverter(converterConfig);
1369
+ const converted = sparkGraph.convertSnapshot(snapshot, converter);
1370
+ await this.applySnapshotFull(converted, {
1371
+ skipBuild: true,
1372
+ dry: options?.dry,
1373
+ });
1374
+ return converted;
1375
+ }
1376
+ async pause() {
1377
+ if (!this.runtime)
1378
+ return;
1379
+ this.runtime.pause();
1380
+ }
1381
+ async resume() {
1382
+ if (!this.runtime)
1383
+ return;
1384
+ this.runtime.resume();
1385
+ }
1366
1386
  hydrate(snapshot, opts) {
1367
1387
  // Hydrate via runtime for exact restore (this emits events on runtime emitter)
1368
1388
  this.runtime?.hydrate({
@@ -1961,6 +1981,23 @@ class RemoteGraphRunner extends AbstractGraphRunner {
1961
1981
  skipBuild: options?.skipBuild,
1962
1982
  });
1963
1983
  }
1984
+ async convertSnapshot(converterConfig, options) {
1985
+ const client = await this.ensureClient();
1986
+ const converted = await client.api.convertSnapshot(converterConfig, {
1987
+ dry: options?.dry,
1988
+ });
1989
+ // Hydrate local cache with converted values
1990
+ this.hydrateValueCache(converted, { dry: options?.dry });
1991
+ return converted;
1992
+ }
1993
+ async pause() {
1994
+ const client = await this.ensureClient();
1995
+ await client.api.pause();
1996
+ }
1997
+ async resume() {
1998
+ const client = await this.ensureClient();
1999
+ await client.api.resume();
2000
+ }
1964
2001
  /**
1965
2002
  * Hydrates the local valueCache from a snapshot and emits value events.
1966
2003
  * This ensures the UI can display inputs/outputs immediately without waiting
@@ -5758,7 +5795,7 @@ function useKeyboardShortcutToast() {
5758
5795
  return { toast, showToast, hideToast };
5759
5796
  }
5760
5797
 
5761
- const SelectionBoundOverlay = ({ selection, rfInstance }) => {
5798
+ const SelectionBoundOverlay = ({ selection, rfInstance, viewportTick }) => {
5762
5799
  const selectionBounds = React.useMemo(() => {
5763
5800
  if (typeof document === "undefined" ||
5764
5801
  !rfInstance ||
@@ -5787,7 +5824,7 @@ const SelectionBoundOverlay = ({ selection, rfInstance }) => {
5787
5824
  }
5788
5825
  }
5789
5826
  return bounds;
5790
- }, [selection.nodes, rfInstance]);
5827
+ }, [selection.nodes, rfInstance, viewportTick]);
5791
5828
  if (!selectionBounds || selection.nodes.length < 2) {
5792
5829
  return null;
5793
5830
  }
@@ -6432,6 +6469,10 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
6432
6469
  connectionLineRenderer: ui.getConnectionLineRenderer(),
6433
6470
  };
6434
6471
  }, [ui, uiVersion]);
6472
+ const [selectionOverlayTick, setSelectionOverlayTick] = React.useState(0);
6473
+ const onMove = React.useCallback(() => {
6474
+ setSelectionOverlayTick((t) => t + 1);
6475
+ }, []);
6435
6476
  const onMoveEnd = React.useCallback(() => {
6436
6477
  if (rfInstanceRef.current) {
6437
6478
  const viewport = rfInstanceRef.current.getViewport();
@@ -6463,7 +6504,7 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
6463
6504
  if (userOnInit) {
6464
6505
  userOnInit(inst);
6465
6506
  }
6466
- }, onConnect: onConnect, onEdgesChange: onEdgesChange, onEdgesDelete: onEdgesDelete, onNodesDelete: onNodesDelete, onNodesChange: onNodesChange, onMoveEnd: onMoveEnd, deleteKeyCode: ["Backspace", "Delete"], proOptions: { hideAttribution: true }, noDragClassName: "wb-nodrag", noWheelClassName: "wb-nowheel", noPanClassName: "wb-nopan", children: [BackgroundRenderer ? (jsxRuntime.jsx(BackgroundRenderer, {})) : (jsxRuntime.jsx(react.Background, { id: "workbench-canvas-background", variant: react.BackgroundVariant.Dots, gap: 12, size: 1 })), MinimapRenderer ? jsxRuntime.jsx(MinimapRenderer, {}) : jsxRuntime.jsx(react.MiniMap, {}), ControlsRenderer ? jsxRuntime.jsx(ControlsRenderer, {}) : jsxRuntime.jsx(react.Controls, {}), menuState?.type === "default" &&
6507
+ }, onConnect: onConnect, onEdgesChange: onEdgesChange, onEdgesDelete: onEdgesDelete, onNodesDelete: onNodesDelete, onNodesChange: onNodesChange, onMove: onMove, onMoveEnd: onMoveEnd, deleteKeyCode: ["Backspace", "Delete"], proOptions: { hideAttribution: true }, noDragClassName: "wb-nodrag", noWheelClassName: "wb-nowheel", noPanClassName: "wb-nopan", children: [BackgroundRenderer ? (jsxRuntime.jsx(BackgroundRenderer, {})) : (jsxRuntime.jsx(react.Background, { id: "workbench-canvas-background", variant: react.BackgroundVariant.Dots, gap: 12, size: 1 })), MinimapRenderer ? jsxRuntime.jsx(MinimapRenderer, {}) : jsxRuntime.jsx(react.MiniMap, {}), ControlsRenderer ? jsxRuntime.jsx(ControlsRenderer, {}) : jsxRuntime.jsx(react.Controls, {}), menuState?.type === "default" &&
6467
6508
  (DefaultContextMenuRenderer ? (jsxRuntime.jsx(DefaultContextMenuRenderer, { open: true, clientPos: menuState.menuPos, handlers: defaultContextMenuHandlers, registry: wb.registry, nodeIds: nodeIds, ...(enableKeyboardShortcuts !== false
6468
6509
  ? { enableKeyboardShortcuts, keyboardShortcuts }
6469
6510
  : {}) })) : (jsxRuntime.jsx(DefaultContextMenu, { open: true, clientPos: menuState.menuPos, handlers: defaultContextMenuHandlers, registry: wb.registry, nodeIds: nodeIds, enableKeyboardShortcuts: enableKeyboardShortcuts, keyboardShortcuts: keyboardShortcuts }))), menuState?.type === "node" &&
@@ -6471,7 +6512,7 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
6471
6512
  (NodeContextMenuRenderer ? (jsxRuntime.jsx(NodeContextMenuRenderer, { open: true, clientPos: menuState.menuPos, nodeId: menuState.nodeId, handlers: nodeContextMenuHandlers, bakeableOutputs: bakeableOutputs, runMode: runMode, wb: wb, ...(enableKeyboardShortcuts !== false
6472
6513
  ? { enableKeyboardShortcuts, keyboardShortcuts }
6473
6514
  : {}) })) : (jsxRuntime.jsx(NodeContextMenu, { open: true, clientPos: menuState.menuPos, nodeId: menuState.nodeId, handlers: nodeContextMenuHandlers, bakeableOutputs: bakeableOutputs, runMode: runMode }))), menuState?.type === "selection" &&
6474
- (SelectionContextMenuRenderer ? (jsxRuntime.jsx(SelectionContextMenuRenderer, { open: true, clientPos: menuState.menuPos, handlers: selectionContextMenuHandlers, enableKeyboardShortcuts: enableKeyboardShortcuts, keyboardShortcuts: keyboardShortcuts })) : (jsxRuntime.jsx(SelectionContextMenu, { open: true, clientPos: menuState.menuPos, handlers: selectionContextMenuHandlers, enableKeyboardShortcuts: enableKeyboardShortcuts, keyboardShortcuts: keyboardShortcuts })))] }), jsxRuntime.jsx(SelectionBoundOverlay, { selection: selection, rfInstance: rfInstanceRef.current })] }), toast && (jsxRuntime.jsx(KeyboardShortcutToast, { message: toast.message, onClose: hideToast }, toast.id))] }));
6515
+ (SelectionContextMenuRenderer ? (jsxRuntime.jsx(SelectionContextMenuRenderer, { open: true, clientPos: menuState.menuPos, handlers: selectionContextMenuHandlers, enableKeyboardShortcuts: enableKeyboardShortcuts, keyboardShortcuts: keyboardShortcuts })) : (jsxRuntime.jsx(SelectionContextMenu, { open: true, clientPos: menuState.menuPos, handlers: selectionContextMenuHandlers, enableKeyboardShortcuts: enableKeyboardShortcuts, keyboardShortcuts: keyboardShortcuts })))] }), jsxRuntime.jsx(SelectionBoundOverlay, { selection: selection, rfInstance: rfInstanceRef.current, viewportTick: selectionOverlayTick })] }), toast && (jsxRuntime.jsx(KeyboardShortcutToast, { message: toast.message, onClose: hideToast }, toast.id))] }));
6475
6516
  });
6476
6517
  const WorkbenchCanvas = WorkbenchCanvasComponent;
6477
6518