@cplieger/deadset-ts 8.0.0-dev.15 → 8.0.0-dev.16
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/src/analysis.js +41 -37
- package/dist/src/commands/read.js +6 -7
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +3 -1
- package/dist/src/contract/config.generated.js +1 -1
- package/dist/src/contract/contract.generated.js +119 -2
- package/dist/src/dependencies.js +79 -48
- package/dist/src/entries/build-scripts.js +222 -0
- package/dist/src/{configuration-files.js → entries/configuration-files.js} +20 -58
- package/dist/src/{convention-rows.js → entries/convention-rows.js} +120 -27
- package/dist/src/entries/conventions.js +739 -0
- package/dist/src/{html-entries.js → entries/html-entries.js} +3 -3
- package/dist/src/{mdx-entries.js → entries/mdx-entries.js} +2 -2
- package/dist/src/entries/run-directories.js +77 -0
- package/dist/src/entries/sources.js +144 -0
- package/dist/src/entries/static-module.js +669 -0
- package/dist/src/entries/test-runners.js +684 -0
- package/dist/src/{workflow-steps.js → entries/workflow-steps.js} +18 -8
- package/dist/src/extensions.js +37 -0
- package/dist/src/facts.js +38 -0
- package/dist/src/findings/emitters.js +5 -8
- package/dist/src/findings/self-check.js +36 -20
- package/dist/src/findings-pass.js +5 -6
- package/dist/src/framework-lifecycle.js +1 -1
- package/dist/src/fs/manifest.js +15 -20
- package/dist/src/generated-file.js +172 -29
- package/dist/src/graph.js +2 -4
- package/dist/src/index.js +1 -1
- package/dist/src/injection-container.js +1 -1
- package/dist/src/inventory/commonjs.js +62 -17
- package/dist/src/inventory/enumerate.js +2 -1
- package/dist/src/javascript-file.js +26 -11
- package/dist/src/load/classify.js +28 -9
- package/dist/src/load/diagnostics.js +8 -1
- package/dist/src/load/discover.js +15 -7
- package/dist/src/load/plan.js +2 -2
- package/dist/src/load/synthesize.js +5 -5
- package/dist/src/load/workspace-manifests.js +1 -1
- package/dist/src/matrix.js +6 -13
- package/dist/src/outside-tests.js +1 -1
- package/dist/src/paths.js +16 -0
- package/dist/src/platform-calls.js +78 -0
- package/dist/src/platform-symbols.js +140 -0
- package/dist/src/references.js +202 -32
- package/dist/src/resolve.js +1 -1
- package/dist/src/{configured-declarations.js → roots/configured-declarations.js} +4 -4
- package/dist/src/{entry-point-gaps.js → roots/entry-point-gaps.js} +5 -8
- package/dist/src/{manifest.js → roots/manifest.js} +4 -4
- package/dist/src/roots/published-reach.js +412 -0
- package/dist/src/roots/root-set.js +489 -0
- package/dist/src/roots/unseen-loads.js +208 -0
- package/dist/src/serialization-contract.js +1 -1
- package/dist/src/source-files.js +5 -9
- package/dist/src/suppress.js +30 -32
- package/dist/src/test-support.js +4 -2
- package/dist/src/verbs/analyze.js +13 -1
- package/dist/src/verbs/describe.js +5 -3
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/analysis.ts +75 -52
- package/src/automatic-types.ts +1 -1
- package/src/commands/read.ts +6 -8
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +4 -0
- package/src/contract/config.generated.ts +1 -1
- package/src/contract/contract.generated.ts +138 -2
- package/src/dependencies.ts +96 -49
- package/src/entries/build-scripts.ts +292 -0
- package/src/{configuration-files.ts → entries/configuration-files.ts} +23 -75
- package/src/{convention-rows.ts → entries/convention-rows.ts} +167 -28
- package/src/{conventions.ts → entries/conventions.ts} +347 -522
- package/src/{html-entries.ts → entries/html-entries.ts} +5 -5
- package/src/{mdx-entries.ts → entries/mdx-entries.ts} +4 -4
- package/src/entries/run-directories.ts +108 -0
- package/src/entries/sources.ts +266 -0
- package/src/entries/static-module.ts +857 -0
- package/src/entries/test-runners.ts +868 -0
- package/src/{workflow-steps.ts → entries/workflow-steps.ts} +29 -11
- package/src/exempt.ts +3 -2
- package/src/extensions.ts +45 -0
- package/src/facts.ts +44 -0
- package/src/file-facts.ts +1 -1
- package/src/findings/emitters.ts +14 -10
- package/src/findings/self-check.ts +41 -22
- package/src/findings/visibility-narrowing.ts +1 -1
- package/src/findings-pass.ts +5 -12
- package/src/framework-lifecycle.ts +1 -1
- package/src/fs/manifest.ts +25 -21
- package/src/generated-file.ts +240 -36
- package/src/graph.ts +3 -5
- package/src/index.ts +1 -1
- package/src/injection-container.ts +1 -1
- package/src/inventory/commonjs.ts +102 -17
- package/src/inventory/enumerate.ts +2 -1
- package/src/javascript-file.ts +29 -12
- package/src/load/classify.ts +49 -13
- package/src/load/diagnostics.ts +11 -1
- package/src/load/discover.ts +27 -11
- package/src/load/plan.ts +11 -2
- package/src/load/synthesize.ts +6 -6
- package/src/load/test-globals.ts +1 -1
- package/src/load/workspace-manifests.ts +1 -1
- package/src/load/workspace-run.ts +1 -1
- package/src/matrix.ts +7 -14
- package/src/outside-tests.ts +1 -1
- package/src/paths.ts +18 -0
- package/src/platform-calls.ts +119 -0
- package/src/platform-symbols.ts +205 -0
- package/src/references.ts +281 -34
- package/src/report.ts +1 -1
- package/src/resolve.ts +1 -1
- package/src/{configured-declarations.ts → roots/configured-declarations.ts} +7 -7
- package/src/{entry-point-gaps.ts → roots/entry-point-gaps.ts} +5 -8
- package/src/{manifest.ts → roots/manifest.ts} +5 -5
- package/src/roots/published-reach.ts +481 -0
- package/src/{roots.ts → roots/root-set.ts} +203 -630
- package/src/roots/unseen-loads.ts +307 -0
- package/src/serialization-contract.ts +1 -1
- package/src/source-files.ts +5 -10
- package/src/suppress.ts +48 -33
- package/src/test-support.ts +8 -3
- package/src/verbs/analyze.ts +17 -4
- package/src/verbs/describe.ts +5 -2
- package/src/verbs/explain.ts +1 -1
- package/dist/src/build-scripts.js +0 -418
- package/dist/src/conventions.js +0 -907
- package/dist/src/entry-points.js +0 -444
- package/dist/src/own-body.js +0 -28
- package/dist/src/roots.js +0 -865
- package/dist/src/unseen-loads.js +0 -189
- package/src/build-scripts.ts +0 -536
- package/src/entry-points.ts +0 -584
- package/src/own-body.ts +0 -42
- package/src/unseen-loads.ts +0 -282
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform's names read through a program's checker: its `require` and `URL`, as
|
|
3
|
+
* `platform-calls.ts` decides them, its worker constructors and `navigator`, and Node's
|
|
4
|
+
* `Worker`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
isArrowFunction,
|
|
9
|
+
isClassDeclaration,
|
|
10
|
+
isClassExpression,
|
|
11
|
+
isFunctionDeclaration,
|
|
12
|
+
isFunctionExpression,
|
|
13
|
+
isMethodDeclaration,
|
|
14
|
+
isModuleDeclaration,
|
|
15
|
+
isPropertyAssignment,
|
|
16
|
+
isPropertyDeclaration,
|
|
17
|
+
isSourceFile,
|
|
18
|
+
isStringLiteralLikeNode,
|
|
19
|
+
isVariableDeclaration,
|
|
20
|
+
type Identifier,
|
|
21
|
+
type Node,
|
|
22
|
+
} from "@typescript/native/ast";
|
|
23
|
+
import { SymbolFlags, type Symbol as TSSymbol } from "@typescript/native/sync";
|
|
24
|
+
import { UNANSWERED, type Answer } from "./query.ts";
|
|
25
|
+
import type { ProjectView } from "./session.ts";
|
|
26
|
+
import { boundExports, NAMESPACE } from "./entries/static-module.ts";
|
|
27
|
+
import { isAmbient } from "./inventory.ts";
|
|
28
|
+
import { callsPlatformBy, carriedNames, type BindingOf, type Bound } from "./platform-calls.ts";
|
|
29
|
+
import { unwrapped } from "./unwrap.ts";
|
|
30
|
+
|
|
31
|
+
/** Counts one request a platform decision puts to the checker. */
|
|
32
|
+
type Asked = () => void;
|
|
33
|
+
|
|
34
|
+
/** The symbol one symbol names through its aliases, or the symbol itself where it is none. */
|
|
35
|
+
function dealiased<Brand>(
|
|
36
|
+
project: ProjectView<Brand>,
|
|
37
|
+
symbol: TSSymbol,
|
|
38
|
+
asked: Asked,
|
|
39
|
+
): Answer<TSSymbol> {
|
|
40
|
+
if ((symbol.flags & SymbolFlags.Alias) === 0) {
|
|
41
|
+
return symbol;
|
|
42
|
+
}
|
|
43
|
+
asked();
|
|
44
|
+
return project.queries.aliased(symbol);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Each declaration of `symbol` in a file of the target, read in this project's program. */
|
|
48
|
+
function ownDeclarations<Brand>(project: ProjectView<Brand>, symbol: TSSymbol): readonly Node[] {
|
|
49
|
+
const own = project.ownPaths();
|
|
50
|
+
return symbol.declarations.flatMap((handle) => {
|
|
51
|
+
const node = own.has(handle.path) ? project.declarationAt(handle)?.node : undefined;
|
|
52
|
+
return node === undefined ? [] : [node];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether one declaration writes a function or a class with a body (roots.23): a function
|
|
58
|
+
* or method declaration with a body, a class declaration, or a variable, a property or a
|
|
59
|
+
* class field whose initializer is a function, an arrow function or a class expression,
|
|
60
|
+
* under no `declare` modifier and in no declaration file.
|
|
61
|
+
*/
|
|
62
|
+
function writesBody(node: Node): boolean {
|
|
63
|
+
const value =
|
|
64
|
+
(isVariableDeclaration(node) || isPropertyAssignment(node) || isPropertyDeclaration(node)) &&
|
|
65
|
+
node.initializer !== undefined
|
|
66
|
+
? unwrapped(node.initializer)
|
|
67
|
+
: node;
|
|
68
|
+
return (
|
|
69
|
+
(isFunctionDeclaration(value) || isMethodDeclaration(value)
|
|
70
|
+
? value.body !== undefined
|
|
71
|
+
: isFunctionExpression(value) ||
|
|
72
|
+
isArrowFunction(value) ||
|
|
73
|
+
isClassDeclaration(value) ||
|
|
74
|
+
isClassExpression(value)) && !isAmbient(value.getSourceFile(), value)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* What the checker binds `symbol` to, one alias step at a time: every name a step of the
|
|
80
|
+
* chain carries it by, and the declarations of the target its last step reaches, which
|
|
81
|
+
* prove it the target's own where one {@link writesBody}. A chain that ends at no
|
|
82
|
+
* declaration, or that the checker leaves unanswered, reaches none.
|
|
83
|
+
*/
|
|
84
|
+
function boundBy<Brand>(
|
|
85
|
+
project: ProjectView<Brand>,
|
|
86
|
+
symbol: Answer<TSSymbol> | undefined,
|
|
87
|
+
asked: Asked,
|
|
88
|
+
): Bound | undefined {
|
|
89
|
+
if (typeof symbol !== "object") {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const names = new Set<string>();
|
|
93
|
+
const stepped = new Set<number>();
|
|
94
|
+
for (let at: TSSymbol | undefined = symbol; at !== undefined && !stepped.has(at.id);) {
|
|
95
|
+
stepped.add(at.id);
|
|
96
|
+
names.add(at.name);
|
|
97
|
+
const own = ownDeclarations(project, at);
|
|
98
|
+
for (const node of own) {
|
|
99
|
+
carriedNames(node).forEach((one) => names.add(one));
|
|
100
|
+
}
|
|
101
|
+
if ((at.flags & SymbolFlags.Alias) === 0) {
|
|
102
|
+
return { names, own, provenOwn: own.some(writesBody) };
|
|
103
|
+
}
|
|
104
|
+
asked();
|
|
105
|
+
const next = project.aliasStepOf(at);
|
|
106
|
+
at = typeof next === "object" ? next : undefined;
|
|
107
|
+
}
|
|
108
|
+
return { names, own: [], provenOwn: false };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Each written name's binding, as this project's checker answers it. */
|
|
112
|
+
function checkerBinding<Brand>(project: ProjectView<Brand>, asked: Asked): BindingOf {
|
|
113
|
+
return (written) => {
|
|
114
|
+
asked();
|
|
115
|
+
return boundBy(project, project.symbolsAt([project.handle(written)])[0], asked);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether a call or construction through `callee`, the batch's answer for which is `symbol`,
|
|
121
|
+
* is one of the platform's `require` or `URL` (roots.23, references-ts.1), as
|
|
122
|
+
* {@link callsPlatformBy} decides it over this project's checker, each request it puts
|
|
123
|
+
* counted by `asked`.
|
|
124
|
+
*/
|
|
125
|
+
export function callsPlatform<Brand>(
|
|
126
|
+
project: ProjectView<Brand>,
|
|
127
|
+
name: "require" | "URL",
|
|
128
|
+
callee: Identifier,
|
|
129
|
+
symbol: Answer<TSSymbol> | undefined,
|
|
130
|
+
asked: Asked,
|
|
131
|
+
): boolean {
|
|
132
|
+
const others = checkerBinding(project, asked);
|
|
133
|
+
return callsPlatformBy(name, callee, (written) =>
|
|
134
|
+
written === callee ? boundBy(project, symbol, asked) : others(written),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Whether a worker's constructor or `navigator`, the batch's answer for which is `symbol`, is
|
|
140
|
+
* the platform's (references-ts.2): a name the checker leaves unanswered, or one whose symbol
|
|
141
|
+
* is no alias and has a declaration outside the target's files.
|
|
142
|
+
*/
|
|
143
|
+
export function isPlatformGlobal<Brand>(
|
|
144
|
+
project: ProjectView<Brand>,
|
|
145
|
+
symbol: Answer<TSSymbol> | undefined,
|
|
146
|
+
): boolean {
|
|
147
|
+
if (symbol === UNANSWERED) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
const own = project.ownPaths();
|
|
151
|
+
return (
|
|
152
|
+
symbol !== undefined &&
|
|
153
|
+
(symbol.flags & SymbolFlags.Alias) === 0 &&
|
|
154
|
+
symbol.declarations.some((handle) => !own.has(handle.path))
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The module names Node's worker threads are imported by. */
|
|
159
|
+
const THREADS: ReadonlySet<string> = new Set(["worker_threads", "node:worker_threads"]);
|
|
160
|
+
|
|
161
|
+
function namesThreads(node: Node | undefined): boolean {
|
|
162
|
+
return node !== undefined && isStringLiteralLikeNode(node) && THREADS.has(node.text);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Whether one declaration is written in the body of `declare module "worker_threads"`. */
|
|
166
|
+
function inThreadsModule(node: Node): boolean {
|
|
167
|
+
for (let at = node; !isSourceFile(at); at = at.parent) {
|
|
168
|
+
if (isModuleDeclaration(at) && namesThreads(at.name)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Whether a `Worker` constructor, the batch's answer for which is `symbol`, is Node's
|
|
177
|
+
* (references-ts.2): its symbol resolves to a declaration of `worker_threads`, or one of its
|
|
178
|
+
* own declarations binds the module's `Worker`, or `holder`, the namespace it is read
|
|
179
|
+
* through, binds the module, each binding read as {@link boundExports} reads one, which
|
|
180
|
+
* decides where the module has no declaration. Each request it puts is counted by `asked`.
|
|
181
|
+
*/
|
|
182
|
+
export function startsThread<Brand>(
|
|
183
|
+
project: ProjectView<Brand>,
|
|
184
|
+
symbol: Answer<TSSymbol> | undefined,
|
|
185
|
+
holder: Answer<TSSymbol> | undefined,
|
|
186
|
+
asked: Asked,
|
|
187
|
+
): boolean {
|
|
188
|
+
const bindingOf = checkerBinding(project, asked);
|
|
189
|
+
const declared = (one: Answer<TSSymbol> | undefined, member: string): boolean =>
|
|
190
|
+
typeof one === "object" &&
|
|
191
|
+
ownDeclarations(project, one).some((node) =>
|
|
192
|
+
boundExports(node, (specifier) => THREADS.has(specifier), bindingOf).includes(member),
|
|
193
|
+
);
|
|
194
|
+
if (declared(symbol, "Worker") || declared(holder, NAMESPACE)) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
const named = typeof symbol === "object" ? dealiased(project, symbol, asked) : undefined;
|
|
198
|
+
return (
|
|
199
|
+
typeof named === "object" &&
|
|
200
|
+
named.declarations.some((handle) => {
|
|
201
|
+
const node = project.declarationAt(handle)?.node;
|
|
202
|
+
return node !== undefined && inThreadsModule(node);
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
}
|