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