@bian-womp/spark-graph 0.2.1 → 0.2.2
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 +49 -27
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/base.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +49 -27
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/base.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -803,6 +803,10 @@ class GraphRuntime {
|
|
|
803
803
|
propagate(srcNodeId, srcHandle, value) {
|
|
804
804
|
// set source output
|
|
805
805
|
const srcNode = this.nodes.get(srcNodeId);
|
|
806
|
+
if (!srcNode) {
|
|
807
|
+
// Node was removed (e.g., graph updated) but an async emit arrived late; ignore
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
806
810
|
srcNode.outputs[srcHandle] = value;
|
|
807
811
|
this.emit("value", {
|
|
808
812
|
nodeId: srcNodeId,
|
|
@@ -2008,35 +2012,38 @@ function setupBasicGraphRegistry() {
|
|
|
2008
2012
|
registry.registerCoercion("base.string", "base.float", (v) => Number(v));
|
|
2009
2013
|
// Object <-> String
|
|
2010
2014
|
registry.registerCoercion("base.string", "base.object", (v) => {
|
|
2011
|
-
|
|
2012
|
-
return JSON.parse(String(v));
|
|
2013
|
-
}
|
|
2014
|
-
catch {
|
|
2015
|
-
return undefined;
|
|
2016
|
-
}
|
|
2015
|
+
return v;
|
|
2017
2016
|
});
|
|
2018
2017
|
registry.registerCoercion("base.object", "base.string", (v) => {
|
|
2019
|
-
|
|
2020
|
-
return
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2018
|
+
if (typeof v === "string")
|
|
2019
|
+
return v;
|
|
2020
|
+
return undefined;
|
|
2021
|
+
});
|
|
2022
|
+
registry.registerCoercion("base.bool", "base.object", (v) => {
|
|
2023
|
+
return v;
|
|
2024
|
+
});
|
|
2025
|
+
registry.registerCoercion("base.object", "base.bool", (v) => {
|
|
2026
|
+
if (typeof v === "boolean")
|
|
2027
|
+
return v;
|
|
2028
|
+
return undefined;
|
|
2029
|
+
});
|
|
2030
|
+
registry.registerCoercion("base.float", "base.object", (v) => {
|
|
2031
|
+
return v;
|
|
2032
|
+
});
|
|
2033
|
+
registry.registerCoercion("base.object", "base.float", (v) => {
|
|
2034
|
+
if (typeof v === "number")
|
|
2035
|
+
return v;
|
|
2036
|
+
return undefined;
|
|
2025
2037
|
});
|
|
2026
2038
|
registry.registerCoercion("base.vec3", "base.object", (v) => {
|
|
2027
|
-
|
|
2028
|
-
return v ? JSON.stringify(v) : undefined;
|
|
2029
|
-
}
|
|
2030
|
-
catch {
|
|
2031
|
-
return undefined;
|
|
2032
|
-
}
|
|
2039
|
+
return v;
|
|
2033
2040
|
});
|
|
2034
2041
|
registry.registerCoercion("base.object", "base.vec3", (v) => {
|
|
2035
2042
|
try {
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
return
|
|
2043
|
+
if (Array.isArray(v) &&
|
|
2044
|
+
v.length === 3 &&
|
|
2045
|
+
v.every((x) => typeof x === "number")) {
|
|
2046
|
+
return v;
|
|
2040
2047
|
}
|
|
2041
2048
|
return undefined;
|
|
2042
2049
|
}
|
|
@@ -2117,6 +2124,20 @@ function setupBasicGraphRegistry() {
|
|
|
2117
2124
|
outputs: { Result: "base.float" },
|
|
2118
2125
|
impl: (ins) => ({ Result: Number(ins.Value) }),
|
|
2119
2126
|
});
|
|
2127
|
+
registry.registerNode({
|
|
2128
|
+
id: "base.string",
|
|
2129
|
+
categoryId: "compute",
|
|
2130
|
+
inputs: { Value: "base.string" },
|
|
2131
|
+
outputs: { Result: "base.string" },
|
|
2132
|
+
impl: (ins) => ({ Result: String(ins.Value) }),
|
|
2133
|
+
});
|
|
2134
|
+
registry.registerNode({
|
|
2135
|
+
id: "base.bool",
|
|
2136
|
+
categoryId: "compute",
|
|
2137
|
+
inputs: { Value: "base.bool" },
|
|
2138
|
+
outputs: { Result: "base.bool" },
|
|
2139
|
+
impl: (ins) => ({ Result: Boolean(ins.Value) }),
|
|
2140
|
+
});
|
|
2120
2141
|
// Integer
|
|
2121
2142
|
registry.registerNode({
|
|
2122
2143
|
id: "base.int",
|
|
@@ -2144,13 +2165,14 @@ function setupBasicGraphRegistry() {
|
|
|
2144
2165
|
}
|
|
2145
2166
|
},
|
|
2146
2167
|
});
|
|
2147
|
-
// Number to String
|
|
2148
2168
|
registry.registerNode({
|
|
2149
|
-
id: "base.
|
|
2169
|
+
id: "base.objectToString",
|
|
2150
2170
|
categoryId: "compute",
|
|
2151
|
-
inputs: {
|
|
2171
|
+
inputs: { Object: "base.object" },
|
|
2152
2172
|
outputs: { Text: "base.string" },
|
|
2153
|
-
impl: (ins) =>
|
|
2173
|
+
impl: (ins) => {
|
|
2174
|
+
return { Text: JSON.stringify(ins.Object) };
|
|
2175
|
+
},
|
|
2154
2176
|
});
|
|
2155
2177
|
// Clamp
|
|
2156
2178
|
registry.registerNode({
|
|
@@ -2980,7 +3002,7 @@ function createValidationGraphDef() {
|
|
|
2980
3002
|
{ nodeId: "nA", typeId: "base.number" },
|
|
2981
3003
|
{ nodeId: "nB", typeId: "base.number" },
|
|
2982
3004
|
{ nodeId: "nC", typeId: "base.math" },
|
|
2983
|
-
{ nodeId: "s1", typeId: "base.
|
|
3005
|
+
{ nodeId: "s1", typeId: "base.objectToString" },
|
|
2984
3006
|
{ nodeId: "cmp", typeId: "base.compare" },
|
|
2985
3007
|
// Global validation issue: unknown node type (no nodeId/edgeId in data)
|
|
2986
3008
|
{ nodeId: "bad", typeId: "unknownType" },
|