@rkmodules/rules 0.0.145 → 0.0.146

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
@@ -609,9 +609,14 @@ function getValue$1(obj, path) {
609
609
  return;
610
610
  }
611
611
  var parts = path.split(".");
612
- var value = obj[parts.shift() || ""];
613
- while (parts.length && value) {
614
- value = value[parts.shift() || ""];
612
+ var key = parts.shift() || "";
613
+ var safeObj = Object.fromEntries(Object.entries(obj).map(function (_a) {
614
+ var _b = __read(_a, 2), k = _b[0], v = _b[1];
615
+ return [safeName(k), v];
616
+ }));
617
+ var value = safeObj[key];
618
+ if (parts.length) {
619
+ return getValue$1(value, parts.join("."));
615
620
  }
616
621
  return value;
617
622
  }
@@ -2577,7 +2582,6 @@ var explodeObject = {
2577
2582
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
2578
2583
  if (key[0] === "_")
2579
2584
  return;
2580
- key = safeName(key);
2581
2585
  if (!outputs[key]) {
2582
2586
  outputs[key] = {};
2583
2587
  }
@@ -6294,13 +6298,14 @@ var Input = function (_a) {
6294
6298
  var normalized = normalizeVarDef(varDef);
6295
6299
  var value = (_b = data.inputs) === null || _b === void 0 ? void 0 : _b[name];
6296
6300
  var isRef = isReference(value);
6301
+ var portId = "".concat(id, "-").concat(safeName(name));
6297
6302
  var handleInputChange = function (param) { return function (value) {
6298
6303
  var _a;
6299
6304
  data.onChange({
6300
6305
  inputs: __assign(__assign({}, data.inputs), (_a = {}, _a[param] = value, _a)),
6301
6306
  });
6302
6307
  }; };
6303
- return (React.createElement(react.Handle, { type: "target", position: react.Position.Left, id: "".concat(id, "-").concat(name), className: classNames(styles$1.Input, styles$1.Port, styles$1["type-".concat(normalized.type)]), style: {
6308
+ return (React.createElement(react.Handle, { type: "target", position: react.Position.Left, id: portId, className: classNames(styles$1.Input, styles$1.Port, styles$1["type-".concat(normalized.type)]), style: {
6304
6309
  "--type-color": "var(--color-".concat(normalized.type, ")"),
6305
6310
  }, onClick: onClick },
6306
6311
  React.createElement("span", { className: styles$1.PortLabel }, normalized.label || name),
@@ -6329,7 +6334,8 @@ var Param = function (_a) {
6329
6334
  var Output = function (_a) {
6330
6335
  var name = _a.name, varDef = _a.varDef, id = _a.id, onClick = _a.onClick, focus = _a.focus;
6331
6336
  var normalized = normalizeVarDef(varDef);
6332
- return (React.createElement(react.Handle, { type: "source", position: react.Position.Right, id: "".concat(id, "-").concat(name), className: classNames(styles$1.Output, styles$1.Port, styles$1["type-".concat(normalized.type)]), style: {
6337
+ var portId = "".concat(id, "-").concat(safeName(name));
6338
+ return (React.createElement(react.Handle, { type: "source", position: react.Position.Right, id: portId, className: classNames(styles$1.Output, styles$1.Port, styles$1["type-".concat(normalized.type)]), style: {
6333
6339
  "--type-color": "var(--color-".concat(normalized.type, ")"),
6334
6340
  }, onClick: onClick },
6335
6341
  React.createElement("span", { className: styles$1.PortLabel },
@@ -6805,6 +6811,8 @@ var OutputNode = React.memo(function (_a) {
6805
6811
  }
6806
6812
  });
6807
6813
  }); };
6814
+ // TODO: this seems specifically for the output node only, adjusting the main rule IO spec,
6815
+ // we need to change the current function spec instead
6808
6816
  var onAdd = function () { return __awaiter(void 0, void 0, void 0, function () {
6809
6817
  var newName;
6810
6818
  var _a;
@@ -6824,6 +6832,8 @@ var OutputNode = React.memo(function (_a) {
6824
6832
  }
6825
6833
  });
6826
6834
  }); };
6835
+ // TODO: this seems specifically for the output node only, adjusting the main rule IO spec,
6836
+ // we need to change the current function spec instead
6827
6837
  var onDelete = function (name) {
6828
6838
  var _a;
6829
6839
  (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
@@ -6877,7 +6887,7 @@ var DynamicOutput = React.memo(function (_a) {
6877
6887
  if (event.name === id) {
6878
6888
  var result = event.result || {};
6879
6889
  setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [
6880
- safeName(name),
6890
+ name,
6881
6891
  { type: "any", label: name },
6882
6892
  ]; })));
6883
6893
  }
@@ -6983,9 +6993,9 @@ function updateNodeArguments(node, inputs, params) {
6983
6993
  * returns an object with the source node id, target node id, source field name and target field name
6984
6994
  */
6985
6995
  function deRefEdgeHandle(handle) {
6986
- var match = handle.match(/^(.+)-(.+)$/);
6996
+ var match = handle.match(/^(.+?)-(.+)$/);
6987
6997
  if (!match) {
6988
- throw new Error("Invalid handle format");
6998
+ throw new Error("Invalid handle format" + handle);
6989
6999
  }
6990
7000
  return { node: match[1], field: match[2] };
6991
7001
  }
@@ -7017,8 +7027,8 @@ function createEdge(nodeId, ref) {
7017
7027
  id: "".concat(ref.path, "-").concat(nodeId, ".").concat(ref.name),
7018
7028
  source: ref.refNode,
7019
7029
  target: nodeId,
7020
- sourceHandle: "".concat(ref.refNode, "-").concat(ref.refField),
7021
- targetHandle: "".concat(nodeId, "-").concat(ref.name),
7030
+ sourceHandle: "".concat(ref.refNode, "-").concat(safeName(ref.refField)),
7031
+ targetHandle: "".concat(nodeId, "-").concat(safeName(ref.name)),
7022
7032
  };
7023
7033
  }
7024
7034
  /**