@rkmodules/rules 0.0.90 → 0.0.92

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
@@ -1808,7 +1808,7 @@ var Engine = /** @class */ (function () {
1808
1808
  };
1809
1809
  Engine.prototype.runGraph = function (node, inputs, params) {
1810
1810
  return __awaiter(this, void 0, void 0, function () {
1811
- 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;
1811
+ 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;
1812
1812
  return __generator(this, function (_e) {
1813
1813
  switch (_e.label) {
1814
1814
  case 0:
@@ -1868,6 +1868,7 @@ var Engine = /** @class */ (function () {
1868
1868
  });
1869
1869
  return [4 /*yield*/, fn.impl(inputs_1, params_1, this)];
1870
1870
  case 3:
1871
+ // call the implentation of sub functions
1871
1872
  result_1 = _e.sent();
1872
1873
  endTime_1 = performance.now();
1873
1874
  context.activations[name_1] = false;
@@ -1892,8 +1893,7 @@ var Engine = /** @class */ (function () {
1892
1893
  case 5:
1893
1894
  result = interpolate(node.outputs || {}, context.scope);
1894
1895
  endTime = performance.now();
1895
- // fire event
1896
- this.fireEvent("result", {
1896
+ response = {
1897
1897
  name: node.name,
1898
1898
  inputs: inputs,
1899
1899
  params: params,
@@ -1903,15 +1903,18 @@ var Engine = /** @class */ (function () {
1903
1903
  startTime: startTime,
1904
1904
  endTime: endTime,
1905
1905
  duration: endTime - startTime,
1906
- });
1906
+ };
1907
+ // fire event
1908
+ this.fireEvent("result", response);
1907
1909
  // console.log("Engine run done", result, context, endTime - startTime);
1908
- return [2 /*return*/, result];
1910
+ return [2 /*return*/, response];
1909
1911
  }
1910
1912
  });
1911
1913
  });
1912
1914
  };
1913
1915
  /**
1914
1916
  * creates an function that can be evaluated by calling its implementation
1917
+ * and registers it in the function index
1915
1918
  * @param node
1916
1919
  * @returns
1917
1920
  */
@@ -1922,6 +1925,7 @@ var Engine = /** @class */ (function () {
1922
1925
  return node;
1923
1926
  }
1924
1927
  var _a = node.body, body = _a === void 0 ? {} : _a, props = __rest(node, ["body"]);
1928
+ // create a primitive function, one that has an implementation and optional mounting function
1925
1929
  var primitive = __assign(__assign({}, props), { outputs: Object.fromEntries(Object.entries(node.outputs || {}).map(function (_a) {
1926
1930
  var _b = __read(_a, 2), key = _b[0]; _b[1];
1927
1931
  return [key, { type: "any" }];
@@ -1958,17 +1962,18 @@ var Engine = /** @class */ (function () {
1958
1962
  finally { if (e_1) throw e_1.error; }
1959
1963
  }
1960
1964
  };
1961
- }, impl: function (inputs, params) { return __awaiter(_this, void 0, void 0, function () {
1965
+ }, impl: function (inputs, params, engine) { return __awaiter(_this, void 0, void 0, function () {
1966
+ var response;
1962
1967
  return __generator(this, function (_a) {
1963
- // console.log(
1964
- // `Running function: ${node.name}`,
1965
- // node,
1966
- // inputs,
1967
- // params
1968
- // );
1969
- return [2 /*return*/, this.runGraph(node, inputs, params)];
1968
+ switch (_a.label) {
1969
+ case 0: return [4 /*yield*/, engine.runGraph(node, inputs, params)];
1970
+ case 1:
1971
+ response = _a.sent();
1972
+ return [2 /*return*/, response.result];
1973
+ }
1970
1974
  });
1971
1975
  }); } });
1976
+ // register the primitive
1972
1977
  this.fnIndex[primitive.name] = primitive;
1973
1978
  return primitive;
1974
1979
  };
@@ -2036,6 +2041,23 @@ var Engine = /** @class */ (function () {
2036
2041
  });
2037
2042
  });
2038
2043
  };
2044
+ Engine.prototype.runDetailed = function (node_1) {
2045
+ return __awaiter(this, arguments, void 0, function (node, inputs) {
2046
+ var _this = this;
2047
+ if (inputs === void 0) { inputs = {}; }
2048
+ return __generator(this, function (_a) {
2049
+ return [2 /*return*/, new Promise(function (resolve) {
2050
+ var unsub = _this.subscribe("result", function (event) {
2051
+ if (event.name === node.name) {
2052
+ resolve(event);
2053
+ unsub();
2054
+ }
2055
+ });
2056
+ _this.run(node, inputs);
2057
+ })];
2058
+ });
2059
+ });
2060
+ };
2039
2061
  Engine.prototype.getFunction = function (name) {
2040
2062
  return this.fnIndex[name];
2041
2063
  };