@bian-womp/spark-remote 0.3.1 → 0.3.3

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
@@ -462,8 +462,14 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
462
462
  // (e.g., { ui } or { runtime }) without dropping the other ones.
463
463
  extData = { ...extData, ...data };
464
464
  },
465
- getExtData: async () => {
466
- return extData;
465
+ updateExtData: async (updates) => {
466
+ if (!extData || typeof extData !== "object" || Array.isArray(extData)) {
467
+ extData = {};
468
+ }
469
+ for (const { path, value } of updates) {
470
+ const pathSegments = sparkGraph.parseJsonPath(path);
471
+ sparkGraph.setValueAtPathWithCreation(extData, pathSegments, value);
472
+ }
467
473
  },
468
474
  snapshot: async () => {
469
475
  const inputs = {};
@@ -484,14 +490,12 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
484
490
  },
485
491
  snapshotFull: async () => {
486
492
  const snap = await originalAdapter.snapshot();
487
- const extData = await originalAdapter.getExtData();
488
493
  const env = graphRuntime?.getEnvironment?.() ?? {};
489
494
  const def = graphRuntime?.getGraphDef();
490
495
  return {
496
+ ...snap,
491
497
  def,
492
498
  environment: env,
493
- inputs: snap.inputs,
494
- outputs: snap.outputs,
495
499
  extData,
496
500
  };
497
501
  },
@@ -557,9 +561,8 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
557
561
  update: async (def, options) => {
558
562
  if (!graphRuntime)
559
563
  return;
560
- const wasPaused = graphRuntime.isPaused();
561
- if (options?.dry && !wasPaused)
562
- graphRuntime.pause();
564
+ // Use requestPause for dry mode to temporarily pause without affecting base run mode
565
+ const releasePause = options?.dry ? graphRuntime.requestPause() : null;
563
566
  try {
564
567
  graphRuntime.update(def, registry);
565
568
  send({
@@ -570,16 +573,14 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
570
573
  });
571
574
  }
572
575
  finally {
573
- if (options?.dry && !wasPaused)
574
- graphRuntime.resume();
576
+ releasePause?.();
575
577
  }
576
578
  },
577
579
  setEnvironment: async (env, opts) => {
578
580
  if (!graphRuntime)
579
581
  return;
580
- const wasPaused = graphRuntime.isPaused();
581
- if (opts?.dry && !wasPaused)
582
- graphRuntime.pause();
582
+ // Use requestPause for dry mode to temporarily pause without affecting base run mode
583
+ const releasePause = opts?.dry ? graphRuntime.requestPause() : null;
583
584
  try {
584
585
  if (opts?.merge) {
585
586
  const current = graphRuntime.getEnvironment();
@@ -591,8 +592,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
591
592
  }
592
593
  }
593
594
  finally {
594
- if (opts?.dry && !wasPaused)
595
- graphRuntime.resume();
595
+ releasePause?.();
596
596
  }
597
597
  },
598
598
  setInputs: (nodeId, inputs, options) => {
@@ -620,7 +620,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
620
620
  engine = undefined;
621
621
  }
622
622
  // Create new engine using shared factory
623
- engine = new sparkGraph.UnifiedEngine(graphRuntime, opts?.runMode);
623
+ engine = new sparkGraph.LocalEngine(graphRuntime, opts?.runMode);
624
624
  engine.launch(opts?.invalidate);
625
625
  },
626
626
  setRunMode: (runMode) => {
@@ -690,7 +690,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
690
690
  applyRegistry: wrapMethod("applyRegistry", originalAdapter.applyRegistry),
691
691
  build: wrapMethod("build", originalAdapter.build),
692
692
  setExtData: wrapMethod("setExtData", originalAdapter.setExtData),
693
- getExtData: wrapMethod("getExtData", originalAdapter.getExtData),
693
+ updateExtData: wrapMethod("updateExtData", originalAdapter.updateExtData),
694
694
  snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
695
695
  snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
696
696
  applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
@@ -769,13 +769,8 @@ class RemoteEngine {
769
769
  this.emit("stats", msg.payload);
770
770
  }
771
771
  }
772
- launch(invalidate, runMode) {
773
- this.transport.send({
774
- message: {
775
- type: "Launch",
776
- payload: { runMode, invalidate },
777
- },
778
- });
772
+ launch() {
773
+ throw new Error("RemoteEngine.launch() is not supported. Use GraphLifecycleApi.launch() instead.");
779
774
  }
780
775
  setRunMode(runMode) {
781
776
  this.transport.send({
@@ -973,13 +968,11 @@ class RemoteGraphLifecycleApi {
973
968
  message: { type: "SetExtData", payload: data },
974
969
  });
975
970
  }
976
- async getExtData() {
971
+ async updateExtData(updates) {
977
972
  const transport = await this.ensureConnected();
978
- const res = await transport.request({
979
- message: { type: "GetExtData" },
973
+ await transport.request({
974
+ message: { type: "UpdateExtData", payload: updates },
980
975
  });
981
- const payload = res?.message || {};
982
- return payload.extData || {};
983
976
  }
984
977
  async setViewport(viewport) {
985
978
  const transport = await this.ensureConnected();
@@ -1531,6 +1524,11 @@ class ServerCommandHandler {
1531
1524
  ack();
1532
1525
  break;
1533
1526
  }
1527
+ case "UpdateExtData": {
1528
+ await this.adapter.updateExtData(msg.payload);
1529
+ ack();
1530
+ break;
1531
+ }
1534
1532
  case "Dispose": {
1535
1533
  this.logCommand("Dispose", env);
1536
1534
  await this.adapter.dispose();