@rkmodules/rules 0.0.67 → 0.0.68

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
@@ -136,7 +136,7 @@ var DISCARD = Symbol("DISCARD");
136
136
  * @param tree
137
137
  * @returns
138
138
  */
139
- function simplifyTree(tree) {
139
+ function simplifyTree$1(tree) {
140
140
  var keys = Object.keys(tree);
141
141
  if (keys.length <= 1)
142
142
  return tree; // ✅ Don't simplify if only one path
@@ -252,6 +252,9 @@ function broadCast(value) {
252
252
  function getBranch(tree, path) {
253
253
  return tree[path];
254
254
  }
255
+ function getPaths(tree) {
256
+ return Object.keys(tree);
257
+ }
255
258
  /**
256
259
  * maps a tree, the tree branches are flatmapped, so if an array is returned for each item in the list, a flat list is returned
257
260
  * @param tree
@@ -651,6 +654,8 @@ var add$1 = {
651
654
  return __generator(this, function (_a) {
652
655
  return [2 /*return*/, {
653
656
  sum: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
657
+ if (itemA === undefined || itemB === undefined)
658
+ return DISCARD;
654
659
  return itemA + itemB;
655
660
  }, true),
656
661
  }];
@@ -817,6 +822,29 @@ function getUnboundSymbols(expr, scope, extraBound) {
817
822
  return Array.from(free).sort();
818
823
  }
819
824
 
825
+ var cosDeg = {
826
+ name: "cosDeg",
827
+ label: "Cosine",
828
+ description: "Cosine of angle in degrees",
829
+ inputs: {
830
+ a: { type: "number", default: 0 },
831
+ },
832
+ outputs: {
833
+ cos: "number",
834
+ },
835
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
836
+ return __generator(this, function (_a) {
837
+ return [2 /*return*/, {
838
+ cos: mapTree(inputs.a, function (angle) {
839
+ if (angle === undefined)
840
+ return DISCARD;
841
+ return Math.cos((angle * Math.PI) / 180);
842
+ }),
843
+ }];
844
+ });
845
+ }); },
846
+ };
847
+
820
848
  var divide = {
821
849
  name: "divide",
822
850
  label: "Divide",
@@ -832,6 +860,8 @@ var divide = {
832
860
  return __generator(this, function (_a) {
833
861
  return [2 /*return*/, {
834
862
  quotient: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
863
+ if (itemA === undefined || itemB === undefined)
864
+ return DISCARD;
835
865
  if (itemB === 0)
836
866
  return DISCARD;
837
867
  return itemA / itemB;
@@ -901,6 +931,30 @@ var lessThan = {
901
931
  }); },
902
932
  };
903
933
 
934
+ var modulo = {
935
+ name: "modulo",
936
+ label: "Modulo",
937
+ description: "Division remainder of two numbers",
938
+ inputs: {
939
+ a: { type: "number", default: 1 },
940
+ b: { type: "number", default: 1 },
941
+ },
942
+ outputs: {
943
+ mod: "number",
944
+ },
945
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
946
+ return __generator(this, function (_a) {
947
+ return [2 /*return*/, {
948
+ mod: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
949
+ if (itemA === undefined || itemB === undefined)
950
+ return DISCARD;
951
+ return itemA % itemB;
952
+ }, true),
953
+ }];
954
+ });
955
+ }); },
956
+ };
957
+
904
958
  var multiply = {
905
959
  name: "multiply",
906
960
  label: "Multiply",
@@ -916,6 +970,8 @@ var multiply = {
916
970
  return __generator(this, function (_a) {
917
971
  return [2 /*return*/, {
918
972
  product: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
973
+ if (itemA === undefined || itemB === undefined)
974
+ return DISCARD;
919
975
  return itemA * itemB;
920
976
  }, true),
921
977
  }];
@@ -923,6 +979,78 @@ var multiply = {
923
979
  }); },
924
980
  };
925
981
 
