@bian-womp/spark-workbench 0.3.39 → 0.3.41
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 -15
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/InMemoryWorkbench.d.ts +4 -0
- package/lib/cjs/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/cjs/src/core/contracts.d.ts +3 -0
- package/lib/cjs/src/core/contracts.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/esm/index.js +28 -16
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/InMemoryWorkbench.d.ts +4 -0
- package/lib/esm/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/esm/src/core/contracts.d.ts +3 -0
- package/lib/esm/src/core/contracts.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -342,6 +342,18 @@ class InMemoryWorkbench extends AbstractWorkbench {
|
|
|
342
342
|
change: { type: "updateParams", nodeId },
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
+
updateResolvedHandles(nodeId, resolvedHandles, options) {
|
|
346
|
+
const n = this._def.nodes.find((n) => n.nodeId === nodeId);
|
|
347
|
+
if (!n)
|
|
348
|
+
return;
|
|
349
|
+
n.resolvedHandles = { ...(n.resolvedHandles ?? {}), ...resolvedHandles };
|
|
350
|
+
this.emit("graphChanged", {
|
|
351
|
+
def: this._def,
|
|
352
|
+
change: { type: "updateResolvedHandles", nodeId },
|
|
353
|
+
...options,
|
|
354
|
+
});
|
|
355
|
+
this.refreshValidation();
|
|
356
|
+
}
|
|
345
357
|
// Position and selection APIs for React Flow bridge
|
|
346
358
|
setPositions(positions, options) {
|
|
347
359
|
this.positions = { ...this.positions, ...positions };
|
|
@@ -651,7 +663,7 @@ class InMemoryWorkbench extends AbstractWorkbench {
|
|
|
651
663
|
try {
|
|
652
664
|
if (!outputTypeId || outputValue === undefined)
|
|
653
665
|
return undefined;
|
|
654
|
-
const unwrap = (v) => sparkGraph.
|
|
666
|
+
const unwrap = (v) => (sparkGraph.isTyped(v) ? sparkGraph.unwrapValue(v) : v);
|
|
655
667
|
const coerceIfNeeded = async (fromType, toTypes, value) => {
|
|
656
668
|
if (!toTypes)
|
|
657
669
|
return value;
|
|
@@ -2188,10 +2200,10 @@ function formatDataUrlAsLabel(dataUrl) {
|
|
|
2188
2200
|
}
|
|
2189
2201
|
}
|
|
2190
2202
|
function resolveOutputDisplay(raw, declared) {
|
|
2191
|
-
if (sparkGraph.
|
|
2203
|
+
if (sparkGraph.isTyped(raw)) {
|
|
2192
2204
|
return {
|
|
2193
|
-
typeId: sparkGraph.
|
|
2194
|
-
value: sparkGraph.
|
|
2205
|
+
typeId: sparkGraph.unwrapTypeId(raw),
|
|
2206
|
+
value: sparkGraph.unwrapValue(raw),
|
|
2195
2207
|
};
|
|
2196
2208
|
}
|
|
2197
2209
|
let typeId = undefined;
|
|
@@ -2230,8 +2242,8 @@ function preformatValueForDisplay(typeId, value, registry) {
|
|
|
2230
2242
|
if (value === undefined || value === null)
|
|
2231
2243
|
return "";
|
|
2232
2244
|
// Unwrap typed outputs
|
|
2233
|
-
if (sparkGraph.
|
|
2234
|
-
return preformatValueForDisplay(sparkGraph.
|
|
2245
|
+
if (sparkGraph.isTyped(value)) {
|
|
2246
|
+
return preformatValueForDisplay(sparkGraph.unwrapTypeId(value), sparkGraph.unwrapValue(value), registry);
|
|
2235
2247
|
}
|
|
2236
2248
|
// Enums
|
|
2237
2249
|
if (typeId && typeId.startsWith("enum:") && registry) {
|
|
@@ -2263,8 +2275,8 @@ function summarizeDeep(value) {
|
|
|
2263
2275
|
return value.length > 512 ? value.slice(0, 512) + "…" : value;
|
|
2264
2276
|
}
|
|
2265
2277
|
// Typed output wrapper
|
|
2266
|
-
if (sparkGraph.
|
|
2267
|
-
return summarizeDeep(sparkGraph.
|
|
2278
|
+
if (sparkGraph.isTyped(value)) {
|
|
2279
|
+
return summarizeDeep(sparkGraph.unwrapValue(value));
|
|
2268
2280
|
}
|
|
2269
2281
|
// Arrays
|
|
2270
2282
|
if (Array.isArray(value)) {
|
|
@@ -4158,20 +4170,16 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
|
|
|
4158
4170
|
});
|
|
4159
4171
|
// Helper to apply resolved handles from event payload to workbench
|
|
4160
4172
|
const applyResolvedHandles = (resolvedHandles) => {
|
|
4161
|
-
let changed = false;
|
|
4162
4173
|
for (const n of wb.def.nodes) {
|
|
4163
4174
|
const updated = resolvedHandles[n.nodeId];
|
|
4164
4175
|
if (updated) {
|
|
4165
4176
|
const before = JSON.stringify(n.resolvedHandles || {});
|
|
4166
4177
|
const after = JSON.stringify(updated);
|
|
4167
4178
|
if (before !== after) {
|
|
4168
|
-
n.
|
|
4169
|
-
changed = true;
|
|
4179
|
+
wb.updateResolvedHandles(n.nodeId, updated);
|
|
4170
4180
|
}
|
|
4171
4181
|
}
|
|
4172
4182
|
}
|
|
4173
|
-
if (changed)
|
|
4174
|
-
wb.refreshValidation();
|
|
4175
4183
|
};
|
|
4176
4184
|
const offRunnerValue = runner.on("value", (e) => {
|
|
4177
4185
|
if (e?.dry)
|
|
@@ -4461,6 +4469,9 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
|
|
|
4461
4469
|
else if (changeType === "setInputs") {
|
|
4462
4470
|
reason = "set-inputs";
|
|
4463
4471
|
}
|
|
4472
|
+
else if (changeType === "updateResolvedHandles") {
|
|
4473
|
+
reason = "update-resolved-handles";
|
|
4474
|
+
}
|
|
4464
4475
|
}
|
|
4465
4476
|
if (event.change?.type === "setInputs") {
|
|
4466
4477
|
const { nodeId, inputs } = event.change;
|
|
@@ -5937,6 +5948,7 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
|
|
|
5937
5948
|
measured: n.measured,
|
|
5938
5949
|
data: n.data && {
|
|
5939
5950
|
typeId: n.data.typeId,
|
|
5951
|
+
handles: n.data.handles,
|
|
5940
5952
|
inputHandles: n.data.inputHandles,
|
|
5941
5953
|
outputHandles: n.data.outputHandles,
|
|
5942
5954
|
showValues: n.data.showValues,
|
|
@@ -6921,8 +6933,8 @@ function WorkbenchStudioCanvas({ autoScroll, onAutoScrollChange, example, onExam
|
|
|
6921
6933
|
if (value === undefined || value === null)
|
|
6922
6934
|
return "";
|
|
6923
6935
|
// Normalize typed wrapper
|
|
6924
|
-
if (sparkGraph.
|
|
6925
|
-
return baseToString(sparkGraph.
|
|
6936
|
+
if (sparkGraph.isTyped(value)) {
|
|
6937
|
+
return baseToString(sparkGraph.unwrapTypeId(value), sparkGraph.unwrapValue(value));
|
|
6926
6938
|
}
|
|
6927
6939
|
const pre = preformatValueForDisplay(typeId, value, wb.registry);
|
|
6928
6940
|
if (pre !== undefined)
|