@bian-womp/spark-remote 0.3.2 → 0.3.4

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/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebSocket } from 'ws';
2
- import { GraphBuilder, LocalEngine } from '@bian-womp/spark-graph';
2
+ import { GraphBuilder, parseJsonPath, setValueAtPathWithCreation, LocalEngine } from '@bian-womp/spark-graph';
3
3
 
4
4
  class SeqGenerator {
5
5
  constructor() {
@@ -460,8 +460,14 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
460
460
  // (e.g., { ui } or { runtime }) without dropping the other ones.
461
461
  extData = { ...extData, ...data };
462
462
  },
463
- getExtData: async () => {
464
- return extData;
463
+ updateExtData: async (updates) => {
464
+ if (!extData || typeof extData !== "object" || Array.isArray(extData)) {
465
+ extData = {};
466
+ }
467
+ for (const { path, value } of updates) {
468
+ const pathSegments = parseJsonPath(path);
469
+ setValueAtPathWithCreation(extData, pathSegments, value);
470
+ }
465
471
  },
466
472
  snapshot: async () => {
467
473
  const inputs = {};
@@ -482,14 +488,12 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
482
488
  },
483
489
  snapshotFull: async () => {
484
490
  const snap = await originalAdapter.snapshot();
485
- const extData = await originalAdapter.getExtData();
486
491
  const env = graphRuntime?.getEnvironment?.() ?? {};
487
492
  const def = graphRuntime?.getGraphDef();
488
493
  return {
494
+ ...snap,
489
495
  def,
490
496
  environment: env,
491
- inputs: snap.inputs,
492
- outputs: snap.outputs,
493
497
  extData,
494
498
  };
495
499
  },
@@ -684,7 +688,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
684
688
  applyRegistry: wrapMethod("applyRegistry", originalAdapter.applyRegistry),
685
689
  build: wrapMethod("build", originalAdapter.build),
686
690
  setExtData: wrapMethod("setExtData", originalAdapter.setExtData),
687
- getExtData: wrapMethod("getExtData", originalAdapter.getExtData),
691
+ updateExtData: wrapMethod("updateExtData", originalAdapter.updateExtData),
688
692
  snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
689
693
  snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
690
694
  applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
@@ -962,13 +966,11 @@ class RemoteGraphLifecycleApi {
962
966
  message: { type: "SetExtData", payload: data },
963
967
  });
964
968
  }
965
- async getExtData() {
969
+ async updateExtData(updates) {
966
970
  const transport = await this.ensureConnected();
967
- const res = await transport.request({
968
- message: { type: "GetExtData" },
971
+ await transport.request({
972
+ message: { type: "UpdateExtData", payload: updates },
969
973
  });
970
- const payload = res?.message || {};
971
- return payload.extData || {};
972
974
  }
973
975
  async setViewport(viewport) {
974
976
  const transport = await this.ensureConnected();
@@ -1403,9 +1405,7 @@ class ServerCommandHandler {
1403
1405
  toNodeId: msg.payload.toNodeId,
1404
1406
  dry: !!dry,
1405
1407
  });
1406
- await this.adapter.copyOutputs(msg.payload.fromNodeId, msg.payload.toNodeId, {
1407
- dry,
1408
- });
1408
+ await this.adapter.copyOutputs(msg.payload.fromNodeId, msg.payload.toNodeId, { dry });
1409
1409
  ack();
1410
1410
  break;
1411
1411
  }
@@ -1416,9 +1416,7 @@ class ServerCommandHandler {
1416
1416
  event: summarize(msg.payload.event),
1417
1417
  dry: !!dry,
1418
1418
  });
1419
- await this.adapter.triggerExternal(msg.payload.nodeId, msg.payload.event, {
1420
- dry,
1421
- });
1419
+ await this.adapter.triggerExternal(msg.payload.nodeId, msg.payload.event, { dry });
1422
1420
  ack();
1423
1421
  break;
1424
1422
  }
@@ -1520,6 +1518,11 @@ class ServerCommandHandler {
1520
1518
  ack();
1521
1519
  break;
1522
1520
  }
1521
+ case "UpdateExtData": {
1522
+ await this.adapter.updateExtData(msg.payload);
1523
+ ack();
1524
+ break;
1525
+ }
1523
1526
  case "Dispose": {
1524
1527
  this.logCommand("Dispose", env);
1525
1528
  await this.adapter.dispose();