@stateward/plugin-errors 1.2.1 → 1.3.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/README.md +9 -8
- package/dist/catch-hides-unexpected.d.ts +4 -1
- package/dist/catch-hides-unexpected.js +87 -11
- package/dist/catch-misses-error.d.ts +1 -1
- package/dist/catch-misses-error.js +63 -20
- package/dist/finally-can-throw.js +46 -6
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/inference/analysis.d.ts +109 -0
- package/dist/inference/analysis.js +170 -0
- package/dist/inference/builtins.d.ts +7 -2
- package/dist/inference/builtins.js +20 -33
- package/dist/inference/deps.js +2 -2
- package/dist/inference/needs.d.ts +16 -0
- package/dist/inference/needs.js +27 -0
- package/dist/inference/packages.d.ts +24 -32
- package/dist/inference/packages.js +156 -675
- package/dist/inference/project.d.ts +2 -2
- package/dist/inference/project.js +3 -2
- package/dist/inference/solve.d.ts +29 -4
- package/dist/inference/solve.js +34 -5
- package/dist/inference/summarize.d.ts +28 -15
- package/dist/inference/summarize.js +339 -135
- package/dist/inference/summary.d.ts +46 -5
- package/dist/inference/summary.js +89 -13
- package/dist/inference/unreachable.d.ts +5 -0
- package/dist/inference/unreachable.js +160 -0
- package/dist/must-handle-error.d.ts +2 -1
- package/dist/must-handle-error.js +4 -4
- package/dist/narrow-try.d.ts +2 -0
- package/dist/narrow-try.js +62 -7
- package/dist/plugin.d.ts +12 -2
- package/dist/plugin.js +4 -2
- package/dist/react/fallbacks.js +35 -14
- package/dist/react/tree.d.ts +10 -0
- package/dist/react/tree.js +54 -7
- package/dist/refactors.js +35 -2
- package/dist/render-throw-without-boundary.d.ts +13 -4
- package/dist/render-throw-without-boundary.js +100 -10
- package/dist/result-ignored.d.ts +4 -1
- package/dist/result-ignored.js +51 -10
- package/dist/result-type.d.ts +2 -0
- package/dist/result-type.js +8 -2
- package/dist/result-unchecked.d.ts +4 -1
- package/dist/result-unchecked.js +320 -96
- package/dist/rules.meta.d.ts +29 -14
- package/dist/rules.meta.js +19 -14
- package/dist/syntax.d.ts +0 -13
- package/dist/syntax.js +0 -79
- package/dist/text.d.ts +15 -2
- package/dist/text.js +28 -5
- package/dist/throws-doc-mismatch.d.ts +1 -1
- package/dist/throws-doc-mismatch.js +59 -5
- package/dist/throws-reads.d.ts +3 -0
- package/dist/throws-reads.js +108 -0
- package/package.json +2 -2
|
@@ -1,237 +1,25 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
1
|
import ts from "@stateward/core/typescript";
|
|
5
|
-
import {
|
|
2
|
+
import { WILDCARD, factKeyOf, factLineOf, factSideOf, packageVersionOf, pathOf, } from "@stateward/core";
|
|
6
3
|
import { BUILTIN_ERRORS, builtinId, isBuiltin } from "./builtins.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { readClass } from "./summary.js";
|
|
4
|
+
import { packageClassId } from "./summarize.js";
|
|
5
|
+
import { UNKNOWN_REASONS } from "./summary.js";
|
|
10
6
|
/**
|
|
11
|
-
* Library facts for the Errors pack: what a call into a
|
|
12
|
-
*
|
|
7
|
+
* Library facts for the Errors pack: what a call into a package throws, from its contract only
|
|
8
|
+
* (0041), from the first source that answers:
|
|
13
9
|
*
|
|
14
10
|
* 1. the project's config (`facts`);
|
|
15
|
-
* 2.
|
|
16
|
-
* 3.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
/** Why a package's function is not (fully) known: fixed strings, shown as they are. */
|
|
22
|
-
export const UNKNOWN_REASONS = [
|
|
23
|
-
// The package as a whole cannot be read.
|
|
24
|
-
"no readable source",
|
|
25
|
-
"not found in its source",
|
|
26
|
-
"native addon",
|
|
27
|
-
"minified",
|
|
28
|
-
"eval",
|
|
29
|
-
"dynamic require",
|
|
30
|
-
"too large to follow",
|
|
31
|
-
// Read, but part of what the function does cannot be followed.
|
|
32
|
-
"untyped @throws",
|
|
33
|
-
"calls a callback",
|
|
34
|
-
"calls code it cannot see",
|
|
35
|
-
"dynamic call",
|
|
36
|
-
"throws a value of unknown class",
|
|
37
|
-
"awaits a promise it cannot follow",
|
|
38
|
-
];
|
|
39
|
-
/**
|
|
40
|
-
* At most this many functions are read per package function asked for.
|
|
41
|
-
* The bounds count, never time: a verdict by time would differ between machines.
|
|
11
|
+
* 2. the facts the loaded packs ship (`Plugin.facts`);
|
|
12
|
+
* 3. else unknown: "its errors are not stated", with a hint that gives the `facts` line.
|
|
13
|
+
*
|
|
14
|
+
* A line names the call when its key resolves to the called declaration (`factLineOf`). The
|
|
15
|
+
* package's code and the doc comments of its declarations are never read.
|
|
42
16
|
*/
|
|
43
|
-
export
|
|
44
|
-
/** A package whose entry reaches more files than this is not parsed further. */
|
|
45
|
-
const MAX_FILES = 500;
|
|
46
|
-
/** Folder entries looked at for a native addon (`.node`, `binding.gyp`). */
|
|
47
|
-
const MAX_SCANNED = 5000;
|
|
48
|
-
/** Average line length above which a file is minified. */
|
|
49
|
-
const MINIFIED_LINE = 500;
|
|
17
|
+
export { UNKNOWN_REASONS };
|
|
50
18
|
const NOTHING = { classes: [], unknown: [] };
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return createHash("sha1").update(text).digest("hex");
|
|
56
|
-
}
|
|
57
|
-
/** The folder of the installed package a file in node_modules belongs to. */
|
|
58
|
-
function installedRoot(file) {
|
|
59
|
-
const marker = "/node_modules/";
|
|
60
|
-
const at = file.lastIndexOf(marker);
|
|
61
|
-
if (at < 0)
|
|
62
|
-
return undefined;
|
|
63
|
-
const parts = file.slice(at + marker.length).split("/");
|
|
64
|
-
const [first = "", second = ""] = parts;
|
|
65
|
-
const name = first.startsWith("@") ? `${first}/${second}` : first;
|
|
66
|
-
return { root: `${file.slice(0, at + marker.length)}${name}`, name };
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* What this process read of each package's package.json, with the file's size and time when it
|
|
70
|
-
* was read: a package upgraded or reinstalled while the process runs (a language server) is read
|
|
71
|
-
* again, and its new content hash keys every cache below, so no old fact is served for it.
|
|
72
|
-
*/
|
|
73
|
-
const infos = new Map();
|
|
74
|
-
let codeId;
|
|
75
|
-
/** The size and time of a file, to tell a changed one; "" when it cannot be read. */
|
|
76
|
-
function stampOf(file) {
|
|
77
|
-
try {
|
|
78
|
-
const stats = statSync(file);
|
|
79
|
-
return `${String(stats.size)}:${String(stats.mtimeMs)}`;
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return "";
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The package at `root`, from its package.json. `checked` holds what this resolver already read,
|
|
87
|
-
* so a package.json is looked at (one stat) once per file summarized, not once per call.
|
|
88
|
-
*/
|
|
89
|
-
function readInfo(name, root, checked) {
|
|
90
|
-
if (checked.has(root))
|
|
91
|
-
return checked.get(root);
|
|
92
|
-
const manifestFile = path.join(root, "package.json");
|
|
93
|
-
const stamp = stampOf(manifestFile);
|
|
94
|
-
const known = infos.get(root);
|
|
95
|
-
if (known?.stamp === stamp) {
|
|
96
|
-
checked.set(root, known.info);
|
|
97
|
-
return known.info;
|
|
98
|
-
}
|
|
99
|
-
let info;
|
|
100
|
-
try {
|
|
101
|
-
const text = readFileSync(manifestFile, "utf8");
|
|
102
|
-
const parsed = JSON.parse(text);
|
|
103
|
-
const manifest = isRecord(parsed) ? parsed : {};
|
|
104
|
-
const version = typeof manifest.version === "string" ? manifest.version : "";
|
|
105
|
-
codeId ??= packageCodeId(import.meta.url);
|
|
106
|
-
info = {
|
|
107
|
-
name,
|
|
108
|
-
root,
|
|
109
|
-
version,
|
|
110
|
-
manifest,
|
|
111
|
-
key: { name, version, integrity: sha1(text), implementation: codeId },
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
info = undefined;
|
|
116
|
-
}
|
|
117
|
-
infos.set(root, { stamp, info });
|
|
118
|
-
checked.set(root, info);
|
|
119
|
-
return info;
|
|
120
|
-
}
|
|
121
|
-
/** The per-process caches' key of a package: its folder and its package.json's content. */
|
|
122
|
-
function packageKey(info) {
|
|
123
|
-
return `${info.root}\u0000${info.key.integrity}`;
|
|
124
|
-
}
|
|
125
|
-
/** The package whose JavaScript a call reaches: next to its declaration, or found by name. */
|
|
126
|
-
function packageOf(call, from, checked) {
|
|
127
|
-
const installed = installedRoot(call.file.replaceAll("\\", "/"));
|
|
128
|
-
if (installed?.name === call.name)
|
|
129
|
-
return readInfo(call.name, installed.root, checked);
|
|
130
|
-
// `@types/x`, a linked package, or `declare module "x"` in the project: the package by its
|
|
131
|
-
// name, as Node finds it from the calling file (a package manager's store keeps `@types/x`
|
|
132
|
-
// away from `x`), else from the declaration.
|
|
133
|
-
const root = findPackageRoot(path.dirname(from), call.name) ??
|
|
134
|
-
findPackageRoot(path.dirname(installed?.root ?? call.file), call.name);
|
|
135
|
-
return root === undefined ? undefined : readInfo(call.name, root, checked);
|
|
136
|
-
}
|
|
137
|
-
const JAVASCRIPT_EXTENSIONS = [".js", ".mjs", ".cjs"];
|
|
138
|
-
function existingFile(file) {
|
|
139
|
-
const candidates = [
|
|
140
|
-
file,
|
|
141
|
-
...JAVASCRIPT_EXTENSIONS.map((extension) => `${file}${extension}`),
|
|
142
|
-
...JAVASCRIPT_EXTENSIONS.map((extension) => path.join(file, `index${extension}`)),
|
|
143
|
-
];
|
|
144
|
-
return candidates.find((candidate) => {
|
|
145
|
-
try {
|
|
146
|
-
return readdirSync(path.dirname(candidate)).includes(path.basename(candidate));
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
/** The first file an `exports` value names for `import`, `default`, `require` or `node`. */
|
|
154
|
-
function exportTarget(value) {
|
|
155
|
-
if (typeof value === "string")
|
|
156
|
-
return value;
|
|
157
|
-
if (!isRecord(value))
|
|
158
|
-
return undefined;
|
|
159
|
-
for (const key of [".", "import", "default", "require", "node"]) {
|
|
160
|
-
const found = exportTarget(value[key]);
|
|
161
|
-
if (found !== undefined)
|
|
162
|
-
return found;
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
/** The JavaScript file a declaration file describes: its sibling, else the package's entry. */
|
|
167
|
-
function entryOf(declarationFile, info) {
|
|
168
|
-
const file = declarationFile.replaceAll("\\", "/");
|
|
169
|
-
if (file.startsWith(`${info.root}/`)) {
|
|
170
|
-
const stem = file.replace(/\.d\.[mc]?ts$/, "");
|
|
171
|
-
const sibling = JAVASCRIPT_EXTENSIONS.map((extension) => `${stem}${extension}`).find((candidate) => existingFile(candidate) === candidate);
|
|
172
|
-
if (sibling !== undefined)
|
|
173
|
-
return sibling;
|
|
174
|
-
}
|
|
175
|
-
const { manifest } = info;
|
|
176
|
-
const named = exportTarget(manifest.exports) ??
|
|
177
|
-
(typeof manifest.module === "string" ? manifest.module : undefined) ??
|
|
178
|
-
(typeof manifest.main === "string" ? manifest.main : undefined) ??
|
|
179
|
-
"index.js";
|
|
180
|
-
return existingFile(path.join(info.root, named));
|
|
181
|
-
}
|
|
182
|
-
// ---- the called declaration ---------------------------------------------------------------------
|
|
183
|
-
function declarationName(node) {
|
|
184
|
-
if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) {
|
|
185
|
-
if (node.name !== undefined)
|
|
186
|
-
return node.name.text;
|
|
187
|
-
return node.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword) === true
|
|
188
|
-
? "default"
|
|
189
|
-
: undefined;
|
|
190
|
-
}
|
|
191
|
-
if (ts.isExportAssignment(node))
|
|
192
|
-
return "default";
|
|
193
|
-
if (ts.isModuleDeclaration(node))
|
|
194
|
-
return ts.isIdentifier(node.name) ? node.name.text : undefined;
|
|
195
|
-
if (ts.isMethodDeclaration(node) ||
|
|
196
|
-
ts.isMethodSignature(node) ||
|
|
197
|
-
ts.isPropertyDeclaration(node) ||
|
|
198
|
-
ts.isPropertySignature(node) ||
|
|
199
|
-
ts.isVariableDeclaration(node) ||
|
|
200
|
-
ts.isInterfaceDeclaration(node)) {
|
|
201
|
-
return ts.isIdentifier(node.name) ? node.name.text : undefined;
|
|
202
|
-
}
|
|
203
|
-
return undefined;
|
|
204
|
-
}
|
|
205
|
-
/** The declaration's path in the package's types: `["Client", "get"]`. */
|
|
206
|
-
export function pathOf(node) {
|
|
207
|
-
const names = [];
|
|
208
|
-
for (let at = node; !ts.isSourceFile(at); at = at.parent) {
|
|
209
|
-
const name = declarationName(at);
|
|
210
|
-
if (name !== undefined)
|
|
211
|
-
names.unshift(name);
|
|
212
|
-
}
|
|
213
|
-
return names;
|
|
214
|
-
}
|
|
215
|
-
/** Whether the declaration says it returns a promise: its facts are what the promise rejects with. */
|
|
216
|
-
function returnsPromise(node) {
|
|
217
|
-
let type;
|
|
218
|
-
if (ts.isFunctionDeclaration(node) ||
|
|
219
|
-
ts.isMethodDeclaration(node) ||
|
|
220
|
-
ts.isMethodSignature(node)) {
|
|
221
|
-
type = node.type;
|
|
222
|
-
}
|
|
223
|
-
else if ((ts.isVariableDeclaration(node) ||
|
|
224
|
-
ts.isPropertySignature(node) ||
|
|
225
|
-
ts.isPropertyDeclaration(node)) &&
|
|
226
|
-
node.type !== undefined &&
|
|
227
|
-
ts.isFunctionTypeNode(node.type)) {
|
|
228
|
-
type = node.type.type;
|
|
229
|
-
}
|
|
230
|
-
return (type !== undefined &&
|
|
231
|
-
ts.isTypeReferenceNode(type) &&
|
|
232
|
-
ts.isIdentifier(type.typeName) &&
|
|
233
|
-
(type.typeName.text === "Promise" || type.typeName.text === "PromiseLike"));
|
|
234
|
-
}
|
|
19
|
+
/** The reason a call into a package with no line, or none of the kind it needs, is unknown. */
|
|
20
|
+
const NOT_STATED = "its errors are not stated";
|
|
21
|
+
/** The reason a promise is unknown when its call's line states `throws` and no `rejects`. */
|
|
22
|
+
const REJECTS_NOT_STATED = "its `facts` line states no `rejects`, the kind its promise needs";
|
|
235
23
|
/** A class a fact names: a built-in error, or the package's own class. */
|
|
236
24
|
function classIdOf(packageName, name) {
|
|
237
25
|
return BUILTIN_ERRORS.has(name) ? builtinId(name) : packageClassId(packageName, name);
|
|
@@ -239,486 +27,179 @@ function classIdOf(packageName, name) {
|
|
|
239
27
|
function side(classes, unknown = []) {
|
|
240
28
|
return { classes: [...new Set(classes)].sort(), unknown: [...new Set(unknown)].sort() };
|
|
241
29
|
}
|
|
242
|
-
function onSide(set, promise) {
|
|
243
|
-
return promise ? { throws: NOTHING, rejects: set } : { throws: set, rejects: NOTHING };
|
|
244
|
-
}
|
|
245
|
-
// ---- 1. config ----------------------------------------------------------------------------------
|
|
246
|
-
function configured(entry, packageName, promise) {
|
|
247
|
-
const named = (list) => (list ?? []).map((name) => classIdOf(packageName, name));
|
|
248
|
-
const thrown = side(named(entry.throws));
|
|
249
|
-
const rejected = side(named(entry.rejects));
|
|
250
|
-
// A promise's function "throws" what its promise rejects with, as a developer says it.
|
|
251
|
-
return promise
|
|
252
|
-
? { throws: NOTHING, rejects: side([...thrown.classes, ...rejected.classes]) }
|
|
253
|
-
: { throws: thrown, rejects: rejected };
|
|
254
|
-
}
|
|
255
|
-
// ---- 2. curated ---------------------------------------------------------------------------
|
|
256
30
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
31
|
+
* What a line says of a call. Kinds are strict: `throws` is what the call throws synchronously,
|
|
32
|
+
* `rejects` what the promise it returns rejects with. The kind the call needs (`rejects` for a
|
|
33
|
+
* call whose value is a promise, `throws` otherwise) is not stated when the line leaves it out,
|
|
34
|
+
* so a line of the other kind never settles the call. A call that returns no promise rejects with
|
|
35
|
+
* nothing.
|
|
260
36
|
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
function declared(call) {
|
|
272
|
-
const reparsed = reparsedWithJsDoc(call.node.getSourceFile());
|
|
273
|
-
const node = sameNode(reparsed, call.node);
|
|
274
|
-
if (node === undefined)
|
|
275
|
-
return undefined;
|
|
276
|
-
const tags = ts.getJSDocTags(node).filter(ts.isJSDocThrowsTag);
|
|
277
|
-
if (tags.length === 0)
|
|
278
|
-
return undefined;
|
|
279
|
-
const classes = [];
|
|
280
|
-
const unknown = [];
|
|
281
|
-
const add = (type) => {
|
|
282
|
-
if (ts.isParenthesizedTypeNode(type))
|
|
283
|
-
add(type.type);
|
|
284
|
-
else if (ts.isUnionTypeNode(type))
|
|
285
|
-
for (const member of type.types)
|
|
286
|
-
add(member);
|
|
287
|
-
else if (type.kind === ts.SyntaxKind.NeverKeyword)
|
|
288
|
-
return;
|
|
289
|
-
else if (ts.isTypeReferenceNode(type)) {
|
|
290
|
-
const name = ts.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
291
|
-
classes.push(classIdOf(call.name, name.text));
|
|
292
|
-
}
|
|
293
|
-
else
|
|
294
|
-
unknown.push("untyped @throws");
|
|
295
|
-
};
|
|
296
|
-
for (const tag of tags) {
|
|
297
|
-
const type = tag.typeExpression?.type;
|
|
298
|
-
if (type === undefined)
|
|
299
|
-
unknown.push("untyped @throws");
|
|
300
|
-
else
|
|
301
|
-
add(type);
|
|
302
|
-
}
|
|
303
|
-
return onSide(side(classes, unknown), returnsPromise(node));
|
|
304
|
-
}
|
|
305
|
-
// ---- 4. inferred --------------------------------------------------------------------------------
|
|
306
|
-
/** What makes a package's code not open to read, file by file. */
|
|
307
|
-
function unreadable(sourceFile) {
|
|
308
|
-
const text = sourceFile.text;
|
|
309
|
-
const lines = text.split("\n").length;
|
|
310
|
-
if (text.length / lines > MINIFIED_LINE)
|
|
311
|
-
return "minified";
|
|
312
|
-
let names = 0;
|
|
313
|
-
let short = 0;
|
|
314
|
-
let found;
|
|
315
|
-
const isLiteral = (node) => node !== undefined && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node));
|
|
316
|
-
const visit = (node) => {
|
|
317
|
-
if (found !== undefined)
|
|
318
|
-
return;
|
|
319
|
-
if ((ts.isVariableDeclaration(node) || ts.isParameter(node) || ts.isFunctionDeclaration(node)) &&
|
|
320
|
-
node.name !== undefined &&
|
|
321
|
-
ts.isIdentifier(node.name)) {
|
|
322
|
-
names++;
|
|
323
|
-
if (node.name.text.length <= 2)
|
|
324
|
-
short++;
|
|
325
|
-
}
|
|
326
|
-
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
327
|
-
const callee = node.expression;
|
|
328
|
-
if (ts.isIdentifier(callee) && (callee.text === "eval" || callee.text === "Function")) {
|
|
329
|
-
found = "eval";
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const dynamicRequire = ts.isIdentifier(callee) && callee.text === "require";
|
|
333
|
-
const dynamicImport = callee.kind === ts.SyntaxKind.ImportKeyword;
|
|
334
|
-
if ((dynamicRequire || dynamicImport) && !isLiteral(node.arguments?.[0])) {
|
|
335
|
-
found = "dynamic require";
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
ts.forEachChild(node, visit);
|
|
340
|
-
};
|
|
341
|
-
visit(sourceFile);
|
|
342
|
-
// Mostly one- and two-letter names: a minifier renamed them.
|
|
343
|
-
if (names >= 20 && short * 2 > names)
|
|
344
|
-
return "minified";
|
|
345
|
-
return found;
|
|
346
|
-
}
|
|
347
|
-
const natives = new Map();
|
|
348
|
-
/** Every entry under `dir`, relative; none when it cannot be read. */
|
|
349
|
-
function listed(dir) {
|
|
350
|
-
try {
|
|
351
|
-
return readdirSync(dir, { recursive: true, encoding: "utf8" });
|
|
352
|
-
}
|
|
353
|
-
catch {
|
|
354
|
-
return [];
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/** Whether the package ships a native addon (a `.node` file or a `binding.gyp`). */
|
|
358
|
-
function hasNativeAddon(info) {
|
|
359
|
-
const known = natives.get(packageKey(info));
|
|
360
|
-
if (known !== undefined)
|
|
361
|
-
return known;
|
|
362
|
-
const entries = listed(info.root).slice(0, MAX_SCANNED);
|
|
363
|
-
const found = entries.some((entry) => !entry.split(path.sep).includes("node_modules") &&
|
|
364
|
-
(entry.endsWith(".node") || path.basename(entry) === "binding.gyp"));
|
|
365
|
-
natives.set(packageKey(info), found);
|
|
366
|
-
return found;
|
|
37
|
+
function configured(entry, packageName, promise) {
|
|
38
|
+
const named = (list) => list === undefined
|
|
39
|
+
? side([], [NOT_STATED])
|
|
40
|
+
: side(list.map((name) => classIdOf(packageName, name)));
|
|
41
|
+
if (!promise)
|
|
42
|
+
return { throws: named(entry.throws), rejects: NOTHING };
|
|
43
|
+
const rejects = entry.rejects === undefined && entry.throws !== undefined
|
|
44
|
+
? side([], [REJECTS_NOT_STATED])
|
|
45
|
+
: named(entry.rejects);
|
|
46
|
+
return { throws: side(named(entry.throws ?? []).classes), rejects };
|
|
367
47
|
}
|
|
368
48
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* into one package are mostly answered from `memo`).
|
|
49
|
+
* The error classes a table states a parent of (`extends`), from `named` up through their parents
|
|
50
|
+
* in the same table, so a reader can follow them: the config's line for a class wins. A class
|
|
51
|
+
* without such a line is left out, so it stays open.
|
|
373
52
|
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
opened.set(key, known);
|
|
383
|
-
return known;
|
|
384
|
-
}
|
|
385
|
-
const source = openPackageSource(info.root, entry);
|
|
386
|
-
let verdict;
|
|
387
|
-
if (hasNativeAddon(info))
|
|
388
|
-
verdict = "native addon";
|
|
389
|
-
else if (source.files.length > MAX_FILES)
|
|
390
|
-
verdict = "too large to follow";
|
|
391
|
-
else {
|
|
392
|
-
for (const file of source.files) {
|
|
393
|
-
const sourceFile = source.sourceFile(file);
|
|
394
|
-
verdict = sourceFile === undefined ? undefined : unreadable(sourceFile);
|
|
395
|
-
if (verdict !== undefined)
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
const made = { source, verdict, summaries: new Map() };
|
|
400
|
-
opened.set(key, made);
|
|
401
|
-
for (const oldest of opened.keys()) {
|
|
402
|
-
if (opened.size <= OPEN_PACKAGES)
|
|
403
|
-
break;
|
|
404
|
-
opened.delete(oldest);
|
|
405
|
-
}
|
|
406
|
-
return made;
|
|
407
|
-
}
|
|
408
|
-
function summaryOf(state, file) {
|
|
409
|
-
const known = state.summaries.get(file);
|
|
410
|
-
if (known !== undefined)
|
|
411
|
-
return known;
|
|
412
|
-
const sourceFile = state.source.sourceFile(file);
|
|
413
|
-
if (sourceFile === undefined)
|
|
414
|
-
return undefined;
|
|
415
|
-
const ctx = {
|
|
416
|
-
file,
|
|
417
|
-
options: {},
|
|
418
|
-
sourceFile,
|
|
419
|
-
types: state.source.types,
|
|
420
|
-
addons: [],
|
|
421
|
-
facts: {},
|
|
422
|
-
shippedFacts: {},
|
|
423
|
-
report() {
|
|
424
|
-
// A package's source is read for facts, never reported on.
|
|
425
|
-
},
|
|
426
|
-
unknown() {
|
|
427
|
-
// As above.
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
const summary = summarizeThrows(ctx);
|
|
431
|
-
state.summaries.set(file, summary);
|
|
432
|
-
return summary;
|
|
433
|
-
}
|
|
434
|
-
function callIds(effects, into) {
|
|
435
|
-
for (const effect of effects) {
|
|
436
|
-
if (effect.k === "call")
|
|
437
|
-
into.push(effect.id);
|
|
438
|
-
else if (effect.k === "try") {
|
|
439
|
-
callIds(effect.body, into);
|
|
440
|
-
callIds(effect.fin, into);
|
|
441
|
-
const handler = effect.handler;
|
|
442
|
-
if (handler !== null) {
|
|
443
|
-
callIds(handler.pre, into);
|
|
444
|
-
for (const branch of handler.branches)
|
|
445
|
-
callIds(branch.body, into);
|
|
446
|
-
callIds(handler.otherwise ?? [], into);
|
|
447
|
-
callIds(handler.after, into);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
/** Why part of a function read from source is unknown, as one of the fixed reasons. */
|
|
453
|
-
function reasonOf(source) {
|
|
454
|
-
switch (source.reason) {
|
|
455
|
-
case REASON.callback:
|
|
456
|
-
return "calls a callback";
|
|
457
|
-
case REASON.dynamic:
|
|
458
|
-
return "dynamic call";
|
|
459
|
-
case REASON.promise:
|
|
460
|
-
return "awaits a promise it cannot follow";
|
|
461
|
-
case REASON.thrownValue:
|
|
462
|
-
case REASON.madeError:
|
|
463
|
-
return "throws a value of unknown class";
|
|
464
|
-
default:
|
|
465
|
-
return source.reason.includes("@throws") ? "untyped @throws" : "calls code it cannot see";
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
/** Reads the function at `names` in the package's source, within the bounds. */
|
|
469
|
-
function inferFrom(info, entry, names) {
|
|
470
|
-
const state = open(info, entry);
|
|
471
|
-
if (state.verdict !== undefined) {
|
|
472
|
-
return { kind: "unknown", reason: state.verdict };
|
|
473
|
-
}
|
|
474
|
-
const notFound = { kind: "unknown", reason: "not found in its source" };
|
|
475
|
-
const target = state.source.exported(entry, names);
|
|
476
|
-
if (target === undefined)
|
|
477
|
-
return notFound;
|
|
478
|
-
const tooLarge = { kind: "unknown", reason: "too large to follow" };
|
|
479
|
-
const functions = new Map();
|
|
480
|
-
const classes = new Map();
|
|
481
|
-
const files = new Set(state.source.files);
|
|
482
|
-
const queue = [target.id];
|
|
483
|
-
for (let id = queue.shift(); id !== undefined; id = queue.shift()) {
|
|
484
|
-
if (functions.has(id))
|
|
53
|
+
function statedClasses(own, shipped, packageName, named) {
|
|
54
|
+
const lineOf = (name) => own?.[name]?.extends ?? (own?.[name] === undefined ? shipped?.[name]?.extends : undefined);
|
|
55
|
+
const found = new Map();
|
|
56
|
+
const queue = [...named];
|
|
57
|
+
for (let name = queue.shift(); name !== undefined; name = queue.shift()) {
|
|
58
|
+
const id = classIdOf(packageName, name);
|
|
59
|
+
const parent = lineOf(name);
|
|
60
|
+
if (found.has(id) || isBuiltin(id) || parent === undefined)
|
|
485
61
|
continue;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (functions.size > MAX_FUNCTIONS)
|
|
495
|
-
return tooLarge;
|
|
496
|
-
const called = [];
|
|
497
|
-
callIds(fact.body, called);
|
|
498
|
-
callIds(fact.returns, called);
|
|
499
|
-
queue.push(...called);
|
|
62
|
+
found.set(id, {
|
|
63
|
+
id,
|
|
64
|
+
name,
|
|
65
|
+
parent: classIdOf(packageName, parent),
|
|
66
|
+
open: false,
|
|
67
|
+
fields: [],
|
|
68
|
+
});
|
|
69
|
+
queue.push(parent);
|
|
500
70
|
}
|
|
501
|
-
|
|
502
|
-
if (result === undefined)
|
|
503
|
-
return notFound;
|
|
504
|
-
const mapped = (id) => isBuiltin(id)
|
|
505
|
-
? id
|
|
506
|
-
: packageClassId(info.name, classes.get(id)?.name ?? id.slice(id.indexOf("#") + 1));
|
|
507
|
-
const sideOf = (thrown) => side([...thrown.classes.keys()].map(mapped), [
|
|
508
|
-
...thrown.unknowns.map(reasonOf),
|
|
509
|
-
...(thrown.more ? ["calls code it cannot see"] : []),
|
|
510
|
-
]);
|
|
511
|
-
const facts = [...classes.values()]
|
|
512
|
-
.map((one) => ({
|
|
513
|
-
id: mapped(one.id),
|
|
514
|
-
name: one.name,
|
|
515
|
-
parent: one.parent === null ? null : mapped(one.parent),
|
|
516
|
-
open: one.open,
|
|
517
|
-
}))
|
|
518
|
-
.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
519
|
-
return {
|
|
520
|
-
kind: "known",
|
|
521
|
-
sides: { throws: sideOf(result.throws), rejects: sideOf(result.rejects) },
|
|
522
|
-
classes: facts,
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
// ---- the global cache ---------------------------------------------------------------------------
|
|
526
|
-
let inferences = 0;
|
|
527
|
-
let cacheHits = 0;
|
|
528
|
-
/** What this process computed and read back, for tests: inference runs and global-cache hits. */
|
|
529
|
-
export function packageFactsStats() {
|
|
530
|
-
return { inferences, cacheHits };
|
|
531
|
-
}
|
|
532
|
-
/** Forgets what this process knows about packages (tests: the next run reads the global cache). */
|
|
533
|
-
export function forgetPackageFacts() {
|
|
534
|
-
infos.clear();
|
|
535
|
-
opened.clear();
|
|
536
|
-
natives.clear();
|
|
537
|
-
memo.clear();
|
|
538
|
-
entries.clear();
|
|
539
|
-
verified.clear();
|
|
71
|
+
return [...found.values()].sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
540
72
|
}
|
|
541
|
-
/** Inferred facts by package (root and content), entry and function, for this process. */
|
|
542
|
-
const memo = new Map();
|
|
543
|
-
/** The global cache's entry of each package (root and content), read once per process. */
|
|
544
|
-
const entries = new Map();
|
|
545
|
-
/** Whether the files behind a cached digest still hold what they held, by root and digest. */
|
|
546
|
-
const verified = new Map();
|
|
547
73
|
/**
|
|
548
|
-
* The
|
|
549
|
-
* of them
|
|
550
|
-
*
|
|
551
|
-
* inferred from, and a file that no longer matches makes the entry a miss.
|
|
74
|
+
* The classes of a table whose lines say `inheritedFacts: false` (TypeORM's `MongoRepository`):
|
|
75
|
+
* a call on one of them, or on a class that extends one, of a method it inherits takes none of
|
|
76
|
+
* the declaring class's facts.
|
|
552
77
|
*/
|
|
553
|
-
function
|
|
554
|
-
|
|
555
|
-
for (const file of files) {
|
|
556
|
-
const relative = path.relative(info.root, file).replaceAll("\\", "/");
|
|
557
|
-
hashes[relative] = fileHash(file) ?? "";
|
|
558
|
-
}
|
|
559
|
-
const lines = Object.keys(hashes)
|
|
560
|
-
.sort()
|
|
561
|
-
.map((relative) => `${relative} ${hashes[relative] ?? ""}`);
|
|
562
|
-
return { digest: sha1(lines.join("\n")), hashes };
|
|
78
|
+
function closedClasses(table) {
|
|
79
|
+
return new Set(Object.entries(table).flatMap(([name, line]) => (line.inheritedFacts === false ? [name] : [])));
|
|
563
80
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
81
|
+
/**
|
|
82
|
+
* The line of `facts` for a call: the one whose key resolves to the called declaration, unless
|
|
83
|
+
* the call's receiver is, or extends, a class of the same module whose line says
|
|
84
|
+
* `inheritedFacts: false`: then that class's own line for the method (`MongoRepository.save`), or
|
|
85
|
+
* for every method (`MongoRepository.*`), or none.
|
|
86
|
+
*/
|
|
87
|
+
function lineFor(types, facts, call) {
|
|
88
|
+
const found = factLineOf(types, facts, call.node, receiverOf(call));
|
|
89
|
+
if (found === undefined)
|
|
569
90
|
return undefined;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
/** An entry of the global cache; `sources`: the digest of the files it was inferred from. */
|
|
585
|
-
function toJson(inferred, sources) {
|
|
586
|
-
return inferred.kind === "unknown"
|
|
587
|
-
? { unknown: inferred.reason, sources }
|
|
588
|
-
: {
|
|
589
|
-
sources,
|
|
590
|
-
throws: { classes: inferred.sides.throws.classes, unknown: inferred.sides.throws.unknown },
|
|
591
|
-
rejects: {
|
|
592
|
-
classes: inferred.sides.rejects.classes,
|
|
593
|
-
unknown: inferred.sides.rejects.unknown,
|
|
594
|
-
},
|
|
595
|
-
classes: inferred.classes.map((one) => ({ ...one })),
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
function isReason(value) {
|
|
599
|
-
return UNKNOWN_REASONS.some((reason) => reason === value);
|
|
600
|
-
}
|
|
601
|
-
function isList(value) {
|
|
602
|
-
return Array.isArray(value);
|
|
603
|
-
}
|
|
604
|
-
function fieldsOf(value) {
|
|
605
|
-
if (value === undefined || typeof value !== "object" || value === null || isList(value)) {
|
|
91
|
+
const table = facts[found.package] ?? {};
|
|
92
|
+
const closed = closedClasses(table);
|
|
93
|
+
const names = pathOf(call.node);
|
|
94
|
+
const [owner] = names;
|
|
95
|
+
const last = names.at(-1);
|
|
96
|
+
if (closed.size === 0 || owner === undefined || last === undefined || names.length < 2) {
|
|
97
|
+
return found;
|
|
98
|
+
}
|
|
99
|
+
if (call.receiverClass === undefined)
|
|
100
|
+
return found;
|
|
101
|
+
const nearest = call.receiverClass(new Set([...closed, owner]));
|
|
102
|
+
// The receiver's class is not read: the declaring class's line is not known to hold for it.
|
|
103
|
+
if (nearest === undefined)
|
|
606
104
|
return undefined;
|
|
105
|
+
if (nearest === owner)
|
|
106
|
+
return found;
|
|
107
|
+
// The class's own line for the method, else its line for every method (`MongoRepository.*`).
|
|
108
|
+
for (const name of [`${nearest}.${last}`, `${nearest}.${WILDCARD}`]) {
|
|
109
|
+
const fact = table[name];
|
|
110
|
+
if (fact !== undefined)
|
|
111
|
+
return { package: found.package, name, fact };
|
|
607
112
|
}
|
|
608
|
-
return
|
|
609
|
-
}
|
|
610
|
-
function listOf(value) {
|
|
611
|
-
return Array.isArray(value) ? value : undefined;
|
|
113
|
+
return undefined;
|
|
612
114
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
return undefined;
|
|
619
|
-
const ids = classes.filter((one) => typeof one === "string");
|
|
620
|
-
const reasons = unknown.filter(isReason);
|
|
621
|
-
return ids.length === classes.length && reasons.length === unknown.length
|
|
622
|
-
? { classes: ids, unknown: reasons }
|
|
115
|
+
/** The value a method is called on (`repo` in `repo.save()`); undefined for a bare call. */
|
|
116
|
+
function receiverOf(call) {
|
|
117
|
+
const { through } = call;
|
|
118
|
+
return through !== undefined && ts.isPropertyAccessExpression(through)
|
|
119
|
+
? through.expression
|
|
623
120
|
: undefined;
|
|
624
121
|
}
|
|
625
|
-
/** A
|
|
626
|
-
function
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
if (
|
|
631
|
-
return { kind: "unknown", reason: fields.unknown };
|
|
632
|
-
const throws = readSide(fields.throws);
|
|
633
|
-
const rejects = readSide(fields.rejects);
|
|
634
|
-
const list = listOf(fields.classes);
|
|
635
|
-
if (throws === undefined || rejects === undefined || list === undefined)
|
|
122
|
+
/** A line that states what the call throws or rejects with; other lines say nothing of it. */
|
|
123
|
+
function statesErrors(fact) {
|
|
124
|
+
return fact !== undefined && (fact.throws !== undefined || fact.rejects !== undefined);
|
|
125
|
+
}
|
|
126
|
+
function says(fact) {
|
|
127
|
+
if (fact === undefined)
|
|
636
128
|
return undefined;
|
|
637
|
-
|
|
638
|
-
for (const item of list) {
|
|
639
|
-
const one = readClass(item);
|
|
640
|
-
if (one === undefined)
|
|
641
|
-
return undefined;
|
|
642
|
-
classes.push(one);
|
|
643
|
-
}
|
|
644
|
-
return { kind: "known", sides: { throws, rejects }, classes };
|
|
129
|
+
return fact.throws?.length === 0 && (fact.rejects ?? []).length === 0 ? "nothing" : "something";
|
|
645
130
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const hit = typeof digest === "string" && stillTheSame(info, digest, cached) ? fromJson(stored) : undefined;
|
|
661
|
-
if (hit !== undefined) {
|
|
662
|
-
cacheHits++;
|
|
663
|
-
memo.set(key, hit);
|
|
664
|
-
return hit;
|
|
665
|
-
}
|
|
666
|
-
inferences++;
|
|
667
|
-
const found = inferFrom(info, entry, names);
|
|
668
|
-
memo.set(key, found);
|
|
669
|
-
const { files } = open(info, entry).source;
|
|
670
|
-
const sources = sourcesOf(info, files.length > MAX_FILES ? [] : files);
|
|
671
|
-
const value = toJson(found, sources.digest);
|
|
672
|
-
const written = new Map([
|
|
673
|
-
[cacheKey, value],
|
|
674
|
-
[`sources ${sources.digest}`, sources.hashes],
|
|
675
|
-
]);
|
|
676
|
-
for (const [name, one] of written)
|
|
677
|
-
cached.set(name, one);
|
|
678
|
-
verified.set(`${packageKey(info)}\u0000${sources.digest}`, true);
|
|
679
|
-
// A failure to write costs the next run time, not facts.
|
|
680
|
-
writePackageCache(info.key, written);
|
|
681
|
-
return found;
|
|
131
|
+
/**
|
|
132
|
+
* The calls into packages that the facts the packs ship say throw and reject with nothing
|
|
133
|
+
* (`throws: []`, as the React pack says of React's hooks), unless the config's own `facts` has a
|
|
134
|
+
* line for the function: that line is read instead, as the resolver reads it.
|
|
135
|
+
*/
|
|
136
|
+
export function quietCalls(ctx) {
|
|
137
|
+
// Without a shipped line that says so, no call is quiet: nothing to look up.
|
|
138
|
+
const none = !Object.values(ctx.shippedFacts).some((functions) => Object.values(functions).some((fact) => says(fact) === "nothing"));
|
|
139
|
+
return {
|
|
140
|
+
test: (call) => !none &&
|
|
141
|
+
factLineOf(ctx.types, ctx.facts, call.node, receiverOf(call)) === undefined &&
|
|
142
|
+
says(factLineOf(ctx.types, ctx.shippedFacts, call.node, receiverOf(call))?.fact) ===
|
|
143
|
+
"nothing",
|
|
144
|
+
};
|
|
682
145
|
}
|
|
683
146
|
// ---- the resolver -------------------------------------------------------------------------------
|
|
684
147
|
/** Finds the facts of the calls into packages of the file `ctx` summarizes. */
|
|
685
148
|
export function packageResolver(ctx) {
|
|
686
|
-
const
|
|
149
|
+
const versions = new Map();
|
|
150
|
+
const versionOf = (name) => {
|
|
151
|
+
let known = versions.get(name);
|
|
152
|
+
if (known === undefined) {
|
|
153
|
+
const read = packageVersionOf({ file: ctx.file }, name);
|
|
154
|
+
known = read.kind === "exact" ? read.version : "";
|
|
155
|
+
versions.set(name, known);
|
|
156
|
+
}
|
|
157
|
+
return known;
|
|
158
|
+
};
|
|
687
159
|
return (call) => {
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
const
|
|
691
|
-
const
|
|
160
|
+
const version = versionOf(call.name);
|
|
161
|
+
// The `facts` line a hint would give, and what it states: the function called decides it.
|
|
162
|
+
const lineSide = factSideOf(ctx.types, call, call.through);
|
|
163
|
+
const promise = lineSide === "rejects";
|
|
164
|
+
const key = factKeyOf(ctx.types, call, call.through);
|
|
165
|
+
const base = { name: call.name, version, key, side: lineSide };
|
|
692
166
|
const facts = (source, sides) => ({
|
|
693
167
|
...base,
|
|
694
168
|
source,
|
|
695
169
|
...sides,
|
|
696
170
|
});
|
|
171
|
+
// Not known: on the side a line would state, so its hint gives that line (`configured`).
|
|
697
172
|
const unknown = (reason) => {
|
|
698
173
|
const set = side([], [reason]);
|
|
699
|
-
return facts("unknown", { throws: set, rejects: set });
|
|
174
|
+
return facts("unknown", promise ? { throws: NOTHING, rejects: set } : { throws: set, rejects: set });
|
|
700
175
|
};
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
176
|
+
const stated = (line, source) => {
|
|
177
|
+
const sides = configured(line.fact, call.name, promise);
|
|
178
|
+
const named = [...sides.throws.classes, ...sides.rejects.classes].flatMap((id) => id.startsWith(packageClassId(call.name, "")) ? [id.slice(id.indexOf("#") + 1)] : []);
|
|
179
|
+
const classes = statedClasses(ctx.facts[line.package], ctx.shippedFacts[line.package], call.name, named);
|
|
180
|
+
return { facts: facts(source, sides), classes };
|
|
181
|
+
};
|
|
182
|
+
// A line that states no kind of error (`external` alone) says nothing of what the call throws.
|
|
183
|
+
const own = lineFor(ctx.types, ctx.facts, call);
|
|
184
|
+
if (own !== undefined && statesErrors(own.fact))
|
|
185
|
+
return stated(own, "config");
|
|
186
|
+
// A line left out for this project's version: not checked, never read as another version's.
|
|
187
|
+
const withheld = (source) => ctx.withheldFacts.find((left) => {
|
|
188
|
+
if (left.source !== source)
|
|
189
|
+
return false;
|
|
190
|
+
const line = lineFor(ctx.types, { [left.package]: left.functions }, call);
|
|
191
|
+
return source === "config" ? line !== undefined : statesErrors(line?.fact);
|
|
192
|
+
});
|
|
193
|
+
const ownLeft = withheld("config");
|
|
194
|
+
if (ownLeft !== undefined)
|
|
195
|
+
return { facts: unknown(ownLeft.reason), classes: [] };
|
|
196
|
+
const shipped = lineFor(ctx.types, ctx.shippedFacts, call);
|
|
197
|
+
if (shipped !== undefined && statesErrors(shipped.fact))
|
|
198
|
+
return stated(shipped, "shipped");
|
|
199
|
+
const packLeft = withheld("shipped");
|
|
200
|
+
if (packLeft !== undefined)
|
|
201
|
+
return { facts: unknown(packLeft.reason), classes: [] };
|
|
202
|
+
return { facts: unknown(NOT_STATED), classes: [] };
|
|
722
203
|
};
|
|
723
204
|
}
|
|
724
205
|
//# sourceMappingURL=packages.js.map
|