@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 +18 -11
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/RemoteGraphLifecycleApi.d.ts +4 -1
- package/lib/cjs/src/RemoteGraphLifecycleApi.d.ts.map +1 -1
- package/lib/cjs/src/server/ServerCommandHandler.d.ts.map +1 -1
- package/lib/cjs/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/lib/esm/index.js +19 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/RemoteGraphLifecycleApi.d.ts +4 -1
- package/lib/esm/src/RemoteGraphLifecycleApi.d.ts.map +1 -1
- package/lib/esm/src/server/ServerCommandHandler.d.ts.map +1 -1
- package/lib/esm/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/package.json +3 -3
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
|
-
|
|
464
|
-
|
|
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
|
-
|
|
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
|
|
969
|
+
async updateExtData(updates) {
|
|
966
970
|
const transport = await this.ensureConnected();
|
|
967
|
-
|
|
968
|
-
message: { type: "
|
|
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();
|
|
@@ -1520,6 +1522,11 @@ class ServerCommandHandler {
|
|
|
1520
1522
|
ack();
|
|
1521
1523
|
break;
|
|
1522
1524
|
}
|
|
1525
|
+
case "UpdateExtData": {
|
|
1526
|
+
await this.adapter.updateExtData(msg.payload);
|
|
1527
|
+
ack();
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1523
1530
|
case "Dispose": {
|
|
1524
1531
|
this.logCommand("Dispose", env);
|
|
1525
1532
|
await this.adapter.dispose();
|