@bian-womp/spark-graph 0.2.2 → 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 +37 -23
- 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 +37 -23
- 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,39 +2140,29 @@ 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
|
-
id: "base.
|
|
2165
|
+
id: "base.string.toObject",
|
|
2152
2166
|
categoryId: "compute",
|
|
2153
2167
|
inputs: { Text: "base.string" },
|
|
2154
2168
|
outputs: { Object: "base.object" },
|
|
@@ -2164,7 +2178,7 @@ function setupBasicGraphRegistry() {
|
|
|
2164
2178
|
},
|
|
2165
2179
|
});
|
|
2166
2180
|
registry.registerNode({
|
|
2167
|
-
id: "base.
|
|
2181
|
+
id: "base.object.toString",
|
|
2168
2182
|
categoryId: "compute",
|
|
2169
2183
|
inputs: { Object: "base.object" },
|
|
2170
2184
|
outputs: { Text: "base.string" },
|
|
@@ -2254,7 +2268,7 @@ function setupBasicGraphRegistry() {
|
|
|
2254
2268
|
impl: (ins) => {
|
|
2255
2269
|
const a = asArray(ins.A ?? []);
|
|
2256
2270
|
const b = asArray(ins.B ?? []);
|
|
2257
|
-
const op = Number(ins.Operation ??
|
|
2271
|
+
const op = Number(ins.Operation ?? BaseMathOperation.Add);
|
|
2258
2272
|
const unaryByOp = {
|
|
2259
2273
|
[BaseMathOperation.Round]: (x) => Math.round(x),
|
|
2260
2274
|
[BaseMathOperation.Floor]: (x) => Math.floor(x),
|
|
@@ -2315,7 +2329,7 @@ function setupBasicGraphRegistry() {
|
|
|
2315
2329
|
outputs: { Result: "base.bool[]" },
|
|
2316
2330
|
impl: (ins) => {
|
|
2317
2331
|
const [a, b] = broadcast(ins.A, ins.B);
|
|
2318
|
-
const op = Number(ins.Operation ?? BaseCompareOperation.Equal)
|
|
2332
|
+
const op = Number(ins.Operation ?? BaseCompareOperation.Equal);
|
|
2319
2333
|
const compareByOp = {
|
|
2320
2334
|
[BaseCompareOperation.LessThan]: (x, y) => x < y,
|
|
2321
2335
|
[BaseCompareOperation.LessThanOrEqual]: (x, y) => x <= y,
|
|
@@ -2340,7 +2354,7 @@ function setupBasicGraphRegistry() {
|
|
|
2340
2354
|
outputs: { Result: "base.bool[]" },
|
|
2341
2355
|
inputDefaults: { Operation: BaseLogicOperation.Not },
|
|
2342
2356
|
impl: (ins) => {
|
|
2343
|
-
const op = Number(ins.Operation ?? BaseLogicOperation.Not)
|
|
2357
|
+
const op = Number(ins.Operation ?? BaseLogicOperation.Not);
|
|
2344
2358
|
if (op === BaseLogicOperation.Not) {
|
|
2345
2359
|
const a = asBoolArray(ins.A ?? []);
|
|
2346
2360
|
return { Result: a.map((x) => !x) };
|
|
@@ -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,10 +3011,10 @@ 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
|
-
{ nodeId: "s1", typeId: "base.
|
|
3017
|
+
{ nodeId: "s1", typeId: "base.object.toString" },
|
|
3004
3018
|
{ nodeId: "cmp", typeId: "base.compare" },
|
|
3005
3019
|
// Global validation issue: unknown node type (no nodeId/edgeId in data)
|
|
3006
3020
|
{ nodeId: "bad", typeId: "unknownType" },
|