@bian-womp/spark-graph 0.2.63 → 0.2.64
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":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/misc/utils/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,QAAQ,CAAC;AAQhB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAEvE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,EACvB,SAAS,CAAC,EAAE,cAAc,GACzB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/misc/utils/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,QAAQ,CAAC;AAQhB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAA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,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D,CAwEA;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,EACJ,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,CAAC,GACvC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAUD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAwM3E"}
|
package/lib/esm/index.js
CHANGED
|
@@ -3755,7 +3755,7 @@ function mergeGraphDefinitions(target, source, converter) {
|
|
|
3755
3755
|
? transformedNode.resolvedHandles.inputs[handleId]
|
|
3756
3756
|
: transformedNode.resolvedHandles.inputs[handleId]?.typeId
|
|
3757
3757
|
: undefined;
|
|
3758
|
-
|
|
3758
|
+
const convertedValue = converter({
|
|
3759
3759
|
nodeId: newId,
|
|
3760
3760
|
handleId,
|
|
3761
3761
|
value,
|
|
@@ -3763,11 +3763,23 @@ function mergeGraphDefinitions(target, source, converter) {
|
|
|
3763
3763
|
nodeTypeId,
|
|
3764
3764
|
handleDataType,
|
|
3765
3765
|
});
|
|
3766
|
+
// If converter returns null, skip this input default (delete it)
|
|
3767
|
+
if (convertedValue !== null) {
|
|
3768
|
+
transformedInputDefaults[handleId] = convertedValue;
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
// Only set inputDefaults if there are any remaining after conversion
|
|
3772
|
+
if (Object.keys(transformedInputDefaults).length > 0) {
|
|
3773
|
+
transformedNode.resolvedHandles = {
|
|
3774
|
+
...transformedNode.resolvedHandles,
|
|
3775
|
+
inputDefaults: transformedInputDefaults,
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
else if (transformedNode.resolvedHandles) {
|
|
3779
|
+
// Remove inputDefaults if all were deleted
|
|
3780
|
+
const { inputDefaults, ...restHandles } = transformedNode.resolvedHandles;
|
|
3781
|
+
transformedNode.resolvedHandles = restHandles;
|
|
3766
3782
|
}
|
|
3767
|
-
transformedNode.resolvedHandles = {
|
|
3768
|
-
...transformedNode.resolvedHandles,
|
|
3769
|
-
inputDefaults: transformedInputDefaults,
|
|
3770
|
-
};
|
|
3771
3783
|
}
|
|
3772
3784
|
}
|
|
3773
3785
|
return transformedNode;
|
|
@@ -3850,16 +3862,28 @@ function offsetImportedPositions(targetPositions, sourcePositions, sourceDef, no
|
|
|
3850
3862
|
* Source values override target when merging.
|
|
3851
3863
|
*/
|
|
3852
3864
|
function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOutputs, nodeIdMap, converter, nodeTypeMap, handleTypeMap) {
|
|
3853
|
-
|
|
3854
|
-
const
|
|
3865
|
+
// Deep copy target inputs/outputs to avoid mutating the original
|
|
3866
|
+
const mergedInputs = {};
|
|
3867
|
+
const mergedOutputs = {};
|
|
3868
|
+
// Copy target inputs/outputs
|
|
3869
|
+
for (const [nodeId, inputs] of Object.entries(targetInputs)) {
|
|
3870
|
+
mergedInputs[nodeId] = { ...inputs };
|
|
3871
|
+
}
|
|
3872
|
+
for (const [nodeId, outputs] of Object.entries(targetOutputs)) {
|
|
3873
|
+
mergedOutputs[nodeId] = { ...outputs };
|
|
3874
|
+
}
|
|
3855
3875
|
for (const [oldId, inputs] of Object.entries(sourceInputs)) {
|
|
3856
3876
|
const newId = nodeIdMap[oldId];
|
|
3857
3877
|
if (newId) {
|
|
3858
3878
|
const transformedInputs = {};
|
|
3859
3879
|
const nodeTypeId = nodeTypeMap?.get(oldId);
|
|
3880
|
+
// Ensure mergedInputs[newId] exists
|
|
3881
|
+
if (!mergedInputs[newId]) {
|
|
3882
|
+
mergedInputs[newId] = {};
|
|
3883
|
+
}
|
|
3860
3884
|
for (const [handleId, value] of Object.entries(inputs)) {
|
|
3861
3885
|
const handleDataType = handleTypeMap?.get(oldId)?.get(handleId);
|
|
3862
|
-
|
|
3886
|
+
const convertedValue = converter
|
|
3863
3887
|
? converter({
|
|
3864
3888
|
nodeId: newId,
|
|
3865
3889
|
handleId,
|
|
@@ -3869,10 +3893,23 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
3869
3893
|
handleDataType,
|
|
3870
3894
|
})
|
|
3871
3895
|
: value;
|
|
3896
|
+
// If converter returns null, delete this input
|
|
3897
|
+
if (convertedValue === null) {
|
|
3898
|
+
delete mergedInputs[newId][handleId];
|
|
3899
|
+
}
|
|
3900
|
+
else {
|
|
3901
|
+
// Otherwise, set the converted value
|
|
3902
|
+
transformedInputs[handleId] = convertedValue;
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
// Merge transformed inputs
|
|
3906
|
+
if (Object.keys(transformedInputs).length > 0) {
|
|
3907
|
+
mergedInputs[newId] = { ...mergedInputs[newId], ...transformedInputs };
|
|
3908
|
+
}
|
|
3909
|
+
// Clean up empty node input objects
|
|
3910
|
+
if (Object.keys(mergedInputs[newId]).length === 0) {
|
|
3911
|
+
delete mergedInputs[newId];
|
|
3872
3912
|
}
|
|
3873
|
-
mergedInputs[newId] = mergedInputs[newId]
|
|
3874
|
-
? { ...mergedInputs[newId], ...transformedInputs }
|
|
3875
|
-
: transformedInputs;
|
|
3876
3913
|
}
|
|
3877
3914
|
}
|
|
3878
3915
|
for (const [oldId, outputs] of Object.entries(sourceOutputs)) {
|
|
@@ -3880,12 +3917,16 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
3880
3917
|
if (newId) {
|
|
3881
3918
|
const transformedOutputs = {};
|
|
3882
3919
|
const nodeTypeId = nodeTypeMap?.get(oldId);
|
|
3920
|
+
// Ensure mergedOutputs[newId] exists
|
|
3921
|
+
if (!mergedOutputs[newId]) {
|
|
3922
|
+
mergedOutputs[newId] = {};
|
|
3923
|
+
}
|
|
3883
3924
|
for (const [handleId, value] of Object.entries(outputs)) {
|
|
3884
3925
|
const handleDataType = handleTypeMap?.get(oldId)?.get(handleId);
|
|
3885
3926
|
const runtimeTypeId = isTypedOutput(value)
|
|
3886
3927
|
? getTypedOutputTypeId(value)
|
|
3887
3928
|
: undefined;
|
|
3888
|
-
|
|
3929
|
+
const convertedValue = converter
|
|
3889
3930
|
? converter({
|
|
3890
3931
|
nodeId: newId,
|
|
3891
3932
|
handleId,
|
|
@@ -3896,10 +3937,26 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
3896
3937
|
runtimeTypeId,
|
|
3897
3938
|
})
|
|
3898
3939
|
: value;
|
|
3940
|
+
// If converter returns null, delete this output
|
|
3941
|
+
if (convertedValue === null) {
|
|
3942
|
+
delete mergedOutputs[newId][handleId];
|
|
3943
|
+
}
|
|
3944
|
+
else {
|
|
3945
|
+
// Otherwise, set the converted value
|
|
3946
|
+
transformedOutputs[handleId] = convertedValue;
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
// Merge transformed outputs
|
|
3950
|
+
if (Object.keys(transformedOutputs).length > 0) {
|
|
3951
|
+
mergedOutputs[newId] = {
|
|
3952
|
+
...mergedOutputs[newId],
|
|
3953
|
+
...transformedOutputs,
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
// Clean up empty node output objects
|
|
3957
|
+
if (Object.keys(mergedOutputs[newId]).length === 0) {
|
|
3958
|
+
delete mergedOutputs[newId];
|
|
3899
3959
|
}
|
|
3900
|
-
mergedOutputs[newId] = mergedOutputs[newId]
|
|
3901
|
-
? { ...mergedOutputs[newId], ...transformedOutputs }
|
|
3902
|
-
: transformedOutputs;
|
|
3903
3960
|
}
|
|
3904
3961
|
}
|
|
3905
3962
|
return { mergedInputs, mergedOutputs };
|
|
@@ -4018,10 +4075,14 @@ function buildValueConverter(config) {
|
|
|
4018
4075
|
}
|
|
4019
4076
|
}
|
|
4020
4077
|
if (changed && newValue !== matchValue) {
|
|
4078
|
+
// If mapped to null, set null at the path (which may delete nested property)
|
|
4021
4079
|
setValueAtPath(transformedInner, match.path, newValue);
|
|
4022
4080
|
}
|
|
4023
4081
|
}
|
|
4024
4082
|
}
|
|
4083
|
+
// If the entire typed output should be deleted (all paths mapped to null),
|
|
4084
|
+
// we'd need to check if the whole inner value is null/empty, but for now
|
|
4085
|
+
// we'll return the transformed value or original
|
|
4025
4086
|
return changed ? typed(typedTypeId, transformedInner) : value;
|
|
4026
4087
|
}
|
|
4027
4088
|
}
|
|
@@ -4031,6 +4092,10 @@ function buildValueConverter(config) {
|
|
|
4031
4092
|
if (mapping.valueMap instanceof Map) {
|
|
4032
4093
|
if (mapping.valueMap.has(innerValue)) {
|
|
4033
4094
|
newValue = mapping.valueMap.get(innerValue);
|
|
4095
|
+
// If mapped to null, return null to delete the output
|
|
4096
|
+
if (newValue === null) {
|
|
4097
|
+
return null;
|
|
4098
|
+
}
|
|
4034
4099
|
return typed(typedTypeId, newValue);
|
|
4035
4100
|
}
|
|
4036
4101
|
}
|
|
@@ -4039,6 +4104,10 @@ function buildValueConverter(config) {
|
|
|
4039
4104
|
typeof innerValue === "number") {
|
|
4040
4105
|
if (innerValue in mapping.valueMap) {
|
|
4041
4106
|
newValue = mapping.valueMap[innerValue];
|
|
4107
|
+
// If mapped to null, return null to delete the output
|
|
4108
|
+
if (newValue === null) {
|
|
4109
|
+
return null;
|
|
4110
|
+
}
|
|
4042
4111
|
return typed(typedTypeId, newValue);
|
|
4043
4112
|
}
|
|
4044
4113
|
}
|