@rkmodules/rules 0.0.141 → 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)) {
@@ -2997,6 +3000,7 @@ var Engine = /** @class */ (function () {
2997
3000
  context = {
2998
3001
  scope: { inputs: inputs },
2999
3002
  inputs: { inputs: inputs },
3003
+ params: { params: params },
3000
3004
  timings: {},
3001
3005
  activations: {},
3002
3006
  };
@@ -3021,6 +3025,7 @@ var Engine = /** @class */ (function () {
3021
3025
  params_1 = fnCall.params || {};
3022
3026
  result_1 = {};
3023
3027
  context.inputs[name_1] = inputs_1;
3028
+ context.params[name_1] = params_1;
3024
3029
  cacheResult = this.checkCache(name_1, inputs_1);
3025
3030
  if (!(cacheResult !== this.cacheMiss)) return [3 /*break*/, 2];
3026
3031
  // use as result
@@ -6706,8 +6711,9 @@ var DynamicInput = React.memo(function (_a) {
6706
6711
  var inputs = __assign({}, data.inputDefs);
6707
6712
  var dynIndex = 1;
6708
6713
  Object.keys(data.inputs || {}).forEach(function (name) {
6709
- if (!(inputs === null || inputs === void 0 ? void 0 : inputs[name]) && dynIndex < 10) {
6710
- 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) };
6711
6717
  dynIndex++;
6712
6718
  }
6713
6719
  });
@@ -6831,7 +6837,10 @@ var DynamicOutput = React.memo(function (_a) {
6831
6837
  return engine.subscribe("functionResult", function (event) {
6832
6838
  if (event.name === id) {
6833
6839
  var result = event.result || {};
6834
- 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
+ ]; })));
6835
6844
  }
6836
6845
  });
6837
6846
  }, []);
@@ -6929,6 +6938,18 @@ function useUpdatePositions(fn) {
6929
6938
  function updateNodeArguments(node, inputs, params) {
6930
6939
  return __assign(__assign({}, node), { data: __assign(__assign({}, node.data), { inputs: inputs, params: params }) });
6931
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
+ }
6932
6953
  function createNode(engine, id, fncall, options) {
6933
6954
  var _a, _b;
6934
6955
  var calledFn = engine.getFunction(fncall.name);
@@ -7199,9 +7220,8 @@ function FlowInner(_a) {
7199
7220
  }), 2); _h[0].isOver; var drop = _h[1];
7200
7221
  // connecting nodes
7201
7222
  var onConnect = React.useCallback(function (params) {
7202
- var _a, _b;
7203
- var sourceField = (_a = params.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7204
- 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;
7205
7225
  if (!sourceField || !targetField) {
7206
7226
  console.warn("Invalid connection handles", params);
7207
7227
  return;
@@ -7221,9 +7241,8 @@ function FlowInner(_a) {
7221
7241
  onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
7222
7242
  var newFn = fn;
7223
7243
  edgesToDelete.forEach(function (edge) {
7224
- var _a, _b;
7225
- var sourceField = (_a = edge.sourceHandle) === null || _a === void 0 ? void 0 : _a.split("-")[1];
7226
- 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;
7227
7246
  if (!sourceField || !targetField) {
7228
7247
  console.warn("Invalid connection handles", edge);
7229
7248
  return;
@@ -8319,5 +8338,5 @@ function DDContext(_a) {
8319
8338
  return React.createElement(DndProvider, { backend: HTML5Backend }, children);
8320
8339
  }
8321
8340
 
8322
- 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 };
8323
8342
  //# sourceMappingURL=index.esm.js.map