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