@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.cjs.js CHANGED
@@ -615,6 +615,9 @@ function getValue$1(obj, path) {
615
615
  }
616
616
  return value;
617
617
  }
618
+ function safeName(name) {
619
+ return name.replace(/\W/g, "_");
620
+ }
618
621
  function interpolateValue(value, scope) {
619
622
  // interpolating arrays
620
623
  if (Array.isArray(value)) {
@@ -6710,8 +6713,9 @@ var DynamicInput = React.memo(function (_a) {
6710
6713
  var inputs = __assign({}, data.inputDefs);
6711
6714
  var dynIndex = 1;
6712
6715
  Object.keys(data.inputs || {}).forEach(function (name) {
6713
- if (!(inputs === null || inputs === void 0 ? void 0 : inputs[name]) && dynIndex < 10) {
6714
- inputs[name] = { type: "any", label: "D".concat(dynIndex) };
6716
+ var safeKey = safeName(name);
6717
+ if (!(inputs === null || inputs === void 0 ? void 0 : inputs[safeKey])) {
6718
+ inputs[safeKey] = { type: "any", label: "D".concat(dynIndex) };
6715
6719
  dynIndex++;
6716
6720
  }
6717
6721
  });
@@ -6835,7 +6839,10 @@ var DynamicOutput = React.memo(function (_a) {
6835
6839
  return engine.subscribe("functionResult", function (event) {
6836
6840
  if (event.name === id) {
6837
6841
  var result = event.result || {};
6838
- setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [name, "any"]; })));
6842
+ setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
6843
+ safeName(name),
6844
+ { type: "any", label: name },
6845
+ ]; })));
6839
6846
  }
6840
6847
  });
6841
6848
  }, []);
@@ -6933,6 +6940,18 @@ function useUpdatePositions(fn) {
6933
6940
  function updateNodeArguments(node, inputs, params) {
6934
6941
  return __assign(__assign({}, node), { data: __assign(__assign({}, node.data), { inputs: inputs, params: params }) });
6935
6942
  }
6943
+ /**
6944
+ * gets the source and target node and field from an edge by de-referencing the handles
6945
+ * the handles are in the format `${nodeId}-${fieldName}`
6946
+ * returns an object with the source node id, target node id, source field name and target field name
6947
+ */
6948
+ function deRefEdgeHandle(handle) {
6949
+ var match = handle.match(/^(.+)-(.+)$/);
6950
+ if (!match) {
6951
+ throw new Error("Invalid handle format");
6952
+ }
6953
+ return { node: match[1], field: match[2] };
6954
+ }
6936
6955
  function createNode(engine, id, fncall, options) {
6937
6956
  var _a, _b;
6938
6957
  var calledFn = engine.getFunction(fncall.name);
@@ -7203,9 +7222,8 @@ function FlowInner(_a) {
7203
7222
  }), 2); _h[0].isOver; var drop = _h[1];
7204
7223
  // connecting nodes
7205
7224
  var onConnect = React.useCallback(function (params) {
7206
- var _a, _b;
7207
- var sourceField = (_a = params.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7208
- var targetField = (_b = params.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
7225
+ var sourceField = deRefEdgeHandle(params.sourceHandle).field;
7226
+ var targetField = deRefEdgeHandle(params.targetHandle).field;
7209
7227
  if (!sourceField || !targetField) {
7210
7228
  console.warn("Invalid connection handles", params);
7211
7229
  return;
@@ -7225,9 +7243,8 @@ function FlowInner(_a) {
7225
7243
  onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
7226
7244
  var newFn = fn;
7227
7245
  edgesToDelete.forEach(function (edge) {
7228
- var _a, _b;
7229
- var sourceField = (_a = edge.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7230
- var targetField = (_b = edge.targetHandle) === null || _b === void 0 ? void 0 : _b.split("-")[1];
7246
+ var sourceField = deRefEdgeHandle(edge.sourceHandle).field;
7247
+ var targetField = deRefEdgeHandle(edge.targetHandle).field;
7231
7248
  if (!sourceField || !targetField) {
7232
7249
  console.warn("Invalid connection handles", edge);
7233
7250
  return;
@@ -8336,6 +8353,7 @@ exports.Param = Param;
8336
8353
  exports.binaryOnTree = binaryOnTree;
8337
8354
  exports.binaryOnTreeBranch = binaryOnTreeBranch;
8338
8355
  exports.broadCast = broadCast;
8356
+ exports.deRefEdgeHandle = deRefEdgeHandle;
8339
8357
  exports.ensureBranch = ensureBranch;
8340
8358
  exports.expandTree = expandTree;
8341
8359
  exports.forEachBranch = forEachBranch;
@@ -8365,6 +8383,7 @@ exports.normalizeVarDef = normalizeVarDef;
8365
8383
  exports.parseReference = parseReference;
8366
8384
  exports.primitives = primitives;
8367
8385
  exports.pushItem = pushItem;
8386
+ exports.safeName = safeName;
8368
8387
  exports.sameShape = sameShape;
8369
8388
  exports.simplifyTree = simplifyTree$1;
8370
8389
  exports.toArray = toArray;