@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 +27 -29
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/RemoteEngine.d.ts +1 -1
- package/lib/cjs/src/RemoteEngine.d.ts.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 +2 -2
- package/lib/cjs/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/lib/cjs/src/transport/Transport.d.ts.map +1 -1
- package/lib/esm/index.js +28 -30
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/RemoteEngine.d.ts +1 -1
- package/lib/esm/src/RemoteEngine.d.ts.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 +2 -2
- package/lib/esm/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/lib/esm/src/transport/Transport.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerCommandHandler.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerCommandHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAInE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EA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AAC;AAEnB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,QAAQ,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,KACxD,IAAI,CAAC;AAEV,qBAAa,oBAAoB;IAI7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO,CAAC;IAJlB,OAAO,CAAC,WAAW,CAA2B;gBAGpC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE;QAChB,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,YAAA;IAGH;;;OAGG;IACH,GAAG,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAIxC;;OAEG;IACG,aAAa,CACjB,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,EACtB,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;IAWhB;;OAEG;YACW,kBAAkB;IAgBhC;;OAEG;YACW,cAAc;IAwO5B;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB;;;;OAIG;IACH,OAAO,CAAC,WAAW;CA6BpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Envelope, RuntimeEvent, RuntimeMetadata } from "@bian-womp/spark-protocol";
|
|
2
|
-
import { GraphBuilder, Registry, GraphRuntime,
|
|
2
|
+
import { GraphBuilder, Registry, GraphRuntime, LocalEngine, type GraphLifecycleApi, type Engine } from "@bian-womp/spark-graph";
|
|
3
3
|
/**
|
|
4
4
|
* ServerRuntimeAdapter extends GraphLifecycleApi and Engine to provide a unified interface
|
|
5
5
|
* for both lifecycle and execution operations on the server side.
|
|
@@ -14,7 +14,7 @@ export interface ServerRuntimeAdapterContext {
|
|
|
14
14
|
registry: Registry;
|
|
15
15
|
builder: GraphBuilder;
|
|
16
16
|
graphRuntime: GraphRuntime | undefined;
|
|
17
|
-
engine:
|
|
17
|
+
engine: LocalEngine | undefined;
|
|
18
18
|
extData: {
|
|
19
19
|
runtime?: RuntimeMetadata;
|
|
20
20
|
} & Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerRuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAIZ,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"ServerRuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAIZ,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EAGX,KAAK,iBAAiB,EACtB,KAAK,MAAM,EAGZ,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,WAAW,oBACf,SAAQ,iBAAiB,EACvB,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;CAEzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;IACvC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,6BAA6B,GAAG;KACzC,CAAC,IAAI,MAAM,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAClE,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,GAAG,GACJ,CACE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,2BAA2B,EACpC,GAAG,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACzC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACxC,KAAK;CACV,CAAC;AAEF,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,EAClD,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,IAAI,EACzC,UAAU,CAAC,EAAE,6BAA6B,GACzC,OAAO,CAAC,oBAAoB,CAAC,CA8X/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CACzC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,SAAS,CAC5B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,GAAG,OAAO,EACpC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
|
-
import { GraphBuilder,
|
|
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
|
},
|
|
@@ -555,9 +559,8 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
555
559
|
update: async (def, options) => {
|
|
556
560
|
if (!graphRuntime)
|
|
557
561
|
return;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
graphRuntime.pause();
|
|
562
|
+
// Use requestPause for dry mode to temporarily pause without affecting base run mode
|
|
563
|
+
const releasePause = options?.dry ? graphRuntime.requestPause() : null;
|
|
561
564
|
try {
|
|
562
565
|
graphRuntime.update(def, registry);
|
|
563
566
|
send({
|
|
@@ -568,16 +571,14 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
568
571
|
});
|
|
569
572
|
}
|
|
570
573
|
finally {
|
|
571
|
-
|
|
572
|
-
graphRuntime.resume();
|
|
574
|
+
releasePause?.();
|
|
573
575
|
}
|
|
574
576
|
},
|
|
575
577
|
setEnvironment: async (env, opts) => {
|
|
576
578
|
if (!graphRuntime)
|
|
577
579
|
return;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
graphRuntime.pause();
|
|
580
|
+
// Use requestPause for dry mode to temporarily pause without affecting base run mode
|
|
581
|
+
const releasePause = opts?.dry ? graphRuntime.requestPause() : null;
|
|
581
582
|
try {
|
|
582
583
|
if (opts?.merge) {
|
|
583
584
|
const current = graphRuntime.getEnvironment();
|
|
@@ -589,8 +590,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
589
590
|
}
|
|
590
591
|
}
|
|
591
592
|
finally {
|
|
592
|
-
|
|
593
|
-
graphRuntime.resume();
|
|
593
|
+
releasePause?.();
|
|
594
594
|
}
|
|
595
595
|
},
|
|
596
596
|
setInputs: (nodeId, inputs, options) => {
|
|
@@ -618,7 +618,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
618
618
|
engine = undefined;
|
|
619
619
|
}
|
|
620
620
|
// Create new engine using shared factory
|
|
621
|
-
engine = new
|
|
621
|
+
engine = new LocalEngine(graphRuntime, opts?.runMode);
|
|
622
622
|
engine.launch(opts?.invalidate);
|
|
623
623
|
},
|
|
624
624
|
setRunMode: (runMode) => {
|
|
@@ -688,7 +688,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
688
688
|
applyRegistry: wrapMethod("applyRegistry", originalAdapter.applyRegistry),
|
|
689
689
|
build: wrapMethod("build", originalAdapter.build),
|
|
690
690
|
setExtData: wrapMethod("setExtData", originalAdapter.setExtData),
|
|
691
|
-
|
|
691
|
+
updateExtData: wrapMethod("updateExtData", originalAdapter.updateExtData),
|
|
692
692
|
snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
|
|
693
693
|
snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
|
|
694
694
|
applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
|
|
@@ -767,13 +767,8 @@ class RemoteEngine {
|
|
|
767
767
|
this.emit("stats", msg.payload);
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
launch(
|
|
771
|
-
|
|
772
|
-
message: {
|
|
773
|
-
type: "Launch",
|
|
774
|
-
payload: { runMode, invalidate },
|
|
775
|
-
},
|
|
776
|
-
});
|
|
770
|
+
launch() {
|
|
771
|
+
throw new Error("RemoteEngine.launch() is not supported. Use GraphLifecycleApi.launch() instead.");
|
|
777
772
|
}
|
|
778
773
|
setRunMode(runMode) {
|
|
779
774
|
this.transport.send({
|
|
@@ -971,13 +966,11 @@ class RemoteGraphLifecycleApi {
|
|
|
971
966
|
message: { type: "SetExtData", payload: data },
|
|
972
967
|
});
|
|
973
968
|
}
|
|
974
|
-
async
|
|
969
|
+
async updateExtData(updates) {
|
|
975
970
|
const transport = await this.ensureConnected();
|
|
976
|
-
|
|
977
|
-
message: { type: "
|
|
971
|
+
await transport.request({
|
|
972
|
+
message: { type: "UpdateExtData", payload: updates },
|
|
978
973
|
});
|
|
979
|
-
const payload = res?.message || {};
|
|
980
|
-
return payload.extData || {};
|
|
981
974
|
}
|
|
982
975
|
async setViewport(viewport) {
|
|
983
976
|
const transport = await this.ensureConnected();
|
|
@@ -1529,6 +1522,11 @@ class ServerCommandHandler {
|
|
|
1529
1522
|
ack();
|
|
1530
1523
|
break;
|
|
1531
1524
|
}
|
|
1525
|
+
case "UpdateExtData": {
|
|
1526
|
+
await this.adapter.updateExtData(msg.payload);
|
|
1527
|
+
ack();
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1532
1530
|
case "Dispose": {
|
|
1533
1531
|
this.logCommand("Dispose", env);
|
|
1534
1532
|
await this.adapter.dispose();
|