@bian-womp/spark-remote 0.2.67 → 0.2.69

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputEncoding.d.ts","sourceRoot":"","sources":["../../../../src/utils/inputEncoding.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;CAAkC,CAAC;AAE5D,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,YAAY,CAO1E;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB"}
package/lib/esm/index.js CHANGED
@@ -443,6 +443,14 @@ async function createRuntimeAdapter(createRegistry, send, extensions) {
443
443
  });
444
444
  originalApi.setExtData(payload.extData || {});
445
445
  },
446
+ cancelNodeRuns: (nodeIds) => {
447
+ graphRuntime?.cancelNodeRuns(nodeIds);
448
+ },
449
+ commit: async () => { },
450
+ undo: async () => false,
451
+ redo: async () => false,
452
+ canUndo: async () => false,
453
+ canRedo: async () => false,
446
454
  describeRegistry: () => {
447
455
  // types (include enum options when available)
448
456
  const types = Array.from(registry.types.entries()).map(([id, d]) => {
@@ -653,10 +661,38 @@ async function createRuntimeAdapter(createRegistry, send, extensions) {
653
661
  launch: wrapMethod("launch", originalApi.launch),
654
662
  whenIdle: wrapMethod("whenIdle", originalApi.whenIdle),
655
663
  dispose: wrapMethod("dispose", originalApi.dispose),
664
+ commit: wrapMethod("commit", originalApi.commit),
665
+ cancelNodeRuns: wrapMethod("cancelNodeRuns", originalApi.cancelNodeRuns),
666
+ undo: wrapMethod("undo", originalApi.undo),
667
+ redo: wrapMethod("redo", originalApi.redo),
668
+ canUndo: wrapMethod("canUndo", originalApi.canUndo),
669
+ canRedo: wrapMethod("canRedo", originalApi.canRedo),
656
670
  };
657
671
  return extendedApi;
658
672
  }
659
673
 
674
+ const UNSET_MARKER = { __sparkUnset: true };
675
+ function isUnsetMarker(value) {
676
+ return (typeof value === "object" &&
677
+ value !== null &&
678
+ "__sparkUnset" in value &&
679
+ value.__sparkUnset === true);
680
+ }
681
+ function encodeInputsForTransport(inputs) {
682
+ const encoded = {};
683
+ for (const [key, value] of Object.entries(inputs)) {
684
+ encoded[key] = value === undefined ? UNSET_MARKER : value;
685
+ }
686
+ return encoded;
687
+ }
688
+ function decodeInputsFromTransport(inputs) {
689
+ const decoded = {};
690
+ for (const [key, value] of Object.entries(inputs)) {
691
+ decoded[key] = isUnsetMarker(value) ? undefined : value;
692
+ }
693
+ return decoded;
694
+ }
695
+
660
696
  class RemoteEngine {
661
697
  constructor(transport) {
662
698
  this.transport = transport;
@@ -694,12 +730,12 @@ class RemoteEngine {
694
730
  },
695
731
  });
696
732
  }
697
- // Batch inputs for a single network round-trip
698
733
  setInputs(nodeId, inputs, options) {
734
+ const encodedInputs = encodeInputsForTransport(inputs);
699
735
  this.transport.send({
700
736
  message: {
701
737
  type: "SetInputs",
702
- payload: { nodeId, inputs },
738
+ payload: { nodeId, inputs: encodedInputs },
703
739
  dry: options?.dry,
704
740
  },
705
741
  });
@@ -1027,6 +1063,16 @@ class RuntimeApiClient {
1027
1063
  message: { type: "RegistryApply", payload: { deltas } },
1028
1064
  });
1029
1065
  }
1066
+ async setInputs(nodeId, inputs, options) {
1067
+ const transport = await this.ensureConnected();
1068
+ await transport.request({
1069
+ message: {
1070
+ type: "SetInputs",
1071
+ payload: { nodeId, inputs },
1072
+ dry: options?.dry,
1073
+ },
1074
+ });
1075
+ }
1030
1076
  async snapshot() {
1031
1077
  const transport = await this.ensureConnected();
1032
1078
  const res = await transport.request({
@@ -1133,6 +1179,44 @@ class RuntimeApiClient {
1133
1179
  message: { type: "SetExtData", payload: data },
1134
1180
  });
1135
1181
  }
1182
+ async commit() {
1183
+ const transport = await this.ensureConnected();
1184
+ await transport.request({
1185
+ message: { type: "Commit" },
1186
+ });
1187
+ }
1188
+ async undo() {
1189
+ const transport = await this.ensureConnected();
1190
+ const res = await transport.request({
1191
+ message: { type: "Undo" },
1192
+ });
1193
+ const payload = res?.message || {};
1194
+ return payload.success ?? false;
1195
+ }
1196
+ async redo() {
1197
+ const transport = await this.ensureConnected();
1198
+ const res = await transport.request({
1199
+ message: { type: "Redo" },
1200
+ });
1201
+ const payload = res?.message || {};
1202
+ return payload.success ?? false;
1203
+ }
1204
+ async canUndo() {
1205
+ const transport = await this.ensureConnected();
1206
+ const res = await transport.request({
1207
+ message: { type: "CanUndo" },
1208
+ });
1209
+ const payload = res?.message || {};
1210
+ return payload.canUndo ?? false;
1211
+ }
1212
+ async canRedo() {
1213
+ const transport = await this.ensureConnected();
1214
+ const res = await transport.request({
1215
+ message: { type: "CanRedo" },
1216
+ });
1217
+ const payload = res?.message || {};
1218
+ return payload.canRedo ?? false;
1219
+ }
1136
1220
  /**
1137
1221
  * Dispose the client and close the transport connection.
1138
1222
  * Idempotent: safe to call multiple times.
@@ -1255,7 +1339,7 @@ class RuntimeApiServer {
1255
1339
  dry: !!dry,
1256
1340
  });
1257
1341
  const nodeId = msg.payload.nodeId;
1258
- const inputs = msg.payload.inputs;
1342
+ const inputs = decodeInputsFromTransport(msg.payload.inputs);
1259
1343
  this.runtimeApi.setInputs(nodeId, inputs, { dry });
1260
1344
  ack();
1261
1345
  break;
@@ -1388,6 +1472,36 @@ class RuntimeApiServer {
1388
1472
  ack();
1389
1473
  break;
1390
1474
  }
1475
+ case "Commit": {
1476
+ this.logCommand("Commit", env);
1477
+ await this.runtimeApi.commit();
1478
+ ack();
1479
+ break;
1480
+ }
1481
+ case "Undo": {
1482
+ this.logCommand("Undo", env);
1483
+ const success = await this.runtimeApi.undo();
1484
+ ack({ success });
1485
+ break;
1486
+ }
1487
+ case "Redo": {
1488
+ this.logCommand("Redo", env);
1489
+ const success = await this.runtimeApi.redo();
1490
+ ack({ success });
1491
+ break;
1492
+ }
1493
+ case "CanUndo": {
1494
+ this.logCommand("CanUndo", env);
1495
+ const canUndo = await this.runtimeApi.canUndo();
1496
+ ack({ canUndo });
1497
+ break;
1498
+ }
1499
+ case "CanRedo": {
1500
+ this.logCommand("CanRedo", env);
1501
+ const canRedo = await this.runtimeApi.canRedo();
1502
+ ack({ canRedo });
1503
+ break;
1504
+ }
1391
1505
  default: {
1392
1506
  this.logCommand("Unknown type", env);
1393
1507
  ack();