@nudojs/cli 0.4.0 → 1.0.1
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/README.md +2 -2
- package/dist/index.js +10405 -12378
- package/package.json +11 -13
- package/dist/evaluator-api.d.ts +0 -162
- package/dist/evaluator-api.js +0 -27683
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nudojs/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=20"
|
|
6
|
+
},
|
|
7
|
+
"description": "Command-line interface for the Nudo type inference engine",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"license": "MIT",
|
|
7
10
|
"keywords": [
|
|
@@ -18,10 +21,6 @@
|
|
|
18
21
|
".": {
|
|
19
22
|
"types": "./dist/index.d.ts",
|
|
20
23
|
"default": "./dist/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./evaluator": {
|
|
23
|
-
"types": "./dist/evaluator-api.d.ts",
|
|
24
|
-
"default": "./dist/evaluator-api.js"
|
|
25
24
|
}
|
|
26
25
|
},
|
|
27
26
|
"bin": {
|
|
@@ -44,14 +43,13 @@
|
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
45
|
"commander": "^13.0.0",
|
|
47
|
-
"@nudojs/
|
|
48
|
-
"@nudojs/
|
|
49
|
-
"@nudojs/
|
|
50
|
-
"@nudojs/
|
|
51
|
-
"@nudojs/harvester": "0.2.
|
|
46
|
+
"@nudojs/core": "1.0.1",
|
|
47
|
+
"@nudojs/service": "1.0.1",
|
|
48
|
+
"@nudojs/env": "0.2.5",
|
|
49
|
+
"@nudojs/parser": "0.4.2",
|
|
50
|
+
"@nudojs/harvester": "0.2.4"
|
|
52
51
|
},
|
|
53
52
|
"scripts": {
|
|
54
|
-
"build": "tsup"
|
|
55
|
-
"build:lib": "tsup src/evaluator-api.ts --format esm --dts"
|
|
53
|
+
"build": "tsup"
|
|
56
54
|
}
|
|
57
55
|
}
|
package/dist/evaluator-api.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
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
|
-
/**
|
|
131
|
-
* Given a test expression and the current environment, produce two
|
|
132
|
-
* environments: one where the test is truthy, one where it is falsy.
|
|
133
|
-
*/
|
|
134
|
-
declare function narrow(test: Node, env: Environment): [trueEnv: Environment, falseEnv: Environment];
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 内置类原型机制:错误类集合、可构造内置类、Object/Array/Map/Set/…/Buffer
|
|
138
|
-
* 的原型成员近似表,以及 `X.prototype` 单例与类命名空间记忆化。
|
|
139
|
-
* 求值器成员分派与补全侧成员派生共用本表的唯一真值。
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
declare const BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS: Record<string, Record<string, TypeValue>>;
|
|
143
|
-
|
|
144
|
-
type LoadedEnv = {
|
|
145
|
-
modules: Record<string, Record<string, TypeValue>>;
|
|
146
|
-
};
|
|
147
|
-
declare function preloadPathEnvs(envNames: string[], baseDir: string): Promise<void>;
|
|
148
|
-
declare function loadEnvsAsync(envNames: string[], globalEnv: Environment, baseDir?: string): Promise<LoadedEnv>;
|
|
149
|
-
declare function loadEnvs(envNames: string[], globalEnv: Environment): LoadedEnv;
|
|
150
|
-
|
|
151
|
-
type NudoConfig = {
|
|
152
|
-
env?: string[];
|
|
153
|
-
mocks?: Record<string, string>;
|
|
154
|
-
};
|
|
155
|
-
declare function findProjectConfig(startDir: string): {
|
|
156
|
-
config: NudoConfig;
|
|
157
|
-
projectDir: string;
|
|
158
|
-
} | null;
|
|
159
|
-
|
|
160
|
-
declare function resolveNpmNudo(source: string, fromDir: string): string | null;
|
|
161
|
-
|
|
162
|
-
export { BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS, type CallRecord, type LoadedEnv, type NudoConfig, USAGE_SITE_MODULE, type UnknownRecord, evaluate, evaluateFunction, evaluateFunctionFull, evaluateProgram, findProjectConfig, getUnreachableRanges, loadEnvs, loadEnvsAsync, memberMayExistOn, narrow, preloadPathEnvs, resetEnvModules, resetMemo, resetMockModules, resetUnreachableRanges, resolveNpmNudo, setCallCollector, setCurrentFileDir, setCurrentSource, setEnvModules, setMaxConcreteIter, setMockModules, setModuleResolver, setNodeTypeCollector, setProvenanceTracking, setSampleCount, setUnknownBuiltinHandler, setUnknownCollector, setUsageSiteTag };
|