@nudojs/core 1.1.3 → 1.2.0

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.
@@ -1,5 +1,5 @@
1
1
  import { File } from '@babel/types';
2
- import { T as Term, A as Abs, P as PrimName, a as Pred, b as Phi, C as Confidence } from './hof-types-tAeoYvzY.js';
2
+ import { T as Term, A as Abs, P as PrimName, a as Pred, b as Phi, C as Confidence } from './hof-types-COqDeD5F.js';
3
3
 
4
4
  declare function resetParseSourceCache(): void;
5
5
  declare function getParseSourceCacheSize(): number;
@@ -41,7 +41,7 @@ import {
41
41
  unknown,
42
42
  v,
43
43
  withExecPhi
44
- } from "./chunk-6DOKR7BM.js";
44
+ } from "./chunk-WB565PQK.js";
45
45
 
46
46
  // src/algebra/constraint.ts
47
47
  var SELF = "__nudo_self__";
@@ -2541,9 +2541,9 @@ function promoteAsFn(ctx, name, args, loc) {
2541
2541
  loc
2542
2542
  });
2543
2543
  }
2544
- function promoteCb(ctx, cbName, method, argTerms, loc) {
2545
- if (!ctx.params.has(cbName)) return;
2546
- const prev = ctx.shapes.get(cbName);
2544
+ function promoteCb(ctx, cevalName, method, argTerms, loc) {
2545
+ if (!ctx.params.has(cevalName)) return;
2546
+ const prev = ctx.shapes.get(cevalName);
2547
2547
  if (!prev) return;
2548
2548
  if (prev.shape.k !== "any" && prev.shape.k !== "unknown") return;
2549
2549
  let paramTypes;
@@ -2553,7 +2553,7 @@ function promoteCb(ctx, cbName, method, argTerms, loc) {
2553
2553
  returnType = abs({ k: "prim", type: "boolean" }, void 0, void 0, "path");
2554
2554
  } else {
2555
2555
  paramTypes = argTerms.map((t) => abs({ k: "any" }, t, void 0, "path"));
2556
- returnType = abs({ k: "any" }, v(`B:${cbName}`), void 0, "path");
2556
+ returnType = abs({ k: "any" }, v(`B:${cevalName}`), void 0, "path");
2557
2557
  }
2558
2558
  const fnShape = {
2559
2559
  k: "fn",
@@ -2561,9 +2561,9 @@ function promoteCb(ctx, cbName, method, argTerms, loc) {
2561
2561
  paramTypes,
2562
2562
  returnType
2563
2563
  };
2564
- promoteShape(ctx, cbName, fnShape, loc, false);
2564
+ promoteShape(ctx, cevalName, fnShape, loc, false);
2565
2565
  ctx.sites.push({
2566
- param: cbName,
2566
+ param: cevalName,
2567
2567
  argTerms,
2568
2568
  result: returnType,
2569
2569
  loc
@@ -2675,14 +2675,14 @@ function scanPromotions(body, params, paramTermIds, initialShapes) {
2675
2675
  }
2676
2676
 
2677
2677
  // src/algebra/generalize.ts
2678
- var bRunMemo = /* @__PURE__ */ new Map();
2679
- function bPathRunOf(source, modules, inject) {
2678
+ var evalRunMemo = /* @__PURE__ */ new Map();
2679
+ function evalRunOf(source, modules, inject) {
2680
2680
  const mKey = `${source}|${runTranspiledOptionsMemoKey({ ...inject ?? {}, ...modules ? { modules } : {} })}`;
2681
- if (bRunMemo.size >= 256) {
2682
- const oldest = bRunMemo.keys().next().value;
2683
- if (oldest !== void 0) bRunMemo.delete(oldest);
2681
+ if (evalRunMemo.size >= 256) {
2682
+ const oldest = evalRunMemo.keys().next().value;
2683
+ if (oldest !== void 0) evalRunMemo.delete(oldest);
2684
2684
  }
2685
- let run = bRunMemo.get(mKey);
2685
+ let run = evalRunMemo.get(mKey);
2686
2686
  if (run === void 0) {
2687
2687
  const merged = modules ?? inject?.modules;
2688
2688
  const r = tryRunTranspiled(source, {
@@ -2692,7 +2692,7 @@ function bPathRunOf(source, modules, inject) {
2692
2692
  });
2693
2693
  if (r === void 0) return void 0;
2694
2694
  run = r;
2695
- bRunMemo.set(mKey, run);
2695
+ evalRunMemo.set(mKey, run);
2696
2696
  }
2697
2697
  return run;
2698
2698
  }
@@ -3090,7 +3090,7 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
3090
3090
  );
3091
3091
  const envGated = envGatedSource && freeIdentifiers(body, boundNames).size > 0;
3092
3092
  const replaceGated = /@nudo:replace\b/.test(source) && !hasReps;
3093
- const bEligible = !unresolvableImports && !mockGated && !envGated && !replaceGated;
3093
+ const evalEligible = !unresolvableImports && !mockGated && !envGated && !replaceGated;
3094
3094
  const run = (args, phi = pTrue) => {
3095
3095
  const { key, varOrder } = instantiateMemoKey(args, phi);
3096
3096
  const hit = instMemo.get(key);
@@ -3098,27 +3098,27 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
3098
3098
  return alphaRenameResult(hit.result, hit.varOrder, varOrder);
3099
3099
  }
3100
3100
  let result;
3101
- if (bEligible) {
3101
+ if (evalEligible) {
3102
3102
  try {
3103
- const bRun = bPathRunOf(source, opts.modules, opts.inject);
3104
- if (!bRun) {
3103
+ const evalRun = evalRunOf(source, opts.modules, opts.inject);
3104
+ if (!evalRun) {
3105
3105
  } else if (fnName.includes(".")) {
3106
3106
  const [clsName, methodName] = fnName.split(".", 2);
3107
- const clsAbs = bRun[clsName ?? ""];
3107
+ const clsAbs = evalRun[clsName ?? ""];
3108
3108
  if (clsAbs && typeof clsAbs === "object" && "shape" in clsAbs) {
3109
3109
  const nCtor = ctorParamCountOf(fileAst, clsName ?? "");
3110
3110
  const inst = $new(clsAbs, Array.from({ length: nCtor }, () => abs({ k: "any" }, void 0, pTrue, "path")));
3111
3111
  result = withExecPhi(phi, () => $invoke(inst, methodName ?? "", args));
3112
3112
  }
3113
- } else if (fnName in bRun) {
3114
- const bArgs = args.map((a, i) => {
3113
+ } else if (fnName in evalRun) {
3114
+ const evalArgs = args.map((a, i) => {
3115
3115
  const shape2 = promoteScan.promotedShapes.get(params[i]);
3116
3116
  if (shape2 && (a.shape.k === "any" || a.shape.k === "unknown")) {
3117
3117
  return { shape: shape2, term: a.term, pred: a.pred, conf: "path" };
3118
3118
  }
3119
3119
  return a;
3120
3120
  });
3121
- result = callTranspiledExportFull(bRun, fnName, bArgs, { phi }).result;
3121
+ result = callTranspiledExportFull(evalRun, fnName, evalArgs, { phi }).result;
3122
3122
  }
3123
3123
  } catch {
3124
3124
  }
@@ -4029,17 +4029,17 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
4029
4029
  const resolve = collectCallResolvers(source, knownFns, opts);
4030
4030
  const forwards = collectForwarders(source, knownSet, resolve, file);
4031
4031
  const varAbs = opts?.varAbs ?? /* @__PURE__ */ new Map();
4032
- const bCallIndex = /* @__PURE__ */ new Map();
4032
+ const evalCallIndex = /* @__PURE__ */ new Map();
4033
4033
  for (const r of opts?.bCalls ?? []) {
4034
4034
  if (!r.callLoc) continue;
4035
4035
  const key = `${r.fnName}\0${r.callLoc.line}`;
4036
- const list = bCallIndex.get(key) ?? [];
4036
+ const list = evalCallIndex.get(key) ?? [];
4037
4037
  list.push(r.args);
4038
- bCallIndex.set(key, list);
4038
+ evalCallIndex.set(key, list);
4039
4039
  }
4040
4040
  const takeBCallArgs = (fnName, line) => {
4041
4041
  if (line === void 0) return void 0;
4042
- const list = bCallIndex.get(`${fnName}\0${line}`);
4042
+ const list = evalCallIndex.get(`${fnName}\0${line}`);
4043
4043
  if (!list || list.length === 0) return void 0;
4044
4044
  return list.shift();
4045
4045
  };
@@ -4632,10 +4632,10 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
4632
4632
  let absArgs = parsed.absArgs;
4633
4633
  let hasInfo = parsed.hasInfo;
4634
4634
  if (!hasInfo) {
4635
- const bArgs = takeBCallArgs(fnName, loc?.start.line);
4636
- if (bArgs && bArgs.length > 0) {
4637
- absArgs = bArgs;
4638
- hasInfo = bArgs.some(isInformativeArg);
4635
+ const evalArgs = takeBCallArgs(fnName, loc?.start.line);
4636
+ if (evalArgs && evalArgs.length > 0) {
4637
+ absArgs = evalArgs;
4638
+ hasInfo = evalArgs.some(isInformativeArg);
4639
4639
  }
4640
4640
  }
4641
4641
  if (!hasInfo || absArgs.length === 0) return;
@@ -4698,10 +4698,10 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
4698
4698
  let absArgs = parsedExt.absArgs;
4699
4699
  let hasInfo = parsedExt.hasInfo;
4700
4700
  if (!hasInfo) {
4701
- const bArgs = takeBCallArgs(ext.fnName, loc?.start.line);
4702
- if (bArgs && bArgs.length > 0) {
4703
- absArgs = bArgs;
4704
- hasInfo = bArgs.some(isInformativeArg);
4701
+ const evalArgs = takeBCallArgs(ext.fnName, loc?.start.line);
4702
+ if (evalArgs && evalArgs.length > 0) {
4703
+ absArgs = evalArgs;
4704
+ hasInfo = evalArgs.some(isInformativeArg);
4705
4705
  }
4706
4706
  }
4707
4707
  if (!hasInfo || absArgs.length === 0) return;