@rkmodules/rules 0.0.163 → 0.0.164
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/dist/index.cjs.js +54 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +54 -7
- package/dist/index.esm.mjs.map +1 -1
- package/dist/lib/Engine/util.d.ts +1 -0
- package/dist/lib/Flow/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
|
@@ -587,6 +587,30 @@ function mergeTrees() {
|
|
|
587
587
|
return out;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
+
function mergeWithOrder() {
|
|
591
|
+
var objects = [];
|
|
592
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
593
|
+
objects[_i] = arguments[_i];
|
|
594
|
+
}
|
|
595
|
+
var merged = {};
|
|
596
|
+
var keys = [];
|
|
597
|
+
objects.forEach(function (obj) {
|
|
598
|
+
Object.keys(obj).forEach(function (key) {
|
|
599
|
+
if (!keys.includes(key)) {
|
|
600
|
+
keys.push(key);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
keys.forEach(function (key) {
|
|
605
|
+
for (var i = objects.length - 1; i >= 0; i--) {
|
|
606
|
+
if (key in objects[i]) {
|
|
607
|
+
merged[key] = objects[i][key];
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
return merged;
|
|
613
|
+
}
|
|
590
614
|
function isReference(value) {
|
|
591
615
|
return (typeof value === "string" && !!value.match(/^<([\w\.]+)>$/)
|
|
592
616
|
// value.startsWith("<") &&
|
|
@@ -7057,16 +7081,22 @@ OutputNode.displayName = "OutputNode";
|
|
|
7057
7081
|
|
|
7058
7082
|
var DynamicOutput = React.memo(function (_a) {
|
|
7059
7083
|
var id = _a.id, data = _a.data, selected = _a.selected;
|
|
7060
|
-
var
|
|
7084
|
+
var outputDefs = data.outputDefs || {};
|
|
7085
|
+
Object.keys(data.outputs || {}).forEach(function (key) {
|
|
7086
|
+
if (!outputDefs[key]) {
|
|
7087
|
+
outputDefs[key] = { type: "any", label: key };
|
|
7088
|
+
}
|
|
7089
|
+
});
|
|
7090
|
+
var _b = __read(React.useState(outputDefs), 2), outputs = _b[0], setOutputs = _b[1];
|
|
7061
7091
|
var engine = useEngine();
|
|
7062
7092
|
React.useEffect(function () {
|
|
7063
7093
|
return engine.subscribe("functionResult", function (event) {
|
|
7064
7094
|
if (event.name === id) {
|
|
7065
7095
|
var result = event.result || {};
|
|
7066
|
-
setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
|
|
7096
|
+
setOutputs(mergeWithOrder(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
|
|
7067
7097
|
name,
|
|
7068
7098
|
{ type: "any", label: name },
|
|
7069
|
-
]; })));
|
|
7099
|
+
]; })), outputs));
|
|
7070
7100
|
}
|
|
7071
7101
|
});
|
|
7072
7102
|
}, []);
|
|
@@ -7293,6 +7323,7 @@ function createNode(engine, id, fncall, options) {
|
|
|
7293
7323
|
description: calledFn === null || calledFn === void 0 ? void 0 : calledFn.description,
|
|
7294
7324
|
inputs: fncall.inputs,
|
|
7295
7325
|
params: fncall.params,
|
|
7326
|
+
outputs: {},
|
|
7296
7327
|
inputDefs: __assign(__assign({}, fncall.inputDefs), calledFn === null || calledFn === void 0 ? void 0 : calledFn.inputs),
|
|
7297
7328
|
paramDefs: (calledFn === null || calledFn === void 0 ? void 0 : calledFn.params) || {},
|
|
7298
7329
|
outputDefs: (calledFn === null || calledFn === void 0 ? void 0 : calledFn.outputs) || {},
|
|
@@ -7314,6 +7345,16 @@ function createEdge(nodeId, ref) {
|
|
|
7314
7345
|
targetHandle: "".concat(nodeId, "-").concat(safeName(ref.name)),
|
|
7315
7346
|
};
|
|
7316
7347
|
}
|
|
7348
|
+
function addOutputToNode(nodes, ref, targetId) {
|
|
7349
|
+
var _a;
|
|
7350
|
+
var node = nodes[ref.refNode];
|
|
7351
|
+
if (!node) {
|
|
7352
|
+
console.warn("Node not found: " + ref.refNode);
|
|
7353
|
+
console.log(nodes, ref, targetId);
|
|
7354
|
+
return;
|
|
7355
|
+
}
|
|
7356
|
+
node.data.outputs = __assign(__assign({}, node.data.outputs), (_a = {}, _a[ref.refField] = "".concat(targetId, ".").concat(ref.name), _a));
|
|
7357
|
+
}
|
|
7317
7358
|
/**
|
|
7318
7359
|
* flow state stores nodes and edges for the flow graph these can be updated when the function changes
|
|
7319
7360
|
* using setFn
|
|
@@ -7344,6 +7385,7 @@ var useFlowState = create$1(function (set, get) { return ({
|
|
|
7344
7385
|
}
|
|
7345
7386
|
var oldKeys = Object.keys((oldFn === null || oldFn === void 0 ? void 0 : oldFn.body) || {});
|
|
7346
7387
|
var newKeys = Object.keys(fn.body || {});
|
|
7388
|
+
var edgesToAdd = [];
|
|
7347
7389
|
// remove all the nodes that were removed
|
|
7348
7390
|
Object.keys(nodes).forEach(function (key) {
|
|
7349
7391
|
if (!newKeys.includes(key)) {
|
|
@@ -7375,7 +7417,7 @@ var useFlowState = create$1(function (set, get) { return ({
|
|
|
7375
7417
|
// add edges
|
|
7376
7418
|
var refs = getReferences(fncall.inputs || {});
|
|
7377
7419
|
refs.forEach(function (ref) {
|
|
7378
|
-
|
|
7420
|
+
edgesToAdd.push([key_1, ref]);
|
|
7379
7421
|
});
|
|
7380
7422
|
}
|
|
7381
7423
|
// make sure there is an input node if inputs are defined
|
|
@@ -7400,7 +7442,7 @@ var useFlowState = create$1(function (set, get) { return ({
|
|
|
7400
7442
|
// add edges
|
|
7401
7443
|
var refs = getReferences(fncall.inputs || {});
|
|
7402
7444
|
refs.forEach(function (ref) {
|
|
7403
|
-
|
|
7445
|
+
edgesToAdd.push([key, ref]);
|
|
7404
7446
|
});
|
|
7405
7447
|
});
|
|
7406
7448
|
// update the changed nodes
|
|
@@ -7422,9 +7464,14 @@ var useFlowState = create$1(function (set, get) { return ({
|
|
|
7422
7464
|
edges = edges === null || edges === void 0 ? void 0 : edges.filter(function (e) { return e.target !== key; });
|
|
7423
7465
|
// add the edge
|
|
7424
7466
|
refs.forEach(function (ref) {
|
|
7425
|
-
|
|
7467
|
+
edgesToAdd.push([key, ref]);
|
|
7426
7468
|
});
|
|
7427
7469
|
});
|
|
7470
|
+
edgesToAdd.forEach(function (_a) {
|
|
7471
|
+
var _b = __read(_a, 2), nodeId = _b[0], ref = _b[1];
|
|
7472
|
+
edges.push(createEdge(nodeId, ref));
|
|
7473
|
+
addOutputToNode(nodes, ref, nodeId);
|
|
7474
|
+
});
|
|
7428
7475
|
// console.log("final graph", nodes, edges);
|
|
7429
7476
|
// update the function, nodes and edges
|
|
7430
7477
|
set({ fn: fn, nodes: nodes, edges: edges });
|
|
@@ -8695,5 +8742,5 @@ function DDContext(_a) {
|
|
|
8695
8742
|
return React.createElement(DndProvider, { backend: HTML5Backend }, children);
|
|
8696
8743
|
}
|
|
8697
8744
|
|
|
8698
|
-
export { DDContext, DISCARD, Engine, Flow, FlowContext, GenericNode, Input, InputBoolean, InputNumber, InputSelect, InputString, InputText, Lib, Output, Param, binaryOnTree, binaryOnTreeBranch, broadCast, deRefEdgeHandle, ensureBranch, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmpty, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, safeName, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useControls, useDraggableNode, useEngine, useFlow, useFunction, useGraphedFunction, usePositions, usePrompts, useUpdatePositions, useVariable, variableStore };
|
|
8745
|
+
export { DDContext, DISCARD, Engine, Flow, FlowContext, GenericNode, Input, InputBoolean, InputNumber, InputSelect, InputString, InputText, Lib, Output, Param, binaryOnTree, binaryOnTreeBranch, broadCast, deRefEdgeHandle, ensureBranch, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmpty, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, mergeWithOrder, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, safeName, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useControls, useDraggableNode, useEngine, useFlow, useFunction, useGraphedFunction, usePositions, usePrompts, useUpdatePositions, useVariable, variableStore };
|
|
8699
8746
|
//# sourceMappingURL=index.esm.mjs.map
|