982
+ var pow = {
983
+ name: "pow",
984
+ label: "Power",
985
+ description: "Power a number",
986
+ inputs: {
987
+ x: { type: "number", default: 0 },
988
+ n: { type: "number", default: 2 },
989
+ },
990
+ outputs: {
991
+ pow: "number",
992
+ },
993
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
994
+ return __generator(this, function (_a) {
995
+ return [2 /*return*/, {
996
+ pow: binaryOnTree(inputs.x, inputs.n, function (x, n) {
997
+ if (x === undefined || n === undefined)
998
+ return DISCARD;
999
+ return Math.pow(x, n);
1000
+ }),
1001
+ }];
1002
+ });
1003
+ }); },
1004
+ };
1005
+
1006
+ var sinDeg = {
1007
+ name: "sinDeg",
1008
+ label: "Sine",
1009
+ description: "Sine of angle in degrees",
1010
+ inputs: {
1011
+ a: { type: "number", default: 0 },
1012
+ },
1013
+ outputs: {
1014
+ sin: "number",
1015
+ },
1016
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1017
+ return __generator(this, function (_a) {
1018
+ return [2 /*return*/, {
1019
+ sin: mapTree(inputs.a, function (angle) {
1020
+ if (angle === undefined)
1021
+ return DISCARD;
1022
+ return Math.sin((angle * Math.PI) / 180);
1023
+ }),
1024
+ }];
1025
+ });
1026
+ }); },
1027
+ };
1028
+
1029
+ var sqrt = {
1030
+ name: "sqrt",
1031
+ label: "Square root",
1032
+ description: "Square root of a number",
1033
+ inputs: {
1034
+ x: { type: "number", default: 0 },
1035
+ },
1036
+ outputs: {
1037
+ sqrt: "number",
1038
+ },
1039
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1040
+ return __generator(this, function (_a) {
1041
+ return [2 /*return*/, {
1042
+ sqrt: mapTree(inputs.x, function (x) {
1043
+ if (x === undefined)
1044
+ return DISCARD;
1045
+ if (x < 0)
1046
+ return DISCARD;
1047
+ return Math.sqrt(x);
1048
+ }),
1049
+ }];
1050
+ });
1051
+ }); },
1052
+ };
1053
+
926
1054
  var subtract$1 = {
927
1055
  name: "subtract",
928
1056
  label: "Subtract",
@@ -938,6 +1066,8 @@ var subtract$1 = {
938
1066
  return __generator(this, function (_a) {
939
1067
  return [2 /*return*/, {
940
1068
  difference: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
1069
+ if (itemA === undefined || itemB === undefined)
1070
+ return DISCARD;
941
1071
  return itemA - itemB;
942
1072
  }, true),
943
1073
  }];
@@ -945,6 +1075,29 @@ var subtract$1 = {
945
1075
  }); },
946
1076
  };
947
1077
 
1078
+ var tanDeg = {
1079
+ name: "tanDeg",
1080
+ label: "Tangent",
1081
+ description: "Tangent of angle in degrees",
1082
+ inputs: {
1083
+ a: { type: "number", default: 0 },
1084
+ },
1085
+ outputs: {
1086
+ tan: "number",
1087
+ },
1088
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1089
+ return __generator(this, function (_a) {
1090
+ return [2 /*return*/, {
1091
+ tan: mapTree(inputs.a, function (angle) {
1092
+ if (angle === undefined)
1093
+ return DISCARD;
1094
+ return Math.tan((angle * Math.PI) / 180);
1095
+ }),
1096
+ }];
1097
+ });
1098
+ }); },
1099
+ };
1100
+
948
1101
  var _a$5;
949
1102
  var primitives$5 = (_a$5 = {},
950
1103
  _a$5[calc.name] = calc,
@@ -954,6 +1107,12 @@ var primitives$5 = (_a$5 = {},
954
1107
  _a$5[subtract$1.name] = subtract$1,
955
1108
  _a$5[multiply.name] = multiply,
956
1109
  _a$5[divide.name] = divide,
1110
+ _a$5[modulo.name] = modulo,
1111
+ _a$5[sinDeg.name] = sinDeg,
1112
+ _a$5[cosDeg.name] = cosDeg,
1113
+ _a$5[tanDeg.name] = tanDeg,
1114
+ _a$5[sqrt.name] = sqrt,
1115
+ _a$5[pow.name] = pow,
957
1116
  _a$5);
958
1117
 
959
1118
  var filterList = {
@@ -1121,6 +1280,45 @@ var shiftList = {
1121
1280
  }); },
