@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/misc/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,eAAe,CAAC;AA+IvB,wBAAgB,uBAAuB,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/misc/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,eAAe,CAAC;AA+IvB,wBAAgB,uBAAuB,IAAI,QAAQ,CAk4BlD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,QA+BnD;AAqBD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,QA6BvD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,6BAUrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../../src/plugins/compute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,GAAG,EAAE,gBAAgB,CAAC,GAAG,CAAC,KACvB,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9E,eAAO,MAAM,eAAe,EAAE,sBAAsB,CAAC,WAAW,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../../src/plugins/compute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,GAAG,EAAE,gBAAgB,CAAC,GAAG,CAAC,KACvB,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9E,eAAO,MAAM,eAAe,EAAE,sBAAsB,CAAC,WAAW,EAAE,EAAE,CAgCnE,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1765,6 +1765,30 @@ const ComputeCategory = {
|
|
|
1765
1765
|
ctx.emit(h, v);
|
|
1766
1766
|
}
|
|
1767
1767
|
},
|
|
1768
|
+
onExternalEvent(event, ctx) {
|
|
1769
|
+
try {
|
|
1770
|
+
const e = event;
|
|
1771
|
+
// Preferred: call a function on ctx.state keyed by e.action
|
|
1772
|
+
const action = e?.action;
|
|
1773
|
+
if (action && typeof ctx.state?.[action] === "function") {
|
|
1774
|
+
const fn = ctx.state[action];
|
|
1775
|
+
// Normalize args: prefer explicit args array, else wrap single value;
|
|
1776
|
+
let args = [];
|
|
1777
|
+
if (Array.isArray(e?.args))
|
|
1778
|
+
args = [...e.args];
|
|
1779
|
+
else if (e?.args !== undefined)
|
|
1780
|
+
args = [e.args];
|
|
1781
|
+
else if (e?.params !== undefined)
|
|
1782
|
+
args = [e.params];
|
|
1783
|
+
void fn(...args);
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
console.warn("Unsupported external event", event);
|
|
1787
|
+
}
|
|
1788
|
+
catch {
|
|
1789
|
+
console.warn("Error handling external event", event);
|
|
1790
|
+
}
|
|
1791
|
+
},
|
|
1768
1792
|
}),
|
|
1769
1793
|
policy: { mode: "push", asyncConcurrency: "switch" },
|
|
1770
1794
|
};
|
|
@@ -2116,36 +2140,26 @@ function setupBasicGraphRegistry() {
|
|
|
2116
2140
|
});
|
|
2117
2141
|
// Number
|
|
2118
2142
|
registry.registerNode({
|
|
2119
|
-
id: "base.number",
|
|
2143
|
+
id: "base.input.number",
|
|
2120
2144
|
categoryId: "compute",
|
|
2121
2145
|
inputs: { Value: "base.float" },
|
|
2122
2146
|
outputs: { Result: "base.float" },
|
|
2123
2147
|
impl: (ins) => ({ Result: Number(ins.Value) }),
|
|
2124
2148
|
});
|
|
2125
2149
|
registry.registerNode({
|
|
2126
|
-
id: "base.string",
|
|
2150
|
+
id: "base.input.string",
|
|
2127
2151
|
categoryId: "compute",
|
|
2128
2152
|
inputs: { Value: "base.string" },
|
|
2129
2153
|
outputs: { Result: "base.string" },
|
|
2130
2154
|
impl: (ins) => ({ Result: String(ins.Value) }),
|
|
2131
2155
|
});
|
|
2132
2156
|
registry.registerNode({
|
|
2133
|
-
id: "base.bool",
|
|
2157
|
+
id: "base.input.bool",
|
|
2134
2158
|
categoryId: "compute",
|
|
2135
2159
|
inputs: { Value: "base.bool" },
|
|
2136
2160
|
outputs: { Result: "base.bool" },
|
|
2137
2161
|
impl: (ins) => ({ Result: Boolean(ins.Value) }),
|
|
2138
2162
|
});
|
|
2139
|
-
// Integer
|
|
2140
|
-
registry.registerNode({
|
|
2141
|
-
id: "base.int",
|
|
2142
|
-
categoryId: "compute",
|
|
2143
|
-
inputs: { Value: "base.float" },
|
|
2144
|
-
outputs: { Result: "base.float" },
|
|
2145
|
-
impl: (ins) => ({
|
|
2146
|
-
Result: Math.trunc(Number(ins.Value)),
|
|
2147
|
-
}),
|
|
2148
|
-
});
|
|
2149
2163
|
// JSON parser node: base.stringToObject
|
|
2150
2164
|
registry.registerNode({
|
|
2151
2165
|
id: "base.string.toObject",
|
|
@@ -2964,8 +2978,8 @@ function createAsyncGraphRegistry() {
|
|
|
2964
2978
|
function createProgressGraphDef() {
|
|
2965
2979
|
const def = {
|
|
2966
2980
|
nodes: [
|
|
2967
|
-
{ nodeId: "steps", typeId: "base.number" },
|
|
2968
|
-
{ nodeId: "delay", typeId: "base.number" },
|
|
2981
|
+
{ nodeId: "steps", typeId: "base.input.number" },
|
|
2982
|
+
{ nodeId: "delay", typeId: "base.input.number" },
|
|
2969
2983
|
{ nodeId: "work", typeId: "async.progress" },
|
|
2970
2984
|
],
|
|
2971
2985
|
edges: [
|
|
@@ -2997,8 +3011,8 @@ function createValidationGraphDef() {
|
|
|
2997
3011
|
// - Multi inbound to same input
|
|
2998
3012
|
const def = {
|
|
2999
3013
|
nodes: [
|
|
3000
|
-
{ nodeId: "nA", typeId: "base.number" },
|
|
3001
|
-
{ nodeId: "nB", typeId: "base.number" },
|
|
3014
|
+
{ nodeId: "nA", typeId: "base.input.number" },
|
|
3015
|
+
{ nodeId: "nB", typeId: "base.input.number" },
|
|
3002
3016
|
{ nodeId: "nC", typeId: "base.math" },
|
|
3003
3017
|
{ nodeId: "s1", typeId: "base.object.toString" },
|
|
3004
3018
|
{ nodeId: "cmp", typeId: "base.compare" },
|