@rkmodules/rules 0.0.106 → 0.0.107

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,8 +2088,8 @@ 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 = {
@@ -2377,7 +2385,7 @@ var Engine = /** @class */ (function () {
2377
2385
  if ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[toField]) {
2378
2386
  var normDef = normalizeVarDef(fn.inputs[toField]);
2379
2387
  if (normDef.default !== undefined) {
2380
- to.inputs[toField] = normDef.default;
2388
+ to.inputs[toField] = getDefault(normDef, to.inputs);
2381
2389
  }
2382
2390
  }
2383
2391
  }
@@ -2408,7 +2416,7 @@ var Engine = /** @class */ (function () {
2408
2416
  var _b = __read(_a, 2), key = _b[0], def = _b[1];
2409
2417
  var normDef = normalizeVarDef(def);
2410
2418
  if (normDef.default !== undefined) {
2411
- inputs[key] = normDef.default;
2419
+ inputs[key] = getDefault(normDef, inputs);
2412
2420
  }
2413
2421
  });
2414
2422
  // get params defaults
@@ -2417,7 +2425,7 @@ var Engine = /** @class */ (function () {
2417
2425
  var _b = __read(_a, 2), key = _b[0], def = _b[1];
2418
2426
  var normDef = normalizeVarDef(def);
2419
2427
  if (normDef.default !== undefined) {
2420
- params[key] = normDef.default;
2428
+ params[key] = getDefault(normDef, params);
2421
2429
  }
2422
2430
  });
2423
2431
  var newCall = {