@nudojs/core 1.1.4 → 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.
- package/dist/{check-report-AtnAfY9U.d.ts → check-report-TEOZ4cPZ.d.ts} +1 -1
- package/dist/{chunk-XOHKHJHE.js → chunk-GD5XIQQK.js} +34 -34
- package/dist/{chunk-SQSO4NKT.js → chunk-WB565PQK.js} +245 -186
- package/dist/exec.d.ts +2 -2
- package/dist/exec.js +25 -25
- package/dist/{hof-types-tAeoYvzY.d.ts → hof-types-COqDeD5F.d.ts} +3 -3
- package/dist/{index-D4rnOHre.d.ts → index-DMjMPLV0.d.ts} +39 -39
- package/dist/index.d.ts +17 -17
- package/dist/index.js +48 -48
- package/dist/internal.d.ts +26 -26
- package/dist/internal.js +16 -16
- package/package.json +1 -1
|
@@ -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-
|
|
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-
|
|
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,
|
|
2545
|
-
if (!ctx.params.has(
|
|
2546
|
-
const prev = ctx.shapes.get(
|
|
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:${
|
|
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,
|
|
2564
|
+
promoteShape(ctx, cevalName, fnShape, loc, false);
|
|
2565
2565
|
ctx.sites.push({
|
|
2566
|
-
param:
|
|
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
|
|
2679
|
-
function
|
|
2678
|
+
var evalRunMemo = /* @__PURE__ */ new Map();
|
|
2679
|
+
function evalRunOf(source, modules, inject) {
|
|
2680
2680
|
const mKey = `${source}|${runTranspiledOptionsMemoKey({ ...inject ?? {}, ...modules ? { modules } : {} })}`;
|
|
2681
|
-
if (
|
|
2682
|
-
const oldest =
|
|
2683
|
-
if (oldest !== void 0)
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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 (
|
|
3101
|
+
if (evalEligible) {
|
|
3102
3102
|
try {
|
|
3103
|
-
const
|
|
3104
|
-
if (!
|
|
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 =
|
|
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
|
|
3114
|
-
const
|
|
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(
|
|
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
|
|
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 =
|
|
4036
|
+
const list = evalCallIndex.get(key) ?? [];
|
|
4037
4037
|
list.push(r.args);
|
|
4038
|
-
|
|
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 =
|
|
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
|
|
4636
|
-
if (
|
|
4637
|
-
absArgs =
|
|
4638
|
-
hasInfo =
|
|
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
|
|
4702
|
-
if (
|
|
4703
|
-
absArgs =
|
|
4704
|
-
hasInfo =
|
|
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;
|