@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/dependencies.ts
CHANGED
|
@@ -29,24 +29,26 @@ import {
|
|
|
29
29
|
type Node,
|
|
30
30
|
type SourceFile,
|
|
31
31
|
} from "@typescript/native/ast";
|
|
32
|
+
import { amdLoadOf, amdPlatform } from "./amd.ts";
|
|
32
33
|
import { automaticTypes, type AutomaticTypes } from "./automatic-types.ts";
|
|
33
34
|
import {
|
|
34
|
-
configurationFiles,
|
|
35
35
|
declaredIn as declaredBeside,
|
|
36
36
|
dependenciesNamed,
|
|
37
37
|
moduleStrings,
|
|
38
38
|
outsideChain,
|
|
39
|
+
type ConfigurationFiles,
|
|
39
40
|
type OutsideModule,
|
|
40
41
|
type ParseFile,
|
|
41
|
-
} from "./configuration-files.ts";
|
|
42
|
+
} from "./entries/configuration-files.ts";
|
|
42
43
|
import type { FindingPosition } from "./finding.ts";
|
|
43
44
|
import type { Host } from "./host.ts";
|
|
45
|
+
import { declarationBindings } from "./import-bindings.ts";
|
|
44
46
|
import { nodeKey, type Inventory } from "./inventory.ts";
|
|
45
47
|
import { packageScope } from "./load/package-scope.ts";
|
|
46
48
|
import {
|
|
47
49
|
ancestors,
|
|
50
|
+
cannotStartPackageName,
|
|
48
51
|
dirnamePath,
|
|
49
|
-
isAbsolutePath,
|
|
50
52
|
joinPath,
|
|
51
53
|
relativePath,
|
|
52
54
|
resolvePath,
|
|
@@ -55,8 +57,11 @@ import type { DependencySection, Module } from "./ref.ts";
|
|
|
55
57
|
import { UNANSWERED } from "./query.ts";
|
|
56
58
|
import type { Handle, ProjectView } from "./session.ts";
|
|
57
59
|
import { sourceFilesOf, type SourceFiles } from "./source-files.ts";
|
|
58
|
-
import { manifestCommands, nodemonTexts } from "./manifest.ts";
|
|
59
|
-
import {
|
|
60
|
+
import { manifestCommands, nodemonTexts } from "./roots/manifest.ts";
|
|
61
|
+
import { writtenName } from "./platform-calls.ts";
|
|
62
|
+
import { callsPlatform } from "./platform-symbols.ts";
|
|
63
|
+
import { parenthesesRemoved } from "./unwrap.ts";
|
|
64
|
+
import type { Workflows } from "./entries/workflow-steps.ts";
|
|
60
65
|
import {
|
|
61
66
|
pathsNamed,
|
|
62
67
|
preloadedPackages,
|
|
@@ -299,7 +304,7 @@ function configurationPackages(
|
|
|
299
304
|
}
|
|
300
305
|
seen.add(file);
|
|
301
306
|
for (const entry of extendsOf(host, file, parse)) {
|
|
302
|
-
if (
|
|
307
|
+
if (cannotStartPackageName(entry)) {
|
|
303
308
|
const local = resolvePath(dirnamePath(file), entry);
|
|
304
309
|
pending.push(local.endsWith(".json") ? local : `${local}.json`);
|
|
305
310
|
} else {
|
|
@@ -329,34 +334,18 @@ function importOf(specifier: Node): Node | undefined {
|
|
|
329
334
|
|
|
330
335
|
/** The local names one import declaration binds. */
|
|
331
336
|
function bindingsOf(node: Node | undefined): readonly Texted[] {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (isImportEqualsDeclaration(node)) {
|
|
336
|
-
return [node.name];
|
|
337
|
-
}
|
|
338
|
-
if (!isImportDeclaration(node) || node.importClause === undefined) {
|
|
339
|
-
return [];
|
|
340
|
-
}
|
|
341
|
-
const clause = node.importClause;
|
|
342
|
-
const names: Texted[] = clause.name === undefined ? [] : [clause.name];
|
|
343
|
-
const bindings = clause.namedBindings;
|
|
344
|
-
if (bindings !== undefined) {
|
|
345
|
-
if (bindings.kind === SyntaxKind.NamespaceImport) {
|
|
346
|
-
names.push(bindings.name);
|
|
347
|
-
} else {
|
|
348
|
-
names.push(...bindings.elements.map((element) => element.name));
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
return names;
|
|
337
|
+
return node !== undefined && (isImportDeclaration(node) || isImportEqualsDeclaration(node))
|
|
338
|
+
? declarationBindings(node).map((binding) => binding.name)
|
|
339
|
+
: [];
|
|
352
340
|
}
|
|
353
341
|
|
|
354
342
|
/**
|
|
355
343
|
* Every package one project needs, and which declaration each use is written in.
|
|
356
344
|
* One local walk and one batched resolution per file: a use of an import binding is
|
|
357
345
|
* an identifier resolving to the binding's own symbol, so a local declaration that
|
|
358
|
-
* shadows the name is not one. A string of a configuration file
|
|
359
|
-
* the manifest beside the file
|
|
346
|
+
* shadows the name is not one. A string of a configuration file, as the entry sources
|
|
347
|
+
* read them in `configuration`, uses each dependency the manifest beside the file
|
|
348
|
+
* declares that it spells.
|
|
360
349
|
*/
|
|
361
350
|
export function projectNeeds<Brand>(
|
|
362
351
|
project: ProjectView<Brand>,
|
|
@@ -364,6 +353,8 @@ export function projectNeeds<Brand>(
|
|
|
364
353
|
host: Host,
|
|
365
354
|
targetRoot: string,
|
|
366
355
|
parse: ParseFile,
|
|
356
|
+
configuration: ConfigurationFiles,
|
|
357
|
+
workflows: Workflows,
|
|
367
358
|
): ProjectNeeds {
|
|
368
359
|
const programPackages = new Set<string>();
|
|
369
360
|
for (const name of project.program.getSourceFileNames()) {
|
|
@@ -417,7 +408,6 @@ export function projectNeeds<Brand>(
|
|
|
417
408
|
return names;
|
|
418
409
|
};
|
|
419
410
|
const files = sourceFilesOf(project, targetRoot);
|
|
420
|
-
const configuration = configurationFiles(host, targetRoot, files, parse);
|
|
421
411
|
for (const { file, manifestDir } of configuration.modules) {
|
|
422
412
|
const names = declaredAt(joinPath(manifestDir, MANIFEST));
|
|
423
413
|
for (const { node, text } of moduleStrings(file)) {
|
|
@@ -437,7 +427,7 @@ export function projectNeeds<Brand>(
|
|
|
437
427
|
targetRoot,
|
|
438
428
|
files,
|
|
439
429
|
parse,
|
|
440
|
-
scriptRunFiles(host, targetRoot, files),
|
|
430
|
+
scriptRunFiles(host, targetRoot, files, workflows),
|
|
441
431
|
);
|
|
442
432
|
for (const { file, manifestDirs } of [...configuration.outside, ...ranFiles]) {
|
|
443
433
|
for (const manifestDir of manifestDirs) {
|
|
@@ -460,6 +450,7 @@ function scriptRunFiles(
|
|
|
460
450
|
host: Host,
|
|
461
451
|
targetRoot: string,
|
|
462
452
|
files: SourceFiles,
|
|
453
|
+
workflows: Workflows,
|
|
463
454
|
): readonly { readonly path: string; readonly manifestDir: string }[] {
|
|
464
455
|
const root = resolvePath(host.workingDirectory(), targetRoot);
|
|
465
456
|
const dirs = new Set<string>([root]);
|
|
@@ -472,12 +463,7 @@ function scriptRunFiles(
|
|
|
472
463
|
}
|
|
473
464
|
}
|
|
474
465
|
const named = new Map<string, readonly string[]>([
|
|
475
|
-
[
|
|
476
|
-
root,
|
|
477
|
-
workflowReadings(host, root)
|
|
478
|
-
.flatMap(pathsNamed)
|
|
479
|
-
.map((one) => one.path),
|
|
480
|
-
],
|
|
466
|
+
[root, workflows.readings.flatMap(pathsNamed).map((one) => one.path)],
|
|
481
467
|
]);
|
|
482
468
|
for (const dir of dirs) {
|
|
483
469
|
const read = readDocument(host, joinPath(dir, MANIFEST));
|
|
@@ -522,20 +508,9 @@ function manifestUses(host: Host, dir: string, manifest: Record<string, unknown>
|
|
|
522
508
|
}
|
|
523
509
|
|
|
524
510
|
/** What the target root's workflow steps, git hooks and recipes use, held with their files' whole text. */
|
|
525
|
-
function workflowUses(
|
|
526
|
-
const uses = usesOf(
|
|
527
|
-
return { ...uses, held: [uses.held, ...
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* What the target root's workflow steps, git hooks, hook managers and recipes run, each held
|
|
532
|
-
* with the directory the file writes for it.
|
|
533
|
-
*/
|
|
534
|
-
function workflowReadings(host: Host, targetRoot: string): readonly CommandReading[] {
|
|
535
|
-
return workflowCommands(host, targetRoot).map(({ text, dir, writtenDirectory }) => {
|
|
536
|
-
const reading = readCommands(text, dir);
|
|
537
|
-
return { ...reading, held: [reading.held, writtenDirectory ?? ""].join("\n") };
|
|
538
|
-
});
|
|
511
|
+
function workflowUses(workflows: Workflows): CommandUses {
|
|
512
|
+
const uses = usesOf(workflows.readings);
|
|
513
|
+
return { ...uses, held: [uses.held, ...workflows.texts].join("\n") };
|
|
539
514
|
}
|
|
540
515
|
|
|
541
516
|
/** What some command strings say about the packages they use. */
|
|
@@ -661,8 +636,17 @@ function fileNeeds<Brand>(
|
|
|
661
636
|
if (names.size > 0 || automatic.globals.size > 0) {
|
|
662
637
|
visit(file);
|
|
663
638
|
}
|
|
639
|
+
const loads = runtimeLoads(file);
|
|
640
|
+
const callees = loads.flatMap((load) => load.callees);
|
|
641
|
+
const amdCallees = new Set(loads.flatMap((load) => (load.amd ? load.callees : [])));
|
|
664
642
|
|
|
665
|
-
const asked = [
|
|
643
|
+
const asked = [
|
|
644
|
+
...specifiers,
|
|
645
|
+
...bindings.map(({ node }) => node),
|
|
646
|
+
...candidates,
|
|
647
|
+
...globals,
|
|
648
|
+
...callees,
|
|
649
|
+
];
|
|
666
650
|
const handles: Handle<Brand>[] = asked.map((node) => project.handle(node));
|
|
667
651
|
const resolved = project.symbolsAt(handles);
|
|
668
652
|
|
|
@@ -738,35 +722,96 @@ function fileNeeds<Brand>(
|
|
|
738
722
|
for (const reference of file.typeReferenceDirectives) {
|
|
739
723
|
use(ownersOf(file, held, file), typePackages(reference.fileName, programPackages));
|
|
740
724
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
725
|
+
// A callee the checker leaves unanswered may be a require, so its call holds the
|
|
726
|
+
// dependency it names by live code, as program.33 holds one.
|
|
727
|
+
const calleesAt = unresolvedAt + globals.length;
|
|
728
|
+
const decided = new Map<string, boolean>();
|
|
729
|
+
const requires = new Set<Identifier>();
|
|
730
|
+
const unansweredCallees = new Set<Identifier>();
|
|
731
|
+
callees.forEach((callee, index) => {
|
|
732
|
+
const symbol = resolved[calleesAt + index];
|
|
733
|
+
if (symbol === UNANSWERED) {
|
|
734
|
+
unansweredCallees.add(callee);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
// The decision reads the callee's symbol, its written name and its platform name, and nothing else.
|
|
738
|
+
const platform = amdCallees.has(callee) ? amdPlatform(callee) : "require";
|
|
739
|
+
const key =
|
|
740
|
+
symbol === undefined ? undefined : `${symbol.id}\u0000${platform}\u0000${callee.text}`;
|
|
741
|
+
const answer =
|
|
742
|
+
(key === undefined ? undefined : decided.get(key)) ??
|
|
743
|
+
callsPlatform(project, platform, callee, symbol);
|
|
744
|
+
if (key !== undefined) {
|
|
745
|
+
decided.set(key, answer);
|
|
746
|
+
}
|
|
747
|
+
if (answer) {
|
|
748
|
+
requires.add(callee);
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
for (const { specifier, named, callees: through } of loads) {
|
|
752
|
+
if (through.length === 0 || through.some((one) => requires.has(one))) {
|
|
744
753
|
use(ownersOf(file, held, specifier), [named]);
|
|
754
|
+
} else if (through.some((one) => unansweredCallees.has(one))) {
|
|
755
|
+
use([PROJECT_OWNER], [named]);
|
|
745
756
|
}
|
|
746
757
|
}
|
|
747
758
|
return resolved.slice(0, specifiers.length).includes(UNANSWERED);
|
|
748
759
|
}
|
|
749
760
|
|
|
750
761
|
/**
|
|
751
|
-
*
|
|
752
|
-
*
|
|
762
|
+
* A call of one file that may load or resolve a package at run time: the literal specifier
|
|
763
|
+
* naming it, and the names a `require` would be written with, of which one has to be a
|
|
764
|
+
* `require` for the call to need the package; none for a use where it stands.
|
|
753
765
|
*/
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
766
|
+
interface RuntimeLoad {
|
|
767
|
+
readonly specifier: Texted;
|
|
768
|
+
readonly named: string;
|
|
769
|
+
readonly callees: readonly Identifier[];
|
|
770
|
+
/** Whether the specifier is an id of an AMD call's dependency list, its callee AMD's `define` or `require`. */
|
|
771
|
+
readonly amd: boolean;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* The calls one file may load or resolve a package with at run time, each of whose first
|
|
776
|
+
* argument is literal text naming a package: a `require()` call, which the compiler lists among
|
|
777
|
+
* a file's imports only in a JavaScript file and only through the bare name; a `.resolve` of
|
|
778
|
+
* another name, which needs it where that name is a `require`; and `import.meta.resolve` or
|
|
779
|
+
* a `.resolve` of the name `require`, whatever it names, a use where it stands; and each id of
|
|
780
|
+
* an AMD dependency list (references-ts.37), which needs it where the call is AMD's.
|
|
781
|
+
*/
|
|
782
|
+
function runtimeLoads(file: SourceFile): readonly RuntimeLoad[] {
|
|
783
|
+
const found: RuntimeLoad[] = [];
|
|
759
784
|
const visit = (node: Node): void => {
|
|
760
|
-
|
|
761
|
-
|
|
785
|
+
const amd = amdLoadOf(node);
|
|
786
|
+
if (amd !== undefined) {
|
|
787
|
+
for (const { id } of amd.ids) {
|
|
788
|
+
const named = packageOfSpecifier(id.text);
|
|
789
|
+
if (named !== undefined) {
|
|
790
|
+
found.push({ specifier: id, named, callees: [amd.callee], amd: true });
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
} else if (isCallExpression(node)) {
|
|
762
794
|
const [argument] = node.arguments;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
callee
|
|
766
|
-
|
|
767
|
-
(
|
|
768
|
-
|
|
769
|
-
|
|
795
|
+
if (argument !== undefined && isLiteralText(argument)) {
|
|
796
|
+
const named = packageOfSpecifier(argument.text);
|
|
797
|
+
const callee = parenthesesRemoved(node.expression);
|
|
798
|
+
const receiver =
|
|
799
|
+
isPropertyAccessExpression(callee) && callee.name.text === "resolve"
|
|
800
|
+
? parenthesesRemoved(callee.expression)
|
|
801
|
+
: undefined;
|
|
802
|
+
const stands =
|
|
803
|
+
receiver !== undefined &&
|
|
804
|
+
((isMetaProperty(receiver) && receiver.name.text === "meta") ||
|
|
805
|
+
(isIdentifier(receiver) && receiver.text === "require"));
|
|
806
|
+
const callees = stands
|
|
807
|
+
? []
|
|
808
|
+
: [
|
|
809
|
+
writtenName(callee),
|
|
810
|
+
receiver === undefined ? undefined : writtenName(receiver),
|
|
811
|
+
].filter((one) => one !== undefined);
|
|
812
|
+
if (named !== undefined && (stands || callees.length > 0)) {
|
|
813
|
+
found.push({ specifier: argument, named, callees, amd: false });
|
|
814
|
+
}
|
|
770
815
|
}
|
|
771
816
|
}
|
|
772
817
|
node.forEachChild(visit);
|
|
@@ -989,6 +1034,7 @@ function addNeededPeers(
|
|
|
989
1034
|
export function dependenciesOf(
|
|
990
1035
|
host: Host,
|
|
991
1036
|
targetRoot: string,
|
|
1037
|
+
workflows: Workflows,
|
|
992
1038
|
perProject: readonly ProjectNeeds[],
|
|
993
1039
|
candidates: readonly string[],
|
|
994
1040
|
members: readonly string[] = [],
|
|
@@ -1011,7 +1057,7 @@ export function dependenciesOf(
|
|
|
1011
1057
|
unbuilt.add(path);
|
|
1012
1058
|
}
|
|
1013
1059
|
}
|
|
1014
|
-
const workflow = workflowUses(
|
|
1060
|
+
const workflow = workflowUses(workflows);
|
|
1015
1061
|
const declared: DeclaredDependency[] = [];
|
|
1016
1062
|
const ran = new Set<string>();
|
|
1017
1063
|
const peers = new Map<string, readonly string[]>();
|
package/src/destructuring.ts
CHANGED
|
@@ -213,17 +213,6 @@ function sourceOf(target: Node): Source | undefined {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
/** What resolving one project's property reads cost at the client boundary. */
|
|
217
|
-
interface DestructuringCost {
|
|
218
|
-
/** Batched type lookups, one per capped run of a file's patterns and assigned values. */
|
|
219
|
-
readonly patternBatches: number;
|
|
220
|
-
/**
|
|
221
|
-
* Per-type lookups: one property table per distinct destructured type, and each step
|
|
222
|
-
* an assignment target takes into its assigned value.
|
|
223
|
-
*/
|
|
224
|
-
readonly patternLookups: number;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
216
|
/** Resolves property reads to the symbols the destructured values' types declare. */
|
|
228
217
|
interface Destructuring {
|
|
229
218
|
/**
|
|
@@ -232,7 +221,6 @@ interface Destructuring {
|
|
|
232
221
|
* {@link UNANSWERED} where a question about the value's type went unanswered.
|
|
233
222
|
*/
|
|
234
223
|
resolve(reads: readonly PropertyRead[]): readonly Answer<TSSymbol | undefined>[];
|
|
235
|
-
readonly cost: DestructuringCost;
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/** A type along a destructuring, or the mark that a question about it went unanswered. */
|
|
@@ -250,8 +238,6 @@ export function destructuring<Brand>(
|
|
|
250
238
|
): Destructuring {
|
|
251
239
|
const queries = project.queries;
|
|
252
240
|
const tables = new Map<number, Answer<ReadonlyMap<string, TSSymbol>>>();
|
|
253
|
-
let patternBatches = 0;
|
|
254
|
-
let patternLookups = 0;
|
|
255
241
|
|
|
256
242
|
const tableOf = (type: Type): Answer<ReadonlyMap<string, TSSymbol>> => {
|
|
257
243
|
const known = tables.get(type.id);
|
|
@@ -261,7 +247,6 @@ export function destructuring<Brand>(
|
|
|
261
247
|
let table: Answer<ReadonlyMap<string, TSSymbol>> = new Map<string, TSSymbol>();
|
|
262
248
|
if ((type.flags & TypeFlags.AnyOrUnknown) === 0) {
|
|
263
249
|
const read = properties.of(type);
|
|
264
|
-
patternLookups += read.asked ? 1 : 0;
|
|
265
250
|
table = isAnswered(read.properties)
|
|
266
251
|
? new Map(read.properties.map((property) => [property.name, property]))
|
|
267
252
|
: UNANSWERED;
|
|
@@ -274,7 +259,6 @@ export function destructuring<Brand>(
|
|
|
274
259
|
if ((type.flags & TypeFlags.Union) === 0) {
|
|
275
260
|
return type;
|
|
276
261
|
}
|
|
277
|
-
patternLookups += 1;
|
|
278
262
|
return queries.nonNullable(type);
|
|
279
263
|
};
|
|
280
264
|
|
|
@@ -290,11 +274,9 @@ export function destructuring<Brand>(
|
|
|
290
274
|
if (index === undefined) {
|
|
291
275
|
return undefined;
|
|
292
276
|
}
|
|
293
|
-
patternLookups += 1;
|
|
294
277
|
const elements = queries.typeArguments(type);
|
|
295
278
|
return isAnswered(elements) ? elements[index] : UNANSWERED;
|
|
296
279
|
}
|
|
297
|
-
patternLookups += 1;
|
|
298
280
|
const array = queries.isArray(type);
|
|
299
281
|
if (!isAnswered(array)) {
|
|
300
282
|
return UNANSWERED;
|
|
@@ -302,7 +284,6 @@ export function destructuring<Brand>(
|
|
|
302
284
|
if (!array) {
|
|
303
285
|
return undefined;
|
|
304
286
|
}
|
|
305
|
-
patternLookups += 1;
|
|
306
287
|
const elements = queries.typeArguments(type);
|
|
307
288
|
return isAnswered(elements) ? elements[0] : UNANSWERED;
|
|
308
289
|
};
|
|
@@ -320,7 +301,6 @@ export function destructuring<Brand>(
|
|
|
320
301
|
if (more.length > 0) {
|
|
321
302
|
return UNANSWERED;
|
|
322
303
|
}
|
|
323
|
-
patternLookups += 1;
|
|
324
304
|
return queries.typeOfSymbol(property);
|
|
325
305
|
};
|
|
326
306
|
|
|
@@ -328,7 +308,6 @@ export function destructuring<Brand>(
|
|
|
328
308
|
if (callee === undefined || callee === UNANSWERED) {
|
|
329
309
|
return callee;
|
|
330
310
|
}
|
|
331
|
-
patternLookups += 1;
|
|
332
311
|
const signatures = queries.signaturesOf(callee, SignatureKind.Call);
|
|
333
312
|
if (!isAnswered(signatures)) {
|
|
334
313
|
return UNANSWERED;
|
|
@@ -337,7 +316,6 @@ export function destructuring<Brand>(
|
|
|
337
316
|
if (signature === undefined) {
|
|
338
317
|
return undefined;
|
|
339
318
|
}
|
|
340
|
-
patternLookups += 1;
|
|
341
319
|
return queries.returnTypeOf(signature);
|
|
342
320
|
};
|
|
343
321
|
|
|
@@ -369,7 +347,6 @@ export function destructuring<Brand>(
|
|
|
369
347
|
if (result !== undefined && result !== UNANSWERED) {
|
|
370
348
|
let parts: Answer<readonly Type[]> = [result];
|
|
371
349
|
if (result.isUnionType()) {
|
|
372
|
-
patternLookups += 1;
|
|
373
350
|
parts = queries.constituents(result);
|
|
374
351
|
}
|
|
375
352
|
const values: readonly Found[] = isAnswered(parts)
|
|
@@ -403,7 +380,6 @@ export function destructuring<Brand>(
|
|
|
403
380
|
if (property === undefined) {
|
|
404
381
|
return undefined;
|
|
405
382
|
}
|
|
406
|
-
patternLookups += 1;
|
|
407
383
|
return queries.typeOfSymbol(property);
|
|
408
384
|
}
|
|
409
385
|
return elementOf(defined, next.index);
|
|
@@ -425,7 +401,6 @@ export function destructuring<Brand>(
|
|
|
425
401
|
}
|
|
426
402
|
}
|
|
427
403
|
const asked = [...asking];
|
|
428
|
-
patternBatches += Math.ceil(asked.length / cap);
|
|
429
404
|
const answered = new Map<Node, Found>();
|
|
430
405
|
queries.typesAt(asked, cap).forEach((type, index) => {
|
|
431
406
|
const node = asked[index];
|
|
@@ -456,10 +431,5 @@ export function destructuring<Brand>(
|
|
|
456
431
|
});
|
|
457
432
|
};
|
|
458
433
|
|
|
459
|
-
return {
|
|
460
|
-
resolve,
|
|
461
|
-
get cost() {
|
|
462
|
-
return { patternBatches, patternLookups };
|
|
463
|
-
},
|
|
464
|
-
};
|
|
434
|
+
return { resolve };
|
|
465
435
|
}
|