@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.
Files changed (134) hide show
  1. package/dist/src/analysis.js +41 -37
  2. package/dist/src/commands/read.js +6 -7
  3. package/dist/src/conformance-record.js +1 -1
  4. package/dist/src/consumers.js +3 -1
  5. package/dist/src/contract/config.generated.js +1 -1
  6. package/dist/src/contract/contract.generated.js +119 -2
  7. package/dist/src/dependencies.js +79 -48
  8. package/dist/src/entries/build-scripts.js +222 -0
  9. package/dist/src/{configuration-files.js → entries/configuration-files.js} +20 -58
  10. package/dist/src/{convention-rows.js → entries/convention-rows.js} +120 -27
  11. package/dist/src/entries/conventions.js +739 -0
  12. package/dist/src/{html-entries.js → entries/html-entries.js} +3 -3
  13. package/dist/src/{mdx-entries.js → entries/mdx-entries.js} +2 -2
  14. package/dist/src/entries/run-directories.js +77 -0
  15. package/dist/src/entries/sources.js +144 -0
  16. package/dist/src/entries/static-module.js +669 -0
  17. package/dist/src/entries/test-runners.js +684 -0
  18. package/dist/src/{workflow-steps.js → entries/workflow-steps.js} +18 -8
  19. package/dist/src/extensions.js +37 -0
  20. package/dist/src/facts.js +38 -0
  21. package/dist/src/findings/emitters.js +5 -8
  22. package/dist/src/findings/self-check.js +36 -20
  23. package/dist/src/findings-pass.js +5 -6
  24. package/dist/src/framework-lifecycle.js +1 -1
  25. package/dist/src/fs/manifest.js +15 -20
  26. package/dist/src/generated-file.js +172 -29
  27. package/dist/src/graph.js +2 -4
  28. package/dist/src/index.js +1 -1
  29. package/dist/src/injection-container.js +1 -1
  30. package/dist/src/inventory/commonjs.js +62 -17
  31. package/dist/src/inventory/enumerate.js +2 -1
  32. package/dist/src/javascript-file.js +26 -11
  33. package/dist/src/load/classify.js +28 -9
  34. package/dist/src/load/diagnostics.js +8 -1
  35. package/dist/src/load/discover.js +15 -7
  36. package/dist/src/load/plan.js +2 -2
  37. package/dist/src/load/synthesize.js +5 -5
  38. package/dist/src/load/workspace-manifests.js +1 -1
  39. package/dist/src/matrix.js +6 -13
  40. package/dist/src/outside-tests.js +1 -1
  41. package/dist/src/paths.js +16 -0
  42. package/dist/src/platform-calls.js +78 -0
  43. package/dist/src/platform-symbols.js +140 -0
  44. package/dist/src/references.js +202 -32
  45. package/dist/src/resolve.js +1 -1
  46. package/dist/src/{configured-declarations.js → roots/configured-declarations.js} +4 -4
  47. package/dist/src/{entry-point-gaps.js → roots/entry-point-gaps.js} +5 -8
  48. package/dist/src/{manifest.js → roots/manifest.js} +4 -4
  49. package/dist/src/roots/published-reach.js +412 -0
  50. package/dist/src/roots/root-set.js +489 -0
  51. package/dist/src/roots/unseen-loads.js +208 -0
  52. package/dist/src/serialization-contract.js +1 -1
  53. package/dist/src/source-files.js +5 -9
  54. package/dist/src/suppress.js +30 -32
  55. package/dist/src/test-support.js +4 -2
  56. package/dist/src/verbs/analyze.js +13 -1
  57. package/dist/src/verbs/describe.js +5 -3
  58. package/jsr.json +1 -1
  59. package/package.json +2 -2
  60. package/src/analysis.ts +75 -52
  61. package/src/automatic-types.ts +1 -1
  62. package/src/commands/read.ts +6 -8
  63. package/src/conformance-record.ts +1 -1
  64. package/src/consumers.ts +4 -0
  65. package/src/contract/config.generated.ts +1 -1
  66. package/src/contract/contract.generated.ts +138 -2
  67. package/src/dependencies.ts +96 -49
  68. package/src/entries/build-scripts.ts +292 -0
  69. package/src/{configuration-files.ts → entries/configuration-files.ts} +23 -75
  70. package/src/{convention-rows.ts → entries/convention-rows.ts} +167 -28
  71. package/src/{conventions.ts → entries/conventions.ts} +347 -522
  72. package/src/{html-entries.ts → entries/html-entries.ts} +5 -5
  73. package/src/{mdx-entries.ts → entries/mdx-entries.ts} +4 -4
  74. package/src/entries/run-directories.ts +108 -0
  75. package/src/entries/sources.ts +266 -0
  76. package/src/entries/static-module.ts +857 -0
  77. package/src/entries/test-runners.ts +868 -0
  78. package/src/{workflow-steps.ts → entries/workflow-steps.ts} +29 -11
  79. package/src/exempt.ts +3 -2
  80. package/src/extensions.ts +45 -0
  81. package/src/facts.ts +44 -0
  82. package/src/file-facts.ts +1 -1
  83. package/src/findings/emitters.ts +14 -10
  84. package/src/findings/self-check.ts +41 -22
  85. package/src/findings/visibility-narrowing.ts +1 -1
  86. package/src/findings-pass.ts +5 -12
  87. package/src/framework-lifecycle.ts +1 -1
  88. package/src/fs/manifest.ts +25 -21
  89. package/src/generated-file.ts +240 -36
  90. package/src/graph.ts +3 -5
  91. package/src/index.ts +1 -1
  92. package/src/injection-container.ts +1 -1
  93. package/src/inventory/commonjs.ts +102 -17
  94. package/src/inventory/enumerate.ts +2 -1
  95. package/src/javascript-file.ts +29 -12
  96. package/src/load/classify.ts +49 -13
  97. package/src/load/diagnostics.ts +11 -1
  98. package/src/load/discover.ts +27 -11
  99. package/src/load/plan.ts +11 -2
  100. package/src/load/synthesize.ts +6 -6
  101. package/src/load/test-globals.ts +1 -1
  102. package/src/load/workspace-manifests.ts +1 -1
  103. package/src/load/workspace-run.ts +1 -1
  104. package/src/matrix.ts +7 -14
  105. package/src/outside-tests.ts +1 -1
  106. package/src/paths.ts +18 -0
  107. package/src/platform-calls.ts +119 -0
  108. package/src/platform-symbols.ts +205 -0
  109. package/src/references.ts +281 -34
  110. package/src/report.ts +1 -1
  111. package/src/resolve.ts +1 -1
  112. package/src/{configured-declarations.ts → roots/configured-declarations.ts} +7 -7
  113. package/src/{entry-point-gaps.ts → roots/entry-point-gaps.ts} +5 -8
  114. package/src/{manifest.ts → roots/manifest.ts} +5 -5
  115. package/src/roots/published-reach.ts +481 -0
  116. package/src/{roots.ts → roots/root-set.ts} +203 -630
  117. package/src/roots/unseen-loads.ts +307 -0
  118. package/src/serialization-contract.ts +1 -1
  119. package/src/source-files.ts +5 -10
  120. package/src/suppress.ts +48 -33
  121. package/src/test-support.ts +8 -3
  122. package/src/verbs/analyze.ts +17 -4
  123. package/src/verbs/describe.ts +5 -2
  124. package/src/verbs/explain.ts +1 -1
  125. package/dist/src/build-scripts.js +0 -418
  126. package/dist/src/conventions.js +0 -907
  127. package/dist/src/entry-points.js +0 -444
  128. package/dist/src/own-body.js +0 -28
  129. package/dist/src/roots.js +0 -865
  130. package/dist/src/unseen-loads.js +0 -189
  131. package/src/build-scripts.ts +0 -536
  132. package/src/entry-points.ts +0 -584
  133. package/src/own-body.ts +0 -42
  134. package/src/unseen-loads.ts +0 -282
