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