zedbee 0.1.0-beta.20 → 0.1.0-beta.21
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/cache/key.d.ts.map +1 -1
- package/dist/cache/key.js +2 -19
- package/dist/cache/key.js.map +1 -1
- package/dist/checks/applicability.d.ts.map +1 -1
- package/dist/checks/applicability.js +45 -40
- package/dist/checks/applicability.js.map +1 -1
- package/dist/checks/compiler-change-inputs.d.ts +1 -4
- package/dist/checks/compiler-change-inputs.d.ts.map +1 -1
- package/dist/checks/compiler-change-inputs.js +5 -40
- package/dist/checks/compiler-change-inputs.js.map +1 -1
- package/dist/checks/compiler-decision-cache.d.ts +3 -0
- package/dist/checks/compiler-decision-cache.d.ts.map +1 -0
- package/dist/checks/compiler-decision-cache.js +29 -0
- package/dist/checks/compiler-decision-cache.js.map +1 -0
- package/dist/checks/compiler-inputs.d.ts.map +1 -1
- package/dist/checks/compiler-inputs.js +11 -52
- package/dist/checks/compiler-inputs.js.map +1 -1
- package/dist/checks/compiler-paths.d.ts +7 -0
- package/dist/checks/compiler-paths.d.ts.map +1 -0
- package/dist/checks/compiler-paths.js +14 -0
- package/dist/checks/compiler-paths.js.map +1 -0
- package/dist/checks/complexity/adapter.d.ts.map +1 -1
- package/dist/checks/complexity/adapter.js +2 -4
- package/dist/checks/complexity/adapter.js.map +1 -1
- package/dist/checks/dead-code/adapter.d.ts.map +1 -1
- package/dist/checks/dead-code/adapter.js +2 -4
- package/dist/checks/dead-code/adapter.js.map +1 -1
- package/dist/checks/dead-code/import-boundary.d.ts.map +1 -1
- package/dist/checks/dead-code/import-boundary.js +4 -15
- package/dist/checks/dead-code/import-boundary.js.map +1 -1
- package/dist/checks/dead-code/package-metadata.d.ts +1 -1
- package/dist/checks/dead-code/package-metadata.d.ts.map +1 -1
- package/dist/checks/dead-code/package-metadata.js.map +1 -1
- package/dist/checks/dependency-architecture/adapter.d.ts.map +1 -1
- package/dist/checks/dependency-architecture/adapter.js +5 -20
- package/dist/checks/dependency-architecture/adapter.js.map +1 -1
- package/dist/checks/diagnostic-details.d.ts.map +1 -1
- package/dist/checks/diagnostic-details.js +8 -35
- package/dist/checks/diagnostic-details.js.map +1 -1
- package/dist/checks/diagnostic-secret-review.d.ts +3 -0
- package/dist/checks/diagnostic-secret-review.d.ts.map +1 -0
- package/dist/checks/diagnostic-secret-review.js +17 -0
- package/dist/checks/diagnostic-secret-review.js.map +1 -0
- package/dist/checks/dispatch-context.d.ts +1 -1
- package/dist/checks/dispatch-context.d.ts.map +1 -1
- package/dist/checks/dispatch-context.js +4 -11
- package/dist/checks/dispatch-context.js.map +1 -1
- package/dist/checks/dispatch-target.d.ts.map +1 -1
- package/dist/checks/dispatch-target.js +3 -24
- package/dist/checks/dispatch-target.js.map +1 -1
- package/dist/checks/dispatcher.d.ts.map +1 -1
- package/dist/checks/dispatcher.js +2 -21
- package/dist/checks/dispatcher.js.map +1 -1
- package/dist/checks/duplication/adapter.d.ts.map +1 -1
- package/dist/checks/duplication/adapter.js +2 -4
- package/dist/checks/duplication/adapter.js.map +1 -1
- package/dist/checks/eslint/lint-adapter.d.ts.map +1 -1
- package/dist/checks/eslint/lint-adapter.js +3 -5
- package/dist/checks/eslint/lint-adapter.js.map +1 -1
- package/dist/checks/eslint/project/adapter.d.ts.map +1 -1
- package/dist/checks/eslint/project/adapter.js +3 -2
- package/dist/checks/eslint/project/adapter.js.map +1 -1
- package/dist/checks/eslint/project/installation.d.ts.map +1 -1
- package/dist/checks/eslint/project/installation.js +3 -2
- package/dist/checks/eslint/project/installation.js.map +1 -1
- package/dist/checks/eslint/project/protocol.d.ts.map +1 -1
- package/dist/checks/eslint/project/protocol.js +3 -2
- package/dist/checks/eslint/project/protocol.js.map +1 -1
- package/dist/checks/eslint/project/supported-version.d.ts +2 -0
- package/dist/checks/eslint/project/supported-version.d.ts.map +1 -0
- package/dist/checks/eslint/project/supported-version.js +2 -0
- package/dist/checks/eslint/project/supported-version.js.map +1 -0
- package/dist/checks/eslint/project/trust.js +1 -1
- package/dist/checks/eslint/project/trust.js.map +1 -1
- package/dist/checks/eslint/project/types.d.ts +2 -1
- package/dist/checks/eslint/project/types.d.ts.map +1 -1
- package/dist/checks/eslint/project/types.js +2 -1
- package/dist/checks/eslint/project/types.js.map +1 -1
- package/dist/checks/eslint/project/worker.js +8 -2
- package/dist/checks/eslint/project/worker.js.map +1 -1
- package/dist/checks/eslint/rule-settings.d.ts.map +1 -1
- package/dist/checks/eslint/rule-settings.js +3 -73
- package/dist/checks/eslint/rule-settings.js.map +1 -1
- package/dist/checks/events.d.ts +9 -1
- package/dist/checks/events.d.ts.map +1 -1
- package/dist/checks/incomplete-error.d.ts +2 -0
- package/dist/checks/incomplete-error.d.ts.map +1 -1
- package/dist/checks/incomplete-error.js +16 -0
- package/dist/checks/incomplete-error.js.map +1 -1
- package/dist/checks/installation-diagnostic.d.ts.map +1 -1
- package/dist/checks/installation-diagnostic.js +9 -28
- package/dist/checks/installation-diagnostic.js.map +1 -1
- package/dist/checks/prettier/project-installation.d.ts.map +1 -1
- package/dist/checks/prettier/project-installation.js +3 -33
- package/dist/checks/prettier/project-installation.js.map +1 -1
- package/dist/checks/prettier/project-trust.d.ts +0 -2
- package/dist/checks/prettier/project-trust.d.ts.map +1 -1
- package/dist/checks/prettier/project-trust.js +1 -9
- package/dist/checks/prettier/project-trust.js.map +1 -1
- package/dist/checks/prettier/project-version.d.ts +16 -0
- package/dist/checks/prettier/project-version.d.ts.map +1 -0
- package/dist/checks/prettier/project-version.js +49 -0
- package/dist/checks/prettier/project-version.js.map +1 -0
- package/dist/checks/prettier/settings.d.ts +1 -1
- package/dist/checks/project/import-specifier.d.ts +4 -0
- package/dist/checks/project/import-specifier.d.ts.map +1 -0
- package/dist/checks/project/import-specifier.js +17 -0
- package/dist/checks/project/import-specifier.js.map +1 -0
- package/dist/checks/react/adapter.d.ts.map +1 -1
- package/dist/checks/react/adapter.js +2 -4
- package/dist/checks/react/adapter.js.map +1 -1
- package/dist/checks/runner/context.d.ts.map +1 -1
- package/dist/checks/runner/context.js +2 -9
- package/dist/checks/runner/context.js.map +1 -1
- package/dist/checks/runner/protocol.d.ts +1 -1
- package/dist/checks/runner/protocol.d.ts.map +1 -1
- package/dist/checks/runner/protocol.js +12 -7
- package/dist/checks/runner/protocol.js.map +1 -1
- package/dist/checks/runner/worker.js +4 -30
- package/dist/checks/runner/worker.js.map +1 -1
- package/dist/checks/sanitize-result.d.ts.map +1 -1
- package/dist/checks/sanitize-result.js +22 -6
- package/dist/checks/sanitize-result.js.map +1 -1
- package/dist/checks/structural-security/adapter.d.ts.map +1 -1
- package/dist/checks/structural-security/adapter.js +2 -4
- package/dist/checks/structural-security/adapter.js.map +1 -1
- package/dist/checks/typescript/adapter.d.ts.map +1 -1
- package/dist/checks/typescript/adapter.js +3 -5
- package/dist/checks/typescript/adapter.js.map +1 -1
- package/dist/checks/typescript/captured-directory.d.ts +2 -0
- package/dist/checks/typescript/captured-directory.d.ts.map +1 -0
- package/dist/checks/typescript/captured-directory.js +22 -0
- package/dist/checks/typescript/captured-directory.js.map +1 -0
- package/dist/checks/typescript/compiler-host.d.ts.map +1 -1
- package/dist/checks/typescript/compiler-host.js +5 -21
- package/dist/checks/typescript/compiler-host.js.map +1 -1
- package/dist/checks/typescript/compiler-scope-graph.d.ts +1 -3
- package/dist/checks/typescript/compiler-scope-graph.d.ts.map +1 -1
- package/dist/checks/typescript/compiler-scope-graph.js +520 -642
- package/dist/checks/typescript/compiler-scope-graph.js.map +1 -1
- package/dist/checks/typescript/compiler-scope-witnesses.d.ts +30 -0
- package/dist/checks/typescript/compiler-scope-witnesses.d.ts.map +1 -0
- package/dist/checks/typescript/compiler-scope-witnesses.js +151 -0
- package/dist/checks/typescript/compiler-scope-witnesses.js.map +1 -0
- package/dist/checks/typescript/config.d.ts.map +1 -1
- package/dist/checks/typescript/config.js +2 -21
- package/dist/checks/typescript/config.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -16
- package/dist/cli.js.map +1 -1
- package/dist/commands/checks.d.ts.map +1 -1
- package/dist/commands/checks.js +62 -48
- package/dist/commands/checks.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -6
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +17 -10
- package/dist/commands/scan.js.map +1 -1
- package/dist/config/file-policy.d.ts.map +1 -1
- package/dist/config/file-policy.js +1 -18
- package/dist/config/file-policy.js.map +1 -1
- package/dist/config/immutable-configuration.d.ts.map +1 -1
- package/dist/config/immutable-configuration.js +2 -75
- package/dist/config/immutable-configuration.js.map +1 -1
- package/dist/config/json-schema.d.ts.map +1 -1
- package/dist/config/json-schema.js +2 -6
- package/dist/config/json-schema.js.map +1 -1
- package/dist/config/load-config.d.ts.map +1 -1
- package/dist/config/load-config.js +33 -36
- package/dist/config/load-config.js.map +1 -1
- package/dist/config/schema.d.ts +5 -6
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +2 -15
- package/dist/config/schema.js.map +1 -1
- package/dist/config/settings-registry.d.ts +1 -1
- package/dist/config/settings-registry.d.ts.map +1 -1
- package/dist/config/settings-registry.js.map +1 -1
- package/dist/config/strict-json.d.ts +3 -0
- package/dist/config/strict-json.d.ts.map +1 -0
- package/dist/config/strict-json.js +81 -0
- package/dist/config/strict-json.js.map +1 -0
- package/dist/core/check-ids.d.ts +3 -0
- package/dist/core/check-ids.d.ts.map +1 -0
- package/dist/core/check-ids.js +16 -0
- package/dist/core/check-ids.js.map +1 -0
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/diagnostics/local-scan-diagnostics.d.ts.map +1 -1
- package/dist/diagnostics/local-scan-diagnostics.js +3 -3
- package/dist/diagnostics/local-scan-diagnostics.js.map +1 -1
- package/dist/diagnostics/scan-performance.d.ts +2 -2
- package/dist/diagnostics/scan-performance.d.ts.map +1 -1
- package/dist/diagnostics/scan-performance.js +2 -2
- package/dist/diagnostics/scan-performance.js.map +1 -1
- package/dist/doctor/project-eslint.d.ts.map +1 -1
- package/dist/doctor/project-eslint.js +2 -1
- package/dist/doctor/project-eslint.js.map +1 -1
- package/dist/fixes/build-plan.d.ts +1 -1
- package/dist/fixes/build-plan.d.ts.map +1 -1
- package/dist/fixes/build-plan.js +0 -1
- package/dist/fixes/build-plan.js.map +1 -1
- package/dist/fixes/public-plan.d.ts +1 -0
- package/dist/fixes/public-plan.d.ts.map +1 -1
- package/dist/fixes/public-plan.js +9 -5
- package/dist/fixes/public-plan.js.map +1 -1
- package/dist/git/baseline-renames.d.ts +3 -0
- package/dist/git/baseline-renames.d.ts.map +1 -0
- package/dist/git/baseline-renames.js +20 -0
- package/dist/git/baseline-renames.js.map +1 -0
- package/dist/git/change-set.d.ts +1 -0
- package/dist/git/change-set.d.ts.map +1 -1
- package/dist/git/change-set.js +25 -35
- package/dist/git/change-set.js.map +1 -1
- package/dist/git/common-directory.d.ts +3 -0
- package/dist/git/common-directory.d.ts.map +1 -0
- package/dist/git/common-directory.js +12 -0
- package/dist/git/common-directory.js.map +1 -0
- package/dist/git/snapshot-work.d.ts +2 -0
- package/dist/git/snapshot-work.d.ts.map +1 -1
- package/dist/git/snapshot-work.js +9 -0
- package/dist/git/snapshot-work.js.map +1 -1
- package/dist/git/snapshot.d.ts +2 -0
- package/dist/git/snapshot.d.ts.map +1 -1
- package/dist/git/snapshot.js +22 -0
- package/dist/git/snapshot.js.map +1 -1
- package/dist/hooks/detect.d.ts.map +1 -1
- package/dist/hooks/detect.js +4 -26
- package/dist/hooks/detect.js.map +1 -1
- package/dist/hooks/raw-hook-path.d.ts +3 -0
- package/dist/hooks/raw-hook-path.d.ts.map +1 -0
- package/dist/hooks/raw-hook-path.js +38 -0
- package/dist/hooks/raw-hook-path.js.map +1 -0
- package/dist/init/generated-formatting-overrides.d.ts +3 -0
- package/dist/init/generated-formatting-overrides.d.ts.map +1 -0
- package/dist/init/generated-formatting-overrides.js +67 -0
- package/dist/init/generated-formatting-overrides.js.map +1 -0
- package/dist/init/presentation.d.ts +1 -1
- package/dist/init/presentation.d.ts.map +1 -1
- package/dist/init/presentation.js +37 -1
- package/dist/init/presentation.js.map +1 -1
- package/dist/init/prettier-discovery.d.ts +0 -10
- package/dist/init/prettier-discovery.d.ts.map +1 -1
- package/dist/init/prettier-discovery.js +2 -48
- package/dist/init/prettier-discovery.js.map +1 -1
- package/dist/init/recommend.d.ts.map +1 -1
- package/dist/init/recommend.js +15 -34
- package/dist/init/recommend.js.map +1 -1
- package/dist/init/write-config.d.ts.map +1 -1
- package/dist/init/write-config.js +9 -26
- package/dist/init/write-config.js.map +1 -1
- package/dist/inspection/workspaces.d.ts +2 -0
- package/dist/inspection/workspaces.d.ts.map +1 -1
- package/dist/inspection/workspaces.js +3 -0
- package/dist/inspection/workspaces.js.map +1 -1
- package/dist/policy/evaluate.d.ts +1 -0
- package/dist/policy/evaluate.d.ts.map +1 -1
- package/dist/policy/evaluate.js +14 -8
- package/dist/policy/evaluate.js.map +1 -1
- package/dist/renderers/json.d.ts +3 -1
- package/dist/renderers/json.d.ts.map +1 -1
- package/dist/renderers/json.js +11 -16
- package/dist/renderers/json.js.map +1 -1
- package/dist/renderers/text.d.ts.map +1 -1
- package/dist/renderers/text.js +24 -77
- package/dist/renderers/text.js.map +1 -1
- package/dist/reporting/check-coverage.d.ts +2 -0
- package/dist/reporting/check-coverage.d.ts.map +1 -1
- package/dist/reporting/check-coverage.js +11 -0
- package/dist/reporting/check-coverage.js.map +1 -1
- package/dist/reporting/fix-presentation.d.ts +7 -43
- package/dist/reporting/fix-presentation.d.ts.map +1 -1
- package/dist/reporting/fix-presentation.js +3 -57
- package/dist/reporting/fix-presentation.js.map +1 -1
- package/dist/reporting/presentation.d.ts.map +1 -1
- package/dist/reporting/presentation.js +3 -2
- package/dist/reporting/presentation.js.map +1 -1
- package/dist/reporting/scan-phase-labels.d.ts +3 -0
- package/dist/reporting/scan-phase-labels.d.ts.map +1 -0
- package/dist/reporting/scan-phase-labels.js +14 -0
- package/dist/reporting/scan-phase-labels.js.map +1 -0
- package/dist/reporting/static-dashboard.d.ts +6 -0
- package/dist/reporting/static-dashboard.d.ts.map +1 -0
- package/dist/reporting/static-dashboard.js +8 -0
- package/dist/reporting/static-dashboard.js.map +1 -0
- package/dist/reporting/text-scan-progress.d.ts +7 -0
- package/dist/reporting/text-scan-progress.d.ts.map +1 -0
- package/dist/reporting/text-scan-progress.js +57 -0
- package/dist/reporting/text-scan-progress.js.map +1 -0
- package/dist/runtime/background-node.d.ts +2 -0
- package/dist/runtime/background-node.d.ts.map +1 -0
- package/dist/runtime/background-node.js +13 -0
- package/dist/runtime/background-node.js.map +1 -0
- package/dist/scan/analysis-session.d.ts +5 -2
- package/dist/scan/analysis-session.d.ts.map +1 -1
- package/dist/scan/analysis-session.js +16 -8
- package/dist/scan/analysis-session.js.map +1 -1
- package/dist/scan/merge-scan.d.ts.map +1 -1
- package/dist/scan/merge-scan.js +84 -37
- package/dist/scan/merge-scan.js.map +1 -1
- package/dist/scan/run-scan.d.ts.map +1 -1
- package/dist/scan/run-scan.js +9 -6
- package/dist/scan/run-scan.js.map +1 -1
- package/dist/scan/source-excerpts.d.ts +0 -2
- package/dist/scan/source-excerpts.d.ts.map +1 -1
- package/dist/scan/source-excerpts.js +13 -42
- package/dist/scan/source-excerpts.js.map +1 -1
- package/dist/service/server-connection.d.ts.map +1 -1
- package/dist/service/server-connection.js +3 -19
- package/dist/service/server-connection.js.map +1 -1
- package/dist/telemetry/client.d.ts.map +1 -1
- package/dist/telemetry/client.js +2 -10
- package/dist/telemetry/client.js.map +1 -1
- package/dist/telemetry/performance-summary.d.ts.map +1 -1
- package/dist/telemetry/performance-summary.js +1 -1
- package/dist/telemetry/performance-summary.js.map +1 -1
- package/dist/telemetry/schema.d.ts +129 -129
- package/dist/telemetry/state.d.ts +10 -10
- package/dist/ui/action-button-face.d.ts +7 -0
- package/dist/ui/action-button-face.d.ts.map +1 -0
- package/dist/ui/action-button-face.js +18 -0
- package/dist/ui/action-button-face.js.map +1 -0
- package/dist/ui/doctor-dashboard.d.ts.map +1 -1
- package/dist/ui/doctor-dashboard.js +3 -11
- package/dist/ui/doctor-dashboard.js.map +1 -1
- package/dist/ui/fix-app.d.ts.map +1 -1
- package/dist/ui/fix-app.js +2 -12
- package/dist/ui/fix-app.js.map +1 -1
- package/dist/ui/init-view.d.ts.map +1 -1
- package/dist/ui/init-view.js +2 -12
- package/dist/ui/init-view.js.map +1 -1
- package/dist/ui/live-dashboard.d.ts.map +1 -1
- package/dist/ui/live-dashboard.js +16 -16
- package/dist/ui/live-dashboard.js.map +1 -1
- package/dist/ui/outcome-strip.d.ts.map +1 -1
- package/dist/ui/outcome-strip.js +6 -8
- package/dist/ui/outcome-strip.js.map +1 -1
- package/dist/updates/notification.d.ts.map +1 -1
- package/dist/updates/notification.js +2 -10
- package/dist/updates/notification.js.map +1 -1
- package/docs/cli-reference.md +2 -0
- package/package.json +1 -1
|
@@ -1,49 +1,13 @@
|
|
|
1
|
+
import { acquireCompilerProof, compilerProofSlot, proofDigest, readProofInput, validCompilerProof, } from "./compiler-scope-witnesses.js";
|
|
2
|
+
export { releaseCompilerScopeProofs, validateCompilerScopeProofs, } from "./compiler-scope-witnesses.js";
|
|
1
3
|
import { dependencyResolutionContainingFile } from "./dependency-resolution-path.js";
|
|
2
4
|
import { setImmediate as yieldTurn } from "node:timers/promises";
|
|
3
5
|
import { isBuiltin } from "node:module";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
6
|
import { dirname, resolve, relative, sep, isAbsolute } from "node:path";
|
|
6
|
-
import { CapturedDependencies
|
|
7
|
+
import { CapturedDependencies } from "../../cache/captured-dependencies.js";
|
|
7
8
|
import { captureSnapshotRegistry } from "../../inspection/snapshot-registry.js";
|
|
8
|
-
import { readContainedFile } from "../../inspection/read-json.js";
|
|
9
9
|
import { classifyCompilerChanges } from "../compiler-change-inputs.js";
|
|
10
|
-
import { CheckIncompleteError } from "../incomplete-error.js";
|
|
11
10
|
import { loadCompilerScopeInputs } from "./compiler-scope-inputs.js";
|
|
12
|
-
const owners = new WeakMap();
|
|
13
|
-
// A proof may temporarily own a full dependency capture. Serialize acquisition
|
|
14
|
-
// and cap retained witness metadata separately, below the reuse owner's budget.
|
|
15
|
-
let activeProof = false;
|
|
16
|
-
const waiting = [];
|
|
17
|
-
async function acquire(signal, run) {
|
|
18
|
-
signal?.throwIfAborted();
|
|
19
|
-
await new Promise((accept, reject) => {
|
|
20
|
-
const start = () => {
|
|
21
|
-
signal?.removeEventListener("abort", cancel);
|
|
22
|
-
activeProof = true;
|
|
23
|
-
accept();
|
|
24
|
-
};
|
|
25
|
-
const cancel = () => {
|
|
26
|
-
const index = waiting.indexOf(start);
|
|
27
|
-
if (index !== -1)
|
|
28
|
-
waiting.splice(index, 1);
|
|
29
|
-
reject(signal.reason);
|
|
30
|
-
};
|
|
31
|
-
if (!activeProof)
|
|
32
|
-
start();
|
|
33
|
-
else {
|
|
34
|
-
waiting.push(start);
|
|
35
|
-
signal?.addEventListener("abort", cancel, { once: true });
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
try {
|
|
39
|
-
signal?.throwIfAborted();
|
|
40
|
-
return await run();
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
activeProof = false;
|
|
44
|
-
waiting.shift()?.();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
11
|
class ProofLimit extends Error {
|
|
48
12
|
}
|
|
49
13
|
class SnapshotLookup extends Error {
|
|
@@ -53,7 +17,6 @@ class SnapshotLookup extends Error {
|
|
|
53
17
|
this.path = path;
|
|
54
18
|
}
|
|
55
19
|
}
|
|
56
|
-
const hash = (text) => createHash("sha256").update(text).digest("hex");
|
|
57
20
|
const unknown = {
|
|
58
21
|
independent: false,
|
|
59
22
|
reason: "unknown",
|
|
@@ -67,74 +30,507 @@ function within(root, path) {
|
|
|
67
30
|
return (part === "" ||
|
|
68
31
|
(!isAbsolute(part) && part !== ".." && !part.startsWith(`..${sep}`)));
|
|
69
32
|
}
|
|
70
|
-
async function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
33
|
+
async function captureWorkspaceSignature(inspection, workspace, context, state) {
|
|
34
|
+
const { changes, separateInstall, changedPaths, dependencies, captured, witnesses, charge, librarySeen, ts, } = state;
|
|
35
|
+
context.signal?.throwIfAborted();
|
|
36
|
+
if (inspection.workspaces.length > 32)
|
|
37
|
+
return { independent: false, reason: "limit" };
|
|
38
|
+
const side = inspection.workspaces.find((w) => w.relativeRoot === workspace.relativeRoot);
|
|
39
|
+
if (side === undefined)
|
|
40
|
+
return unknown;
|
|
41
|
+
const inputs = await loadCompilerScopeInputs(inspection, side, context.signal);
|
|
42
|
+
if (!inputs.complete)
|
|
43
|
+
return {
|
|
44
|
+
independent: false,
|
|
45
|
+
reason: inputs.reason === "limit" ? "limit" : "unknown",
|
|
46
|
+
};
|
|
47
|
+
const texts = new Map(), signature = new Map();
|
|
48
|
+
let textBytes = 0;
|
|
49
|
+
const add = async (path, limit) => {
|
|
50
|
+
const remaining = Math.floor((8 * 1024 * 1024 - textBytes) / 2);
|
|
51
|
+
if (remaining <= 0)
|
|
52
|
+
throw new Error("Proof text limit");
|
|
53
|
+
const text = await readProofInput(inspection.snapshotRoot, path, Math.min(limit, remaining), context.signal);
|
|
54
|
+
textBytes += text.length * 2;
|
|
55
|
+
texts.set(resolve(inspection.snapshotRoot, path), text);
|
|
56
|
+
if (!changes.localNpmInputs.has(path))
|
|
57
|
+
signature.set(path, proofDigest(text));
|
|
58
|
+
witnesses.push({
|
|
59
|
+
root: inspection.snapshotRoot,
|
|
60
|
+
path,
|
|
61
|
+
digest: proofDigest(text),
|
|
62
|
+
limit,
|
|
63
|
+
});
|
|
64
|
+
return text;
|
|
65
|
+
};
|
|
66
|
+
for (const path of inputs.inputPaths)
|
|
67
|
+
await add(path, side.sourceFiles.includes(path) ? 1024 * 1024 : 64 * 1024);
|
|
68
|
+
// The production host can see all captured repository source files. Resolve
|
|
69
|
+
// their names too; an edge outside this workspace prevents narrowing.
|
|
70
|
+
const inventory = new Set(inspection.workspaces
|
|
71
|
+
.flatMap((w) => w.sourceFiles)
|
|
72
|
+
.map((p) => resolve(inspection.snapshotRoot, p)));
|
|
73
|
+
for (const w of inspection.workspaces) {
|
|
74
|
+
inventory.add(resolve(inspection.snapshotRoot, w.manifestPath));
|
|
75
|
+
if (!texts.has(resolve(inspection.snapshotRoot, w.manifestPath)))
|
|
76
|
+
await add(w.manifestPath, 64 * 1024);
|
|
77
|
+
}
|
|
78
|
+
if (separateInstall) {
|
|
79
|
+
const roots = new Set([
|
|
80
|
+
side.relativeRoot,
|
|
81
|
+
...changedPaths.map((path) => path.split("/")[0]),
|
|
82
|
+
]);
|
|
83
|
+
for (const root of roots) {
|
|
84
|
+
if (!changes.separateNpmRoots.has(root))
|
|
85
|
+
return unknown;
|
|
86
|
+
const packageText = texts.get(resolve(inspection.snapshotRoot, root, "package.json"));
|
|
87
|
+
const packageManifest = JSON.parse(packageText ?? "null");
|
|
88
|
+
if (packageManifest === null || packageManifest.workspaces !== undefined)
|
|
89
|
+
return unknown;
|
|
90
|
+
const lock = JSON.parse(await add(`${root}/package-lock.json`, 2 * 1024 * 1024));
|
|
91
|
+
if (!lock?.packages ||
|
|
92
|
+
![2, 3].includes(lock.lockfileVersion) ||
|
|
93
|
+
Array.isArray(lock.packages) ||
|
|
94
|
+
typeof lock.packages !== "object")
|
|
95
|
+
return unknown;
|
|
96
|
+
for (const [path, entry] of Object.entries(lock.packages)) {
|
|
97
|
+
if (path !== "" &&
|
|
98
|
+
(!path.startsWith("node_modules/") ||
|
|
99
|
+
path.includes("\\") ||
|
|
100
|
+
path.split("/").some((part) => part === ".." || part === ".")))
|
|
101
|
+
return unknown;
|
|
102
|
+
if (typeof entry !== "object" ||
|
|
103
|
+
entry === null ||
|
|
104
|
+
("link" in entry && entry.link === true) ||
|
|
105
|
+
("resolved" in entry &&
|
|
106
|
+
typeof entry.resolved === "string" &&
|
|
107
|
+
/^(?:file:|link:|workspace:|[.\/])/iu.test(entry.resolved)))
|
|
108
|
+
return unknown;
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
|
-
else if (hash(await read(w.root, w.path, w.limit, signal)) !== w.digest)
|
|
95
|
-
return false;
|
|
96
111
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
for (const record of owner.records.values()) {
|
|
113
|
-
let verified = false;
|
|
114
|
-
try {
|
|
115
|
-
verified = await valid(record, signal);
|
|
112
|
+
// TypeScript may prefer a nested directory's package.json to index.ts.
|
|
113
|
+
// Inventory its possible presence before treating index files as a closed
|
|
114
|
+
// graph. Unsupported nested manifests retain full analyzer coverage.
|
|
115
|
+
const manifests = new Set();
|
|
116
|
+
for (const path of inventory) {
|
|
117
|
+
let directory = dirname(path);
|
|
118
|
+
while (within(inspection.snapshotRoot, directory)) {
|
|
119
|
+
manifests.add(relative(inspection.snapshotRoot, resolve(directory, "package.json"))
|
|
120
|
+
.split(sep)
|
|
121
|
+
.join("/"));
|
|
122
|
+
if (manifests.size > 4096)
|
|
123
|
+
throw new ProofLimit();
|
|
124
|
+
if (directory === inspection.snapshotRoot)
|
|
125
|
+
break;
|
|
126
|
+
directory = dirname(directory);
|
|
116
127
|
}
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
}
|
|
129
|
+
const knownManifests = new Set(inspection.workspaces.map((w) => w.manifestPath));
|
|
130
|
+
const absentPaths = new Set();
|
|
131
|
+
for (const path of manifests) {
|
|
132
|
+
if (knownManifests.has(path))
|
|
133
|
+
continue;
|
|
134
|
+
context.signal?.throwIfAborted();
|
|
135
|
+
const registry = await captureSnapshotRegistry(inspection.snapshotRoot, [
|
|
136
|
+
path,
|
|
137
|
+
]);
|
|
138
|
+
if (registry.resolve(path) !== undefined ||
|
|
139
|
+
registry.entries().some((e) => e.kind === "symlink"))
|
|
140
|
+
return unknown;
|
|
141
|
+
witnesses.push({
|
|
142
|
+
root: inspection.snapshotRoot,
|
|
143
|
+
path,
|
|
144
|
+
limit: 64 * 1024,
|
|
145
|
+
});
|
|
146
|
+
absentPaths.add(resolve(inspection.snapshotRoot, path));
|
|
147
|
+
}
|
|
148
|
+
for (const path of texts.keys())
|
|
149
|
+
inventory.add(path);
|
|
150
|
+
const directories = new Set();
|
|
151
|
+
for (const path of inventory) {
|
|
152
|
+
let directory = dirname(path);
|
|
153
|
+
while (within(inspection.snapshotRoot, directory)) {
|
|
154
|
+
directories.add(directory);
|
|
155
|
+
if (directory === inspection.snapshotRoot)
|
|
156
|
+
break;
|
|
157
|
+
directory = dirname(directory);
|
|
119
158
|
}
|
|
120
|
-
if (!verified)
|
|
121
|
-
throw new CheckIncompleteError({
|
|
122
|
-
code: "COMPARISON_INPUTS_CHANGED",
|
|
123
|
-
message: "Inputs used to select compiler checks changed during this scan.",
|
|
124
|
-
remediation: "Wait for dependency installation or file updates to finish, then rerun the scan.",
|
|
125
|
-
});
|
|
126
159
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
160
|
+
const snapshotFile = (path) => {
|
|
161
|
+
const absolute = resolve(path);
|
|
162
|
+
if (inventory.has(absolute))
|
|
163
|
+
return true;
|
|
164
|
+
if (!within(inspection.snapshotRoot, absolute) ||
|
|
165
|
+
relative(inspection.snapshotRoot, absolute)
|
|
166
|
+
.split(sep)
|
|
167
|
+
.includes("node_modules"))
|
|
168
|
+
return undefined;
|
|
169
|
+
if (!absentPaths.has(absolute))
|
|
170
|
+
throw new SnapshotLookup(absolute);
|
|
171
|
+
return false;
|
|
172
|
+
};
|
|
173
|
+
const snapshotDirectory = (path) => {
|
|
174
|
+
const absolute = resolve(path);
|
|
175
|
+
if (directories.has(absolute))
|
|
176
|
+
return true;
|
|
177
|
+
if (absentPaths.has(absolute))
|
|
178
|
+
return false;
|
|
179
|
+
if (within(inspection.snapshotRoot, absolute) &&
|
|
180
|
+
!relative(inspection.snapshotRoot, absolute)
|
|
181
|
+
.split(sep)
|
|
182
|
+
.includes("node_modules"))
|
|
183
|
+
throw new SnapshotLookup(absolute);
|
|
184
|
+
return undefined;
|
|
185
|
+
};
|
|
186
|
+
const snapshotRead = (path) => {
|
|
187
|
+
if (changes.localNpmInputs.has(relative(inspection.snapshotRoot, resolve(path)).split(sep).join("/")))
|
|
188
|
+
throw Error("Resolution uses a changed package manifest");
|
|
189
|
+
snapshotFile(path);
|
|
190
|
+
return texts.get(resolve(path));
|
|
191
|
+
};
|
|
192
|
+
const resolveSnapshotMetadata = async (operation) => {
|
|
193
|
+
for (;;) {
|
|
194
|
+
context.signal?.throwIfAborted();
|
|
195
|
+
try {
|
|
196
|
+
return operation();
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (!(error instanceof SnapshotLookup))
|
|
200
|
+
throw error;
|
|
201
|
+
charge();
|
|
202
|
+
const path = relative(inspection.snapshotRoot, error.path)
|
|
203
|
+
.split(sep)
|
|
204
|
+
.join("/");
|
|
205
|
+
const registry = await captureSnapshotRegistry(inspection.snapshotRoot, [path]);
|
|
206
|
+
context.signal?.throwIfAborted();
|
|
207
|
+
if (registry.entries().some((e) => e.kind === "symlink"))
|
|
208
|
+
throw Error("Unsupported resolution alias");
|
|
209
|
+
const entry = registry.resolve(path);
|
|
210
|
+
if (entry?.targetKind === "file")
|
|
211
|
+
throw Error("Unsupported resolution metadata");
|
|
212
|
+
if (entry?.targetKind === "directory") {
|
|
213
|
+
directories.add(error.path);
|
|
214
|
+
witnesses.push({
|
|
215
|
+
root: inspection.snapshotRoot,
|
|
216
|
+
path,
|
|
217
|
+
limit: 0,
|
|
218
|
+
directory: true,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
absentPaths.add(error.path);
|
|
223
|
+
witnesses.push({
|
|
224
|
+
root: inspection.snapshotRoot,
|
|
225
|
+
path,
|
|
226
|
+
limit: 0,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const snapshotHost = {
|
|
233
|
+
fileExists: (path) => snapshotFile(path) ?? false,
|
|
234
|
+
readFile: snapshotRead,
|
|
235
|
+
directoryExists: (path) => snapshotDirectory(path) ?? false,
|
|
236
|
+
realpath: (path) => resolve(path),
|
|
237
|
+
};
|
|
238
|
+
const libraryRoot = dirname(ts.getDefaultLibFilePath({}));
|
|
239
|
+
const dependencyPath = (path) => within(context.repositoryRoot, resolve(path)) ||
|
|
240
|
+
within(libraryRoot, resolve(path));
|
|
241
|
+
const host = {
|
|
242
|
+
fileExists: (path) => snapshotFile(path) ??
|
|
243
|
+
(dependencyPath(path) && captured(() => dependencies.fileExists(path))),
|
|
244
|
+
readFile: (path) => snapshotRead(path) ??
|
|
245
|
+
(dependencyPath(path)
|
|
246
|
+
? captured(() => dependencies.readCapturedFile(path))
|
|
247
|
+
: undefined),
|
|
248
|
+
directoryExists: (path) => snapshotDirectory(path) ??
|
|
249
|
+
(within(context.repositoryRoot, resolve(path)) ||
|
|
250
|
+
(within(libraryRoot, resolve(path)) &&
|
|
251
|
+
captured(() => dependencies.directoryExists(path)))),
|
|
252
|
+
getDirectories: (path) => dependencyPath(path)
|
|
253
|
+
? captured(() => dependencies.getDirectories(path))
|
|
254
|
+
: [],
|
|
255
|
+
realpath: (path) => inventory.has(resolve(path))
|
|
256
|
+
? resolve(path)
|
|
257
|
+
: captured(() => dependencies.realpath(path)),
|
|
258
|
+
};
|
|
259
|
+
// Separately locked projects can prove their captured graph disjoint
|
|
260
|
+
// even if a package is absent. Shared installation layouts still
|
|
261
|
+
// require positive witnesses for all declared packages.
|
|
262
|
+
for (const w of separateInstall
|
|
263
|
+
? []
|
|
264
|
+
: inspection.workspaces.filter((w) => w.relativeRoot === "." ||
|
|
265
|
+
w.relativeRoot === side.relativeRoot ||
|
|
266
|
+
side.relativeRoot.startsWith(`${w.relativeRoot}/`)))
|
|
267
|
+
for (const declaration of w.dependencyDeclarations) {
|
|
268
|
+
let directory = resolve(context.repositoryRoot, side.relativeRoot), found = false;
|
|
269
|
+
while (within(context.repositoryRoot, directory)) {
|
|
270
|
+
charge();
|
|
271
|
+
if (captured(() => dependencies.fileExists(resolve(directory, "node_modules", declaration.name, "package.json")))) {
|
|
272
|
+
found = true;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
if (directory === resolve(context.repositoryRoot))
|
|
276
|
+
break;
|
|
277
|
+
directory = dirname(directory);
|
|
278
|
+
}
|
|
279
|
+
if (!found)
|
|
280
|
+
return unknown;
|
|
281
|
+
}
|
|
282
|
+
const allowed = new Set(side.sourceFiles.map((p) => resolve(inspection.snapshotRoot, p)));
|
|
283
|
+
for (const project of inputs.projects) {
|
|
284
|
+
const options = {
|
|
285
|
+
target: ts.ScriptTarget.ES2022,
|
|
286
|
+
module: ts.ModuleKind.NodeNext,
|
|
287
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
288
|
+
...project.options,
|
|
289
|
+
};
|
|
290
|
+
// Conditional NodeNext/CJS resolution requires usage-specific mode. Keep
|
|
291
|
+
// broad coverage until that variant has an explicit proof implementation.
|
|
292
|
+
if (options.moduleResolution !== ts.ModuleResolutionKind.Bundler &&
|
|
293
|
+
options.moduleResolution !== ts.ModuleResolutionKind.Node10) {
|
|
294
|
+
if (JSON.stringify(options.types) !== "[]")
|
|
295
|
+
return unknown;
|
|
296
|
+
for (const sourcePath of project.sourcePaths) {
|
|
297
|
+
const text = texts.get(resolve(inspection.snapshotRoot, sourcePath));
|
|
298
|
+
const pre = ts.preProcessFile(text, true, true);
|
|
299
|
+
if (pre.importedFiles.length ||
|
|
300
|
+
pre.referencedFiles.length ||
|
|
301
|
+
pre.typeReferenceDirectives.length ||
|
|
302
|
+
pre.libReferenceDirectives.length ||
|
|
303
|
+
/\.d\.[cm]?ts$/iu.test(sourcePath))
|
|
304
|
+
return unknown;
|
|
305
|
+
const tree = ts.createSourceFile(sourcePath, text, ts.ScriptTarget.Latest, true);
|
|
306
|
+
if (!ts.isExternalModule(tree))
|
|
307
|
+
return unknown;
|
|
308
|
+
let unsafe = false;
|
|
309
|
+
const visit = (node) => {
|
|
310
|
+
if (ts.isModuleDeclaration(node) || ts.isCallExpression(node))
|
|
311
|
+
unsafe = true;
|
|
312
|
+
if (!unsafe)
|
|
313
|
+
ts.forEachChild(node, visit);
|
|
314
|
+
};
|
|
315
|
+
visit(tree);
|
|
316
|
+
if (unsafe)
|
|
317
|
+
return unknown;
|
|
318
|
+
}
|
|
319
|
+
// Static source closure still needs the normal library witnesses.
|
|
320
|
+
}
|
|
321
|
+
if (options.plugins !== undefined ||
|
|
322
|
+
options.moduleSuffixes ||
|
|
323
|
+
options.rootDirs ||
|
|
324
|
+
options.noResolve ||
|
|
325
|
+
options.typeRoots ||
|
|
326
|
+
options.allowJs ||
|
|
327
|
+
options.importHelpers)
|
|
328
|
+
return unknown;
|
|
329
|
+
const typeRoots = [];
|
|
330
|
+
let directory = resolve(context.repositoryRoot, dirname(project.configPath));
|
|
331
|
+
while (within(context.repositoryRoot, directory)) {
|
|
332
|
+
typeRoots.push(resolve(directory, "node_modules/@types"));
|
|
333
|
+
if (directory === resolve(context.repositoryRoot))
|
|
334
|
+
break;
|
|
335
|
+
directory = dirname(directory);
|
|
336
|
+
}
|
|
337
|
+
const typeNames = options.types ?? [
|
|
338
|
+
...new Set(typeRoots.flatMap((root) => captured(() => dependencies.directoryEntries(root))
|
|
339
|
+
.filter((e) => e.type === "directory" && !e.name.startsWith("."))
|
|
340
|
+
.map((e) => e.name))),
|
|
341
|
+
];
|
|
342
|
+
const prepared = { ...options, typeRoots };
|
|
343
|
+
const pending = project.sourcePaths.map((path) => resolve(inspection.snapshotRoot, path));
|
|
344
|
+
const seen = new Set();
|
|
345
|
+
const push = (path) => {
|
|
346
|
+
if (!seen.has(path))
|
|
347
|
+
pending.push(path);
|
|
348
|
+
};
|
|
349
|
+
const library = (fileName) => {
|
|
350
|
+
charge();
|
|
351
|
+
if (!/^lib\.[a-z0-9.]+\.d\.ts$/u.test(fileName))
|
|
352
|
+
return undefined;
|
|
353
|
+
const name = fileName.slice(4, -5);
|
|
354
|
+
let directory = resolve(context.repositoryRoot, dirname(project.configPath));
|
|
355
|
+
while (within(context.repositoryRoot, directory)) {
|
|
356
|
+
if (captured(() => dependencies.fileExists(resolve(directory, "node_modules", `@typescript/lib-${name.split(".")[0]}`, "package.json"))))
|
|
357
|
+
return undefined;
|
|
358
|
+
if (directory === resolve(context.repositoryRoot))
|
|
359
|
+
break;
|
|
360
|
+
directory = dirname(directory);
|
|
361
|
+
}
|
|
362
|
+
const file = resolve(libraryRoot, fileName);
|
|
363
|
+
return captured(() => dependencies.fileExists(file))
|
|
364
|
+
? file
|
|
365
|
+
: separateInstall
|
|
366
|
+
? false
|
|
367
|
+
: undefined;
|
|
368
|
+
};
|
|
369
|
+
if (!options.noLib)
|
|
370
|
+
for (const name of options.lib ?? [ts.getDefaultLibFileName(options)]) {
|
|
371
|
+
const file = library(name);
|
|
372
|
+
if (file === undefined)
|
|
373
|
+
return unknown;
|
|
374
|
+
if (file !== false)
|
|
375
|
+
push(file);
|
|
376
|
+
}
|
|
377
|
+
for (const name of typeNames) {
|
|
378
|
+
charge();
|
|
379
|
+
const resolved = (await resolveSnapshotMetadata(() => ts.resolveTypeReferenceDirective(name, resolve(context.repositoryRoot, project.configPath), prepared, host))).resolvedTypeReferenceDirective;
|
|
380
|
+
if (!resolved?.resolvedFileName) {
|
|
381
|
+
if (!separateInstall || !isPackageSpecifier(name))
|
|
382
|
+
return unknown;
|
|
383
|
+
}
|
|
384
|
+
else
|
|
385
|
+
push(resolved.resolvedFileName);
|
|
386
|
+
}
|
|
387
|
+
const resolveOne = (specifier, from, mode) => {
|
|
388
|
+
charge();
|
|
389
|
+
const builtin = isBuiltin(specifier);
|
|
390
|
+
if (specifier.includes("\\") ||
|
|
391
|
+
(!builtin && /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(specifier)) ||
|
|
392
|
+
isAbsolute(specifier))
|
|
393
|
+
return undefined;
|
|
394
|
+
const local = ts.resolveModuleName(specifier, from, prepared, inventory.has(from) ? snapshotHost : host, undefined, undefined, mode).resolvedModule;
|
|
395
|
+
if (local !== undefined)
|
|
396
|
+
return local.resolvedFileName;
|
|
397
|
+
if (builtin) {
|
|
398
|
+
charge();
|
|
399
|
+
return ts.resolveTypeReferenceDirective("node", resolve(context.repositoryRoot, project.configPath), prepared, host).resolvedTypeReferenceDirective?.resolvedFileName;
|
|
400
|
+
}
|
|
401
|
+
if (specifier.startsWith("."))
|
|
402
|
+
return undefined;
|
|
403
|
+
const synthetic = dependencyResolutionContainingFile(context.repositoryRoot, inspection.snapshotRoot, from);
|
|
404
|
+
const installed = ts.resolveModuleName(specifier, synthetic, prepared, host, undefined, undefined, mode).resolvedModule;
|
|
405
|
+
return installed !== undefined &&
|
|
406
|
+
captured(() => dependencies.packageFileExists(installed.resolvedFileName))
|
|
407
|
+
? installed.resolvedFileName
|
|
408
|
+
: undefined;
|
|
409
|
+
};
|
|
410
|
+
const resolveModule = async (specifier, from) => {
|
|
411
|
+
const imports = await resolveSnapshotMetadata(() => resolveOne(specifier, from, ts.ModuleKind.ESNext));
|
|
412
|
+
const requires = await resolveSnapshotMetadata(() => resolveOne(specifier, from, ts.ModuleKind.CommonJS));
|
|
413
|
+
if (imports !== undefined && requires !== undefined)
|
|
414
|
+
return [...new Set([imports, requires])];
|
|
415
|
+
if (separateInstall &&
|
|
416
|
+
imports === undefined &&
|
|
417
|
+
requires === undefined &&
|
|
418
|
+
(isBuiltin(specifier) || isPackageSpecifier(specifier)))
|
|
419
|
+
return [];
|
|
420
|
+
return undefined;
|
|
421
|
+
};
|
|
422
|
+
while (pending.length) {
|
|
423
|
+
context.signal?.throwIfAborted();
|
|
424
|
+
const path = resolve(pending.pop());
|
|
425
|
+
if (seen.has(path))
|
|
426
|
+
continue;
|
|
427
|
+
seen.add(path);
|
|
428
|
+
if (seen.size % 16 === 0)
|
|
429
|
+
await yieldTurn(undefined, context.signal === undefined ? undefined : { signal: context.signal });
|
|
430
|
+
const local = inventory.has(path);
|
|
431
|
+
if (within(libraryRoot, path)) {
|
|
432
|
+
if (librarySeen.has(path))
|
|
433
|
+
continue;
|
|
434
|
+
librarySeen.add(path);
|
|
435
|
+
}
|
|
436
|
+
if (local && !allowed.has(path))
|
|
437
|
+
return { independent: false, reason: "dependency" };
|
|
438
|
+
if (!local && !/\.d\.[cm]?ts$/iu.test(path))
|
|
439
|
+
return unknown;
|
|
440
|
+
const source = local
|
|
441
|
+
? texts.get(path)
|
|
442
|
+
: captured(() => dependencies.readCapturedFile(path));
|
|
443
|
+
if (source === undefined)
|
|
444
|
+
return unknown;
|
|
445
|
+
if (local && !separateInstall && /\.[cm]?jsx?$/iu.test(path))
|
|
446
|
+
return unknown;
|
|
447
|
+
if (local && /@jsx(?:ImportSource|Runtime|Frag)?\b/iu.test(source))
|
|
448
|
+
return unknown;
|
|
449
|
+
const pre = ts.preProcessFile(source, true, true);
|
|
450
|
+
charge(pre.importedFiles.length * 2 +
|
|
451
|
+
pre.referencedFiles.length +
|
|
452
|
+
pre.typeReferenceDirectives.length +
|
|
453
|
+
pre.libReferenceDirectives.length);
|
|
454
|
+
const tree = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true);
|
|
455
|
+
// Nonliteral module loaders and shadowed require are not a closed graph.
|
|
456
|
+
let unsafe = false;
|
|
457
|
+
const visit = (node) => {
|
|
458
|
+
if (!/\.d\.[cm]?ts$/iu.test(path) &&
|
|
459
|
+
ts.isIdentifier(node) &&
|
|
460
|
+
node.text === "require" &&
|
|
461
|
+
!(ts.isCallExpression(node.parent) &&
|
|
462
|
+
node.parent.expression === node &&
|
|
463
|
+
node.parent.arguments.length === 1 &&
|
|
464
|
+
ts.isStringLiteralLike(node.parent.arguments[0])))
|
|
465
|
+
unsafe = true;
|
|
466
|
+
if (ts.isCallExpression(node) &&
|
|
467
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword ||
|
|
468
|
+
(ts.isIdentifier(node.expression) &&
|
|
469
|
+
node.expression.text === "require")) &&
|
|
470
|
+
(node.arguments.length !== 1 ||
|
|
471
|
+
!ts.isStringLiteralLike(node.arguments[0])))
|
|
472
|
+
unsafe = true;
|
|
473
|
+
if (ts.isMetaProperty(node) &&
|
|
474
|
+
node.keywordToken === ts.SyntaxKind.ImportKeyword)
|
|
475
|
+
unsafe = true;
|
|
476
|
+
if (!unsafe)
|
|
477
|
+
ts.forEachChild(node, visit);
|
|
478
|
+
};
|
|
479
|
+
visit(tree);
|
|
480
|
+
if (unsafe)
|
|
481
|
+
return unknown;
|
|
482
|
+
for (const item of pre.importedFiles) {
|
|
483
|
+
const resolved = await resolveModule(item.fileName, path);
|
|
484
|
+
if (!resolved)
|
|
485
|
+
return unknown;
|
|
486
|
+
for (const path of resolved)
|
|
487
|
+
push(path);
|
|
488
|
+
}
|
|
489
|
+
for (const item of pre.referencedFiles) {
|
|
490
|
+
const target = resolve(dirname(path), item.fileName);
|
|
491
|
+
if (local
|
|
492
|
+
? !inventory.has(target)
|
|
493
|
+
: !captured(() => dependencies.packageFileExists(target)))
|
|
494
|
+
return unknown;
|
|
495
|
+
push(target);
|
|
496
|
+
}
|
|
497
|
+
for (const item of pre.typeReferenceDirectives) {
|
|
498
|
+
for (const mode of [
|
|
499
|
+
ts.ModuleKind.ESNext,
|
|
500
|
+
ts.ModuleKind.CommonJS,
|
|
501
|
+
]) {
|
|
502
|
+
charge();
|
|
503
|
+
const found = (await resolveSnapshotMetadata(() => ts.resolveTypeReferenceDirective(item.fileName, path, prepared, host, undefined, undefined, mode))).resolvedTypeReferenceDirective;
|
|
504
|
+
if (!found?.resolvedFileName) {
|
|
505
|
+
if (!separateInstall || !isPackageSpecifier(item.fileName))
|
|
506
|
+
return unknown;
|
|
507
|
+
}
|
|
508
|
+
else
|
|
509
|
+
push(found.resolvedFileName);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
for (const reference of pre.libReferenceDirectives) {
|
|
513
|
+
const name = reference.fileName.toLowerCase();
|
|
514
|
+
if (!/^[a-z0-9.]+$/u.test(name))
|
|
515
|
+
return unknown;
|
|
516
|
+
const file = library(`lib.${name}.d.ts`);
|
|
517
|
+
if (file === undefined)
|
|
518
|
+
return unknown;
|
|
519
|
+
if (file !== false)
|
|
520
|
+
push(file);
|
|
521
|
+
}
|
|
522
|
+
if (local &&
|
|
523
|
+
(options.jsx === ts.JsxEmit.ReactJSX ||
|
|
524
|
+
options.jsx === ts.JsxEmit.ReactJSXDev)) {
|
|
525
|
+
const runtime = await resolveModule(`${options.jsxImportSource ?? "react"}/${options.jsx === ts.JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}`, path);
|
|
526
|
+
if (!runtime)
|
|
527
|
+
return unknown;
|
|
528
|
+
for (const path of runtime)
|
|
529
|
+
push(path);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
136
532
|
}
|
|
137
|
-
return
|
|
533
|
+
return signature;
|
|
138
534
|
}
|
|
139
535
|
export async function proveCompilerWorkspaceIndependence(context, workspace) {
|
|
140
536
|
context.signal?.throwIfAborted();
|
|
@@ -154,40 +550,18 @@ export async function proveCompilerWorkspaceIndependence(context, workspace) {
|
|
|
154
550
|
const prefix = workspace.relativeRoot === "." ? "" : `${workspace.relativeRoot}/`;
|
|
155
551
|
if (changedPaths.some((path) => path.startsWith(prefix)))
|
|
156
552
|
return { independent: false, reason: "changed-input" };
|
|
157
|
-
return
|
|
553
|
+
return acquireCompilerProof(context.signal, async () => {
|
|
158
554
|
context.signal?.throwIfAborted();
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
owner = {
|
|
162
|
-
records: new Map(),
|
|
163
|
-
bytes: 0,
|
|
164
|
-
ids: new WeakMap(),
|
|
165
|
-
next: 0,
|
|
166
|
-
invalidated: false,
|
|
167
|
-
};
|
|
168
|
-
owners.set(context.targetInspection, owner);
|
|
169
|
-
}
|
|
170
|
-
const key = owner === undefined
|
|
171
|
-
? undefined
|
|
172
|
-
: JSON.stringify([
|
|
173
|
-
identity(owner, context.baselineInspection),
|
|
174
|
-
identity(owner, context.targetInspection),
|
|
175
|
-
identity(owner, context.changeSet),
|
|
176
|
-
workspace.relativeRoot,
|
|
177
|
-
context.repositoryRoot,
|
|
178
|
-
]);
|
|
179
|
-
const previous = key === undefined ? undefined : owner?.records.get(key);
|
|
180
|
-
if (previous !== undefined) {
|
|
555
|
+
const slot = compilerProofSlot(context, workspace.relativeRoot);
|
|
556
|
+
if (slot.previous !== undefined) {
|
|
181
557
|
try {
|
|
182
|
-
if (await
|
|
558
|
+
if (await validCompilerProof(slot.previous, context.signal))
|
|
183
559
|
return { independent: true, reason: "disjoint-inputs" };
|
|
184
560
|
}
|
|
185
561
|
catch {
|
|
186
562
|
context.signal?.throwIfAborted();
|
|
187
563
|
}
|
|
188
|
-
|
|
189
|
-
owner.records.delete(key);
|
|
190
|
-
owner.bytes -= JSON.stringify(previous).length * 2;
|
|
564
|
+
slot.invalidate(slot.previous);
|
|
191
565
|
}
|
|
192
566
|
try {
|
|
193
567
|
const dependencyContext = { repositoryRoot: context.repositoryRoot };
|
|
@@ -214,510 +588,19 @@ export async function proveCompilerWorkspaceIndependence(context, workspace) {
|
|
|
214
588
|
context.baselineInspection,
|
|
215
589
|
context.targetInspection,
|
|
216
590
|
]) {
|
|
217
|
-
context
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
let textBytes = 0;
|
|
231
|
-
const add = async (path, limit) => {
|
|
232
|
-
const remaining = Math.floor((8 * 1024 * 1024 - textBytes) / 2);
|
|
233
|
-
if (remaining <= 0)
|
|
234
|
-
throw new Error("Proof text limit");
|
|
235
|
-
const text = await read(inspection.snapshotRoot, path, Math.min(limit, remaining), context.signal);
|
|
236
|
-
textBytes += text.length * 2;
|
|
237
|
-
texts.set(resolve(inspection.snapshotRoot, path), text);
|
|
238
|
-
if (!changes.localNpmInputs.has(path))
|
|
239
|
-
signature.set(path, hash(text));
|
|
240
|
-
witnesses.push({
|
|
241
|
-
root: inspection.snapshotRoot,
|
|
242
|
-
path,
|
|
243
|
-
digest: hash(text),
|
|
244
|
-
limit,
|
|
245
|
-
});
|
|
246
|
-
return text;
|
|
247
|
-
};
|
|
248
|
-
for (const path of inputs.inputPaths)
|
|
249
|
-
await add(path, side.sourceFiles.includes(path) ? 1024 * 1024 : 64 * 1024);
|
|
250
|
-
// The production host can see all captured repository source files. Resolve
|
|
251
|
-
// their names too; an edge outside this workspace prevents narrowing.
|
|
252
|
-
const inventory = new Set(inspection.workspaces
|
|
253
|
-
.flatMap((w) => w.sourceFiles)
|
|
254
|
-
.map((p) => resolve(inspection.snapshotRoot, p)));
|
|
255
|
-
for (const w of inspection.workspaces) {
|
|
256
|
-
inventory.add(resolve(inspection.snapshotRoot, w.manifestPath));
|
|
257
|
-
if (!texts.has(resolve(inspection.snapshotRoot, w.manifestPath)))
|
|
258
|
-
await add(w.manifestPath, 64 * 1024);
|
|
259
|
-
}
|
|
260
|
-
if (separateInstall) {
|
|
261
|
-
const roots = new Set([
|
|
262
|
-
side.relativeRoot,
|
|
263
|
-
...changedPaths.map((path) => path.split("/")[0]),
|
|
264
|
-
]);
|
|
265
|
-
for (const root of roots) {
|
|
266
|
-
if (!changes.separateNpmRoots.has(root))
|
|
267
|
-
return unknown;
|
|
268
|
-
const packageText = texts.get(resolve(inspection.snapshotRoot, root, "package.json"));
|
|
269
|
-
const packageManifest = JSON.parse(packageText ?? "null");
|
|
270
|
-
if (packageManifest === null ||
|
|
271
|
-
packageManifest.workspaces !== undefined)
|
|
272
|
-
return unknown;
|
|
273
|
-
const lock = JSON.parse(await add(`${root}/package-lock.json`, 2 * 1024 * 1024));
|
|
274
|
-
if (!lock?.packages ||
|
|
275
|
-
![2, 3].includes(lock.lockfileVersion) ||
|
|
276
|
-
Array.isArray(lock.packages) ||
|
|
277
|
-
typeof lock.packages !== "object")
|
|
278
|
-
return unknown;
|
|
279
|
-
for (const [path, entry] of Object.entries(lock.packages)) {
|
|
280
|
-
if (path !== "" &&
|
|
281
|
-
(!path.startsWith("node_modules/") ||
|
|
282
|
-
path.includes("\\") ||
|
|
283
|
-
path.split("/").some((part) => part === ".." || part === ".")))
|
|
284
|
-
return unknown;
|
|
285
|
-
if (typeof entry !== "object" ||
|
|
286
|
-
entry === null ||
|
|
287
|
-
("link" in entry && entry.link === true) ||
|
|
288
|
-
("resolved" in entry &&
|
|
289
|
-
typeof entry.resolved === "string" &&
|
|
290
|
-
/^(?:file:|link:|workspace:|[.\/])/iu.test(entry.resolved)))
|
|
291
|
-
return unknown;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// TypeScript may prefer a nested directory's package.json to index.ts.
|
|
296
|
-
// Inventory its possible presence before treating index files as a closed
|
|
297
|
-
// graph. Unsupported nested manifests retain full analyzer coverage.
|
|
298
|
-
const manifests = new Set();
|
|
299
|
-
for (const path of inventory) {
|
|
300
|
-
let directory = dirname(path);
|
|
301
|
-
while (within(inspection.snapshotRoot, directory)) {
|
|
302
|
-
manifests.add(relative(inspection.snapshotRoot, resolve(directory, "package.json"))
|
|
303
|
-
.split(sep)
|
|
304
|
-
.join("/"));
|
|
305
|
-
if (manifests.size > 4096)
|
|
306
|
-
throw new ProofLimit();
|
|
307
|
-
if (directory === inspection.snapshotRoot)
|
|
308
|
-
break;
|
|
309
|
-
directory = dirname(directory);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const knownManifests = new Set(inspection.workspaces.map((w) => w.manifestPath));
|
|
313
|
-
const absentPaths = new Set();
|
|
314
|
-
for (const path of manifests) {
|
|
315
|
-
if (knownManifests.has(path))
|
|
316
|
-
continue;
|
|
317
|
-
context.signal?.throwIfAborted();
|
|
318
|
-
const registry = await captureSnapshotRegistry(inspection.snapshotRoot, [path]);
|
|
319
|
-
if (registry.resolve(path) !== undefined ||
|
|
320
|
-
registry.entries().some((e) => e.kind === "symlink"))
|
|
321
|
-
return unknown;
|
|
322
|
-
witnesses.push({
|
|
323
|
-
root: inspection.snapshotRoot,
|
|
324
|
-
path,
|
|
325
|
-
limit: 64 * 1024,
|
|
326
|
-
});
|
|
327
|
-
absentPaths.add(resolve(inspection.snapshotRoot, path));
|
|
328
|
-
}
|
|
329
|
-
for (const path of texts.keys())
|
|
330
|
-
inventory.add(path);
|
|
331
|
-
const directories = new Set();
|
|
332
|
-
for (const path of inventory) {
|
|
333
|
-
let directory = dirname(path);
|
|
334
|
-
while (within(inspection.snapshotRoot, directory)) {
|
|
335
|
-
directories.add(directory);
|
|
336
|
-
if (directory === inspection.snapshotRoot)
|
|
337
|
-
break;
|
|
338
|
-
directory = dirname(directory);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
const snapshotFile = (path) => {
|
|
342
|
-
const absolute = resolve(path);
|
|
343
|
-
if (inventory.has(absolute))
|
|
344
|
-
return true;
|
|
345
|
-
if (!within(inspection.snapshotRoot, absolute) ||
|
|
346
|
-
relative(inspection.snapshotRoot, absolute)
|
|
347
|
-
.split(sep)
|
|
348
|
-
.includes("node_modules"))
|
|
349
|
-
return undefined;
|
|
350
|
-
if (!absentPaths.has(absolute))
|
|
351
|
-
throw new SnapshotLookup(absolute);
|
|
352
|
-
return false;
|
|
353
|
-
};
|
|
354
|
-
const snapshotDirectory = (path) => {
|
|
355
|
-
const absolute = resolve(path);
|
|
356
|
-
if (directories.has(absolute))
|
|
357
|
-
return true;
|
|
358
|
-
if (absentPaths.has(absolute))
|
|
359
|
-
return false;
|
|
360
|
-
if (within(inspection.snapshotRoot, absolute) &&
|
|
361
|
-
!relative(inspection.snapshotRoot, absolute)
|
|
362
|
-
.split(sep)
|
|
363
|
-
.includes("node_modules"))
|
|
364
|
-
throw new SnapshotLookup(absolute);
|
|
365
|
-
return undefined;
|
|
366
|
-
};
|
|
367
|
-
const snapshotRead = (path) => {
|
|
368
|
-
if (changes.localNpmInputs.has(relative(inspection.snapshotRoot, resolve(path))
|
|
369
|
-
.split(sep)
|
|
370
|
-
.join("/")))
|
|
371
|
-
throw Error("Resolution uses a changed package manifest");
|
|
372
|
-
snapshotFile(path);
|
|
373
|
-
return texts.get(resolve(path));
|
|
374
|
-
};
|
|
375
|
-
const resolveSnapshotMetadata = async (operation) => {
|
|
376
|
-
for (;;) {
|
|
377
|
-
context.signal?.throwIfAborted();
|
|
378
|
-
try {
|
|
379
|
-
return operation();
|
|
380
|
-
}
|
|
381
|
-
catch (error) {
|
|
382
|
-
if (!(error instanceof SnapshotLookup))
|
|
383
|
-
throw error;
|
|
384
|
-
charge();
|
|
385
|
-
const path = relative(inspection.snapshotRoot, error.path)
|
|
386
|
-
.split(sep)
|
|
387
|
-
.join("/");
|
|
388
|
-
const registry = await captureSnapshotRegistry(inspection.snapshotRoot, [path]);
|
|
389
|
-
context.signal?.throwIfAborted();
|
|
390
|
-
if (registry.entries().some((e) => e.kind === "symlink"))
|
|
391
|
-
throw Error("Unsupported resolution alias");
|
|
392
|
-
const entry = registry.resolve(path);
|
|
393
|
-
if (entry?.targetKind === "file")
|
|
394
|
-
throw Error("Unsupported resolution metadata");
|
|
395
|
-
if (entry?.targetKind === "directory") {
|
|
396
|
-
directories.add(error.path);
|
|
397
|
-
witnesses.push({
|
|
398
|
-
root: inspection.snapshotRoot,
|
|
399
|
-
path,
|
|
400
|
-
limit: 0,
|
|
401
|
-
directory: true,
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
absentPaths.add(error.path);
|
|
406
|
-
witnesses.push({
|
|
407
|
-
root: inspection.snapshotRoot,
|
|
408
|
-
path,
|
|
409
|
-
limit: 0,
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
const snapshotHost = {
|
|
416
|
-
fileExists: (path) => snapshotFile(path) ?? false,
|
|
417
|
-
readFile: snapshotRead,
|
|
418
|
-
directoryExists: (path) => snapshotDirectory(path) ?? false,
|
|
419
|
-
realpath: (path) => resolve(path),
|
|
420
|
-
};
|
|
421
|
-
const libraryRoot = dirname(ts.getDefaultLibFilePath({}));
|
|
422
|
-
const dependencyPath = (path) => within(context.repositoryRoot, resolve(path)) ||
|
|
423
|
-
within(libraryRoot, resolve(path));
|
|
424
|
-
const host = {
|
|
425
|
-
fileExists: (path) => snapshotFile(path) ??
|
|
426
|
-
(dependencyPath(path) &&
|
|
427
|
-
captured(() => dependencies.fileExists(path))),
|
|
428
|
-
readFile: (path) => snapshotRead(path) ??
|
|
429
|
-
(dependencyPath(path)
|
|
430
|
-
? captured(() => dependencies.readCapturedFile(path))
|
|
431
|
-
: undefined),
|
|
432
|
-
directoryExists: (path) => snapshotDirectory(path) ??
|
|
433
|
-
(within(context.repositoryRoot, resolve(path)) ||
|
|
434
|
-
(within(libraryRoot, resolve(path)) &&
|
|
435
|
-
captured(() => dependencies.directoryExists(path)))),
|
|
436
|
-
getDirectories: (path) => dependencyPath(path)
|
|
437
|
-
? captured(() => dependencies.getDirectories(path))
|
|
438
|
-
: [],
|
|
439
|
-
realpath: (path) => inventory.has(resolve(path))
|
|
440
|
-
? resolve(path)
|
|
441
|
-
: captured(() => dependencies.realpath(path)),
|
|
442
|
-
};
|
|
443
|
-
// Separately locked projects can prove their captured graph disjoint
|
|
444
|
-
// even if a package is absent. Shared installation layouts still
|
|
445
|
-
// require positive witnesses for all declared packages.
|
|
446
|
-
for (const w of separateInstall
|
|
447
|
-
? []
|
|
448
|
-
: inspection.workspaces.filter((w) => w.relativeRoot === "." ||
|
|
449
|
-
w.relativeRoot === side.relativeRoot ||
|
|
450
|
-
side.relativeRoot.startsWith(`${w.relativeRoot}/`)))
|
|
451
|
-
for (const declaration of w.dependencyDeclarations) {
|
|
452
|
-
let directory = resolve(context.repositoryRoot, side.relativeRoot), found = false;
|
|
453
|
-
while (within(context.repositoryRoot, directory)) {
|
|
454
|
-
charge();
|
|
455
|
-
if (captured(() => dependencies.fileExists(resolve(directory, "node_modules", declaration.name, "package.json")))) {
|
|
456
|
-
found = true;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
if (directory === resolve(context.repositoryRoot))
|
|
460
|
-
break;
|
|
461
|
-
directory = dirname(directory);
|
|
462
|
-
}
|
|
463
|
-
if (!found)
|
|
464
|
-
return unknown;
|
|
465
|
-
}
|
|
466
|
-
const allowed = new Set(side.sourceFiles.map((p) => resolve(inspection.snapshotRoot, p)));
|
|
467
|
-
for (const project of inputs.projects) {
|
|
468
|
-
const options = {
|
|
469
|
-
target: ts.ScriptTarget.ES2022,
|
|
470
|
-
module: ts.ModuleKind.NodeNext,
|
|
471
|
-
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
472
|
-
...project.options,
|
|
473
|
-
};
|
|
474
|
-
// Conditional NodeNext/CJS resolution requires usage-specific mode. Keep
|
|
475
|
-
// broad coverage until that variant has an explicit proof implementation.
|
|
476
|
-
if (options.moduleResolution !== ts.ModuleResolutionKind.Bundler &&
|
|
477
|
-
options.moduleResolution !== ts.ModuleResolutionKind.Node10) {
|
|
478
|
-
if (JSON.stringify(options.types) !== "[]")
|
|
479
|
-
return unknown;
|
|
480
|
-
for (const sourcePath of project.sourcePaths) {
|
|
481
|
-
const text = texts.get(resolve(inspection.snapshotRoot, sourcePath));
|
|
482
|
-
const pre = ts.preProcessFile(text, true, true);
|
|
483
|
-
if (pre.importedFiles.length ||
|
|
484
|
-
pre.referencedFiles.length ||
|
|
485
|
-
pre.typeReferenceDirectives.length ||
|
|
486
|
-
pre.libReferenceDirectives.length ||
|
|
487
|
-
/\.d\.[cm]?ts$/iu.test(sourcePath))
|
|
488
|
-
return unknown;
|
|
489
|
-
const tree = ts.createSourceFile(sourcePath, text, ts.ScriptTarget.Latest, true);
|
|
490
|
-
if (!ts.isExternalModule(tree))
|
|
491
|
-
return unknown;
|
|
492
|
-
let unsafe = false;
|
|
493
|
-
const visit = (node) => {
|
|
494
|
-
if (ts.isModuleDeclaration(node) || ts.isCallExpression(node))
|
|
495
|
-
unsafe = true;
|
|
496
|
-
if (!unsafe)
|
|
497
|
-
ts.forEachChild(node, visit);
|
|
498
|
-
};
|
|
499
|
-
visit(tree);
|
|
500
|
-
if (unsafe)
|
|
501
|
-
return unknown;
|
|
502
|
-
}
|
|
503
|
-
// Static source closure still needs the normal library witnesses.
|
|
504
|
-
}
|
|
505
|
-
if (options.plugins !== undefined ||
|
|
506
|
-
options.moduleSuffixes ||
|
|
507
|
-
options.rootDirs ||
|
|
508
|
-
options.noResolve ||
|
|
509
|
-
options.typeRoots ||
|
|
510
|
-
options.allowJs ||
|
|
511
|
-
options.importHelpers)
|
|
512
|
-
return unknown;
|
|
513
|
-
const typeRoots = [];
|
|
514
|
-
let directory = resolve(context.repositoryRoot, dirname(project.configPath));
|
|
515
|
-
while (within(context.repositoryRoot, directory)) {
|
|
516
|
-
typeRoots.push(resolve(directory, "node_modules/@types"));
|
|
517
|
-
if (directory === resolve(context.repositoryRoot))
|
|
518
|
-
break;
|
|
519
|
-
directory = dirname(directory);
|
|
520
|
-
}
|
|
521
|
-
const typeNames = options.types ?? [
|
|
522
|
-
...new Set(typeRoots.flatMap((root) => captured(() => dependencies.directoryEntries(root))
|
|
523
|
-
.filter((e) => e.type === "directory" && !e.name.startsWith("."))
|
|
524
|
-
.map((e) => e.name))),
|
|
525
|
-
];
|
|
526
|
-
const prepared = { ...options, typeRoots };
|
|
527
|
-
const pending = project.sourcePaths.map((path) => resolve(inspection.snapshotRoot, path));
|
|
528
|
-
const seen = new Set();
|
|
529
|
-
const push = (path) => {
|
|
530
|
-
if (!seen.has(path))
|
|
531
|
-
pending.push(path);
|
|
532
|
-
};
|
|
533
|
-
const library = (fileName) => {
|
|
534
|
-
charge();
|
|
535
|
-
if (!/^lib\.[a-z0-9.]+\.d\.ts$/u.test(fileName))
|
|
536
|
-
return undefined;
|
|
537
|
-
const name = fileName.slice(4, -5);
|
|
538
|
-
let directory = resolve(context.repositoryRoot, dirname(project.configPath));
|
|
539
|
-
while (within(context.repositoryRoot, directory)) {
|
|
540
|
-
if (captured(() => dependencies.fileExists(resolve(directory, "node_modules", `@typescript/lib-${name.split(".")[0]}`, "package.json"))))
|
|
541
|
-
return undefined;
|
|
542
|
-
if (directory === resolve(context.repositoryRoot))
|
|
543
|
-
break;
|
|
544
|
-
directory = dirname(directory);
|
|
545
|
-
}
|
|
546
|
-
const file = resolve(libraryRoot, fileName);
|
|
547
|
-
return captured(() => dependencies.fileExists(file))
|
|
548
|
-
? file
|
|
549
|
-
: separateInstall
|
|
550
|
-
? false
|
|
551
|
-
: undefined;
|
|
552
|
-
};
|
|
553
|
-
if (!options.noLib)
|
|
554
|
-
for (const name of options.lib ?? [
|
|
555
|
-
ts.getDefaultLibFileName(options),
|
|
556
|
-
]) {
|
|
557
|
-
const file = library(name);
|
|
558
|
-
if (file === undefined)
|
|
559
|
-
return unknown;
|
|
560
|
-
if (file !== false)
|
|
561
|
-
push(file);
|
|
562
|
-
}
|
|
563
|
-
for (const name of typeNames) {
|
|
564
|
-
charge();
|
|
565
|
-
const resolved = (await resolveSnapshotMetadata(() => ts.resolveTypeReferenceDirective(name, resolve(context.repositoryRoot, project.configPath), prepared, host))).resolvedTypeReferenceDirective;
|
|
566
|
-
if (!resolved?.resolvedFileName) {
|
|
567
|
-
if (!separateInstall || !isPackageSpecifier(name))
|
|
568
|
-
return unknown;
|
|
569
|
-
}
|
|
570
|
-
else
|
|
571
|
-
push(resolved.resolvedFileName);
|
|
572
|
-
}
|
|
573
|
-
const resolveOne = (specifier, from, mode) => {
|
|
574
|
-
charge();
|
|
575
|
-
const builtin = isBuiltin(specifier);
|
|
576
|
-
if (specifier.includes("\\") ||
|
|
577
|
-
(!builtin && /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(specifier)) ||
|
|
578
|
-
isAbsolute(specifier))
|
|
579
|
-
return undefined;
|
|
580
|
-
const local = ts.resolveModuleName(specifier, from, prepared, inventory.has(from) ? snapshotHost : host, undefined, undefined, mode).resolvedModule;
|
|
581
|
-
if (local !== undefined)
|
|
582
|
-
return local.resolvedFileName;
|
|
583
|
-
if (builtin) {
|
|
584
|
-
charge();
|
|
585
|
-
return ts.resolveTypeReferenceDirective("node", resolve(context.repositoryRoot, project.configPath), prepared, host).resolvedTypeReferenceDirective?.resolvedFileName;
|
|
586
|
-
}
|
|
587
|
-
if (specifier.startsWith("."))
|
|
588
|
-
return undefined;
|
|
589
|
-
const synthetic = dependencyResolutionContainingFile(context.repositoryRoot, inspection.snapshotRoot, from);
|
|
590
|
-
const installed = ts.resolveModuleName(specifier, synthetic, prepared, host, undefined, undefined, mode).resolvedModule;
|
|
591
|
-
return installed !== undefined &&
|
|
592
|
-
captured(() => dependencies.packageFileExists(installed.resolvedFileName))
|
|
593
|
-
? installed.resolvedFileName
|
|
594
|
-
: undefined;
|
|
595
|
-
};
|
|
596
|
-
const resolveModule = async (specifier, from) => {
|
|
597
|
-
const imports = await resolveSnapshotMetadata(() => resolveOne(specifier, from, ts.ModuleKind.ESNext));
|
|
598
|
-
const requires = await resolveSnapshotMetadata(() => resolveOne(specifier, from, ts.ModuleKind.CommonJS));
|
|
599
|
-
if (imports !== undefined && requires !== undefined)
|
|
600
|
-
return [...new Set([imports, requires])];
|
|
601
|
-
if (separateInstall &&
|
|
602
|
-
imports === undefined &&
|
|
603
|
-
requires === undefined &&
|
|
604
|
-
(isBuiltin(specifier) || isPackageSpecifier(specifier)))
|
|
605
|
-
return [];
|
|
606
|
-
return undefined;
|
|
607
|
-
};
|
|
608
|
-
while (pending.length) {
|
|
609
|
-
context.signal?.throwIfAborted();
|
|
610
|
-
const path = resolve(pending.pop());
|
|
611
|
-
if (seen.has(path))
|
|
612
|
-
continue;
|
|
613
|
-
seen.add(path);
|
|
614
|
-
if (seen.size % 16 === 0)
|
|
615
|
-
await yieldTurn(undefined, context.signal === undefined
|
|
616
|
-
? undefined
|
|
617
|
-
: { signal: context.signal });
|
|
618
|
-
const local = inventory.has(path);
|
|
619
|
-
if (within(libraryRoot, path)) {
|
|
620
|
-
if (librarySeen.has(path))
|
|
621
|
-
continue;
|
|
622
|
-
librarySeen.add(path);
|
|
623
|
-
}
|
|
624
|
-
if (local && !allowed.has(path))
|
|
625
|
-
return { independent: false, reason: "dependency" };
|
|
626
|
-
if (!local && !/\.d\.[cm]?ts$/iu.test(path))
|
|
627
|
-
return unknown;
|
|
628
|
-
const source = local
|
|
629
|
-
? texts.get(path)
|
|
630
|
-
: captured(() => dependencies.readCapturedFile(path));
|
|
631
|
-
if (source === undefined)
|
|
632
|
-
return unknown;
|
|
633
|
-
if (local && !separateInstall && /\.[cm]?jsx?$/iu.test(path))
|
|
634
|
-
return unknown;
|
|
635
|
-
if (local && /@jsx(?:ImportSource|Runtime|Frag)?\b/iu.test(source))
|
|
636
|
-
return unknown;
|
|
637
|
-
const pre = ts.preProcessFile(source, true, true);
|
|
638
|
-
charge(pre.importedFiles.length * 2 +
|
|
639
|
-
pre.referencedFiles.length +
|
|
640
|
-
pre.typeReferenceDirectives.length +
|
|
641
|
-
pre.libReferenceDirectives.length);
|
|
642
|
-
const tree = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true);
|
|
643
|
-
// Nonliteral module loaders and shadowed require are not a closed graph.
|
|
644
|
-
let unsafe = false;
|
|
645
|
-
const visit = (node) => {
|
|
646
|
-
if (!/\.d\.[cm]?ts$/iu.test(path) &&
|
|
647
|
-
ts.isIdentifier(node) &&
|
|
648
|
-
node.text === "require" &&
|
|
649
|
-
!(ts.isCallExpression(node.parent) &&
|
|
650
|
-
node.parent.expression === node &&
|
|
651
|
-
node.parent.arguments.length === 1 &&
|
|
652
|
-
ts.isStringLiteralLike(node.parent.arguments[0])))
|
|
653
|
-
unsafe = true;
|
|
654
|
-
if (ts.isCallExpression(node) &&
|
|
655
|
-
(node.expression.kind === ts.SyntaxKind.ImportKeyword ||
|
|
656
|
-
(ts.isIdentifier(node.expression) &&
|
|
657
|
-
node.expression.text === "require")) &&
|
|
658
|
-
(node.arguments.length !== 1 ||
|
|
659
|
-
!ts.isStringLiteralLike(node.arguments[0])))
|
|
660
|
-
unsafe = true;
|
|
661
|
-
if (ts.isMetaProperty(node) &&
|
|
662
|
-
node.keywordToken === ts.SyntaxKind.ImportKeyword)
|
|
663
|
-
unsafe = true;
|
|
664
|
-
if (!unsafe)
|
|
665
|
-
ts.forEachChild(node, visit);
|
|
666
|
-
};
|
|
667
|
-
visit(tree);
|
|
668
|
-
if (unsafe)
|
|
669
|
-
return unknown;
|
|
670
|
-
for (const item of pre.importedFiles) {
|
|
671
|
-
const resolved = await resolveModule(item.fileName, path);
|
|
672
|
-
if (!resolved)
|
|
673
|
-
return unknown;
|
|
674
|
-
for (const path of resolved)
|
|
675
|
-
push(path);
|
|
676
|
-
}
|
|
677
|
-
for (const item of pre.referencedFiles) {
|
|
678
|
-
const target = resolve(dirname(path), item.fileName);
|
|
679
|
-
if (local
|
|
680
|
-
? !inventory.has(target)
|
|
681
|
-
: !captured(() => dependencies.packageFileExists(target)))
|
|
682
|
-
return unknown;
|
|
683
|
-
push(target);
|
|
684
|
-
}
|
|
685
|
-
for (const item of pre.typeReferenceDirectives) {
|
|
686
|
-
for (const mode of [
|
|
687
|
-
ts.ModuleKind.ESNext,
|
|
688
|
-
ts.ModuleKind.CommonJS,
|
|
689
|
-
]) {
|
|
690
|
-
charge();
|
|
691
|
-
const found = (await resolveSnapshotMetadata(() => ts.resolveTypeReferenceDirective(item.fileName, path, prepared, host, undefined, undefined, mode))).resolvedTypeReferenceDirective;
|
|
692
|
-
if (!found?.resolvedFileName) {
|
|
693
|
-
if (!separateInstall || !isPackageSpecifier(item.fileName))
|
|
694
|
-
return unknown;
|
|
695
|
-
}
|
|
696
|
-
else
|
|
697
|
-
push(found.resolvedFileName);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
for (const reference of pre.libReferenceDirectives) {
|
|
701
|
-
const name = reference.fileName.toLowerCase();
|
|
702
|
-
if (!/^[a-z0-9.]+$/u.test(name))
|
|
703
|
-
return unknown;
|
|
704
|
-
const file = library(`lib.${name}.d.ts`);
|
|
705
|
-
if (file === undefined)
|
|
706
|
-
return unknown;
|
|
707
|
-
if (file !== false)
|
|
708
|
-
push(file);
|
|
709
|
-
}
|
|
710
|
-
if (local &&
|
|
711
|
-
(options.jsx === ts.JsxEmit.ReactJSX ||
|
|
712
|
-
options.jsx === ts.JsxEmit.ReactJSXDev)) {
|
|
713
|
-
const runtime = await resolveModule(`${options.jsxImportSource ?? "react"}/${options.jsx === ts.JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}`, path);
|
|
714
|
-
if (!runtime)
|
|
715
|
-
return unknown;
|
|
716
|
-
for (const path of runtime)
|
|
717
|
-
push(path);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
591
|
+
const signature = await captureWorkspaceSignature(inspection, workspace, context, {
|
|
592
|
+
changes,
|
|
593
|
+
separateInstall,
|
|
594
|
+
changedPaths,
|
|
595
|
+
dependencies,
|
|
596
|
+
captured,
|
|
597
|
+
witnesses,
|
|
598
|
+
charge,
|
|
599
|
+
librarySeen,
|
|
600
|
+
ts,
|
|
601
|
+
});
|
|
602
|
+
if (!(signature instanceof Map))
|
|
603
|
+
return signature;
|
|
721
604
|
signatures.push(signature);
|
|
722
605
|
}
|
|
723
606
|
if (signatures[0].size !== signatures[1].size ||
|
|
@@ -742,20 +625,15 @@ export async function proveCompilerWorkspaceIndependence(context, workspace) {
|
|
|
742
625
|
].some((prefix) => path.startsWith(prefix))))))
|
|
743
626
|
return unknown;
|
|
744
627
|
const record = {
|
|
745
|
-
key: key
|
|
628
|
+
key: slot.key,
|
|
746
629
|
manifest,
|
|
747
630
|
context: dependencyContext,
|
|
748
631
|
witnesses,
|
|
749
632
|
};
|
|
750
|
-
if (!(await
|
|
633
|
+
if (!(await validCompilerProof(record, context.signal)))
|
|
751
634
|
return unknown;
|
|
752
|
-
if (
|
|
753
|
-
|
|
754
|
-
if (owner.records.size >= 256 || owner.bytes + bytes > 32 * 1024 * 1024)
|
|
755
|
-
return { independent: false, reason: "limit" };
|
|
756
|
-
owner.records.set(key, record);
|
|
757
|
-
owner.bytes += bytes;
|
|
758
|
-
}
|
|
635
|
+
if (!slot.retain(record))
|
|
636
|
+
return { independent: false, reason: "limit" };
|
|
759
637
|
return { independent: true, reason: "disjoint-inputs" };
|
|
760
638
|
}
|
|
761
639
|
catch (error) {
|