@rkmodules/rules 0.0.142 → 0.0.143

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.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)) {
@@ -6708,8 +6711,9 @@ var DynamicInput = React.memo(function (_a) {
6708
6711
  var inputs = __assign({}, data.inputDefs);
6709
6712
  var dynIndex = 1;
6710
6713
  Object.keys(data.inputs || {}).forEach(function (name) {
6711
- if (!(inputs === null || inputs === void 0 ? void 0 : inputs[name]) && dynIndex < 10) {
6712
- inputs[name] = { type: "any", label: "D".concat(dynIndex) };
6714
+ var safeKey = safeName(name);
6715
+ if (!(inputs === null || inputs === void 0 ? void 0 : inputs[safeKey])) {
6716
+ inputs[safeKey] = { type: "any", label: "D".concat(dynIndex) };
6713
6717
  dynIndex++;
6714
6718
  }
6715
6719
  });
@@ -6833,7 +6837,10 @@ var DynamicOutput = React.memo(function (_a) {
6833
6837
  return engine.subscribe("functionResult", function (event) {
6834
6838
  if (event.name === id) {
6835
6839
  var result = event.result || {};
6836
- setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [name, "any"]; })));
6840
+ setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
6841
+ safeName(name),
6842
+ { type: "any", label: name },
6843
+ ]; })));
6837
6844
  }
6838
6845
  });
6839
6846
  }, []);
@@ -6931,6 +6938,18 @@ function useUpdatePositions(fn) {
6931
6938
  function updateNodeArguments(node, inputs, params) {
6932
6939
  return __assign(__assign({}, node), { data: __assign(__assign({}, node.data), { inputs: inputs, params: params }) });
6933
6940
  }
6941
+ /**
6942
+ * gets the source and target node and field from an edge by de-referencing the handles
6943
+ * the handles are in the format `${nodeId}-${fieldName}`
6944
+ * returns an object with the source node id, target node id, source field name and target field name
6945
+ */
6946
+ function deRefEdgeHandle(handle) {
6947
+ var match = handle.match(/^(.+)-(.+)$/);
6948
+ if (!match) {
6949
+ throw new Error("Invalid handle format");
6950
+ }
6951
+ return { node: match[1], field: match[2] };
6952
+ }
6934
6953
  function createNode(engine, id, fncall, options) {
6935
6954
  var _a, _b;
6936
6955
  var calledFn = engine.getFunction(fncall.name);
@@ -7201,9 +7220,8 @@ function FlowInner(_a) {
7201
7220
  }), 2); _h[0].isOver; var drop = _h[1];
7202
7221
  // connecting nodes
7203
7222
  var onConnect = React.useCallback(function (params) {
7204
- var _a, _b;
7205
- var sourceField = (_a = params.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7206
- var targetField = (_b = params.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
7223
+ var sourceField = deRefEdgeHandle(params.sourceHandle).field;
7224
+ var targetField = deRefEdgeHandle(params.targetHandle).field;
7207
7225
  if (!sourceField || !targetField) {
7208
7226
  console.warn("Invalid connection handles", params);
7209
7227
  return;
@@ -7223,9 +7241,8 @@ function FlowInner(_a) {
7223
7241
  onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
7224
7242
  var newFn = fn;
7225
7243
  edgesToDelete.forEach(function (edge) {
7226
- var _a, _b;
7227
- var sourceField = (_a = edge.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7228
- var targetField = (_b = edge.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
7244
+ var sourceField = deRefEdgeHandle(edge.sourceHandle).field;
7245
+ var targetField = deRefEdgeHandle(edge.targetHandle).field;
7229
7246
  if (!sourceField || !targetField) {
7230
7247
  console.warn("Invalid connection handles", edge);
7231
7248
  return;
@@ -8321,5 +8338,5 @@ function DDContext(_a) {
8321
8338
  return React.createElement(DndProvider, { backend: HTML5Backend }, children);
8322
8339
  }
8323
8340
 
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 };
8341
+ 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
8342
  //# sourceMappingURL=index.esm.js.map