@@ -1,444 +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
- import { isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isMetaProperty, isNewExpression, isNoSubstitutionTemplateLiteral, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isStringLiteral, } from "@typescript/native/ast";
7
- import { SymbolFlags } from "@typescript/native/sync";
8
- import { configurationFiles, filesNamedBy, moduleStrings, } from "./configuration-files.js";
9
- import { buildScriptEntries } from "./build-scripts.js";
10
- import { htmlEntries } from "./html-entries.js";
11
- import { documentEntries } from "./mdx-entries.js";
12
- import { hasOwnBody } from "./own-body.js";
13
- import { dirnamePath, relativePath, resolvePath } from "./paths.js";
14
- import { UNANSWERED } from "./query.js";
15
- import { workflowEntries } from "./workflow-steps.js";
16
- import { unwrapped } from "./unwrap.js";
17
- import { globExpression } from "./text/glob.js";
18
- /** The extensions the test runner and the browser-test runner load a configuration from. */
19
- const MODULE_EXTENSIONS = ["js", "mjs", "cjs", "ts", "mts", "cts"];
20
- /** The tool file names the configuration form does not cover. */
21
- const CONVENTIONS = [
22
- {
23
- rule: "test-runner",
24
- stems: ["vitest.workspace", "vitest.projects"],
25
- extensions: MODULE_EXTENSIONS,
26
- testRunner: true,
27
- },
28
- ];
29
- /** The stem of the browser-test runner's configuration, whose test directory is read. */
30
- const BROWSER_TEST_CONFIG = "playwright.config";
31
- /** The browser-test runner's own test-file pattern, which holds where a configuration names none. */
32
- const BROWSER_TEST_MATCH = "**/*.{spec,test}.{js,ts,jsx,tsx,cjs,cts,cjsx,ctsx,mjs,mts,mjsx,mtsx}";
33
- /** The members of a test-runner configuration's `test` object that name setup files. */
34
- const SETUP_MEMBERS = ["setupFiles", "globalSetup"];
35
- /** A member that moves the directory every path of a test-runner configuration is read from. */
36
- const ROOT_MEMBER = "root";
37
- /**
38
- * A URL reference's scheme. A reference with none that does not start with a solidus is
39
- * relative, the bare name included: https://url.spec.whatwg.org/#relative-url-string
40
- */
41
- const URL_SCHEME = /^[a-z][a-z\d+.-]*:/iu;
42
- /** The constructors whose first argument addresses a worker script. */
43
- const WORKER_CONSTRUCTORS = new Set(["Worker", "SharedWorker"]);
44
- /** The file's name, the last segment of its path. */
45
- function basename(path) {
46
- return path.slice(path.lastIndexOf("/") + 1);
47
- }
48
- /** The convention one file name is, with the spelling a root reports it by. */
49
- function conventionOf(name) {
50
- for (const convention of CONVENTIONS) {
51
- for (const stem of convention.stems) {
52
- if (convention.extensions.some((ext) => name === `${stem}.${ext}`)) {
53
- return { convention, spelled: `${stem}.*` };
54
- }
55
- }
56
- }
57
- return undefined;
58
- }
59
- /** The text a string literal or a template with no substitution denotes. */
60
- function literalOf(node) {
61
- if (node !== undefined && (isStringLiteral(node) || isNoSubstitutionTemplateLiteral(node))) {
62
- return node.text;
63
- }
64
- return undefined;
65
- }
66
- /**
67
- * The object literals one configuration file's default export is written as: the
68
- * literal itself, or each literal argument of the call it is, at any depth of calls.
69
- * A default export written as anything else, a name or a computation, yields none,
70
- * because its value is not in the file's text.
71
- */
72
- function configObjects(file) {
73
- const found = [];
74
- const collect = (node) => {
75
- const at = unwrapped(node);
76
- if (isObjectLiteralExpression(at)) {
77
- found.push(at);
78
- return;
79
- }
80
- if (isCallExpression(at)) {
81
- for (const argument of at.arguments) {
82
- collect(argument);
83
- }
84
- }
85
- };
86
- for (const statement of file.statements) {
87
- if (isExportAssignment(statement) && !statement.isExportEquals) {
88
- collect(statement.expression);
89
- }
90
- }
91
- return found;
92
- }
93
- /**
94
- * The value one member of an object literal is written with, when it is written as
95
- * `name: value`, and undefined where the literal writes no such member.
96
- */
97
- function memberOf(object, name) {
98
- if (!isObjectLiteralExpression(object)) {
99
- return undefined;
100
- }
101
- for (const property of object.properties) {
102
- if (isPropertyAssignment(property) &&
103
- isIdentifier(property.name) &&
104
- property.name.text === name) {
105
- return property.initializer;
106
- }
107
- }
108
- return undefined;
109
- }
110
- /**
111
- * The strings one member holds, when it is written as a literal or an array of
112
- * literals. `undefined` is a value the text does not state.
113
- */
114
- export function literalsOf(value) {
115
- const at = unwrapped(value);
116
- const single = literalOf(at);
117
- if (single !== undefined) {
118
- return [single];
119
- }
120
- if (!isArrayLiteralExpression(at)) {
121
- return undefined;
122
- }
123
- const found = [];
124
- for (const element of at.elements) {
125
- const text = literalOf(unwrapped(element));
126
- if (text === undefined) {
127
- return undefined;
128
- }
129
- found.push(text);
130
- }
131
- return found;
132
- }
133
- /**
134
- * Whether a literal is a relative URL reference, which is also how the test runner reads a
135
- * setup file's path against its root.
136
- */
137
- function isRelative(text) {
138
- return text !== "" && !text.startsWith("/") && !URL_SCHEME.test(text);
139
- }
140
- /** A URL reference with its query and its fragment removed, which name no part of the file. */
141
- function pathPart(text) {
142
- const cut = text.search(/[?#]/u);
143
- return cut < 0 ? text : text.slice(0, cut);
144
- }
145
- /** The own files one relative literal names, read against a directory. */
146
- function filesNamed(files, dir, text) {
147
- if (!isRelative(text)) {
148
- return [];
149
- }
150
- return files.named(resolvePath(dir, pathPart(text)));
151
- }
152
- /** Whether one file name is the browser-test runner's configuration. */
153
- function isBrowserTestConfig(name) {
154
- return MODULE_EXTENSIONS.some((ext) => name === `${BROWSER_TEST_CONFIG}.${ext}`);
155
- }
156
- /**
157
- * The files the configuration files of one project enter: each configuration module,
158
- * with what it exports, and each own file a relative string of a configuration module
159
- * or a JSON configuration file names, read against that file's directory. A string at a
160
- * selection key of an applied convention row names no file.
161
- */
162
- function configurationEntries(host, targetRoot, files, parse, selected) {
163
- const { modules, documents, outside } = configurationFiles(host, targetRoot, files, parse);
164
- const found = [];
165
- const unselected = (file) => {
166
- const starts = selected.get(file.fileName)?.starts;
167
- return moduleStrings(file)
168
- .filter((one) => starts?.has(one.node.getStart()) !== true)
169
- .map((one) => one.text);
170
- };
171
- const unselectedIn = (path, texts) => {
172
- const left = [...(selected.get(path)?.texts ?? [])];
173
- return texts.filter((text) => {
174
- const at = left.indexOf(text);
175
- if (at < 0) {
176
- return true;
177
- }
178
- left.splice(at, 1);
179
- return false;
180
- });
181
- };
182
- const strings = (dir, texts) => {
183
- for (const text of texts) {
184
- for (const file of filesNamedBy(files, dir, text)) {
185
- found.push({ file, rule: "configuration-string", source: text, exports: true });
186
- }
187
- }
188
- };
189
- for (const { file, form } of modules) {
190
- found.push({ file, rule: "configuration-file", source: form, exports: true });
191
- strings(dirnamePath(file.fileName), unselected(file));
192
- }
193
- for (const document of documents) {
194
- strings(dirnamePath(document.path), unselectedIn(document.path, document.strings));
195
- }
196
- for (const { file } of outside) {
197
- strings(dirnamePath(file.fileName), unselected(file));
198
- }
199
- return found;
200
- }
201
- /**
202
- * The setup files one test-runner configuration names: every literal under
203
- * `test.setupFiles` and `test.globalSetup`, read against the configuration's own
204
- * directory. A configuration that moves its root names them against a directory its
205
- * text may not state, so none is read from it.
206
- */
207
- function setupFilesOf(file, files) {
208
- const objects = configObjects(file);
209
- const tests = objects
210
- .map((object) => memberOf(object, "test"))
211
- .filter((value) => value !== undefined)
212
- .map(unwrapped);
213
- if ([...objects, ...tests].some((object) => memberOf(object, ROOT_MEMBER) !== undefined)) {
214
- return [];
215
- }
216
- const dir = dirnamePath(file.fileName);
217
- const found = [];
218
- for (const test of tests) {
219
- for (const name of SETUP_MEMBERS) {
220
- const value = memberOf(test, name);
221
- for (const text of value === undefined ? [] : (literalsOf(value) ?? [])) {
222
- for (const named of filesNamed(files, dir, text)) {
223
- found.push({ file: named, rule: "test-runner", source: text, exports: false });
224
- }
225
- }
226
- }
227
- }
228
- return found;
229
- }
230
- /**
231
- * The test files one browser-test configuration names: every own file below its
232
- * test directory that its test-file pattern matches. The directory is the literal
233
- * `testDir` reads against the configuration's directory, or that directory where no
234
- * object of the configuration writes one; the pattern is the literal `testMatch`, or
235
- * the runner's own where none is written. A member whose value is not a literal
236
- * leaves the set unknown, and an unknown set enters nothing.
237
- */
238
- function browserTestsOf(file, files) {
239
- const objects = configObjects(file);
240
- if (objects.length === 0) {
241
- return [];
242
- }
243
- let testDir = ".";
244
- let patterns = [BROWSER_TEST_MATCH];
245
- for (const object of objects) {
246
- const dir = memberOf(object, "testDir");
247
- if (dir !== undefined) {
248
- testDir = literalOf(unwrapped(dir));
249
- }
250
- const match = memberOf(object, "testMatch");
251
- if (match !== undefined) {
252
- patterns = literalsOf(match);
253
- }
254
- }
255
- if (testDir === undefined || patterns === undefined) {
256
- return [];
257
- }
258
- const under = resolvePath(dirnamePath(file.fileName), testDir);
259
- const found = [];
260
- for (const pattern of patterns) {
261
- const expression = globExpression(pattern);
262
- for (const candidate of files.byName.values()) {
263
- const below = relativePath(under, candidate.fileName);
264
- if (below !== undefined && expression.test(below)) {
265
- found.push({ file: candidate, rule: "browser-tests", source: pattern, exports: false });
266
- }
267
- }
268
- }
269
- return found;
270
- }
271
- /**
272
- * The address one worker argument writes: a relative literal, or a `URL` built from
273
- * a literal against `import.meta.url`. Any other argument is computed and addresses
274
- * nothing the text states.
275
- */
276
- function workerAddress(argument) {
277
- if (argument === undefined) {
278
- return undefined;
279
- }
280
- const at = unwrapped(argument);
281
- const literal = literalOf(at);
282
- if (literal !== undefined) {
283
- return { literal, url: undefined };
284
- }
285
- if (!isNewExpression(at) || !isIdentifier(at.expression) || at.expression.text !== "URL") {
286
- return undefined;
287
- }
288
- const [reference, base] = at.arguments ?? [];
289
- const text = literalOf(reference === undefined ? undefined : unwrapped(reference));
290
- if (text === undefined || base === undefined) {
291
- return undefined;
292
- }
293
- const meta = unwrapped(base);
294
- if (!isPropertyAccessExpression(meta) ||
295
- !isMetaProperty(meta.expression) ||
296
- !isIdentifier(meta.name) ||
297
- meta.name.text !== "url") {
298
- return undefined;
299
- }
300
- return { literal: text, url: at.expression };
301
- }
302
- /**
303
- * Every call one file writes that addresses a worker: `new Worker(...)`,
304
- * `new SharedWorker(...)` and `navigator.serviceWorker.register(...)`, each with an
305
- * address its text states.
306
- */
307
- function workerSitesOf(file) {
308
- const found = [];
309
- const visit = (node) => {
310
- if (isNewExpression(node) &&
311
- isIdentifier(node.expression) &&
312
- WORKER_CONSTRUCTORS.has(node.expression.text)) {
313
- const address = workerAddress(node.arguments?.[0]);
314
- if (address !== undefined) {
315
- found.push({
316
- literal: address.literal,
317
- platformNames: [node.expression],
318
- url: address.url,
319
- });
320
- }
321
- }
322
- if (isCallExpression(node)) {
323
- const callee = node.expression;
324
- if (isPropertyAccessExpression(callee) &&
325
- isIdentifier(callee.name) &&
326
- callee.name.text === "register" &&
327
- isPropertyAccessExpression(callee.expression) &&
328
- isIdentifier(callee.expression.name) &&
329
- callee.expression.name.text === "serviceWorker" &&
330
- isIdentifier(callee.expression.expression) &&
331
- callee.expression.expression.text === "navigator") {
332
- const address = workerAddress(node.arguments[0]);
333
- if (address !== undefined) {
334
- found.push({
335
- literal: address.literal,
336
- platformNames: [callee.expression.expression],
337
- url: address.url,
338
- });
339
- }
340
- }
341
- }
342
- node.forEachChild(visit);
343
- };
344
- file.forEachChild(visit);
345
- return found;
346
- }
347
- /**
348
- * The workers one file addresses. A call's `Worker`, `SharedWorker` or `navigator` must
349
- * resolve to a symbol the platform declares, which a file of the target may augment and no
350
- * import brings in; a name only the target declares is the target's own constructor or
351
- * object, which addresses no worker this rule knows. One batch per file that writes such a call.
352
- */
353
- function workersOf(project, file, files) {
354
- const sites = workerSitesOf(file);
355
- if (sites.length === 0) {
356
- return [];
357
- }
358
- const names = sites.flatMap((site) => site.platformNames);
359
- const urls = sites.flatMap((site) => site.url ?? []);
360
- const symbols = project.symbolsAt([...names, ...urls].map((name) => project.handle(name)));
361
- const platform = new Set();
362
- // A name the checker could not resolve is read as the platform's, so a worker it
363
- // stands on is rooted rather than reported.
364
- names.forEach((name, index) => {
365
- const symbol = symbols[index];
366
- if (symbol === UNANSWERED) {
367
- platform.add(name);
368
- return;
369
- }
370
- if (symbol !== undefined &&
371
- (symbol.flags & SymbolFlags.Alias) === 0 &&
372
- symbol.declarations.some((handle) => !files.byName.has(handle.path))) {
373
- platform.add(name);
374
- }
375
- });
376
- urls.forEach((url, index) => {
377
- const symbol = symbols[names.length + index];
378
- if (typeof symbol !== "object" || !hasOwnBody(project, symbol)) {
379
- platform.add(url);
380
- }
381
- });
382
- const dir = dirnamePath(file.fileName);
383
- const found = [];
384
- for (const site of sites) {
385
- if (!site.platformNames.every((name) => platform.has(name)) ||
386
- (site.url !== undefined && !platform.has(site.url))) {
387
- continue;
388
- }
389
- for (const named of filesNamed(files, dir, site.literal)) {
390
- found.push({ file: named, rule: "worker", source: site.literal, exports: false });
391
- }
392
- }
393
- return found;
394
- }
395
- /**
396
- * Every file of one project the rules enter, in no particular order and possibly more
397
- * than once: a file two rules enter appears once per rule.
398
- *
399
- * `testFiles` is the configuration's test-file patterns, matched against each
400
- * file's path below the target root; a file one of them matches is a test file the
401
- * runner executes.
402
- */
403
- export function entryPoints(project, files, testFiles, host, targetRoot, parse, selected = new Map()) {
404
- const found = [...configurationEntries(host, targetRoot, files, parse, selected)];
405
- const tests = testFiles.map((pattern) => ({ pattern, expression: globExpression(pattern) }));
406
- for (const [path, file] of files.byPath) {
407
- const name = basename(path);
408
- const named = conventionOf(name);
409
- if (named !== undefined) {
410
- found.push({ file, rule: named.convention.rule, source: named.spelled, exports: true });
411
- if (named.convention.testRunner) {
412
- found.push(...setupFilesOf(file, files));
413
- }
414
- }
415
- if (isBrowserTestConfig(name)) {
416
- found.push(...browserTestsOf(file, files));
417
- }
418
- for (const { pattern, expression } of tests) {
419
- if (expression.test(path)) {
420
- found.push({ file, rule: "test-runner", source: pattern, exports: false });
421
- }
422
- }
423
- found.push(...workersOf(project, file, files));
424
- }
425
- for (const { file, source } of htmlEntries(host, targetRoot, files, parse)) {
426
- found.push({ file, rule: "html-entry", source, exports: true });
427
- }
428
- for (const { file, source, names } of documentEntries(host, targetRoot, files)) {
429
- found.push({
430
- file,
431
- rule: "document-import",
432
- source,
433
- exports: true,
434
- ...(names === undefined ? {} : { names }),
435
- });
436
- }
437
- for (const { file, source } of buildScriptEntries(host, targetRoot, files, parse)) {
438
- found.push({ file, rule: "bundler-entry", source, exports: true });
439
- }
440
- for (const { file, source } of workflowEntries(host, targetRoot, files)) {
441
- found.push({ file, rule: "workflow-step", source, exports: true });
442
- }
443
- return found;
444
- }
@@ -1,28 +0,0 @@
1
- import { isArrowFunction, isClassDeclaration, isClassExpression, isFunctionDeclaration, isFunctionExpression, isVariableDeclaration, } from "@typescript/native/ast";
2
- import { SymbolFlags } from "@typescript/native/sync";
3
- import { isAmbient } from "./inventory.js";
4
- import { unwrapped } from "./unwrap.js";
5
- /**
6
- * Whether `symbol`, through its aliases, names a function or class the target writes with a
7
- * body, which a call or construction runs in place of the platform's `require` or `URL`. Any
8
- * other answer, an unresolved one included, is the platform's, whose call loads a file.
9
- */
10
- export function hasOwnBody(project, symbol) {
11
- const named = (symbol.flags & SymbolFlags.Alias) === 0 ? symbol : project.queries.aliased(symbol);
12
- const own = project.ownPaths();
13
- return (typeof named === "object" &&
14
- named.declarations.some((handle) => {
15
- const node = own.has(handle.path) ? project.declarationAt(handle)?.node : undefined;
16
- const value = node !== undefined && isVariableDeclaration(node) && node.initializer !== undefined
17
- ? unwrapped(node.initializer)
18
- : node;
19
- return (value !== undefined &&
20
- (isFunctionDeclaration(value)
21
- ? value.body !== undefined
22
- : isFunctionExpression(value) ||
23
- isArrowFunction(value) ||
24
- isClassDeclaration(value) ||
25
- isClassExpression(value)) &&
26
- !isAmbient(value.getSourceFile(), value));
27
- }));
28
- }