@nudojs/service 0.3.1 → 1.0.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/chunk-FSIHAE7I.js +5871 -0
- package/dist/config-UlReSTfh.d.ts +152 -0
- package/dist/evaluator/evaluator-api.d.ts +28 -0
- package/dist/evaluator/evaluator-api.js +68 -0
- package/dist/index.d.ts +117 -5
- package/dist/index.js +955 -464
- package/package.json +14 -7
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Node } from '@babel/types';
|
|
2
|
+
import { TypeValue, Environment } from '@nudojs/core';
|
|
3
|
+
|
|
4
|
+
/** 值上命名成员是否可能存在(union 部分成员持有的 no-method 降 warning
|
|
5
|
+
* 用):primitive/literal 走 wrapper 原型近似表('x'.charCodeAt),
|
|
6
|
+
* instance 走近似方法表。诊断侧据此区分"部分成员可能有"与"确定没有"。 */
|
|
7
|
+
declare function memberMayExistOn(tv: TypeValue, propName: string): boolean;
|
|
8
|
+
type SourceRange = {
|
|
9
|
+
start: {
|
|
10
|
+
line: number;
|
|
11
|
+
column: number;
|
|
12
|
+
};
|
|
13
|
+
end: {
|
|
14
|
+
line: number;
|
|
15
|
+
column: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
declare function setCurrentSource(source: string): void;
|
|
19
|
+
declare const RETURN_SIGNAL: unique symbol;
|
|
20
|
+
declare const BRANCH_SIGNAL: unique symbol;
|
|
21
|
+
declare const THROW_SIGNAL: unique symbol;
|
|
22
|
+
type ReturnSignal = {
|
|
23
|
+
readonly [RETURN_SIGNAL]: true;
|
|
24
|
+
readonly value: TypeValue;
|
|
25
|
+
};
|
|
26
|
+
type BranchSignal = {
|
|
27
|
+
readonly [BRANCH_SIGNAL]: true;
|
|
28
|
+
readonly returnedValue: TypeValue;
|
|
29
|
+
readonly fallthroughEnv: Environment;
|
|
30
|
+
};
|
|
31
|
+
type ThrowSignal = {
|
|
32
|
+
readonly [THROW_SIGNAL]: true;
|
|
33
|
+
readonly thrown: TypeValue;
|
|
34
|
+
readonly loc?: SourceRange;
|
|
35
|
+
};
|
|
36
|
+
type EvalResult = TypeValue | ReturnSignal | BranchSignal | ThrowSignal;
|
|
37
|
+
declare function resetMemo(): void;
|
|
38
|
+
declare function setModuleResolver(resolver: ((source: string, fromDir: string) => {
|
|
39
|
+
ast: Node;
|
|
40
|
+
filePath: string;
|
|
41
|
+
json?: unknown;
|
|
42
|
+
} | null) | null): void;
|
|
43
|
+
declare function setEnvModules(modules: Record<string, Record<string, TypeValue>>): void;
|
|
44
|
+
declare function resetEnvModules(): void;
|
|
45
|
+
declare function setMockModules(mocks: Map<string, {
|
|
46
|
+
fromPath: string;
|
|
47
|
+
names?: string[];
|
|
48
|
+
}>): void;
|
|
49
|
+
declare function resetMockModules(): void;
|
|
50
|
+
declare function setUnknownBuiltinHandler(handler: ((name: string, loc?: {
|
|
51
|
+
start: {
|
|
52
|
+
line: number;
|
|
53
|
+
column: number;
|
|
54
|
+
};
|
|
55
|
+
end: {
|
|
56
|
+
line: number;
|
|
57
|
+
column: number;
|
|
58
|
+
};
|
|
59
|
+
}) => void) | null): void;
|
|
60
|
+
declare function setSampleCount(count: number): void;
|
|
61
|
+
declare function setMaxConcreteIter(count: number): void;
|
|
62
|
+
declare function setNodeTypeCollector(collector: ((node: Node, tv: TypeValue) => void) | null): void;
|
|
63
|
+
type CallRecord = {
|
|
64
|
+
fnName: string;
|
|
65
|
+
argTypes: TypeValue[];
|
|
66
|
+
resultType: TypeValue;
|
|
67
|
+
throws: TypeValue;
|
|
68
|
+
/** Line-relative. Per-fn cache replay shifts this by lineDelta — if you
|
|
69
|
+
* add another position field (callee loc, arg loc), extend
|
|
70
|
+
* shiftCallRecordLines in analyzer.ts in the same change. */
|
|
71
|
+
callLoc?: {
|
|
72
|
+
line: number;
|
|
73
|
+
column: number;
|
|
74
|
+
};
|
|
75
|
+
targetModule?: string;
|
|
76
|
+
targetExport?: string;
|
|
77
|
+
/** export names the same function value was re-exported under after its
|
|
78
|
+
* defining module (barrel `index.js`, CJS forwarding shims); usage-site
|
|
79
|
+
* records stay name-matchable against them */
|
|
80
|
+
targetAliases?: string[];
|
|
81
|
+
/** module whose evaluation created the function value (definition site).
|
|
82
|
+
* Usage-site collection transitively evaluates the library under require(),
|
|
83
|
+
* so records of the library's INTERNAL calls (no export tag) can still be
|
|
84
|
+
* attributed to the defining file — while test-local functions and builtin
|
|
85
|
+
* statics stay unattributed and cannot pollute same-name candidates. */
|
|
86
|
+
fnModule?: string;
|
|
87
|
+
};
|
|
88
|
+
/** usage-site 执行标记:外部调用记录的实参里携带的闭包(测试回调等)在
|
|
89
|
+
* case 合成重求值时被执行,其内部错误属于使用现场文件,与本文件分析无关。
|
|
90
|
+
* 分析侧在注入前对全部外部实参调用本函数;执行来源栈读到该标记时
|
|
91
|
+
* recordUnknown.originModule 记为标记值,分析侧据此丢弃。不按模块路径
|
|
92
|
+
* 比较——跨文件依赖(本文件 require 链上加载的模块)的执行记录是合法
|
|
93
|
+
* 的可达分析,不能误伤。 */
|
|
94
|
+
declare const USAGE_SITE_MODULE = "__usage_site__";
|
|
95
|
+
declare function setUsageSiteTag(tv: TypeValue, _seen?: Set<object>): void;
|
|
96
|
+
declare function setCallCollector(collector: ((record: CallRecord) => void) | null): void;
|
|
97
|
+
type UnknownRecord = {
|
|
98
|
+
kind: "method" | "property" | "global";
|
|
99
|
+
name: string;
|
|
100
|
+
receiverType?: TypeValue;
|
|
101
|
+
loc?: {
|
|
102
|
+
line: number;
|
|
103
|
+
column: number;
|
|
104
|
+
};
|
|
105
|
+
reason?: string;
|
|
106
|
+
origin?: {
|
|
107
|
+
line: number;
|
|
108
|
+
column: number;
|
|
109
|
+
};
|
|
110
|
+
/** 定义当前正在执行的函数的模块(执行来源栈顶)。case 合成重求值会执行
|
|
111
|
+
* 注入实参携带的使用现场闭包体,其内部错误记录属于使用现场文件——
|
|
112
|
+
* 分析侧据此丢弃(行数守卫会被同行号假阳性骗过)。 */
|
|
113
|
+
originModule?: string;
|
|
114
|
+
};
|
|
115
|
+
declare function setUnknownCollector(collector: ((record: UnknownRecord) => void) | null): void;
|
|
116
|
+
declare function setProvenanceTracking(enabled: boolean): void;
|
|
117
|
+
declare function evaluate(node: Node, env: Environment): EvalResult;
|
|
118
|
+
type CallResult = {
|
|
119
|
+
value: TypeValue;
|
|
120
|
+
throws: TypeValue;
|
|
121
|
+
throwLoc?: SourceRange;
|
|
122
|
+
};
|
|
123
|
+
declare function evaluateFunction(fnNode: Node, args: TypeValue[], env: Environment): TypeValue;
|
|
124
|
+
declare function evaluateFunctionFull(fnNode: Node, args: TypeValue[], env: Environment): CallResult;
|
|
125
|
+
declare function evaluateProgram(node: Node, env: Environment): TypeValue;
|
|
126
|
+
declare function getUnreachableRanges(): SourceRange[];
|
|
127
|
+
declare function resetUnreachableRanges(): void;
|
|
128
|
+
declare function setCurrentFileDir(dir: string): void;
|
|
129
|
+
|
|
130
|
+
type NudoConfig = {
|
|
131
|
+
env?: string[];
|
|
132
|
+
mocks?: Record<string, string>;
|
|
133
|
+
interface?: {
|
|
134
|
+
/** 侧车 ambient 绑定总开关(check/LSP 执法与 interface 打印共用) */
|
|
135
|
+
autoBind?: boolean;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
type InterfaceConfig = {
|
|
139
|
+
autoBind: boolean;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* 归一化 `nudo.interface` 配置段:autoBind 默认 true。
|
|
143
|
+
* (emit/ignore 白名单键随 Phase 2 root 推导落地时再引入——不留未接线的
|
|
144
|
+
* 声明面,用户写了会被静默忽略。)
|
|
145
|
+
*/
|
|
146
|
+
declare function interfaceConfig(config: NudoConfig | null | undefined): InterfaceConfig;
|
|
147
|
+
declare function findProjectConfig(startDir: string): {
|
|
148
|
+
config: NudoConfig;
|
|
149
|
+
projectDir: string;
|
|
150
|
+
} | null;
|
|
151
|
+
|
|
152
|
+
export { type CallRecord as C, type InterfaceConfig as I, type NudoConfig as N, USAGE_SITE_MODULE as U, type UnknownRecord as a, evaluateFunction as b, evaluateFunctionFull as c, evaluateProgram as d, evaluate as e, findProjectConfig as f, getUnreachableRanges as g, resetMemo as h, interfaceConfig as i, resetMockModules as j, resetUnreachableRanges as k, setCurrentFileDir as l, memberMayExistOn as m, setCurrentSource as n, setEnvModules as o, setMaxConcreteIter as p, setMockModules as q, resetEnvModules as r, setCallCollector as s, setModuleResolver as t, setNodeTypeCollector as u, setProvenanceTracking as v, setSampleCount as w, setUnknownBuiltinHandler as x, setUnknownCollector as y, setUsageSiteTag as z };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { C as CallRecord, I as InterfaceConfig, N as NudoConfig, U as USAGE_SITE_MODULE, a as UnknownRecord, e as evaluate, b as evaluateFunction, c as evaluateFunctionFull, d as evaluateProgram, f as findProjectConfig, g as getUnreachableRanges, i as interfaceConfig, m as memberMayExistOn, r as resetEnvModules, h as resetMemo, j as resetMockModules, k as resetUnreachableRanges, s as setCallCollector, l as setCurrentFileDir, n as setCurrentSource, o as setEnvModules, p as setMaxConcreteIter, q as setMockModules, t as setModuleResolver, u as setNodeTypeCollector, v as setProvenanceTracking, w as setSampleCount, x as setUnknownBuiltinHandler, y as setUnknownCollector, z as setUsageSiteTag } from '../config-UlReSTfh.js';
|
|
2
|
+
import { Node } from '@babel/types';
|
|
3
|
+
import { Environment, TypeValue } from '@nudojs/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Given a test expression and the current environment, produce two
|
|
7
|
+
* environments: one where the test is truthy, one where it is falsy.
|
|
8
|
+
*/
|
|
9
|
+
declare function narrow(test: Node, env: Environment): [trueEnv: Environment, falseEnv: Environment];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 内置类原型机制:错误类集合、可构造内置类、Object/Array/Map/Set/…/Buffer
|
|
13
|
+
* 的原型成员近似表,以及 `X.prototype` 单例与类命名空间记忆化。
|
|
14
|
+
* 求值器成员分派与补全侧成员派生共用本表的唯一真值。
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare const BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS: Record<string, Record<string, TypeValue>>;
|
|
18
|
+
|
|
19
|
+
type LoadedEnv = {
|
|
20
|
+
modules: Record<string, Record<string, TypeValue>>;
|
|
21
|
+
};
|
|
22
|
+
declare function preloadPathEnvs(envNames: string[], baseDir: string): Promise<void>;
|
|
23
|
+
declare function loadEnvsAsync(envNames: string[], globalEnv: Environment, baseDir?: string): Promise<LoadedEnv>;
|
|
24
|
+
declare function loadEnvs(envNames: string[], globalEnv: Environment): LoadedEnv;
|
|
25
|
+
|
|
26
|
+
declare function resolveNpmNudo(source: string, fromDir: string): string | null;
|
|
27
|
+
|
|
28
|
+
export { BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS, type LoadedEnv, loadEnvs, loadEnvsAsync, narrow, preloadPathEnvs, resolveNpmNudo };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS,
|
|
3
|
+
USAGE_SITE_MODULE,
|
|
4
|
+
evaluate,
|
|
5
|
+
evaluateFunction,
|
|
6
|
+
evaluateFunctionFull,
|
|
7
|
+
evaluateProgram,
|
|
8
|
+
findProjectConfig,
|
|
9
|
+
getUnreachableRanges,
|
|
10
|
+
interfaceConfig,
|
|
11
|
+
loadEnvs,
|
|
12
|
+
loadEnvsAsync,
|
|
13
|
+
memberMayExistOn,
|
|
14
|
+
narrow,
|
|
15
|
+
preloadPathEnvs,
|
|
16
|
+
resetEnvModules,
|
|
17
|
+
resetMemo,
|
|
18
|
+
resetMockModules,
|
|
19
|
+
resetUnreachableRanges,
|
|
20
|
+
resolveNpmNudo,
|
|
21
|
+
setCallCollector,
|
|
22
|
+
setCurrentFileDir,
|
|
23
|
+
setCurrentSource,
|
|
24
|
+
setEnvModules,
|
|
25
|
+
setMaxConcreteIter,
|
|
26
|
+
setMockModules,
|
|
27
|
+
setModuleResolver,
|
|
28
|
+
setNodeTypeCollector,
|
|
29
|
+
setProvenanceTracking,
|
|
30
|
+
setSampleCount,
|
|
31
|
+
setUnknownBuiltinHandler,
|
|
32
|
+
setUnknownCollector,
|
|
33
|
+
setUsageSiteTag
|
|
34
|
+
} from "../chunk-FSIHAE7I.js";
|
|
35
|
+
export {
|
|
36
|
+
BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS,
|
|
37
|
+
USAGE_SITE_MODULE,
|
|
38
|
+
evaluate,
|
|
39
|
+
evaluateFunction,
|
|
40
|
+
evaluateFunctionFull,
|
|
41
|
+
evaluateProgram,
|
|
42
|
+
findProjectConfig,
|
|
43
|
+
getUnreachableRanges,
|
|
44
|
+
interfaceConfig,
|
|
45
|
+
loadEnvs,
|
|
46
|
+
loadEnvsAsync,
|
|
47
|
+
memberMayExistOn,
|
|
48
|
+
narrow,
|
|
49
|
+
preloadPathEnvs,
|
|
50
|
+
resetEnvModules,
|
|
51
|
+
resetMemo,
|
|
52
|
+
resetMockModules,
|
|
53
|
+
resetUnreachableRanges,
|
|
54
|
+
resolveNpmNudo,
|
|
55
|
+
setCallCollector,
|
|
56
|
+
setCurrentFileDir,
|
|
57
|
+
setCurrentSource,
|
|
58
|
+
setEnvModules,
|
|
59
|
+
setMaxConcreteIter,
|
|
60
|
+
setMockModules,
|
|
61
|
+
setModuleResolver,
|
|
62
|
+
setNodeTypeCollector,
|
|
63
|
+
setProvenanceTracking,
|
|
64
|
+
setSampleCount,
|
|
65
|
+
setUnknownBuiltinHandler,
|
|
66
|
+
setUnknownCollector,
|
|
67
|
+
setUsageSiteTag
|
|
68
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Node, File } from '@babel/types';
|
|
2
2
|
import { TypeValue, Abs, PolyFn, AbsModuleExports, AstEnv, Phi, BMemberDiag, BCallRecord, TranspiledCallResult } from '@nudojs/core';
|
|
3
3
|
export { AbsInlay, BMemberDiag, collectAbsInlays } from '@nudojs/core';
|
|
4
|
-
import { CallRecord } from '
|
|
5
|
-
export {
|
|
4
|
+
import { C as CallRecord } from './config-UlReSTfh.js';
|
|
5
|
+
export { I as InterfaceConfig, N as NudoConfig, f as findProjectConfig, i as interfaceConfig } from './config-UlReSTfh.js';
|
|
6
6
|
import { HarvestedEnv } from '@nudojs/harvester';
|
|
7
7
|
import { FunctionWithDirectives } from '@nudojs/parser';
|
|
8
8
|
|
|
@@ -177,6 +177,7 @@ declare function collectCallRecords(filePath: string, source: string): CallRecor
|
|
|
177
177
|
* (CLI watch / vite-plugin)在 dep 变更时应 `clearBPathCache()` 或上述逐出。
|
|
178
178
|
*/
|
|
179
179
|
declare function analyzeFile(filePath: string, source: string, activeCases?: Map<string, number>, externalCallRecords?: CallRecord[]): AnalysisResult;
|
|
180
|
+
|
|
180
181
|
type CaseInfo = {
|
|
181
182
|
functionName: string;
|
|
182
183
|
caseName: string;
|
|
@@ -283,9 +284,11 @@ declare function serializeInferJson(result: AnalysisResult, file: string): Infer
|
|
|
283
284
|
* nudo 推断目标文件判定(纯扩展名规则,路径无需存在)。
|
|
284
285
|
*
|
|
285
286
|
* 规则:.js / .mjs / .ts 可作为推断目标;其余扩展(.cjs/.tsx/.jsx/.mts/.d.ts…)
|
|
286
|
-
* 一律 false
|
|
287
|
+
* 一律 false。显式排除:
|
|
287
288
|
* - .d.ts —— 类型声明文件(harvester 的输入),不是可求值的实现源码;
|
|
288
|
-
* - .tsx / .jsx —— JSX 构造的求值超出 nudo
|
|
289
|
+
* - .tsx / .jsx —— JSX 构造的求值超出 nudo 推断器范围;
|
|
290
|
+
* - *.nudo.js / *.nudo.ts —— 侧车契约模块(interface 绑定源),不是源码
|
|
291
|
+
* 推断目标;目录级 check/infer/doctor 展开不得把它们当实现分析。
|
|
289
292
|
*
|
|
290
293
|
* 消费方:CLI 的 collectNudoFiles/watch 过滤/doctor 目录展开(.ts 放开后统一
|
|
291
294
|
* 走本函数,避免各处手写 endsWith 漂移),以及 LSP 的 isNudoFile(接线由
|
|
@@ -722,4 +725,113 @@ declare function mockDirectivesToAbsSeeds(functions: Array<{
|
|
|
722
725
|
directives: FunctionWithDirectives["directives"];
|
|
723
726
|
}>): AbsMockSeeds;
|
|
724
727
|
|
|
725
|
-
|
|
728
|
+
/**
|
|
729
|
+
* `nudo interface` 的打印数据源(design-refine-derivation §11 第 0 步):
|
|
730
|
+
* 逐顶层函数展示有效契约分层——effectiveInterface 命中(手写契约 / 侧车
|
|
731
|
+
* 生成段)时 params/returns 用 formatConstraint 组合式显示;未命中走
|
|
732
|
+
* implicit:直接展示 analyzer 的现成推断结果(case 实参与 Combined 的
|
|
733
|
+
* TypeValue 串,不强求约束式)。
|
|
734
|
+
*
|
|
735
|
+
* autoBind 沿 package.json#nudo.interface(findProjectConfig → interfaceConfig)
|
|
736
|
+
* 下传,可用 opts 覆盖(测试 / CLI 显式开关);读盘用 defaultLoadModule
|
|
737
|
+
* (与 check 的 refine 解析同一扩展名表)。
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
type InterfaceSurfaceEntry = {
|
|
741
|
+
fn: string;
|
|
742
|
+
/** 本文件 named export(自动绑定边界口径:localNamedExports) */
|
|
743
|
+
kind: "export" | "local";
|
|
744
|
+
source: "handwritten" | "generated" | "implicit";
|
|
745
|
+
params: Array<{
|
|
746
|
+
name: string;
|
|
747
|
+
display: string;
|
|
748
|
+
}>;
|
|
749
|
+
returns?: string;
|
|
750
|
+
};
|
|
751
|
+
type InterfaceSurfaceOpts = {
|
|
752
|
+
/** 覆盖项目配置的 autoBind(默认 findProjectConfig → interfaceConfig) */
|
|
753
|
+
autoBind?: boolean;
|
|
754
|
+
/** 模块源码装载器(测试注入);默认 defaultLoadModule 真实读盘 */
|
|
755
|
+
loadModule?: LoadModule;
|
|
756
|
+
/** 跨文件调用记录(--callsites 采集):implicit 展示的实参域原料 */
|
|
757
|
+
records?: CallRecord[];
|
|
758
|
+
};
|
|
759
|
+
/** 单条 interface 打印行(CLI runInterface 与 LSP agent 面共用) */
|
|
760
|
+
declare function formatInterfaceSurfaceLine(e: InterfaceSurfaceEntry): string;
|
|
761
|
+
/**
|
|
762
|
+
* 单文件 interface 表面:analyzer 推断结果给出函数清单与 implicit 展示,
|
|
763
|
+
* effectiveInterface 给出契约命中(手写 > 生成段)。诊断 side-channel
|
|
764
|
+
* 在收尾时取走丢弃——打印命令不执法,interface-load 等错误留给 check 路径。
|
|
765
|
+
*/
|
|
766
|
+
declare function interfaceSurface(filePath: string, opts?: InterfaceSurfaceOpts): Promise<InterfaceSurfaceEntry[]>;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* `nudo interface --emit` 的写盘器(design-refine-derivation §5.4 / §7.3 / §11):
|
|
770
|
+
* 把分析产出的调用点域投影(joinThenProject,先 Abs join 再投影)固化为侧车
|
|
771
|
+
* `*.nudo.js` / `*.nudo.ts` 的 `@generated` 段——`export const <fn> = fn({…}, …)`。
|
|
772
|
+
*
|
|
773
|
+
* - 生成段 = 三行:`@generated` 头注释 + `// source: <相对file>:<fn>` + export 行。
|
|
774
|
+
* DSL 由 formatConstraint 产出,**写入前 round-trip 自检**(生成文本经
|
|
775
|
+
* execNudoModule 求值、导出须 isNudoConstraint 且 fn 槽存在):展示兜底形态
|
|
776
|
+
* (`x?:` 可选字段、`.eq()` 伪链、`{谓词原文}`)不是合法 DSL,自检拦下 →
|
|
777
|
+
* not-projectable 跳过,不写垃圾。
|
|
778
|
+
* - 手写导出永不覆盖:目标名已是侧车手写绑定 → 跳过写入并报
|
|
779
|
+
* `nudo:interface-name-clash`(error,手写优先)。
|
|
780
|
+
* - mode=update:剥离全部生成段再重排(幂等;非目标的既有生成段原样保留,
|
|
781
|
+
* 不随 --fn 丢失);mode=add:仅追加缺失段。
|
|
782
|
+
* - 目标过滤(§7.3):--fn 白名单 > --all 全量 > 默认只刷新已有生成段
|
|
783
|
+
* (「无根只处理已存在生成段」;Phase 1 无 root 闭包下行推导)。
|
|
784
|
+
* - autoBind=false 不影响 emit(显式动作,非 ambient 加载)。
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
type EmitInterfaceSkipReason = "name-clash" | "not-projectable" | "not-an-export" | "no-change"
|
|
788
|
+
/** 手工合并的多声明符 @generated 段:按段原子保留,不拆不重写 */
|
|
789
|
+
| "multi-declarator";
|
|
790
|
+
type EmitInterfaceOpts = {
|
|
791
|
+
/** 目标导出名白名单(Phase 1:只过滤目标文件自身的导出;跨文件 root 闭包 emit 是 Phase 2 下行推导能力) */
|
|
792
|
+
fnNames?: string[];
|
|
793
|
+
/** update=剥离全部生成段再重排(幂等);add=仅追加缺失段 */
|
|
794
|
+
mode: "add" | "update";
|
|
795
|
+
/** 全部顶层导出(显式 opt-in,CLI 侧文档警告勿默认) */
|
|
796
|
+
all?: boolean;
|
|
797
|
+
/** 不写盘,返回 unifiedDiff */
|
|
798
|
+
dryRun?: boolean;
|
|
799
|
+
/**
|
|
800
|
+
* 跨文件调用记录(--callsites 采集):域根导出(本文件无调用点、仅有
|
|
801
|
+
* 外部使用现场记录)的投影原料;缺省时仅用本文件调用点证据。
|
|
802
|
+
*/
|
|
803
|
+
records?: CallRecord[];
|
|
804
|
+
};
|
|
805
|
+
type EmitInterfaceResult = {
|
|
806
|
+
written: string[];
|
|
807
|
+
skipped: Array<{
|
|
808
|
+
fn: string;
|
|
809
|
+
reason: EmitInterfaceSkipReason;
|
|
810
|
+
}>;
|
|
811
|
+
changed: boolean;
|
|
812
|
+
diff?: string;
|
|
813
|
+
issues: Array<{
|
|
814
|
+
code: string;
|
|
815
|
+
severity: "error" | "warning";
|
|
816
|
+
message: string;
|
|
817
|
+
}>;
|
|
818
|
+
/** 侧车绝对路径(新建或已有) */
|
|
819
|
+
sidecarPath: string;
|
|
820
|
+
/**
|
|
821
|
+
* 默认过滤(无 --fn/--all)且侧车无既有 @generated 段可刷 —— 调用方
|
|
822
|
+
* 用它把「no interface changes」解释成首次 emit 的用法提示,而非漂移。
|
|
823
|
+
*/
|
|
824
|
+
emptyDefaultTargets?: boolean;
|
|
825
|
+
};
|
|
826
|
+
/**
|
|
827
|
+
* 单文件 emit:分析 → 逐目标投影/自检 → 组装侧车内容 →(非 dryRun)写盘。
|
|
828
|
+
* 诊断 side-channel(round-trip 自检触发的 refine/interface diags)收尾取走丢弃。
|
|
829
|
+
*/
|
|
830
|
+
declare function emitInterface(filePath: string, opts: EmitInterfaceOpts): Promise<EmitInterfaceResult>;
|
|
831
|
+
/**
|
|
832
|
+
* emit 摘要行(CLI runInterfaceEmit 与 LSP agent 面共用;路径由调用方按
|
|
833
|
+
* 展示口径传入——CLI 传 cwd 相对、agent 传绝对路径)。
|
|
834
|
+
*/
|
|
835
|
+
declare function formatEmitSummary(sourcePath: string, sidecarRel: string, result: EmitInterfaceResult): string[];
|
|
836
|
+
|
|
837
|
+
export { type AbsGraphOptions, type AbsMockSeeds, type AbsModuleCacheEntry, type AbsModuleGraphResult, type AbsModuleLoadIssue, type AnalysisResult, type BPathBuiltinUnknown, type BPathDiagnostics, type BPathRunResult, type BPathUnreachable, type BindingInfo, CallRecord, type CaseHint, type CaseInfo, type CaseResult, type CompletionItem, type Diagnostic, type DiagnosticSeverity, type DiagnosticTag, type EmitInterfaceOpts, type EmitInterfaceResult, type EmitInterfaceSkipReason, type EmitResult, type EmitSkipReason, type FunctionAnalysis, type HoverInfo, type InferJson, type InferJsonCase, type InferJsonFunction, type InterfaceSurfaceEntry, type InterfaceSurfaceOpts, type LoadModule, type ModuleExports, type ModuleGraphCache, type NodeEnvResult, type PackageHarvest, type ReferenceInfo, SEMANTIC_TOKEN_MODIFIERS, SEMANTIC_TOKEN_TYPES, type SemanticToken, type SourceLocation, type SymbolInfo, type SymbolTable, analyzeExportsFromSource, analyzeFile, analyzeFileAsync, autoHarvestModules, barePackageName, bareSpecToAbsModules, buildCaseDirective, buildModuleGraph, buildSemanticTokens, clearAbsModuleCache, clearAnalysisFileCache, clearAnalysisSessionCaches, clearBPathCache, clearFnAnalysisCache, clearHarvestCache, collectAbsBindingsFromGraph, collectBPathDiagnostics, collectBPathReplacements, collectBarePackages, collectCallRecords, collectDependencySpecs, collectDtsFromEntry, collectEnvGlobals, collectEnvModules, collectStaticImports, computeDirtySet, defaultAbsLoadModule, defaultLoadModule, emitInterface, encodeSemanticTokens, envValueToAbs, evalAbsModuleGraph, evalProgramAbsWithModules, evictAbsModuleCacheFiles, evictAnalysisCachesForFiles, evictAnalysisFileCacheForFiles, evictBPathCacheForFiles, evictFnAnalysisCacheForFiles, formatEmitSummary, formatHarvestSummary, formatInterfaceSurfaceLine, generateDts, generateFunctionDtsLines, generateGuardFunction, generateGuardFunctionFromAbs, getAnalysisFileCacheSize, getCasesForFile, getCompletionsAtPosition, getHoverAtPosition, getTypeAtPosition, getTypeAtPositionAsync, harvestNodeTypes, harvestPackage, harvestPackageCached, harvestToAbsModules, harvestedValueToAbs, insertGeneratedCaseDirectives, interfaceSurface, isBPathCapable, isNudoTargetPath, lookupHarvested, mockDirectivesToAbsSeeds, packageHarvestToAbsModules, resetAllAnalysisCaches, resolvePackageRoot, serializeCaseArg, serializeInferJson, stripGeneratedCaseDirectives, summarizeNodeEnv, topoSortDirty, tryBPathCall, tryBPathCallFull, tryRunBPath, typeValueToTSType, typeValueToZodSchema, unifiedDiff };
|