@rkmodules/rules 0.0.106 → 0.0.108

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
@@ -2050,6 +2050,14 @@ function topSort(fn) {
2050
2050
  var orderedBody = Object.fromEntries(ordered.map(function (id) { return [id, fn.body[id]]; }));
2051
2051
  return __assign(__assign({}, fn), { body: orderedBody });
2052
2052
  }
2053
+ function getDefault(varDef, inputs) {
2054
+ if (inputs === void 0) { inputs = {}; }
2055
+ var normDef = normalizeVarDef(varDef);
2056
+ if (typeof normDef.default === "function") {
2057
+ return normDef.default(inputs);
2058
+ }
2059
+ return normDef.default;
2060
+ }
2053
2061
  var Engine = /** @class */ (function () {
2054
2062
  function Engine(morePrimitives, env) {
2055
2063
  if (morePrimitives === void 0) { morePrimitives = {}; }
@@ -2080,12 +2088,13 @@ var Engine = /** @class */ (function () {
2080
2088
  Object.entries(node.inputs || {}).forEach(function (_a) {
2081
2089
  var _b = __read(_a, 2), name = _b[0], def = _b[1];
2082
2090
  var normDef = normalizeVarDef(def);
2083
- if (!inputs[name] && normDef.default !== undefined) {
2084
- inputs[name] = normDef.default;
2091
+ if (inputs[name] === undefined && normDef.default !== undefined) {
2092
+ inputs[name] = getDefault(normDef, inputs);
2085
2093
  }
2086
2094
  });
2087
2095
  context = {
2088
2096
  scope: { inputs: inputs },
2097
+ inputs: { inputs: inputs },
2089
2098
  timings: {},
2090
2099
  activations: {},
2091
2100
  };
@@ -2109,6 +2118,7 @@ var Engine = /** @class */ (function () {
2109
2118
  inputs_1 = interpolate(fnCall.inputs || {}, context.scope);
2110
2119
  params_1 = fnCall.params || {};
2111
2120
  result_1 = {};
2121
+ context.inputs[name_1] = inputs_1;
2112
2122
  cacheResult = this.checkCache(name_1, inputs_1);
2113
2123
  if (!(cacheResult !== this.cacheMiss)) return [3 /*break*/, 2];
2114
2124
  // use as result
@@ -2377,7 +2387,7 @@ var Engine = /** @class */ (function () {
2377
2387
  if ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[toField]) {
2378
2388
  var normDef = normalizeVarDef(fn.inputs[toField]);
2379
2389
  if (normDef.default !== undefined) {
2380
- to.inputs[toField] = normDef.default;
2390
+ to.inputs[toField] = getDefault(normDef, to.inputs);
2381
2391
  }
2382
2392
  }
2383
2393
  }
@@ -2408,7 +2418,7 @@ var Engine = /** @class */ (function () {
2408
2418
  var _b = __read(_a, 2), key = _b[0], def = _b[1];
2409
2419
  var normDef = normalizeVarDef(def);
2410
2420
  if (normDef.default !== undefined) {
2411
- inputs[key] = normDef.default;
2421
+ inputs[key] = getDefault(normDef, inputs);
2412
2422
  }
2413
2423
  });
2414
2424
  // get params defaults
@@ -2417,7 +2427,7 @@ var Engine = /** @class */ (function () {
2417
2427
  var _b = __read(_a, 2), key = _b[0], def = _b[1];
2418
2428
  var normDef = normalizeVarDef(def);
2419
2429
  if (normDef.default !== undefined) {
2420
- params[key] = normDef.default;
2430
+ params[key] = getDefault(normDef, params);
2421
2431
  }
2422
2432
  });
2423
2433
  var newCall = {