@rkmodules/rules 0.0.136 → 0.0.138

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
@@ -1772,15 +1772,53 @@ var uniqueItems = {
1772
1772
  inputs: {
1773
1773
  items: "any",
1774
1774
  },
1775
+ params: {
1776
+ excludeEmpty: {
1777
+ type: "boolean",
1778
+ default: false,
1779
+ label: "remove empty",
1780
+ },
1781
+ },
1775
1782
  outputs: {
1776
1783
  unique: "any",
1777
1784
  },
1778
- impl: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
1785
+ impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
1786
+ var noEmpty;
1779
1787
  var _c = _b.items, items = _c === void 0 ? {} : _c;
1780
1788
  return __generator(this, function (_d) {
1789
+ noEmpty = params.excludeEmpty;
1781
1790
  return [2 /*return*/, {
1782
1791
  unique: mapTreeBranch(items, function (items) {
1783
- return Array.from(new Set(items));
1792
+ var unique = new Set(items);
1793
+ if (noEmpty) {
1794
+ unique.delete(undefined);
1795
+ unique.delete(null);
1796
+ }
1797
+ return Array.from(unique);
1798
+ }),
1799
+ }];
1800
+ });
1801
+ }); },
1802
+ };
1803
+
1804
+ var coalesce = {
1805
+ name: "coalesce",
1806
+ label: "Coalesce Items",
1807
+ description: "Outputs the first item if it's not empty, otherwise the second item",
1808
+ inputs: {
1809
+ treeA: { type: "any" },
1810
+ treeB: { type: "any" },
1811
+ },
1812
+ outputs: {
1813
+ tree: "any",
1814
+ },
1815
+ impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
1816
+ var _c = _b.treeA, treeA = _c === void 0 ? {} : _c, _d = _b.treeB, treeB = _d === void 0 ? {} : _d;
1817
+ return __generator(this, function (_e) {
1818
+ return [2 /*return*/, {
1819
+ tree: nAryOnTree([treeA, treeB], function (_a) {
1820
+ var _b = __read(_a, 2), itemA = _b[0], itemB = _b[1];
1821
+ return itemA !== undefined && itemA !== null ? itemA : itemB;
1784
1822
  }),
1785
1823
  }];
1786
1824
  });
@@ -1796,6 +1834,7 @@ var primitives$6 = (_a$6 = {},
1796
1834
  _a$6[relativeItem.name] = relativeItem,
1797
1835
  _a$6[relativeItems.name] = relativeItems,
1798
1836
  _a$6[concat.name] = concat,
1837
+ _a$6[coalesce.name] = coalesce,
1799
1838
  _a$6[uniqueItems.name] = uniqueItems,
1800
1839
  _a$6);
1801
1840
 
@@ -6654,9 +6693,13 @@ var OutputNode = React.memo(function (_a) {
6654
6693
  newName = _b.sent();
6655
6694
  if (newName !== null && newName !== oldName) {
6656
6695
  (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
6696
+ var keys = Object.keys(fn.outputs || {});
6697
+ var newKeys = keys.map(function (key) {
6698
+ return key === oldName ? newName : key;
6699
+ });
6657
6700
  var outputs = __assign({}, fn.outputs);
6658
6701
  outputs[newName] = outputs[oldName];
6659
- delete outputs[oldName];
6702
+ outputs = Object.fromEntries(newKeys.map(function (key) { return [key, outputs[key]]; }));
6660
6703
  return { outputs: outputs };
6661
6704
  });
6662
6705
  }