@nudojs/core 1.2.2 → 1.4.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-0B9Z66n0.d.ts → check-report-Ci1dDysO.d.ts} +102 -25
- package/dist/{chunk-TOURNNEA.js → chunk-7QUVTEYZ.js} +1154 -254
- package/dist/{chunk-4V3CRVSD.js → chunk-LFCF6BLE.js} +3486 -2107
- package/dist/exec.d.ts +590 -3
- package/dist/exec.js +21 -1
- package/dist/index.d.ts +127 -132
- package/dist/index.js +417 -269
- package/dist/internal.d.ts +111 -7
- package/dist/internal.js +102 -28
- package/dist/run-WJfj477N.d.ts +769 -0
- package/package.json +1 -1
- package/dist/hof-types-DqDpAxfh.d.ts +0 -382
- package/dist/index-BNiZvVHw.d.ts +0 -739
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { File } from '@babel/types';
|
|
2
|
-
import {
|
|
2
|
+
import { A as Abs, T as Term, P as PrimName, a as Pred, L as LiteralValue, b as Phi, C as Confidence } from './run-WJfj477N.js';
|
|
3
3
|
|
|
4
4
|
declare function resetParseSourceCache(): void;
|
|
5
5
|
declare function getParseSourceCacheSize(): number;
|
|
@@ -8,6 +8,30 @@ declare function parseSource(source: string, opts?: {
|
|
|
8
8
|
keepTs?: boolean;
|
|
9
9
|
}): File;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Promise 构造 / then 链 / 静态方法 + micro 队列
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare function enterPromiseExecutorScope(): void;
|
|
16
|
+
declare function leavePromiseExecutorScope(): number;
|
|
17
|
+
/** $fork 在 executor 内发生时打点(多臂 resolve 需 join,不得 first-wins 假精确) */
|
|
18
|
+
declare function notePromiseExecutorFork(): void;
|
|
19
|
+
/** 队列硬上限:无界增长是 LSP 长会话泄漏点(只进不出的模块求值路径) */
|
|
20
|
+
declare const MAX_PROMISE_MICROS = 1024;
|
|
21
|
+
declare function queuePromiseMicro(task: () => void): void;
|
|
22
|
+
declare function getPromiseMicrosLength(): number;
|
|
23
|
+
declare function drainPromiseMicros(): void;
|
|
24
|
+
/**
|
|
25
|
+
* new Promise(executor):调用 executor(resolve, reject),收集 resolve 实参作为
|
|
26
|
+
* promise inner。原生只认第一次 settle——顺序双 resolve 取第一次;执行器内
|
|
27
|
+
* $fork 分叉时各臂 settle 值 join(路径敏感,不得 first-wins 假精确)。
|
|
28
|
+
* reject 不填 resolved 通道;永不 settle / 抽象 fn / 执行抛 → promise<unknown>。
|
|
29
|
+
*/
|
|
30
|
+
declare function evalPromiseCtor(args: Abs[]): Abs;
|
|
31
|
+
/** then/catch/finally:可映射回调 → 新 inner;做不到诚实 promise<unknown> */
|
|
32
|
+
declare function evalPromiseMethod(name: string, recv: Abs, args: Abs[]): Abs | undefined;
|
|
33
|
+
declare function evalPromiseStatic(name: string, args: Abs[]): Abs | undefined;
|
|
34
|
+
|
|
11
35
|
/**
|
|
12
36
|
* 项(Term)防爆炸:深度/宽度阈值 → leak 为新鲜 var + 等式约束。
|
|
13
37
|
*/
|
|
@@ -36,6 +60,21 @@ declare function leakIfNeeded(a: Abs, budget?: LeakBudget, label?: string): Abs;
|
|
|
36
60
|
* refine / LSP 共享单一定义——历史上三份内联拷贝已各自漂移过)。
|
|
37
61
|
*/
|
|
38
62
|
declare function normPath(p: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* 稳定路径键:统一 Windows 盘符形态(`file:///c:/x` / `/c:/x` / `c:\x` / `c:/x` /
|
|
65
|
+
* `C:/x` → `c:/x`),POSIX 绝对路径过 normPath 后恒等。幂等。
|
|
66
|
+
*
|
|
67
|
+
* L0 memo 依赖索引与定向逐出、模块图脏传播查找必须走同一键——否则跨形态
|
|
68
|
+
* 逐出/脏传播在 Windows 上 miss(FIX-RESIDUAL-3)。core 不引 path:此处只做
|
|
69
|
+
* 纯字符串归一,相对路径的 resolve 由宿主(LSP cacheKey)负责。
|
|
70
|
+
*/
|
|
71
|
+
declare function stablePathKey(p: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* 把 `buildModuleGraph` 的 imports/dependents 边表按键形态归一到 stablePathKey。
|
|
74
|
+
* 边目标来自 resolveModuleFile(fs 原生,如 `c:\a.js`)、from 节点可能已是
|
|
75
|
+
* 键形态(`c:/a.js`)——混形态会让 computeDirtySet 跨形态查找漏边。
|
|
76
|
+
*/
|
|
77
|
+
declare function stablePathKeyGraph(m: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
39
78
|
/** core 不引 path:相对 spec 纯字符串拼接(与 LSP resolve 对齐时双方 norm) */
|
|
40
79
|
declare function resolveDepPath(fromFile: string, spec: string): string;
|
|
41
80
|
/**
|
|
@@ -51,26 +90,6 @@ declare function isNodeModulesPath(p: string): boolean;
|
|
|
51
90
|
*/
|
|
52
91
|
declare function sidecarPathOf(file: string): string;
|
|
53
92
|
|
|
54
|
-
/**
|
|
55
|
-
* 约束模板构建器(参数无关)。
|
|
56
|
-
*
|
|
57
|
-
* number().gt(0) → 占位项 self 上的 Pred
|
|
58
|
-
* number().int().ge(0) → 整数 + 下界
|
|
59
|
-
* string().min(1) → 非空串(长度)
|
|
60
|
-
* array(number().gt(0)) → 元素约束
|
|
61
|
-
* shape({ id: number().gt(0) }) → object 形状约束
|
|
62
|
-
* lit(42) → 字面量(prim + eq(self, 42))
|
|
63
|
-
* union(number().gt(0), lit(0)) → 成员析取(or / joinAbs)
|
|
64
|
-
* fn({ x: number().gt(0) }, number()) → 一等函数约束
|
|
65
|
-
* number().gt(0).shift(1) → 界平移(x>0 ⇒ x+n>1)
|
|
66
|
-
* instantiate("ms") → Pred ms > 0 / u.id > 0 ∧ …
|
|
67
|
-
*
|
|
68
|
-
* 在 *.nudo.js 里执行;不是 zod 绑定,是我们自己的运行时 API。
|
|
69
|
-
* 不需要 interface/type 语法——契约用 JS 表达式声明。
|
|
70
|
-
* 命名:litC/andC 与 term.ts 的 lit、pred.ts 的 and 消歧(桶导出不再冲突)。
|
|
71
|
-
* 侧车注入表仍以 `lit`/`and` 为键名(*.nudo.js 用户写法不变)。
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
93
|
/** 模板占位项;instantiate 时换成真实参数名 */
|
|
75
94
|
declare const SELF = "__nudo_self__";
|
|
76
95
|
/** 字段访问项:u.id */
|
|
@@ -149,9 +168,21 @@ declare function array(item: NudoConstraint | ConstraintBuilder | number | strin
|
|
|
149
168
|
*/
|
|
150
169
|
declare function shape(fields: Record<string, NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined>): ConstraintBuilder;
|
|
151
170
|
/** litC(v):字面量契约——prim 按 v 类型、eq(self, v) pred 编码(不开新字段) */
|
|
152
|
-
declare function litC(v:
|
|
171
|
+
declare function litC(v: LiteralValue): ConstraintBuilder;
|
|
153
172
|
/** union(...cs):成员析取;instantiate 为 or(...),entry Abs 为成员 joinAbs。空参 throw */
|
|
154
173
|
declare function union(...cs: (NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined)[]): ConstraintBuilder;
|
|
174
|
+
/**
|
|
175
|
+
* nullable(c):允许 null / undefined 的约束(nullish 显式化)。
|
|
176
|
+
* 糖 = union(c, lit(null), lit(undefined))。
|
|
177
|
+
* `return null` / `return undefined` 只对含 nullish 的契约合法;
|
|
178
|
+
* 对不含 nullish 的契约(如 number().gt(0))报 constraint-violated。
|
|
179
|
+
*/
|
|
180
|
+
declare function nullable(c: NudoConstraint | ConstraintBuilder | number | string | boolean): ConstraintBuilder;
|
|
181
|
+
/**
|
|
182
|
+
* 契约域是否包含 nullish(null / undefined)。
|
|
183
|
+
* union 任一成员含 nullish 即含;lit(null)/lit(undefined) 的 eq 谓词识别。
|
|
184
|
+
*/
|
|
185
|
+
declare function constraintAdmitsNullish(c: NudoConstraint): boolean;
|
|
155
186
|
/**
|
|
156
187
|
* fn(params, returns?, { throws? }):一等函数约束。
|
|
157
188
|
* Phase 1 只展示不执法:参数位 instantiate 恒真(pTrue),
|
|
@@ -172,6 +203,22 @@ declare function partial(c: NudoConstraint | ConstraintBuilder): ConstraintBuild
|
|
|
172
203
|
declare function pick(c: NudoConstraint | ConstraintBuilder, keys: string[]): ConstraintBuilder;
|
|
173
204
|
/** omit(c, keys):shape 去字段;非 shape throw */
|
|
174
205
|
declare function omit(c: NudoConstraint | ConstraintBuilder, keys: string[]): ConstraintBuilder;
|
|
206
|
+
/**
|
|
207
|
+
* 约束构建器表面名表(单一真源):case 实参文法、mock 类型表达式识别与
|
|
208
|
+
* 侧车注入共用的名字 → 实现映射。键名是 *.nudo.js / 指令里的用户写法
|
|
209
|
+
* (`lit`/`and` 而非内部的 litC/andC)。
|
|
210
|
+
*
|
|
211
|
+
* 任何「构建器名单」硬编码(CONSTRAINT_EXPR_RE 一类的识别正则)必须由
|
|
212
|
+
* `CONSTRAINT_BUILDER_NAMES` 生成,禁止再手维护一份。
|
|
213
|
+
*/
|
|
214
|
+
declare const CONSTRAINT_BUILDERS: Record<string, unknown>;
|
|
215
|
+
/** 构建器表面名(供文法正则 / 测试枚举;顺序即表定义顺序) */
|
|
216
|
+
declare const CONSTRAINT_BUILDER_NAMES: readonly string[];
|
|
217
|
+
/**
|
|
218
|
+
* 约束表达式头:`name(` 形态。由 CONSTRAINT_BUILDER_NAMES 生成——
|
|
219
|
+
* 名单只在 CONSTRAINT_BUILDERS 一处维护。
|
|
220
|
+
*/
|
|
221
|
+
declare const CONSTRAINT_EXPR_RE: RegExp;
|
|
175
222
|
/** 把模板绑定到参数名:self → paramName;shape 展开为字段访问 Pred */
|
|
176
223
|
declare function instantiateConstraint(c: NudoConstraint, paramName: string): Pred;
|
|
177
224
|
/**
|
|
@@ -219,6 +266,10 @@ type NamedImport = {
|
|
|
219
266
|
names: string[];
|
|
220
267
|
spec: string;
|
|
221
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* `@nudo:import` 命名/namespace 导入(D5=F1:文法在 directive-scan 单源)。
|
|
271
|
+
* default 等未识别形态发 nudo:contract-syntax,不再静默丢弃。
|
|
272
|
+
*/
|
|
222
273
|
declare function extractNudoImports(source: string): NamedImport[];
|
|
223
274
|
/** refine 侧车加载诊断(severity 由消费方按 code 定档,形状对齐 Issue 子集) */
|
|
224
275
|
type RefineDiag = {
|
|
@@ -280,10 +331,24 @@ declare function extractRefineReturnFromSource(source: string, fnName: string, o
|
|
|
280
331
|
* @nudo:case "neg" (0) !! throws → 申报任意 throw
|
|
281
332
|
* @nudo:case "neg" (0) !! throws Error → 申报 Error
|
|
282
333
|
*
|
|
283
|
-
* 与 refine
|
|
284
|
-
* undefined = 无申报(L2 照常执法)。
|
|
334
|
+
* 与 refine 同扫函数前注释块(D6=G2 同一 scope 绑定)。
|
|
335
|
+
* 返回 `*` = 申报任意;数组 = 按名申报;undefined = 无申报(L2 照常执法)。
|
|
285
336
|
*/
|
|
286
337
|
declare function extractDeclaredThrows(source: string, fnName: string): string[] | "*" | undefined;
|
|
338
|
+
/**
|
|
339
|
+
* 函数级预算旋钮(#64 P4):
|
|
340
|
+
* @nudo:budget forks=20000
|
|
341
|
+
* @nudo:budget calls=50000 depth=128
|
|
342
|
+
* @nudo:budget forks=20000, calls=50000
|
|
343
|
+
*
|
|
344
|
+
* 与 @nudo:throws 同路径扫函数前注释块(D6=G2 同一 scope 绑定)。
|
|
345
|
+
* 只抬高预算(不降低全局默认);未声明的维度沿用全局。非法值忽略。
|
|
346
|
+
*/
|
|
347
|
+
declare function extractFnBudget(source: string, fnName: string): {
|
|
348
|
+
forks?: number;
|
|
349
|
+
calls?: number;
|
|
350
|
+
depth?: number;
|
|
351
|
+
} | undefined;
|
|
287
352
|
|
|
288
353
|
/**
|
|
289
354
|
* Interface 分层推导(design-refine-derivation §2.1/§2.2/§11 第 0 步):
|
|
@@ -386,6 +451,8 @@ type EffectiveInterface = {
|
|
|
386
451
|
returns?: boolean;
|
|
387
452
|
};
|
|
388
453
|
};
|
|
454
|
+
/** 与 resetNudoModuleExecCache 同口径:分析会话/测试间清空失败去重表 */
|
|
455
|
+
declare function resetSidecarLoadFailureCache(): void;
|
|
389
456
|
/**
|
|
390
457
|
* 单点读取口:手写 ∪ 侧车同名 ∪ 生成段 → 有效契约(含来源标注)。
|
|
391
458
|
* 无任何契约 → undefined(implicit 由调用方处理)。
|
|
@@ -621,6 +688,16 @@ type CheckJsonMulti = {
|
|
|
621
688
|
budgetTruncated?: boolean;
|
|
622
689
|
};
|
|
623
690
|
budget?: CheckReport["budget"];
|
|
691
|
+
/**
|
|
692
|
+
* 路径/IO 错误(additive)。`pathErrors` 非空 ⇒ `ok: false` ⇒ CLI exit 1。
|
|
693
|
+
* ok↔exit 单一来源:CLI 在 --json 路径只按信封 ok 设 exit。
|
|
694
|
+
*/
|
|
695
|
+
pathErrors?: Array<{
|
|
696
|
+
path: string;
|
|
697
|
+
code: string;
|
|
698
|
+
message: string;
|
|
699
|
+
suggestion?: string;
|
|
700
|
+
}>;
|
|
624
701
|
reports: CheckJson[];
|
|
625
702
|
};
|
|
626
703
|
declare function serializeCheckJson(r: CheckReport): CheckJson;
|
|
@@ -658,4 +735,4 @@ declare function formatGitlabCodeQuality(r: CheckReport, opts?: {
|
|
|
658
735
|
workspaceRoot?: string;
|
|
659
736
|
}): GitlabCodeQualityIssue[];
|
|
660
737
|
|
|
661
|
-
export {
|
|
738
|
+
export { constraintAdmitsNullish as $, type EffectiveInterface as A, type InterfaceDiag as B, type CheckIssue as C, type Diagnostic as D, type EffectiveInterfaceOpts as E, type InterfaceTierInfo as F, type GitlabCodeQualityIssue as G, type NamedImport as H, type InterfaceSource as I, type NudoField as J, type NudoFnConstraint as K, type LeakBudget as L, MAX_PROMISE_MICROS as M, type NudoConstraint as N, NudoSidecarError as O, type NudoSig as P, type RefineEntry as Q, type RefineDiag as R, type RefineResolveOpts as S, SELF as T, actionsForIssue as U, andC as V, any as W, array as X, boolean as Y, checkArg as Z, checkCall as _, type InterfaceTierOpts as a, constraintToEntryAbs as a0, drainPromiseMicros as a1, effectiveInterface as a2, enterPromiseExecutorScope as a3, evalPromiseCtor as a4, evalPromiseMethod as a5, evalPromiseStatic as a6, execNudoModule as a7, extractDeclaredThrows as a8, extractFnBudget as a9, notePromiseExecutorFork as aA, nullable as aB, number as aC, omit as aD, partial as aE, pick as aF, queuePromiseMicro as aG, refineDiagCount as aH, refineToIndexedFull as aI, resetNudoModuleExecCache as aJ, resetParseSourceCache as aK, resetSidecarLoadFailureCache as aL, serializeCheckJson as aM, serializeCheckJsonMulti as aN, setInterfaceDiagCollector as aO, setRefineDiagCollector as aP, shape as aQ, sidecarClosureFingerprint as aR, sidecarPathOf as aS, string as aT, takeInterfaceDiags as aU, takeInterfaceDiagsSince as aV, takeRefineDiags as aW, takeRefineDiagsSince as aX, throwConstraintToKinds as aY, union as aZ, extractNudoImports as aa, extractRefineReturnFromSource as ab, extractRefinesFromSource as ac, fn as ad, fnConstraintToEntryReqs as ae, formatCheckReport as af, formatConstraint as ag, formatDiagnostics as ah, formatEffectiveInterfaceDisplay as ai, formatGithubAnnotations as aj, formatGitlabCodeQuality as ak, formatInterfaceTierLine as al, generatedExportNames as am, getParseSourceCacheSize as an, getTerm as ao, instantiateConstraint as ap, interfaceDiagCount as aq, interfaceSourceOf as ar, interfaceTierOf as as, isIntFlag as at, isNodeModulesPath as au, isNudoConstraint as av, leavePromiseExecutorScope as aw, lenTerm as ax, litC as ay, localNamedExports as az, type LoadDepsFingerprint as b, extractAllLoadSpecs as c, defaultLeakBudget as d, exceedsBudget as e, loadModuleDepsFingerprint as f, getPromiseMicrosLength as g, resolveDepPath as h, stablePathKey as i, stablePathKeyGraph as j, termNodes as k, leakIfNeeded as l, maybeLeak as m, normPath as n, type CheckReport as o, parseSource as p, CONSTRAINT_BUILDERS as q, resetLeakCounter as r, sidecarSpecsOf as s, termDepth as t, CONSTRAINT_BUILDER_NAMES as u, CONSTRAINT_EXPR_RE as v, type CheckAction as w, type CheckJson as x, type CheckJsonMulti as y, type ConstraintBuilder as z };
|