@bian-womp/spark-remote 0.3.74 → 0.3.76

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
@@ -494,7 +494,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
494
494
  }
495
495
  if (graphRuntime) {
496
496
  console.info(`[ServerRuntimeAdapter:${id}] Disposing previous graph runtime before building new one`);
497
- graphRuntime.dispose();
497
+ graphRuntime.dispose("runtime-rebuild");
498
498
  graphRuntime = undefined;
499
499
  }
500
500
  const environment = opts?.environment || {};
@@ -566,9 +566,22 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
566
566
  const def = payload.def;
567
567
  if (!def)
568
568
  return;
569
- // Only build if skipBuild is not true
569
+ // Only rebuild when needed. If runtime already exists, update in place so
570
+ // the current engine stays attached (important for undo/redo flows).
570
571
  if (!options?.skipBuild) {
571
- await originalAdapter.build(def, { environment: payload.environment });
572
+ if (!graphRuntime) {
573
+ await originalAdapter.build(def, { environment: payload.environment });
574
+ }
575
+ else {
576
+ const releasePause = graphRuntime.requestPause();
577
+ try {
578
+ graphRuntime.setEnvironment(payload.environment || {});
579
+ graphRuntime.update(def, registry);
580
+ }
581
+ finally {
582
+ releasePause();
583
+ }
584
+ }
572
585
  }
573
586
  else if (!graphRuntime) {
574
587
  // If skipping build but no runtime exists, we still need to build
@@ -734,7 +747,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
734
747
  engine = undefined;
735
748
  }
736
749
  if (graphRuntime) {
737
- graphRuntime.dispose();
750
+ graphRuntime.dispose("adapter-dispose");
738
751
  graphRuntime = undefined;
739
752
  }
740
753
  },