@bian-womp/spark-graph 0.2.3 → 0.2.4
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 +31 -17
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/base.d.ts.map +1 -1
- package/lib/cjs/src/plugins/compute.d.ts.map +1 -1
- package/lib/esm/index.js +31 -17
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/base.d.ts.map +1 -1
- package/lib/esm/src/plugins/compute.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -1767,6 +1767,30 @@ const ComputeCategory = {
|
|
|
1767
1767
|
ctx.emit(h, v);
|
|
1768
1768
|
}
|
|
1769
1769
|
},
|
|
1770
|
+
onExternalEvent(event, ctx) {
|
|
1771
|
+
try {
|
|
1772
|
+
const e = event;
|
|
1773
|
+
// Preferred: call a function on ctx.state keyed by e.action
|
|
1774
|
+
const action = e?.action;
|
|
1775
|
+
if (action && typeof ctx.state?.[action] === "function") {
|
|
1776
|
+
const fn = ctx.state[action];
|
|
1777
|
+
// Normalize args: prefer explicit args array, else wrap single value;
|
|
1778
|
+
let args = [];
|
|
1779
|
+
if (Array.isArray(e?.args))
|
|
1780
|
+
args = [...e.args];
|
|
1781
|
+
else if (e?.args !== undefined)
|
|
1782
|
+
args = [e.args];
|
|
1783
|
+
else if (e?.params !== undefined)
|
|
1784
|
+
args = [e.params];
|
|
1785
|
+
void fn(...args);
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
console.warn("Unsupported external event", event);
|
|
1789
|
+
}
|
|
1790
|
+
catch {
|
|
1791
|
+
console.warn("Error handling external event", event);
|
|
1792
|
+
}
|
|
1793
|
+
},
|
|
1770
1794
|
}),
|
|
1771
1795
|
policy: { mode: "push", asyncConcurrency: "switch" },
|
|
1772
1796
|
};
|
|
@@ -2118,36 +2142,26 @@ function setupBasicGraphRegistry() {
|
|
|
2118
2142
|
});
|
|
2119
2143
|
// Number
|
|
2120
2144
|
registry.registerNode({
|
|
2121
|
-
id: "base.number",
|
|
2145
|
+
id: "base.input.number",
|
|
2122
2146
|
categoryId: "compute",
|
|
2123
2147
|
inputs: { Value: "base.float" },
|
|
2124
2148
|
outputs: { Result: "base.float" },
|
|
2125
2149
|
impl: (ins) => ({ Result: Number(ins.Value) }),
|
|
2126
2150
|
});
|
|
2127
2151
|
registry.registerNode({
|
|
2128
|
-
id: "base.string",
|
|
2152
|
+
id: "base.input.string",
|
|
2129
2153
|
categoryId: "compute",
|
|
2130
2154
|
inputs: { Value: "base.string" },
|
|
2131
2155
|
outputs: { Result: "base.string" },
|
|
2132
2156
|
impl: (ins) => ({ Result: String(ins.Value) }),
|
|
2133
2157
|
});
|
|
2134
2158
|
registry.registerNode({
|
|
2135
|
-
id: "base.bool",
|
|
2159
|
+
id: "base.input.bool",
|
|
2136
2160
|
categoryId: "compute",
|
|
2137
2161
|
inputs: { Value: "base.bool" },
|
|
2138
2162
|
outputs: { Result: "base.bool" },
|
|
2139
2163
|
impl: (ins) => ({ Result: Boolean(ins.Value) }),
|
|
2140
2164
|
});
|
|
2141
|
-
// Integer
|
|
2142
|
-
registry.registerNode({
|
|
2143
|
-
id: "base.int",
|
|
2144
|
-
categoryId: "compute",
|
|
2145
|
-
inputs: { Value: "base.float" },
|
|
2146
|
-
outputs: { Result: "base.float" },
|
|
2147
|
-
impl: (ins) => ({
|
|
2148
|
-
Result: Math.trunc(Number(ins.Value)),
|
|
2149
|
-
}),
|
|
2150
|
-
});
|
|
2151
2165
|
// JSON parser node: base.stringToObject
|
|
2152
2166
|
registry.registerNode({
|
|
2153
2167
|
id: "base.string.toObject",
|
|
@@ -2966,8 +2980,8 @@ function createAsyncGraphRegistry() {
|
|
|
2966
2980
|
function createProgressGraphDef() {
|
|
2967
2981
|
const def = {
|
|
2968
2982
|
nodes: [
|
|
2969
|
-
{ nodeId: "steps", typeId: "base.number" },
|
|
2970
|
-
{ nodeId: "delay", typeId: "base.number" },
|
|
2983
|
+
{ nodeId: "steps", typeId: "base.input.number" },
|
|
2984
|
+
{ nodeId: "delay", typeId: "base.input.number" },
|
|
2971
2985
|
{ nodeId: "work", typeId: "async.progress" },
|
|
2972
2986
|
],
|
|
2973
2987
|
edges: [
|
|
@@ -2999,8 +3013,8 @@ function createValidationGraphDef() {
|
|
|
2999
3013
|
// - Multi inbound to same input
|
|
3000
3014
|
const def = {
|
|
3001
3015
|
nodes: [
|
|
3002
|
-
{ nodeId: "nA", typeId: "base.number" },
|
|
3003
|
-
{ nodeId: "nB", typeId: "base.number" },
|
|
3016
|
+
{ nodeId: "nA", typeId: "base.input.number" },
|
|
3017
|
+
{ nodeId: "nB", typeId: "base.input.number" },
|
|
3004
3018
|
{ nodeId: "nC", typeId: "base.math" },
|
|
3005
3019
|
{ nodeId: "s1", typeId: "base.object.toString" },
|
|
3006
3020
|
{ nodeId: "cmp", typeId: "base.compare" },
|