@bian-womp/spark-remote 0.3.2 → 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
  },
@@ -686,7 +690,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
686
690
  applyRegistry: wrapMethod("applyRegistry", originalAdapter.applyRegistry),
687
691
  build: wrapMethod("build", originalAdapter.build),
688
692
  setExtData: wrapMethod("setExtData", originalAdapter.setExtData),
689
- getExtData: wrapMethod("getExtData", originalAdapter.getExtData),
693
+ updateExtData: wrapMethod("updateExtData", originalAdapter.updateExtData),
690
694
  snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
691
695
  snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
692
696
  applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
@@ -964,13 +968,11 @@ class RemoteGraphLifecycleApi {
964
968
  message: { type: "SetExtData", payload: data },
965
969
  });
966
970
  }
967
- async getExtData() {
971
+ async updateExtData(updates) {
968
972
  const transport = await this.ensureConnected();
969
- const res = await transport.request({
970
- message: { type: "GetExtData" },
973
+ await transport.request({
974
+ message: { type: "UpdateExtData", payload: updates },
971
975
  });
972
- const payload = res?.message || {};
973
- return payload.extData || {};
974
976
  }
975
977
  async setViewport(viewport) {
976
978
  const transport = await this.ensureConnected();
@@ -1522,6 +1524,11 @@ class ServerCommandHandler {
1522
1524
  ack();
1523
1525
  break;
1524
1526
  }
1527
+ case "UpdateExtData": {
1528
+ await this.adapter.updateExtData(msg.payload);
1529
+ ack();
1530
+ break;
1531
+ }
1525
1532
  case "Dispose": {
1526
1533
  this.logCommand("Dispose", env);
1527
1534
  await this.adapter.dispose();