@rkmodules/rules 0.0.142 → 0.0.144
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 +29 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +28 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Engine/util.d.ts +1 -0
- package/dist/lib/hooks/useFlow.d.ts +9 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -613,6 +613,9 @@ function getValue$1(obj, path) {
|
|
|
613
613
|
}
|
|
614
614
|
return value;
|
|
615
615
|
}
|
|
616
|
+
function safeName(name) {
|
|
617
|
+
return name.replace(/\W/g, "_");
|
|
618
|
+
}
|
|
616
619
|
function interpolateValue(value, scope) {
|
|
617
620
|
// interpolating arrays
|
|
618
621
|
if (Array.isArray(value)) {
|
|
@@ -2572,6 +2575,7 @@ var explodeObject = {
|
|
|
2572
2575
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
2573
2576
|
if (key[0] === "_")
|
|
2574
2577
|
return;
|
|
2578
|
+
key = safeName(key);
|
|
2575
2579
|
if (!outputs[key]) {
|
|
2576
2580
|
outputs[key] = {};
|
|
2577
2581
|
}
|
|
@@ -6708,8 +6712,9 @@ var DynamicInput = React.memo(function (_a) {
|
|
|
6708
6712
|
var inputs = __assign({}, data.inputDefs);
|
|
6709
6713
|
var dynIndex = 1;
|
|
6710
6714
|
Object.keys(data.inputs || {}).forEach(function (name) {
|
|
6711
|
-
|
|
6712
|
-
|
|
6715
|
+
var safeKey = safeName(name);
|
|
6716
|
+
if (!(inputs === null || inputs === void 0 ? void 0 : inputs[safeKey])) {
|
|
6717
|
+
inputs[safeKey] = { type: "any", label: "D".concat(dynIndex) };
|
|
6713
6718
|
dynIndex++;
|
|
6714
6719
|
}
|
|
6715
6720
|
});
|
|
@@ -6833,7 +6838,10 @@ var DynamicOutput = React.memo(function (_a) {
|
|
|
6833
6838
|
return engine.subscribe("functionResult", function (event) {
|
|
6834
6839
|
if (event.name === id) {
|
|
6835
6840
|
var result = event.result || {};
|
|
6836
|
-
setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
|
|
6841
|
+
setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
|
|
6842
|
+
safeName(name),
|
|
6843
|
+
{ type: "any", label: name },
|
|
6844
|
+
]; })));
|
|
6837
6845
|
}
|
|
6838
6846
|
});
|
|
6839
6847
|
}, []);
|
|
@@ -6931,6 +6939,18 @@ function useUpdatePositions(fn) {
|
|
|
6931
6939
|
function updateNodeArguments(node, inputs, params) {
|
|
6932
6940
|
return __assign(__assign({}, node), { data: __assign(__assign({}, node.data), { inputs: inputs, params: params }) });
|
|
6933
6941
|
}
|
|
6942
|
+
/**
|
|
6943
|
+
* gets the source and target node and field from an edge by de-referencing the handles
|
|
6944
|
+
* the handles are in the format `${nodeId}-${fieldName}`
|
|
6945
|
+
* returns an object with the source node id, target node id, source field name and target field name
|
|
6946
|
+
*/
|
|
6947
|
+
function deRefEdgeHandle(handle) {
|
|
6948
|
+
var match = handle.match(/^(.+)-(.+)$/);
|
|
6949
|
+
if (!match) {
|
|
6950
|
+
throw new Error("Invalid handle format");
|
|
6951
|
+
}
|
|
6952
|
+
return { node: match[1], field: match[2] };
|
|
6953
|
+
}
|
|
6934
6954
|
function createNode(engine, id, fncall, options) {
|
|
6935
6955
|
var _a, _b;
|
|
6936
6956
|
var calledFn = engine.getFunction(fncall.name);
|
|
@@ -7201,9 +7221,8 @@ function FlowInner(_a) {
|
|
|
7201
7221
|
}), 2); _h[0].isOver; var drop = _h[1];
|
|
7202
7222
|
// connecting nodes
|
|
7203
7223
|
var onConnect = React.useCallback(function (params) {
|
|
7204
|
-
var
|
|
7205
|
-
var
|
|
7206
|
-
var targetField = (_b = params.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
|
|
7224
|
+
var sourceField = deRefEdgeHandle(params.sourceHandle).field;
|
|
7225
|
+
var targetField = deRefEdgeHandle(params.targetHandle).field;
|
|
7207
7226
|
if (!sourceField || !targetField) {
|
|
7208
7227
|
console.warn("Invalid connection handles", params);
|
|
7209
7228
|
return;
|
|
@@ -7223,9 +7242,8 @@ function FlowInner(_a) {
|
|
|
7223
7242
|
onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
|
|
7224
7243
|
var newFn = fn;
|
|
7225
7244
|
edgesToDelete.forEach(function (edge) {
|
|
7226
|
-
var
|
|
7227
|
-
var
|
|
7228
|
-
var targetField = (_b = edge.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
|
|
7245
|
+
var sourceField = deRefEdgeHandle(edge.sourceHandle).field;
|
|
7246
|
+
var targetField = deRefEdgeHandle(edge.targetHandle).field;
|
|
7229
7247
|
if (!sourceField || !targetField) {
|
|
7230
7248
|
console.warn("Invalid connection handles", edge);
|
|
7231
7249
|
return;
|
|
@@ -8321,5 +8339,5 @@ function DDContext(_a) {
|
|
|
8321
8339
|
return React.createElement(DndProvider, { backend: HTML5Backend }, children);
|
|
8322
8340
|
}
|
|
8323
8341
|
|
|
8324
|
-
export { DDContext, DISCARD, Engine, Flow, FlowContext, GenericNode, Input, Lib, Output, Param, binaryOnTree, binaryOnTreeBranch, broadCast, 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, 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 };
|
|
8342
|
+
export { DDContext, DISCARD, Engine, Flow, FlowContext, GenericNode, Input, 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 };
|
|
8325
8343
|
//# sourceMappingURL=index.esm.js.map
|