@cplieger/deadset-ts 8.0.0-dev.15 → 8.0.0-dev.17
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/alias-chain.js +0 -5
- package/dist/src/amd.js +81 -0
- package/dist/src/analysis.js +94 -54
- package/dist/src/augmentations.js +23 -24
- package/dist/src/bindings.js +382 -0
- package/dist/src/calls.js +25 -8
- package/dist/src/commands/read.js +6 -7
- package/dist/src/commands/tools.js +5 -9
- package/dist/src/component-files.js +3 -2
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +9 -10
- package/dist/src/contextual-uses.js +1 -17
- package/dist/src/contract/config.generated.js +5 -2
- package/dist/src/contract/contract.generated.js +119 -2
- package/dist/src/contract/report.generated.js +6 -2
- package/dist/src/dependencies.js +98 -71
- package/dist/src/destructuring.js +1 -19
- package/dist/src/element-access.js +179 -164
- package/dist/src/entries/build-scripts.js +222 -0
- package/dist/src/{configuration-files.js → entries/configuration-files.js} +22 -64
- 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} +9 -12
- package/dist/src/{mdx-entries.js → entries/mdx-entries.js} +3 -3
- package/dist/src/entries/run-directories.js +77 -0
- package/dist/src/entries/sources.js +144 -0
- package/dist/src/entries/static-module.js +670 -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/completion.js +40 -4
- package/dist/src/findings/emitters.js +5 -8
- package/dist/src/{implementations.js → findings/implementations.js} +3 -3
- package/dist/src/{in-operands.js → findings/in-operands.js} +2 -2
- package/dist/src/findings/self-check.js +36 -20
- package/dist/src/findings-pass.js +5 -6
- package/dist/src/framework-lifecycle.js +42 -15
- package/dist/src/fs/manifest.js +15 -20
- package/dist/src/generated-file.js +172 -29
- package/dist/src/graph.js +14 -8
- package/dist/src/import-bindings.js +73 -28
- package/dist/src/index/sites.js +557 -0
- package/dist/src/index.js +1 -1
- package/dist/src/indexed-access.js +523 -478
- package/dist/src/injection-container.js +1 -1
- package/dist/src/interface-satisfaction.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/keyof-comparisons.js +124 -103
- 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/expected-module.js +2 -2
- package/dist/src/load/plan.js +2 -2
- package/dist/src/load/specifiers.js +2 -4
- package/dist/src/load/synthesize.js +10 -5
- package/dist/src/load/workspace-manifests.js +1 -1
- package/dist/src/load/workspace-resolution.js +2 -2
- package/dist/src/matrix.js +12 -17
- package/dist/src/module-declarations.js +70 -85
- package/dist/src/overrides.js +134 -112
- package/dist/src/paths.js +56 -1
- package/dist/src/platform-calls.js +78 -0
- package/dist/src/platform-symbols.js +134 -0
- package/dist/src/references/read-rule.js +1 -0
- package/dist/src/references/read-rules.js +48 -0
- package/dist/src/references/sink.js +151 -0
- package/dist/src/references/sources.js +450 -0
- package/dist/src/references.js +111 -1116
- package/dist/src/resolve.js +1 -1
- package/dist/src/{configured-declarations.js → roots/configured-declarations.js} +7 -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 +236 -0
- package/dist/src/serialization-contract.js +9 -4
- package/dist/src/source-files.js +5 -9
- package/dist/src/stores.js +4 -2
- package/dist/src/suppress.js +30 -32
- package/dist/src/sweep.js +25 -13
- package/dist/src/symbol-keys.js +89 -83
- package/dist/src/tests/file-class.js +76 -0
- package/dist/src/{outside-tests.js → tests/outside.js} +7 -7
- package/dist/src/{test-support.js → tests/support.js} +5 -12
- package/dist/src/type-parameter-reads.js +178 -139
- package/dist/src/unimplemented-callees.js +262 -242
- package/dist/src/verbs/analyze.js +15 -3
- package/dist/src/verbs/describe.js +5 -3
- package/dist/src/verbs/explain.js +50 -28
- package/dist/src/verbs/print-retained.js +2 -2
- package/jsr.json +1 -1
- package/package.json +3 -3
- package/src/alias-chain.ts +0 -7
- package/src/amd.ts +130 -0
- package/src/analysis.ts +156 -70
- package/src/augmentations.ts +41 -27
- package/src/automatic-types.ts +1 -1
- package/src/bindings.ts +460 -0
- package/src/calls.ts +25 -7
- package/src/commands/read.ts +6 -8
- package/src/commands/tools.ts +5 -11
- package/src/component-files.ts +4 -2
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +12 -11
- package/src/contextual-uses.ts +2 -22
- package/src/contract/config.generated.ts +5 -2
- package/src/contract/contract.generated.ts +138 -2
- package/src/contract/report.generated.ts +6 -2
- package/src/dependencies.ts +117 -71
- package/src/destructuring.ts +1 -31
- package/src/element-access.ts +188 -182
- package/src/entries/build-scripts.ts +292 -0
- package/src/{configuration-files.ts → entries/configuration-files.ts} +33 -82
- package/src/{convention-rows.ts → entries/convention-rows.ts} +167 -28
- package/src/{conventions.ts → entries/conventions.ts} +349 -523
- package/src/{html-entries.ts → entries/html-entries.ts} +19 -18
- package/src/{mdx-entries.ts → entries/mdx-entries.ts} +5 -5
- package/src/entries/run-directories.ts +108 -0
- package/src/entries/sources.ts +266 -0
- package/src/entries/static-module.ts +858 -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 +46 -0
- package/src/file-facts.ts +1 -1
- package/src/findings/boundary.ts +2 -0
- package/src/findings/completion.ts +43 -4
- package/src/findings/emitter.ts +1 -1
- package/src/findings/emitters.ts +14 -10
- package/src/{implementations.ts → findings/implementations.ts} +4 -4
- package/src/{in-operands.ts → findings/in-operands.ts} +3 -3
- 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 +43 -15
- package/src/fs/manifest.ts +25 -21
- package/src/generated-file.ts +240 -36
- package/src/graph.ts +27 -11
- package/src/import-bindings.ts +98 -29
- package/src/index/sites.ts +781 -0
- package/src/index.ts +1 -1
- package/src/indexed-access.ts +570 -527
- package/src/injection-container.ts +1 -1
- package/src/interface-satisfaction.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/keyof-comparisons.ts +131 -116
- package/src/load/classify.ts +49 -13
- package/src/load/diagnostics.ts +11 -1
- package/src/load/discover.ts +27 -11
- package/src/load/expected-module.ts +8 -2
- package/src/load/plan.ts +11 -2
- package/src/load/specifiers.ts +8 -5
- package/src/load/synthesize.ts +12 -6
- package/src/load/test-globals.ts +1 -1
- package/src/load/workspace-manifests.ts +1 -1
- package/src/load/workspace-resolution.ts +9 -2
- package/src/load/workspace-run.ts +1 -1
- package/src/matrix.ts +13 -17
- package/src/module-declarations.ts +74 -98
- package/src/overrides.ts +162 -134
- package/src/paths.ts +65 -1
- package/src/platform-calls.ts +119 -0
- package/src/platform-symbols.ts +189 -0
- package/src/references/read-rule.ts +60 -0
- package/src/references/read-rules.ts +55 -0
- package/src/references/sink.ts +213 -0
- package/src/references/sources.ts +632 -0
- package/src/references.ts +174 -1492
- package/src/report.ts +2 -2
- package/src/resolve.ts +1 -1
- package/src/{configured-declarations.ts → roots/configured-declarations.ts} +10 -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 +345 -0
- package/src/serialization-contract.ts +9 -4
- package/src/source-files.ts +5 -10
- package/src/stores.ts +13 -2
- package/src/suppress.ts +48 -33
- package/src/sweep.ts +37 -14
- package/src/symbol-keys.ts +102 -102
- package/src/tests/file-class.ts +118 -0
- package/src/{outside-tests.ts → tests/outside.ts} +16 -10
- package/src/{test-support.ts → tests/support.ts} +15 -21
- package/src/type-parameter-reads.ts +187 -158
- package/src/unimplemented-callees.ts +297 -280
- package/src/verbs/analyze.ts +19 -5
- package/src/verbs/describe.ts +5 -2
- package/src/verbs/explain.ts +75 -32
- package/src/verbs/print-retained.ts +2 -2
- 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
package/src/entry-points.ts
DELETED
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The files a tool or the platform enters without any import naming them, each by a name
|
|
3
|
-
* the tool looks for or a literal it reads. A value that is not a literal is not evaluated
|
|
4
|
-
* or guessed, so a file it would have named is entered by nothing here.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
isArrayLiteralExpression,
|
|
9
|
-
isCallExpression,
|
|
10
|
-
isExportAssignment,
|
|
11
|
-
isIdentifier,
|
|
12
|
-
isMetaProperty,
|
|
13
|
-
isNewExpression,
|
|
14
|
-
isNoSubstitutionTemplateLiteral,
|
|
15
|
-
isObjectLiteralExpression,
|
|
16
|
-
isPropertyAccessExpression,
|
|
17
|
-
isPropertyAssignment,
|
|
18
|
-
isStringLiteral,
|
|
19
|
-
type Node,
|
|
20
|
-
type SourceFile,
|
|
21
|
-
} from "@typescript/native/ast";
|
|
22
|
-
import { SymbolFlags } from "@typescript/native/sync";
|
|
23
|
-
import {
|
|
24
|
-
configurationFiles,
|
|
25
|
-
filesNamedBy,
|
|
26
|
-
moduleStrings,
|
|
27
|
-
type ParseFile,
|
|
28
|
-
} from "./configuration-files.ts";
|
|
29
|
-
import type { Selected } from "./conventions.ts";
|
|
30
|
-
import { buildScriptEntries } from "./build-scripts.ts";
|
|
31
|
-
import type { Host } from "./host.ts";
|
|
32
|
-
import { htmlEntries } from "./html-entries.ts";
|
|
33
|
-
import { documentEntries } from "./mdx-entries.ts";
|
|
34
|
-
import { hasOwnBody } from "./own-body.ts";
|
|
35
|
-
import { dirnamePath, relativePath, resolvePath } from "./paths.ts";
|
|
36
|
-
import { UNANSWERED } from "./query.ts";
|
|
37
|
-
import type { ProjectView } from "./session.ts";
|
|
38
|
-
import type { SourceFiles } from "./source-files.ts";
|
|
39
|
-
import { workflowEntries } from "./workflow-steps.ts";
|
|
40
|
-
import { unwrapped } from "./unwrap.ts";
|
|
41
|
-
import { globExpression } from "./text/glob.ts";
|
|
42
|
-
|
|
43
|
-
/** Which rule entered a file. */
|
|
44
|
-
export type EntryRule =
|
|
45
|
-
/** A configuration module, by the form of its name. */
|
|
46
|
-
| "configuration-file"
|
|
47
|
-
/** A file a relative string of a configuration module or a JSON configuration file names. */
|
|
48
|
-
| "configuration-string"
|
|
49
|
-
/** An entry a build script's bundler call names, whose exports the bundle exposes. */
|
|
50
|
-
| "bundler-entry"
|
|
51
|
-
/** The test runner: its workspace configuration, its setup files and the test files. */
|
|
52
|
-
| "test-runner"
|
|
53
|
-
/** The test files below the browser-test runner's test directory. */
|
|
54
|
-
| "browser-tests"
|
|
55
|
-
/** A worker or service worker a call addresses by a string literal. */
|
|
56
|
-
| "worker"
|
|
57
|
-
/** A file a module script of an HTML file below the target root loads. */
|
|
58
|
-
| "html-entry"
|
|
59
|
-
/** A file a `run:` step of a workflow in the target root's `.github/workflows` names. */
|
|
60
|
-
| "workflow-step"
|
|
61
|
-
/** A file an import line of a Markdown or MDX document below the target root names. */
|
|
62
|
-
| "document-import";
|
|
63
|
-
|
|
64
|
-
/** One file a rule enters. */
|
|
65
|
-
interface EntryPoint {
|
|
66
|
-
readonly file: SourceFile;
|
|
67
|
-
readonly rule: EntryRule;
|
|
68
|
-
/**
|
|
69
|
-
* What named the file: the file-name convention the tool looks for, the test-file
|
|
70
|
-
* pattern that classified it, or the literal a configuration or a call writes.
|
|
71
|
-
*/
|
|
72
|
-
readonly source: string;
|
|
73
|
-
/**
|
|
74
|
-
* Whether what the file exports is read too. A tool loading a configuration reads
|
|
75
|
-
* its default export; a runtime executing a test file or a worker runs its top
|
|
76
|
-
* level and names none of its exports.
|
|
77
|
-
*/
|
|
78
|
-
readonly exports: boolean;
|
|
79
|
-
/** Where the file is entered for some of its exports only, their export names. */
|
|
80
|
-
readonly names?: readonly string[];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** One file-name convention: the stems a tool looks for, under each extension it loads. */
|
|
84
|
-
interface Convention {
|
|
85
|
-
readonly rule: EntryRule;
|
|
86
|
-
readonly stems: readonly string[];
|
|
87
|
-
readonly extensions: readonly string[];
|
|
88
|
-
/** Whether the file is a test-runner configuration whose setup files are read. */
|
|
89
|
-
readonly testRunner: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** The extensions the test runner and the browser-test runner load a configuration from. */
|
|
93
|
-
const MODULE_EXTENSIONS = ["js", "mjs", "cjs", "ts", "mts", "cts"] as const;
|
|
94
|
-
|
|
95
|
-
/** The tool file names the configuration form does not cover. */
|
|
96
|
-
const CONVENTIONS: readonly Convention[] = [
|
|
97
|
-
{
|
|
98
|
-
rule: "test-runner",
|
|
99
|
-
stems: ["vitest.workspace", "vitest.projects"],
|
|
100
|
-
extensions: MODULE_EXTENSIONS,
|
|
101
|
-
testRunner: true,
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
/** The stem of the browser-test runner's configuration, whose test directory is read. */
|
|
106
|
-
const BROWSER_TEST_CONFIG = "playwright.config";
|
|
107
|
-
|
|
108
|
-
/** The browser-test runner's own test-file pattern, which holds where a configuration names none. */
|
|
109
|
-
const BROWSER_TEST_MATCH = "**/*.{spec,test}.{js,ts,jsx,tsx,cjs,cts,cjsx,ctsx,mjs,mts,mjsx,mtsx}";
|
|
110
|
-
|
|
111
|
-
/** The members of a test-runner configuration's `test` object that name setup files. */
|
|
112
|
-
const SETUP_MEMBERS = ["setupFiles", "globalSetup"] as const;
|
|
113
|
-
|
|
114
|
-
/** A member that moves the directory every path of a test-runner configuration is read from. */
|
|
115
|
-
const ROOT_MEMBER = "root";
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A URL reference's scheme. A reference with none that does not start with a solidus is
|
|
119
|
-
* relative, the bare name included: https://url.spec.whatwg.org/#relative-url-string
|
|
120
|
-
*/
|
|
121
|
-
const URL_SCHEME = /^[a-z][a-z\d+.-]*:/iu;
|
|
122
|
-
|
|
123
|
-
/** The constructors whose first argument addresses a worker script. */
|
|
124
|
-
const WORKER_CONSTRUCTORS: ReadonlySet<string> = new Set(["Worker", "SharedWorker"]);
|
|
125
|
-
|
|
126
|
-
/** The file's name, the last segment of its path. */
|
|
127
|
-
function basename(path: string): string {
|
|
128
|
-
return path.slice(path.lastIndexOf("/") + 1);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** The convention one file name is, with the spelling a root reports it by. */
|
|
132
|
-
function conventionOf(
|
|
133
|
-
name: string,
|
|
134
|
-
): { readonly convention: Convention; readonly spelled: string } | undefined {
|
|
135
|
-
for (const convention of CONVENTIONS) {
|
|
136
|
-
for (const stem of convention.stems) {
|
|
137
|
-
if (convention.extensions.some((ext) => name === `${stem}.${ext}`)) {
|
|
138
|
-
return { convention, spelled: `${stem}.*` };
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return undefined;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** The text a string literal or a template with no substitution denotes. */
|
|
146
|
-
function literalOf(node: Node | undefined): string | undefined {
|
|
147
|
-
if (node !== undefined && (isStringLiteral(node) || isNoSubstitutionTemplateLiteral(node))) {
|
|
148
|
-
return node.text;
|
|
149
|
-
}
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* The object literals one configuration file's default export is written as: the
|
|
155
|
-
* literal itself, or each literal argument of the call it is, at any depth of calls.
|
|
156
|
-
* A default export written as anything else, a name or a computation, yields none,
|
|
157
|
-
* because its value is not in the file's text.
|
|
158
|
-
*/
|
|
159
|
-
function configObjects(file: SourceFile): readonly Node[] {
|
|
160
|
-
const found: Node[] = [];
|
|
161
|
-
const collect = (node: Node): void => {
|
|
162
|
-
const at = unwrapped(node);
|
|
163
|
-
if (isObjectLiteralExpression(at)) {
|
|
164
|
-
found.push(at);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (isCallExpression(at)) {
|
|
168
|
-
for (const argument of at.arguments) {
|
|
169
|
-
collect(argument);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
for (const statement of file.statements) {
|
|
174
|
-
if (isExportAssignment(statement) && !statement.isExportEquals) {
|
|
175
|
-
collect(statement.expression);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return found;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* The value one member of an object literal is written with, when it is written as
|
|
183
|
-
* `name: value`, and undefined where the literal writes no such member.
|
|
184
|
-
*/
|
|
185
|
-
function memberOf(object: Node, name: string): Node | undefined {
|
|
186
|
-
if (!isObjectLiteralExpression(object)) {
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
for (const property of object.properties) {
|
|
190
|
-
if (
|
|
191
|
-
isPropertyAssignment(property) &&
|
|
192
|
-
isIdentifier(property.name) &&
|
|
193
|
-
property.name.text === name
|
|
194
|
-
) {
|
|
195
|
-
return property.initializer;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* The strings one member holds, when it is written as a literal or an array of
|
|
203
|
-
* literals. `undefined` is a value the text does not state.
|
|
204
|
-
*/
|
|
205
|
-
export function literalsOf(value: Node): readonly string[] | undefined {
|
|
206
|
-
const at = unwrapped(value);
|
|
207
|
-
const single = literalOf(at);
|
|
208
|
-
if (single !== undefined) {
|
|
209
|
-
return [single];
|
|
210
|
-
}
|
|
211
|
-
if (!isArrayLiteralExpression(at)) {
|
|
212
|
-
return undefined;
|
|
213
|
-
}
|
|
214
|
-
const found: string[] = [];
|
|
215
|
-
for (const element of at.elements) {
|
|
216
|
-
const text = literalOf(unwrapped(element));
|
|
217
|
-
if (text === undefined) {
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
found.push(text);
|
|
221
|
-
}
|
|
222
|
-
return found;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Whether a literal is a relative URL reference, which is also how the test runner reads a
|
|
227
|
-
* setup file's path against its root.
|
|
228
|
-
*/
|
|
229
|
-
function isRelative(text: string): boolean {
|
|
230
|
-
return text !== "" && !text.startsWith("/") && !URL_SCHEME.test(text);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/** A URL reference with its query and its fragment removed, which name no part of the file. */
|
|
234
|
-
function pathPart(text: string): string {
|
|
235
|
-
const cut = text.search(/[?#]/u);
|
|
236
|
-
return cut < 0 ? text : text.slice(0, cut);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** The own files one relative literal names, read against a directory. */
|
|
240
|
-
function filesNamed(files: SourceFiles, dir: string, text: string): readonly SourceFile[] {
|
|
241
|
-
if (!isRelative(text)) {
|
|
242
|
-
return [];
|
|
243
|
-
}
|
|
244
|
-
return files.named(resolvePath(dir, pathPart(text)));
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** Whether one file name is the browser-test runner's configuration. */
|
|
248
|
-
function isBrowserTestConfig(name: string): boolean {
|
|
249
|
-
return MODULE_EXTENSIONS.some((ext) => name === `${BROWSER_TEST_CONFIG}.${ext}`);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* The files the configuration files of one project enter: each configuration module,
|
|
254
|
-
* with what it exports, and each own file a relative string of a configuration module
|
|
255
|
-
* or a JSON configuration file names, read against that file's directory. A string at a
|
|
256
|
-
* selection key of an applied convention row names no file.
|
|
257
|
-
*/
|
|
258
|
-
function configurationEntries(
|
|
259
|
-
host: Host,
|
|
260
|
-
targetRoot: string,
|
|
261
|
-
files: SourceFiles,
|
|
262
|
-
parse: ParseFile | undefined,
|
|
263
|
-
selected: ReadonlyMap<string, Selected>,
|
|
264
|
-
): readonly EntryPoint[] {
|
|
265
|
-
const { modules, documents, outside } = configurationFiles(host, targetRoot, files, parse);
|
|
266
|
-
const found: EntryPoint[] = [];
|
|
267
|
-
const unselected = (file: SourceFile): readonly string[] => {
|
|
268
|
-
const starts = selected.get(file.fileName)?.starts;
|
|
269
|
-
return moduleStrings(file)
|
|
270
|
-
.filter((one) => starts?.has(one.node.getStart()) !== true)
|
|
271
|
-
.map((one) => one.text);
|
|
272
|
-
};
|
|
273
|
-
const unselectedIn = (path: string, texts: readonly string[]): readonly string[] => {
|
|
274
|
-
const left = [...(selected.get(path)?.texts ?? [])];
|
|
275
|
-
return texts.filter((text) => {
|
|
276
|
-
const at = left.indexOf(text);
|
|
277
|
-
if (at < 0) {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
left.splice(at, 1);
|
|
281
|
-
return false;
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
const strings = (dir: string, texts: readonly string[]): void => {
|
|
285
|
-
for (const text of texts) {
|
|
286
|
-
for (const file of filesNamedBy(files, dir, text)) {
|
|
287
|
-
found.push({ file, rule: "configuration-string", source: text, exports: true });
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
for (const { file, form } of modules) {
|
|
292
|
-
found.push({ file, rule: "configuration-file", source: form, exports: true });
|
|
293
|
-
strings(dirnamePath(file.fileName), unselected(file));
|
|
294
|
-
}
|
|
295
|
-
for (const document of documents) {
|
|
296
|
-
strings(dirnamePath(document.path), unselectedIn(document.path, document.strings));
|
|
297
|
-
}
|
|
298
|
-
for (const { file } of outside) {
|
|
299
|
-
strings(dirnamePath(file.fileName), unselected(file));
|
|
300
|
-
}
|
|
301
|
-
return found;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* The setup files one test-runner configuration names: every literal under
|
|
306
|
-
* `test.setupFiles` and `test.globalSetup`, read against the configuration's own
|
|
307
|
-
* directory. A configuration that moves its root names them against a directory its
|
|
308
|
-
* text may not state, so none is read from it.
|
|
309
|
-
*/
|
|
310
|
-
function setupFilesOf(file: SourceFile, files: SourceFiles): readonly EntryPoint[] {
|
|
311
|
-
const objects = configObjects(file);
|
|
312
|
-
const tests = objects
|
|
313
|
-
.map((object) => memberOf(object, "test"))
|
|
314
|
-
.filter((value): value is Node => value !== undefined)
|
|
315
|
-
.map(unwrapped);
|
|
316
|
-
if ([...objects, ...tests].some((object) => memberOf(object, ROOT_MEMBER) !== undefined)) {
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
const dir = dirnamePath(file.fileName);
|
|
320
|
-
const found: EntryPoint[] = [];
|
|
321
|
-
for (const test of tests) {
|
|
322
|
-
for (const name of SETUP_MEMBERS) {
|
|
323
|
-
const value = memberOf(test, name);
|
|
324
|
-
for (const text of value === undefined ? [] : (literalsOf(value) ?? [])) {
|
|
325
|
-
for (const named of filesNamed(files, dir, text)) {
|
|
326
|
-
found.push({ file: named, rule: "test-runner", source: text, exports: false });
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return found;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* The test files one browser-test configuration names: every own file below its
|
|
336
|
-
* test directory that its test-file pattern matches. The directory is the literal
|
|
337
|
-
* `testDir` reads against the configuration's directory, or that directory where no
|
|
338
|
-
* object of the configuration writes one; the pattern is the literal `testMatch`, or
|
|
339
|
-
* the runner's own where none is written. A member whose value is not a literal
|
|
340
|
-
* leaves the set unknown, and an unknown set enters nothing.
|
|
341
|
-
*/
|
|
342
|
-
function browserTestsOf(file: SourceFile, files: SourceFiles): readonly EntryPoint[] {
|
|
343
|
-
const objects = configObjects(file);
|
|
344
|
-
if (objects.length === 0) {
|
|
345
|
-
return [];
|
|
346
|
-
}
|
|
347
|
-
let testDir: string | undefined = ".";
|
|
348
|
-
let patterns: readonly string[] | undefined = [BROWSER_TEST_MATCH];
|
|
349
|
-
for (const object of objects) {
|
|
350
|
-
const dir = memberOf(object, "testDir");
|
|
351
|
-
if (dir !== undefined) {
|
|
352
|
-
testDir = literalOf(unwrapped(dir));
|
|
353
|
-
}
|
|
354
|
-
const match = memberOf(object, "testMatch");
|
|
355
|
-
if (match !== undefined) {
|
|
356
|
-
patterns = literalsOf(match);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
if (testDir === undefined || patterns === undefined) {
|
|
360
|
-
return [];
|
|
361
|
-
}
|
|
362
|
-
const under = resolvePath(dirnamePath(file.fileName), testDir);
|
|
363
|
-
const found: EntryPoint[] = [];
|
|
364
|
-
for (const pattern of patterns) {
|
|
365
|
-
const expression = globExpression(pattern);
|
|
366
|
-
for (const candidate of files.byName.values()) {
|
|
367
|
-
const below = relativePath(under, candidate.fileName);
|
|
368
|
-
if (below !== undefined && expression.test(below)) {
|
|
369
|
-
found.push({ file: candidate, rule: "browser-tests", source: pattern, exports: false });
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return found;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/** One call that addresses a worker, with the names the checker must resolve to the platform. */
|
|
377
|
-
interface WorkerSite {
|
|
378
|
-
readonly literal: string;
|
|
379
|
-
readonly platformNames: readonly Node[];
|
|
380
|
-
/** The `URL` the address is built with; {@link hasOwnBody} owns which one names no file. */
|
|
381
|
-
readonly url: Node | undefined;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* The address one worker argument writes: a relative literal, or a `URL` built from
|
|
386
|
-
* a literal against `import.meta.url`. Any other argument is computed and addresses
|
|
387
|
-
* nothing the text states.
|
|
388
|
-
*/
|
|
389
|
-
function workerAddress(
|
|
390
|
-
argument: Node | undefined,
|
|
391
|
-
): { readonly literal: string; readonly url: Node | undefined } | undefined {
|
|
392
|
-
if (argument === undefined) {
|
|
393
|
-
return undefined;
|
|
394
|
-
}
|
|
395
|
-
const at = unwrapped(argument);
|
|
396
|
-
const literal = literalOf(at);
|
|
397
|
-
if (literal !== undefined) {
|
|
398
|
-
return { literal, url: undefined };
|
|
399
|
-
}
|
|
400
|
-
if (!isNewExpression(at) || !isIdentifier(at.expression) || at.expression.text !== "URL") {
|
|
401
|
-
return undefined;
|
|
402
|
-
}
|
|
403
|
-
const [reference, base] = at.arguments ?? [];
|
|
404
|
-
const text = literalOf(reference === undefined ? undefined : unwrapped(reference));
|
|
405
|
-
if (text === undefined || base === undefined) {
|
|
406
|
-
return undefined;
|
|
407
|
-
}
|
|
408
|
-
const meta = unwrapped(base);
|
|
409
|
-
if (
|
|
410
|
-
!isPropertyAccessExpression(meta) ||
|
|
411
|
-
!isMetaProperty(meta.expression) ||
|
|
412
|
-
!isIdentifier(meta.name) ||
|
|
413
|
-
meta.name.text !== "url"
|
|
414
|
-
) {
|
|
415
|
-
return undefined;
|
|
416
|
-
}
|
|
417
|
-
return { literal: text, url: at.expression };
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Every call one file writes that addresses a worker: `new Worker(...)`,
|
|
422
|
-
* `new SharedWorker(...)` and `navigator.serviceWorker.register(...)`, each with an
|
|
423
|
-
* address its text states.
|
|
424
|
-
*/
|
|
425
|
-
function workerSitesOf(file: SourceFile): readonly WorkerSite[] {
|
|
426
|
-
const found: WorkerSite[] = [];
|
|
427
|
-
const visit = (node: Node): void => {
|
|
428
|
-
if (
|
|
429
|
-
isNewExpression(node) &&
|
|
430
|
-
isIdentifier(node.expression) &&
|
|
431
|
-
WORKER_CONSTRUCTORS.has(node.expression.text)
|
|
432
|
-
) {
|
|
433
|
-
const address = workerAddress(node.arguments?.[0]);
|
|
434
|
-
if (address !== undefined) {
|
|
435
|
-
found.push({
|
|
436
|
-
literal: address.literal,
|
|
437
|
-
platformNames: [node.expression],
|
|
438
|
-
url: address.url,
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (isCallExpression(node)) {
|
|
443
|
-
const callee = node.expression;
|
|
444
|
-
if (
|
|
445
|
-
isPropertyAccessExpression(callee) &&
|
|
446
|
-
isIdentifier(callee.name) &&
|
|
447
|
-
callee.name.text === "register" &&
|
|
448
|
-
isPropertyAccessExpression(callee.expression) &&
|
|
449
|
-
isIdentifier(callee.expression.name) &&
|
|
450
|
-
callee.expression.name.text === "serviceWorker" &&
|
|
451
|
-
isIdentifier(callee.expression.expression) &&
|
|
452
|
-
callee.expression.expression.text === "navigator"
|
|
453
|
-
) {
|
|
454
|
-
const address = workerAddress(node.arguments[0]);
|
|
455
|
-
if (address !== undefined) {
|
|
456
|
-
found.push({
|
|
457
|
-
literal: address.literal,
|
|
458
|
-
platformNames: [callee.expression.expression],
|
|
459
|
-
url: address.url,
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
node.forEachChild(visit);
|
|
465
|
-
};
|
|
466
|
-
file.forEachChild(visit);
|
|
467
|
-
return found;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* The workers one file addresses. A call's `Worker`, `SharedWorker` or `navigator` must
|
|
472
|
-
* resolve to a symbol the platform declares, which a file of the target may augment and no
|
|
473
|
-
* import brings in; a name only the target declares is the target's own constructor or
|
|
474
|
-
* object, which addresses no worker this rule knows. One batch per file that writes such a call.
|
|
475
|
-
*/
|
|
476
|
-
function workersOf<Brand>(
|
|
477
|
-
project: ProjectView<Brand>,
|
|
478
|
-
file: SourceFile,
|
|
479
|
-
files: SourceFiles,
|
|
480
|
-
): readonly EntryPoint[] {
|
|
481
|
-
const sites = workerSitesOf(file);
|
|
482
|
-
if (sites.length === 0) {
|
|
483
|
-
return [];
|
|
484
|
-
}
|
|
485
|
-
const names = sites.flatMap((site) => site.platformNames);
|
|
486
|
-
const urls = sites.flatMap((site) => site.url ?? []);
|
|
487
|
-
const symbols = project.symbolsAt([...names, ...urls].map((name) => project.handle(name)));
|
|
488
|
-
const platform = new Set<Node>();
|
|
489
|
-
// A name the checker could not resolve is read as the platform's, so a worker it
|
|
490
|
-
// stands on is rooted rather than reported.
|
|
491
|
-
names.forEach((name, index) => {
|
|
492
|
-
const symbol = symbols[index];
|
|
493
|
-
if (symbol === UNANSWERED) {
|
|
494
|
-
platform.add(name);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
if (
|
|
498
|
-
symbol !== undefined &&
|
|
499
|
-
(symbol.flags & SymbolFlags.Alias) === 0 &&
|
|
500
|
-
symbol.declarations.some((handle) => !files.byName.has(handle.path))
|
|
501
|
-
) {
|
|
502
|
-
platform.add(name);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
urls.forEach((url, index) => {
|
|
506
|
-
const symbol = symbols[names.length + index];
|
|
507
|
-
if (typeof symbol !== "object" || !hasOwnBody(project, symbol)) {
|
|
508
|
-
platform.add(url);
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
const dir = dirnamePath(file.fileName);
|
|
512
|
-
const found: EntryPoint[] = [];
|
|
513
|
-
for (const site of sites) {
|
|
514
|
-
if (
|
|
515
|
-
!site.platformNames.every((name) => platform.has(name)) ||
|
|
516
|
-
(site.url !== undefined && !platform.has(site.url))
|
|
517
|
-
) {
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
for (const named of filesNamed(files, dir, site.literal)) {
|
|
521
|
-
found.push({ file: named, rule: "worker", source: site.literal, exports: false });
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return found;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Every file of one project the rules enter, in no particular order and possibly more
|
|
529
|
-
* than once: a file two rules enter appears once per rule.
|
|
530
|
-
*
|
|
531
|
-
* `testFiles` is the configuration's test-file patterns, matched against each
|
|
532
|
-
* file's path below the target root; a file one of them matches is a test file the
|
|
533
|
-
* runner executes.
|
|
534
|
-
*/
|
|
535
|
-
export function entryPoints<Brand>(
|
|
536
|
-
project: ProjectView<Brand>,
|
|
537
|
-
files: SourceFiles,
|
|
538
|
-
testFiles: readonly string[],
|
|
539
|
-
host: Host,
|
|
540
|
-
targetRoot: string,
|
|
541
|
-
parse?: ParseFile,
|
|
542
|
-
selected: ReadonlyMap<string, Selected> = new Map(),
|
|
543
|
-
): readonly EntryPoint[] {
|
|
544
|
-
const found: EntryPoint[] = [...configurationEntries(host, targetRoot, files, parse, selected)];
|
|
545
|
-
const tests = testFiles.map((pattern) => ({ pattern, expression: globExpression(pattern) }));
|
|
546
|
-
for (const [path, file] of files.byPath) {
|
|
547
|
-
const name = basename(path);
|
|
548
|
-
const named = conventionOf(name);
|
|
549
|
-
if (named !== undefined) {
|
|
550
|
-
found.push({ file, rule: named.convention.rule, source: named.spelled, exports: true });
|
|
551
|
-
if (named.convention.testRunner) {
|
|
552
|
-
found.push(...setupFilesOf(file, files));
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (isBrowserTestConfig(name)) {
|
|
556
|
-
found.push(...browserTestsOf(file, files));
|
|
557
|
-
}
|
|
558
|
-
for (const { pattern, expression } of tests) {
|
|
559
|
-
if (expression.test(path)) {
|
|
560
|
-
found.push({ file, rule: "test-runner", source: pattern, exports: false });
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
found.push(...workersOf(project, file, files));
|
|
564
|
-
}
|
|
565
|
-
for (const { file, source } of htmlEntries(host, targetRoot, files, parse)) {
|
|
566
|
-
found.push({ file, rule: "html-entry", source, exports: true });
|
|
567
|
-
}
|
|
568
|
-
for (const { file, source, names } of documentEntries(host, targetRoot, files)) {
|
|
569
|
-
found.push({
|
|
570
|
-
file,
|
|
571
|
-
rule: "document-import",
|
|
572
|
-
source,
|
|
573
|
-
exports: true,
|
|
574
|
-
...(names === undefined ? {} : { names }),
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
for (const { file, source } of buildScriptEntries(host, targetRoot, files, parse)) {
|
|
578
|
-
found.push({ file, rule: "bundler-entry", source, exports: true });
|
|
579
|
-
}
|
|
580
|
-
for (const { file, source } of workflowEntries(host, targetRoot, files)) {
|
|
581
|
-
found.push({ file, rule: "workflow-step", source, exports: true });
|
|
582
|
-
}
|
|
583
|
-
return found;
|
|
584
|
-
}
|
package/src/own-body.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isArrowFunction,
|
|
3
|
-
isClassDeclaration,
|
|
4
|
-
isClassExpression,
|
|
5
|
-
isFunctionDeclaration,
|
|
6
|
-
isFunctionExpression,
|
|
7
|
-
isVariableDeclaration,
|
|
8
|
-
} from "@typescript/native/ast";
|
|
9
|
-
import { SymbolFlags, type Symbol as TSSymbol } from "@typescript/native/sync";
|
|
10
|
-
import { isAmbient } from "./inventory.ts";
|
|
11
|
-
import type { ProjectView } from "./session.ts";
|
|
12
|
-
import { unwrapped } from "./unwrap.ts";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Whether `symbol`, through its aliases, names a function or class the target writes with a
|
|
16
|
-
* body, which a call or construction runs in place of the platform's `require` or `URL`. Any
|
|
17
|
-
* other answer, an unresolved one included, is the platform's, whose call loads a file.
|
|
18
|
-
*/
|
|
19
|
-
export function hasOwnBody<Brand>(project: ProjectView<Brand>, symbol: TSSymbol): boolean {
|
|
20
|
-
const named = (symbol.flags & SymbolFlags.Alias) === 0 ? symbol : project.queries.aliased(symbol);
|
|
21
|
-
const own = project.ownPaths();
|
|
22
|
-
return (
|
|
23
|
-
typeof named === "object" &&
|
|
24
|
-
named.declarations.some((handle) => {
|
|
25
|
-
const node = own.has(handle.path) ? project.declarationAt(handle)?.node : undefined;
|
|
26
|
-
const value =
|
|
27
|
-
node !== undefined && isVariableDeclaration(node) && node.initializer !== undefined
|
|
28
|
-
? unwrapped(node.initializer)
|
|
29
|
-
: node;
|
|
30
|
-
return (
|
|
31
|
-
value !== undefined &&
|
|
32
|
-
(isFunctionDeclaration(value)
|
|
33
|
-
? value.body !== undefined
|
|
34
|
-
: isFunctionExpression(value) ||
|
|
35
|
-
isArrowFunction(value) ||
|
|
36
|
-
isClassDeclaration(value) ||
|
|
37
|
-
isClassExpression(value)) &&
|
|
38
|
-
!isAmbient(value.getSourceFile(), value)
|
|
39
|
-
);
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
}
|