@bian-womp/spark-remote 0.3.65 → 0.3.67
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.
|
@@ -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,EAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EAGX,KAAK,iBAAiB,EACtB,KAAK,MAAM,EAKZ,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,WAAW,oBACf,SAAQ,iBAAiB,EACvB,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;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,OAAO,CACX,MAAM,oBAAoB,EAC1B,iBAAiB,CAClB,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACxD,CACE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,2BAA2B,EACpC,GAAG,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACzC,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CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACxD,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,CAwe/B"}
|
package/lib/esm/index.js
CHANGED
|
@@ -375,6 +375,43 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
375
375
|
let graphRuntime;
|
|
376
376
|
let engine;
|
|
377
377
|
let extData = {};
|
|
378
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
379
|
+
const getCustomNodeDataFromExtData = (data) => {
|
|
380
|
+
if (!data)
|
|
381
|
+
return undefined;
|
|
382
|
+
const custom = isRecord(data.custom) ? data.custom : undefined;
|
|
383
|
+
if (!custom)
|
|
384
|
+
return undefined;
|
|
385
|
+
const nodes = isRecord(custom.nodes) ? custom.nodes : undefined;
|
|
386
|
+
if (!nodes)
|
|
387
|
+
return undefined;
|
|
388
|
+
const sanitized = {};
|
|
389
|
+
for (const [nodeId, nodeData] of Object.entries(nodes)) {
|
|
390
|
+
if (isRecord(nodeData))
|
|
391
|
+
sanitized[nodeId] = nodeData;
|
|
392
|
+
}
|
|
393
|
+
return Object.keys(sanitized).length > 0 ? sanitized : undefined;
|
|
394
|
+
};
|
|
395
|
+
const areCustomNodeDataEqual = (left, right) => {
|
|
396
|
+
if (!left && !right)
|
|
397
|
+
return true;
|
|
398
|
+
if (!left || !right)
|
|
399
|
+
return false;
|
|
400
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
401
|
+
};
|
|
402
|
+
const syncCustomNodeDataToRuntime = () => {
|
|
403
|
+
if (!graphRuntime)
|
|
404
|
+
return;
|
|
405
|
+
const customNodeData = getCustomNodeDataFromExtData(extData);
|
|
406
|
+
const existingCustomNodeData = graphRuntime.getCustomNodeData();
|
|
407
|
+
const sanitizedExisting = Object.keys(existingCustomNodeData).length
|
|
408
|
+
? existingCustomNodeData
|
|
409
|
+
: undefined;
|
|
410
|
+
if (areCustomNodeDataEqual(sanitizedExisting, customNodeData)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
graphRuntime.setCustomNodeData(customNodeData ?? {});
|
|
414
|
+
};
|
|
378
415
|
// Helper to get current context
|
|
379
416
|
const getContext = () => ({
|
|
380
417
|
registry,
|
|
@@ -467,6 +504,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
467
504
|
environment,
|
|
468
505
|
startPaused: opts?.startPaused,
|
|
469
506
|
});
|
|
507
|
+
syncCustomNodeDataToRuntime();
|
|
470
508
|
graphRuntime.on("value", (p) => send({ message: { type: "value", payload: p } }));
|
|
471
509
|
graphRuntime.on("invalidate", (p) => send({ message: { type: "invalidate", payload: p } }));
|
|
472
510
|
graphRuntime.on("error", (p) => send({ message: { type: "error", payload: p } }));
|
|
@@ -476,11 +514,13 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
476
514
|
if (!data || typeof data !== "object") {
|
|
477
515
|
// Clear all extData when called with non-object (backward-compatible)
|
|
478
516
|
extData = {};
|
|
517
|
+
syncCustomNodeDataToRuntime();
|
|
479
518
|
return;
|
|
480
519
|
}
|
|
481
520
|
// Merge with existing extData so that callers can update a subset of fields
|
|
482
521
|
// (e.g., { ui } or { runtime }) without dropping the other ones.
|
|
483
522
|
extData = { ...extData, ...data };
|
|
523
|
+
syncCustomNodeDataToRuntime();
|
|
484
524
|
},
|
|
485
525
|
updateExtData: async (updates) => {
|
|
486
526
|
if (!extData || typeof extData !== "object" || Array.isArray(extData)) {
|
|
@@ -494,6 +534,9 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
494
534
|
hasCustomUpdate = true;
|
|
495
535
|
}
|
|
496
536
|
}
|
|
537
|
+
if (hasCustomUpdate) {
|
|
538
|
+
syncCustomNodeDataToRuntime();
|
|
539
|
+
}
|
|
497
540
|
return hasCustomUpdate;
|
|
498
541
|
},
|
|
499
542
|
snapshot: async () => {
|