@rkmodules/rules 0.0.89 → 0.0.91
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 +106 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +106 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Engine/index.d.ts +14 -7
- package/dist/lib/Primitives/Math/ceil.d.ts +2 -0
- package/dist/lib/Primitives/Math/floor.d.ts +2 -0
- package/dist/lib/Primitives/Math/round.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1129,6 +1129,75 @@ var tanDeg = {
|
|
|
1129
1129
|
}); },
|
|
1130
1130
|
};
|
|
1131
1131
|
|
|
1132
|
+
var ceil = {
|
|
1133
|
+
name: "ceil",
|
|
1134
|
+
label: "Round up",
|
|
1135
|
+
description: "Round a number up to the nearest integer",
|
|
1136
|
+
inputs: {
|
|
1137
|
+
x: { type: "number", default: 0 },
|
|
1138
|
+
},
|
|
1139
|
+
outputs: {
|
|
1140
|
+
ceil: "number",
|
|
1141
|
+
},
|
|
1142
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1143
|
+
return __generator(this, function (_a) {
|
|
1144
|
+
return [2 /*return*/, {
|
|
1145
|
+
ceil: mapTree(inputs.x, function (x) {
|
|
1146
|
+
if (x === undefined)
|
|
1147
|
+
return DISCARD;
|
|
1148
|
+
return Math.ceil(x);
|
|
1149
|
+
}),
|
|
1150
|
+
}];
|
|
1151
|
+
});
|
|
1152
|
+
}); },
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
var floor = {
|
|
1156
|
+
name: "floor",
|
|
1157
|
+
label: "Round down",
|
|
1158
|
+
description: "Round a number down to the nearest integer",
|
|
1159
|
+
inputs: {
|
|
1160
|
+
x: { type: "number", default: 0 },
|
|
1161
|
+
},
|
|
1162
|
+
outputs: {
|
|
1163
|
+
floor: "number",
|
|
1164
|
+
},
|
|
1165
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1166
|
+
return __generator(this, function (_a) {
|
|
1167
|
+
return [2 /*return*/, {
|
|
1168
|
+
floor: mapTree(inputs.x, function (x) {
|
|
1169
|
+
if (x === undefined)
|
|
1170
|
+
return DISCARD;
|
|
1171
|
+
return Math.floor(x);
|
|
1172
|
+
}),
|
|
1173
|
+
}];
|
|
1174
|
+
});
|
|
1175
|
+
}); },
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
var round = {
|
|
1179
|
+
name: "round",
|
|
1180
|
+
label: "Round",
|
|
1181
|
+
description: "Round a number to the nearest integer",
|
|
1182
|
+
inputs: {
|
|
1183
|
+
x: { type: "number", default: 0 },
|
|
1184
|
+
},
|
|
1185
|
+
outputs: {
|
|
1186
|
+
round: "number",
|
|
1187
|
+
},
|
|
1188
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1189
|
+
return __generator(this, function (_a) {
|
|
1190
|
+
return [2 /*return*/, {
|
|
1191
|
+
round: mapTree(inputs.x, function (x) {
|
|
1192
|
+
if (x === undefined)
|
|
1193
|
+
return DISCARD;
|
|
1194
|
+
return Math.round(x);
|
|
1195
|
+
}),
|
|
1196
|
+
}];
|
|
1197
|
+
});
|
|
1198
|
+
}); },
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1132
1201
|
var _a$6;
|
|
1133
1202
|
var primitives$6 = (_a$6 = {},
|
|
1134
1203
|
_a$6[calc.name] = calc,
|
|
@@ -1145,6 +1214,9 @@ var primitives$6 = (_a$6 = {},
|
|
|
1145
1214
|
_a$6[tanDeg.name] = tanDeg,
|
|
1146
1215
|
_a$6[sqrt.name] = sqrt,
|
|
1147
1216
|
_a$6[pow.name] = pow,
|
|
1217
|
+
_a$6[round.name] = round,
|
|
1218
|
+
_a$6[ceil.name] = ceil,
|
|
1219
|
+
_a$6[floor.name] = floor,
|
|
1148
1220
|
_a$6);
|
|
1149
1221
|
|
|
1150
1222
|
var filterList = {
|
|
@@ -1734,7 +1806,7 @@ var Engine = /** @class */ (function () {
|
|
|
1734
1806
|
};
|
|
1735
1807
|
Engine.prototype.runGraph = function (node, inputs, params) {
|
|
1736
1808
|
return __awaiter(this, void 0, void 0, function () {
|
|
1737
|
-
var _a, body, executionId, context, startTime, _b, _c, _d, _i, name_1, fnCall, fn, inputs_1, params_1, result_1, cacheResult, startTime_1, endTime_1, result, endTime;
|
|
1809
|
+
var _a, body, executionId, context, startTime, _b, _c, _d, _i, name_1, fnCall, fn, inputs_1, params_1, result_1, cacheResult, startTime_1, endTime_1, result, endTime, response;
|
|
1738
1810
|
return __generator(this, function (_e) {
|
|
1739
1811
|
switch (_e.label) {
|
|
1740
1812
|
case 0:
|
|
@@ -1794,6 +1866,7 @@ var Engine = /** @class */ (function () {
|
|
|
1794
1866
|
});
|
|
1795
1867
|
return [4 /*yield*/, fn.impl(inputs_1, params_1, this)];
|
|
1796
1868
|
case 3:
|
|
1869
|
+
// call the implentation of sub functions
|
|
1797
1870
|
result_1 = _e.sent();
|
|
1798
1871
|
endTime_1 = performance.now();
|
|
1799
1872
|
context.activations[name_1] = false;
|
|
@@ -1818,8 +1891,7 @@ var Engine = /** @class */ (function () {
|
|
|
1818
1891
|
case 5:
|
|
1819
1892
|
result = interpolate(node.outputs || {}, context.scope);
|
|
1820
1893
|
endTime = performance.now();
|
|
1821
|
-
|
|
1822
|
-
this.fireEvent("result", {
|
|
1894
|
+
response = {
|
|
1823
1895
|
name: node.name,
|
|
1824
1896
|
inputs: inputs,
|
|
1825
1897
|
params: params,
|
|
@@ -1829,15 +1901,18 @@ var Engine = /** @class */ (function () {
|
|
|
1829
1901
|
startTime: startTime,
|
|
1830
1902
|
endTime: endTime,
|
|
1831
1903
|
duration: endTime - startTime,
|
|
1832
|
-
}
|
|
1904
|
+
};
|
|
1905
|
+
// fire event
|
|
1906
|
+
this.fireEvent("result", response);
|
|
1833
1907
|
// console.log("Engine run done", result, context, endTime - startTime);
|
|
1834
|
-
return [2 /*return*/,
|
|
1908
|
+
return [2 /*return*/, response];
|
|
1835
1909
|
}
|
|
1836
1910
|
});
|
|
1837
1911
|
});
|
|
1838
1912
|
};
|
|
1839
1913
|
/**
|
|
1840
1914
|
* creates an function that can be evaluated by calling its implementation
|
|
1915
|
+
* and registers it in the function index
|
|
1841
1916
|
* @param node
|
|
1842
1917
|
* @returns
|
|
1843
1918
|
*/
|
|
@@ -1848,6 +1923,7 @@ var Engine = /** @class */ (function () {
|
|
|
1848
1923
|
return node;
|
|
1849
1924
|
}
|
|
1850
1925
|
var _a = node.body, body = _a === void 0 ? {} : _a, props = __rest(node, ["body"]);
|
|
1926
|
+
// create a primitive function, one that has an implementation and optional mounting function
|
|
1851
1927
|
var primitive = __assign(__assign({}, props), { outputs: Object.fromEntries(Object.entries(node.outputs || {}).map(function (_a) {
|
|
1852
1928
|
var _b = __read(_a, 2), key = _b[0]; _b[1];
|
|
1853
1929
|
return [key, { type: "any" }];
|
|
@@ -1884,17 +1960,18 @@ var Engine = /** @class */ (function () {
|
|
|
1884
1960
|
finally { if (e_1) throw e_1.error; }
|
|
1885
1961
|
}
|
|
1886
1962
|
};
|
|
1887
|
-
}, impl: function (inputs, params) { return __awaiter(_this, void 0, void 0, function () {
|
|
1963
|
+
}, impl: function (inputs, params, engine) { return __awaiter(_this, void 0, void 0, function () {
|
|
1964
|
+
var response;
|
|
1888
1965
|
return __generator(this, function (_a) {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
return [2 /*return*/, this.runGraph(node, inputs, params)];
|
|
1966
|
+
switch (_a.label) {
|
|
1967
|
+
case 0: return [4 /*yield*/, engine.runGraph(node, inputs, params)];
|
|
1968
|
+
case 1:
|
|
1969
|
+
response = _a.sent();
|
|
1970
|
+
return [2 /*return*/, response.result];
|
|
1971
|
+
}
|
|
1896
1972
|
});
|
|
1897
1973
|
}); } });
|
|
1974
|
+
// register the primitive
|
|
1898
1975
|
this.fnIndex[primitive.name] = primitive;
|
|
1899
1976
|
return primitive;
|
|
1900
1977
|
};
|
|
@@ -1962,6 +2039,22 @@ var Engine = /** @class */ (function () {
|
|
|
1962
2039
|
});
|
|
1963
2040
|
});
|
|
1964
2041
|
};
|
|
2042
|
+
Engine.prototype.runDetailed = function (node, inputs) {
|
|
2043
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2044
|
+
var _this = this;
|
|
2045
|
+
return __generator(this, function (_a) {
|
|
2046
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
2047
|
+
var unsub = _this.subscribe("result", function (event) {
|
|
2048
|
+
if (event.name === node.name) {
|
|
2049
|
+
resolve(event);
|
|
2050
|
+
unsub();
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
_this.run(node, inputs);
|
|
2054
|
+
})];
|
|
2055
|
+
});
|
|
2056
|
+
});
|
|
2057
|
+
};
|
|
1965
2058
|
Engine.prototype.getFunction = function (name) {
|
|
1966
2059
|
return this.fnIndex[name];
|
|
1967
2060
|
};
|