1122
1281
  };
1123
1282
 
1283
+ var cartesianGroups = {
1284
+ name: "cartesianGroups",
1285
+ label: "Cartesian Groups",
1286
+ description: "Duplicate groups such that all pairings are created.",
1287
+ inputs: {
1288
+ treeA: "any",
1289
+ treeB: "any",
1290
+ },
1291
+ params: {},
1292
+ outputs: {
1293
+ treeA: "any",
1294
+ treeB: "any",
1295
+ },
1296
+ impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
1297
+ var pathsA, pathsB, treeA, treeB;
1298
+ return __generator(this, function (_a) {
1299
+ if (!inputs.treeA || !inputs.treeB) {
1300
+ return [2 /*return*/, {}];
1301
+ }
1302
+ pathsA = getPaths(inputs.treeA);
1303
+ pathsB = getPaths(inputs.treeB);
1304
+ treeA = {};
1305
+ treeB = {};
1306
+ pathsB.forEach(function (pathB, ib) {
1307
+ pathsA.forEach(function (pathA, ia) {
1308
+ var pa = "".concat(ib, ";").concat(pathA);
1309
+ treeA[pa] = inputs.treeA[pathA];
1310
+ var pb = "".concat(pathB, ";").concat(ia);
1311
+ treeB[pb] = inputs.treeB[pathB];
1312
+ });
1313
+ });
1314
+ return [2 /*return*/, {
1315
+ treeA: treeA,
1316
+ treeB: treeB,
1317
+ }];
1318
+ });
1319
+ }); },
1320
+ };
1321
+
1124
1322
  var _a$4;
1125
1323
  var primitives$4 = (_a$4 = {},
1126
1324
  _a$4[splitGroup.name] = splitGroup,
@@ -1129,6 +1327,7 @@ var primitives$4 = (_a$4 = {},
1129
1327
  _a$4[listLength.name] = listLength,
1130
1328
  _a$4[filterList.name] = filterList,
1131
1329
  _a$4[shiftList.name] = shiftList,
1330
+ _a$4[cartesianGroups.name] = cartesianGroups,
1132
1331
  _a$4);
1133
1332
 
1134
1333
  var series = {
@@ -1200,9 +1399,32 @@ var mergeTree = {
1200
1399
  }); },
1201
1400
  };
1202
1401
 
1402
+ var simplifyTree = {
1403
+ name: "simplifyTree",
1404
+ label: "Simplify Tree",
1405
+ description: "Simplify a tree by removing redundant groups.",
1406
+ inputs: {
1407
+ tree: "any",
1408
+ },
1409
+ outputs: {
1410
+ tree: "any",
1411
+ },
1412
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1413
+ return __generator(this, function (_a) {
1414
+ if (!inputs.tree) {
1415
+ return [2 /*return*/, {}];
1416
+ }
1417
+ return [2 /*return*/, {
1418
+ tree: simplifyTree$1(inputs.tree),
1419
+ }];
1420
+ });
1421
+ }); },
1422
+ };
1423
+
1203
1424
  var _a$2;
1204
1425
  var primitives$2 = (_a$2 = {},
1205
1426
  _a$2[mergeTree.name] = mergeTree,
1427
+ _a$2[simplifyTree.name] = simplifyTree,
1206
1428
  _a$2);
1207
1429
 
1208
1430
  var groupAnd = {
@@ -6153,5 +6375,5 @@ function DDContext(_a) {
6153
6375
  return React.createElement(DndProvider, { backend: HTML5Backend }, children);
6154
6376
  }
6155
6377
 
6156
- export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, getBranch, getReferences, getValue$1 as getValue, graftTree, hasReference, interpolate, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizeVarDef, parseReference, primitives, sameShape, simplifyTree, toArray, topSort, treeSize, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable };
6378
+ export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, getBranch, getPaths, getReferences, getValue$1 as getValue, graftTree, hasReference, interpolate, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizeVarDef, parseReference, primitives, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable };
6157
6379
  //# sourceMappingURL=index.esm.js.map