@ttsc/unplugin 0.34.0 → 0.34.2
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/README.md +1 -0
- package/lib/api.js +4 -0
- package/lib/api.js.map +1 -1
- package/lib/api.mjs +2 -0
- package/lib/api.mjs.map +1 -1
- package/lib/core/bridge/TtscProjectRecord.d.cts +4 -1
- package/lib/core/bridge/TtscProjectRecord.d.mts +4 -1
- package/lib/core/bridge/TtscProjectRecord.d.ts +4 -1
- package/lib/core/bridge/projectRecordArgumentsMatch.d.cts +18 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.d.mts +18 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.d.ts +18 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.js +36 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.js.map +1 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.mjs +34 -0
- package/lib/core/bridge/projectRecordArgumentsMatch.mjs.map +1 -0
- package/lib/core/bridge/projectRecordMoved.d.cts +14 -12
- package/lib/core/bridge/projectRecordMoved.d.mts +14 -12
- package/lib/core/bridge/projectRecordMoved.d.ts +14 -12
- package/lib/core/bridge/projectRecordMoved.js +17 -12
- package/lib/core/bridge/projectRecordMoved.js.map +1 -1
- package/lib/core/bridge/projectRecordMoved.mjs +17 -12
- package/lib/core/bridge/projectRecordMoved.mjs.map +1 -1
- package/lib/core/bridge/readProjectRecordFile.d.cts +4 -3
- package/lib/core/bridge/readProjectRecordFile.d.mts +4 -3
- package/lib/core/bridge/readProjectRecordFile.d.ts +4 -3
- package/lib/core/bridge/readProjectRecordFile.js +26 -3
- package/lib/core/bridge/readProjectRecordFile.js.map +1 -1
- package/lib/core/bridge/readProjectRecordFile.mjs +26 -3
- package/lib/core/bridge/readProjectRecordFile.mjs.map +1 -1
- package/lib/core/bridge/refreshProjectRecordFile.d.cts +3 -2
- package/lib/core/bridge/refreshProjectRecordFile.d.mts +3 -2
- package/lib/core/bridge/refreshProjectRecordFile.d.ts +3 -2
- package/lib/core/bridge/refreshProjectRecordFile.js +9 -3
- package/lib/core/bridge/refreshProjectRecordFile.js.map +1 -1
- package/lib/core/bridge/refreshProjectRecordFile.mjs +9 -3
- package/lib/core/bridge/refreshProjectRecordFile.mjs.map +1 -1
- package/lib/core/bridge/refreshProjectRecordFiles.d.cts +1 -1
- package/lib/core/bridge/refreshProjectRecordFiles.d.mts +1 -1
- package/lib/core/bridge/refreshProjectRecordFiles.d.ts +1 -1
- package/lib/core/bridge/refreshProjectRecordFiles.js +2 -2
- package/lib/core/bridge/refreshProjectRecordFiles.js.map +1 -1
- package/lib/core/bridge/refreshProjectRecordFiles.mjs +2 -2
- package/lib/core/bridge/refreshProjectRecordFiles.mjs.map +1 -1
- package/lib/core/index.d.cts +2 -0
- package/lib/core/index.d.mts +2 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +2 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/next/next.js +5 -2
- package/lib/core/next/next.js.map +1 -1
- package/lib/core/next/next.mjs +5 -2
- package/lib/core/next/next.mjs.map +1 -1
- package/lib/core/options/ResolvedTtscUnpluginOptions.d.cts +2 -0
- package/lib/core/options/ResolvedTtscUnpluginOptions.d.mts +2 -0
- package/lib/core/options/ResolvedTtscUnpluginOptions.d.ts +2 -0
- package/lib/core/options/TtscUnpluginOptions.d.cts +8 -0
- package/lib/core/options/TtscUnpluginOptions.d.mts +8 -0
- package/lib/core/options/TtscUnpluginOptions.d.ts +8 -0
- package/lib/core/options/resolveOptions.d.cts +4 -3
- package/lib/core/options/resolveOptions.d.mts +4 -3
- package/lib/core/options/resolveOptions.d.ts +4 -3
- package/lib/core/options/resolveOptions.js +5 -3
- package/lib/core/options/resolveOptions.js.map +1 -1
- package/lib/core/options/resolveOptions.mjs +5 -3
- package/lib/core/options/resolveOptions.mjs.map +1 -1
- package/lib/core/rollup/rollupDeliveryOptions.d.cts +6 -6
- package/lib/core/rollup/rollupDeliveryOptions.d.mts +6 -6
- package/lib/core/rollup/rollupDeliveryOptions.d.ts +6 -6
- package/lib/core/rollup/rollupDeliveryOptions.js +9 -6
- package/lib/core/rollup/rollupDeliveryOptions.js.map +1 -1
- package/lib/core/rollup/rollupDeliveryOptions.mjs +9 -6
- package/lib/core/rollup/rollupDeliveryOptions.mjs.map +1 -1
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.d.cts +10 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.d.mts +10 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.d.ts +10 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.js +13 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.js.map +1 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.mjs +11 -0
- package/lib/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.mjs.map +1 -0
- package/lib/core/transform/cache/TtscCachedProjectTransform.d.cts +6 -0
- package/lib/core/transform/cache/TtscCachedProjectTransform.d.mts +6 -0
- package/lib/core/transform/cache/TtscCachedProjectTransform.d.ts +6 -0
- package/lib/core/transform/cache/createTransformCacheKey.d.cts +11 -8
- package/lib/core/transform/cache/createTransformCacheKey.d.mts +11 -8
- package/lib/core/transform/cache/createTransformCacheKey.d.ts +11 -8
- package/lib/core/transform/cache/createTransformCacheKey.js +11 -8
- package/lib/core/transform/cache/createTransformCacheKey.js.map +1 -1
- package/lib/core/transform/cache/createTransformCacheKey.mjs +11 -8
- package/lib/core/transform/cache/createTransformCacheKey.mjs.map +1 -1
- package/lib/core/transform/generation/TtscCompilerMembershipHint.d.cts +20 -0
- package/lib/core/transform/generation/TtscCompilerMembershipHint.d.mts +20 -0
- package/lib/core/transform/generation/TtscCompilerMembershipHint.d.ts +20 -0
- package/lib/core/transform/generation/applyCompilerMembership.d.cts +15 -0
- package/lib/core/transform/generation/applyCompilerMembership.d.mts +15 -0
- package/lib/core/transform/generation/applyCompilerMembership.d.ts +15 -0
- package/lib/core/transform/generation/applyCompilerMembership.js +41 -0
- package/lib/core/transform/generation/applyCompilerMembership.js.map +1 -0
- package/lib/core/transform/generation/applyCompilerMembership.mjs +39 -0
- package/lib/core/transform/generation/applyCompilerMembership.mjs.map +1 -0
- package/lib/core/transform/generation/captureTransformGeneration.d.cts +7 -0
- package/lib/core/transform/generation/captureTransformGeneration.d.mts +7 -0
- package/lib/core/transform/generation/captureTransformGeneration.d.ts +7 -0
- package/lib/core/transform/generation/captureTransformGeneration.js +20 -7
- package/lib/core/transform/generation/captureTransformGeneration.js.map +1 -1
- package/lib/core/transform/generation/captureTransformGeneration.mjs +20 -7
- package/lib/core/transform/generation/captureTransformGeneration.mjs.map +1 -1
- package/lib/core/transform/generation/onlyLearnedCompileFacts.d.cts +5 -5
- package/lib/core/transform/generation/onlyLearnedCompileFacts.d.mts +5 -5
- package/lib/core/transform/generation/onlyLearnedCompileFacts.d.ts +5 -5
- package/lib/core/transform/generation/onlyLearnedCompileFacts.js +7 -5
- package/lib/core/transform/generation/onlyLearnedCompileFacts.js.map +1 -1
- package/lib/core/transform/generation/onlyLearnedCompileFacts.mjs +7 -5
- package/lib/core/transform/generation/onlyLearnedCompileFacts.mjs.map +1 -1
- package/lib/core/transform/generation/primeCompilerMembership.d.cts +22 -0
- package/lib/core/transform/generation/primeCompilerMembership.d.mts +22 -0
- package/lib/core/transform/generation/primeCompilerMembership.d.ts +22 -0
- package/lib/core/transform/generation/primeCompilerMembership.js +32 -0
- package/lib/core/transform/generation/primeCompilerMembership.js.map +1 -0
- package/lib/core/transform/generation/primeCompilerMembership.mjs +30 -0
- package/lib/core/transform/generation/primeCompilerMembership.mjs.map +1 -0
- package/lib/core/transform/generation/selectReportedMembershipPolicy.d.cts +7 -7
- package/lib/core/transform/generation/selectReportedMembershipPolicy.d.mts +7 -7
- package/lib/core/transform/generation/selectReportedMembershipPolicy.d.ts +7 -7
- package/lib/core/transform/generation/selectReportedMembershipPolicy.js +43 -9
- package/lib/core/transform/generation/selectReportedMembershipPolicy.js.map +1 -1
- package/lib/core/transform/generation/selectReportedMembershipPolicy.mjs +43 -9
- package/lib/core/transform/generation/selectReportedMembershipPolicy.mjs.map +1 -1
- package/lib/core/transform/generation/transformProject.d.cts +7 -0
- package/lib/core/transform/generation/transformProject.d.mts +7 -0
- package/lib/core/transform/generation/transformProject.d.ts +7 -0
- package/lib/core/transform/generation/transformProject.js +3 -0
- package/lib/core/transform/generation/transformProject.js.map +1 -1
- package/lib/core/transform/generation/transformProject.mjs +3 -0
- package/lib/core/transform/generation/transformProject.mjs.map +1 -1
- package/lib/core/transform/project/isPossibleProgramFileName.d.cts +13 -11
- package/lib/core/transform/project/isPossibleProgramFileName.d.mts +13 -11
- package/lib/core/transform/project/isPossibleProgramFileName.d.ts +13 -11
- package/lib/core/transform/project/isPossibleProgramFileName.js +21 -13
- package/lib/core/transform/project/isPossibleProgramFileName.js.map +1 -1
- package/lib/core/transform/project/isPossibleProgramFileName.mjs +21 -13
- package/lib/core/transform/project/isPossibleProgramFileName.mjs.map +1 -1
- package/lib/core/transform/session/sharedCompileIdentity.d.cts +8 -5
- package/lib/core/transform/session/sharedCompileIdentity.d.mts +8 -5
- package/lib/core/transform/session/sharedCompileIdentity.d.ts +8 -5
- package/lib/core/transform/session/sharedCompileIdentity.js +8 -5
- package/lib/core/transform/session/sharedCompileIdentity.js.map +1 -1
- package/lib/core/transform/session/sharedCompileIdentity.mjs +8 -5
- package/lib/core/transform/session/sharedCompileIdentity.mjs.map +1 -1
- package/lib/core/transform/transformTtsc.js +18 -0
- package/lib/core/transform/transformTtsc.js.map +1 -1
- package/lib/core/transform/transformTtsc.mjs +18 -0
- package/lib/core/transform/transformTtsc.mjs.map +1 -1
- package/lib/core/transform/tsconfig/TtscCompilerArgumentsWitness.d.cts +19 -0
- package/lib/core/transform/tsconfig/TtscCompilerArgumentsWitness.d.mts +19 -0
- package/lib/core/transform/tsconfig/TtscCompilerArgumentsWitness.d.ts +19 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.d.cts +14 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.d.mts +14 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.d.ts +14 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.js +26 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.js.map +1 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.mjs +24 -0
- package/lib/core/transform/tsconfig/captureCompilerArguments.mjs.map +1 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.d.cts +13 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.d.mts +13 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.d.ts +13 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.js +23 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.js.map +1 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.mjs +21 -0
- package/lib/core/transform/tsconfig/compilerEnvironmentIdentity.mjs.map +1 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.d.cts +17 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.d.mts +17 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.d.ts +17 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.js +57 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.js.map +1 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.mjs +55 -0
- package/lib/core/transform/tsconfig/resolveCompilerEnvironment.mjs.map +1 -0
- package/lib/core/transform/tsconfig/transformScratchEnvironment.d.cts +6 -6
- package/lib/core/transform/tsconfig/transformScratchEnvironment.d.mts +6 -6
- package/lib/core/transform/tsconfig/transformScratchEnvironment.d.ts +6 -6
- package/lib/core/transform/tsconfig/transformScratchEnvironment.js +7 -7
- package/lib/core/transform/tsconfig/transformScratchEnvironment.js.map +1 -1
- package/lib/core/transform/tsconfig/transformScratchEnvironment.mjs +7 -7
- package/lib/core/transform/tsconfig/transformScratchEnvironment.mjs.map +1 -1
- package/lib/core/transform/watch/notifyProjectRecord.js +3 -0
- package/lib/core/transform/watch/notifyProjectRecord.js.map +1 -1
- package/lib/core/transform/watch/notifyProjectRecord.mjs +3 -0
- package/lib/core/transform/watch/notifyProjectRecord.mjs.map +1 -1
- package/lib/core/tsconfig/ITtscProjectMembershipPolicy.d.cts +14 -1
- package/lib/core/tsconfig/ITtscProjectMembershipPolicy.d.mts +14 -1
- package/lib/core/tsconfig/ITtscProjectMembershipPolicy.d.ts +14 -1
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.d.cts +4 -3
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.d.mts +4 -3
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.d.ts +4 -3
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.js +36 -6
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.js.map +1 -1
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.mjs +36 -6
- package/lib/core/tsconfig/mergeMembershipPolicyOverlay.mjs.map +1 -1
- package/lib/core/tsconfig/readProjectMembershipPolicy.d.cts +3 -2
- package/lib/core/tsconfig/readProjectMembershipPolicy.d.mts +3 -2
- package/lib/core/tsconfig/readProjectMembershipPolicy.d.ts +3 -2
- package/lib/core/tsconfig/readProjectMembershipPolicy.js +49 -15
- package/lib/core/tsconfig/readProjectMembershipPolicy.js.map +1 -1
- package/lib/core/tsconfig/readProjectMembershipPolicy.mjs +49 -15
- package/lib/core/tsconfig/readProjectMembershipPolicy.mjs.map +1 -1
- package/lib/core/tsconfig/resolveMembershipInputExtensions.d.cts +16 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.d.mts +16 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.d.ts +16 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.js +45 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.js.map +1 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.mjs +43 -0
- package/lib/core/tsconfig/resolveMembershipInputExtensions.mjs.map +1 -0
- package/lib/core/turbopack/turbopack.d.cts +2 -2
- package/lib/core/turbopack/turbopack.d.mts +2 -2
- package/lib/core/turbopack/turbopack.d.ts +2 -2
- package/lib/core/turbopack/turbopack.js +15 -7
- package/lib/core/turbopack/turbopack.js.map +1 -1
- package/lib/core/turbopack/turbopack.mjs +15 -7
- package/lib/core/turbopack/turbopack.mjs.map +1 -1
- package/lib/core/unplugin.js +21 -8
- package/lib/core/unplugin.js.map +1 -1
- package/lib/core/unplugin.mjs +21 -8
- package/lib/core/unplugin.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/bridge/TtscProjectRecord.ts +4 -1
- package/src/core/bridge/projectRecordArgumentsMatch.ts +37 -0
- package/src/core/bridge/projectRecordMoved.ts +17 -11
- package/src/core/bridge/readProjectRecordFile.ts +39 -3
- package/src/core/bridge/refreshProjectRecordFile.ts +9 -2
- package/src/core/bridge/refreshProjectRecordFiles.ts +7 -1
- package/src/core/index.ts +2 -0
- package/src/core/next/next.ts +18 -2
- package/src/core/options/ResolvedTtscUnpluginOptions.ts +3 -0
- package/src/core/options/TtscUnpluginOptions.ts +9 -0
- package/src/core/options/resolveOptions.ts +5 -3
- package/src/core/rollup/rollupDeliveryOptions.ts +9 -5
- package/src/core/transform/cache/TRANSFORM_CACHE_MEMBERSHIP_POLICIES.ts +14 -0
- package/src/core/transform/cache/TtscCachedProjectTransform.ts +7 -0
- package/src/core/transform/cache/createTransformCacheKey.ts +13 -8
- package/src/core/transform/generation/TtscCompilerMembershipHint.ts +24 -0
- package/src/core/transform/generation/applyCompilerMembership.ts +44 -0
- package/src/core/transform/generation/captureTransformGeneration.ts +43 -10
- package/src/core/transform/generation/onlyLearnedCompileFacts.ts +7 -5
- package/src/core/transform/generation/primeCompilerMembership.ts +39 -0
- package/src/core/transform/generation/selectReportedMembershipPolicy.ts +59 -13
- package/src/core/transform/generation/transformProject.ts +12 -0
- package/src/core/transform/project/isPossibleProgramFileName.ts +28 -15
- package/src/core/transform/session/sharedCompileIdentity.ts +10 -5
- package/src/core/transform/transformTtsc.ts +21 -0
- package/src/core/transform/tsconfig/TtscCompilerArgumentsWitness.ts +19 -0
- package/src/core/transform/tsconfig/captureCompilerArguments.ts +25 -0
- package/src/core/transform/tsconfig/compilerEnvironmentIdentity.ts +20 -0
- package/src/core/transform/tsconfig/resolveCompilerEnvironment.ts +61 -0
- package/src/core/transform/tsconfig/transformScratchEnvironment.ts +7 -6
- package/src/core/transform/watch/notifyProjectRecord.ts +3 -0
- package/src/core/tsconfig/ITtscProjectMembershipPolicy.ts +15 -1
- package/src/core/tsconfig/mergeMembershipPolicyOverlay.ts +31 -6
- package/src/core/tsconfig/readProjectMembershipPolicy.ts +61 -17
- package/src/core/tsconfig/resolveMembershipInputExtensions.ts +45 -0
- package/src/core/turbopack/turbopack.ts +27 -7
- package/src/core/unplugin.ts +34 -9
|
@@ -5,26 +5,29 @@ import { walkProjectInputs } from "../transform/project/walkProjectInputs";
|
|
|
5
5
|
import { watchInputEvidenceMatchesDisk } from "../transform/watch/watchInputEvidenceMatchesDisk";
|
|
6
6
|
import type { TtscProjectRecord } from "./TtscProjectRecord";
|
|
7
7
|
import { membershipRecordDigest } from "./membershipRecordDigest";
|
|
8
|
+
import { projectRecordArgumentsMatch } from "./projectRecordArgumentsMatch";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* The first recorded input or membership state that current replay
|
|
11
|
-
* establish as unchanged, or nothing when all recorded checks hold. This
|
|
12
|
-
* proof a build start makes of a record (`refreshProjectRecordFiles`),
|
|
11
|
+
* The first invocation, recorded input or membership state that current replay
|
|
12
|
+
* cannot establish as unchanged, or nothing when all recorded checks hold. This
|
|
13
|
+
* is the proof a build start makes of a record (`refreshProjectRecordFiles`),
|
|
13
14
|
* separable from the move it follows with, so a harness or a maintainer can ask
|
|
14
15
|
* the same question of a record without moving it.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* The captured invocation must match the active context before each recorded
|
|
18
|
+
* input is proven against the disk the way a delivery proves a generation
|
|
19
|
+
* (`watchInputEvidenceMatchesDisk`), and the walk is run again under the
|
|
20
|
+
* recorded policy and its digest compared (`membershipRecordDigest`). A plugin
|
|
21
|
+
* source is proven by the metadata of its files where that metadata holds
|
|
22
|
+
* (`pluginSourceFilesDigest`), which stands for their bytes only against a
|
|
23
|
+
* clock reference minted since any rollback, so the proof mints one first, as a
|
|
24
|
+
* delivery does. It holds no generation, so the reference is minted in the
|
|
23
25
|
* probe directory this process keeps (`refreshProcessClockReference`).
|
|
24
26
|
*
|
|
25
27
|
* @returns The tsconfig when it is gone, which a build start answers by
|
|
26
28
|
* removing the record rather than moving it, the first input whose state
|
|
27
|
-
* moved, the project root when
|
|
29
|
+
* moved, the project root when invocation or root membership differs, or
|
|
30
|
+
* `undefined`.
|
|
28
31
|
* @evidence contracts/common.md#principled-implementation
|
|
29
32
|
* Each codec is re-proved against the same filesystem view and membership is
|
|
30
33
|
* re-walked under the stored policy. A fresh process clock reference prevents
|
|
@@ -56,8 +59,11 @@ import { membershipRecordDigest } from "./membershipRecordDigest";
|
|
|
56
59
|
export function projectRecordMoved(
|
|
57
60
|
record: TtscProjectRecord,
|
|
58
61
|
filesystem: TtscTransformFilesystemOperations = DEFAULT_FILESYSTEM_OPERATIONS,
|
|
62
|
+
compilerArgumentsIdentity?: string,
|
|
59
63
|
): string | undefined {
|
|
60
64
|
if (!filesystem.exists(record.tsconfig)) return record.tsconfig;
|
|
65
|
+
if (!projectRecordArgumentsMatch(record, compilerArgumentsIdentity))
|
|
66
|
+
return record.root;
|
|
61
67
|
refreshProcessClockReference(record.root, filesystem);
|
|
62
68
|
for (const [input, evidence] of Object.entries(record.inputs)) {
|
|
63
69
|
if (evidence === null || typeof evidence !== "object") return input;
|
|
@@ -10,9 +10,10 @@ import type { TtscProjectRecord } from "./TtscProjectRecord";
|
|
|
10
10
|
* run over it (`refreshProjectRecordFiles`), and the next generation's delivery
|
|
11
11
|
* writes it whole.
|
|
12
12
|
*
|
|
13
|
-
* Validate consumed input codecs and
|
|
14
|
-
* parsed record. A JSON object header
|
|
15
|
-
* can safely interpret its nested
|
|
13
|
+
* Validate the optional invocation witness, consumed input codecs and
|
|
14
|
+
* membership policy before exposing the parsed record. A JSON object header
|
|
15
|
+
* alone does not establish that observers can safely interpret its nested
|
|
16
|
+
* evidence.
|
|
16
17
|
*
|
|
17
18
|
* @evidence contracts/common.md#principled-implementation Structural guards validate the record, every consumed input codec and membership policy; predicate proof uses the existing producer-schema normalizer rather than inventing missing observations.
|
|
18
19
|
* @evidence contracts/common.md#clear-and-simple-design This disk boundary owns untrusted JSON parsing and small schema predicates; filesystem replay and state-change decisions remain with the existing record consumers.
|
|
@@ -48,11 +49,16 @@ export function readProjectRecordFile(
|
|
|
48
49
|
!Number.isFinite(candidate.signal) ||
|
|
49
50
|
!isInputEvidenceMap(candidate.inputs) ||
|
|
50
51
|
!isMembership(candidate.membership) ||
|
|
52
|
+
(candidate.compilerArguments !== undefined &&
|
|
53
|
+
!isCompilerArguments(candidate.compilerArguments)) ||
|
|
51
54
|
(candidate.dependencies !== undefined && !isStrings(candidate.dependencies))
|
|
52
55
|
) {
|
|
53
56
|
return undefined;
|
|
54
57
|
}
|
|
55
58
|
return {
|
|
59
|
+
...(candidate.compilerArguments === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: { compilerArguments: candidate.compilerArguments }),
|
|
56
62
|
...(candidate.dependencies === undefined
|
|
57
63
|
? {}
|
|
58
64
|
: { dependencies: candidate.dependencies }),
|
|
@@ -105,6 +111,23 @@ function isPolicy(value: unknown): boolean {
|
|
|
105
111
|
)
|
|
106
112
|
return false;
|
|
107
113
|
}
|
|
114
|
+
const extensionOrigins = value.extensionOptionOrigins;
|
|
115
|
+
if (
|
|
116
|
+
extensionOrigins !== undefined &&
|
|
117
|
+
(!isRecord(extensionOrigins) ||
|
|
118
|
+
!isStrings(extensionOrigins.mapperExtensions) ||
|
|
119
|
+
["allowJs", "checkJs", "resolveJsonModule"].some(
|
|
120
|
+
(key) =>
|
|
121
|
+
extensionOrigins[key] !== undefined &&
|
|
122
|
+
typeof extensionOrigins[key] !== "boolean",
|
|
123
|
+
) ||
|
|
124
|
+
["module", "moduleResolution"].some(
|
|
125
|
+
(key) =>
|
|
126
|
+
extensionOrigins[key] !== undefined &&
|
|
127
|
+
typeof extensionOrigins[key] !== "string",
|
|
128
|
+
))
|
|
129
|
+
)
|
|
130
|
+
return false;
|
|
108
131
|
const origins = value.directoryExclusionOrigins;
|
|
109
132
|
return (
|
|
110
133
|
origins === undefined ||
|
|
@@ -174,3 +197,16 @@ function isInputEvidenceMap(
|
|
|
174
197
|
): value is TtscProjectRecord["inputs"] {
|
|
175
198
|
return isRecord(value) && Object.values(value).every(isInputEvidence);
|
|
176
199
|
}
|
|
200
|
+
|
|
201
|
+
/** Argument transport identity and the explicit policy needed for replay. */
|
|
202
|
+
function isCompilerArguments(
|
|
203
|
+
value: unknown,
|
|
204
|
+
): value is NonNullable<TtscProjectRecord["compilerArguments"]> {
|
|
205
|
+
return (
|
|
206
|
+
isRecord(value) &&
|
|
207
|
+
typeof value.identity === "string" &&
|
|
208
|
+
/^[0-9a-f]{64}$/.test(value.identity) &&
|
|
209
|
+
(value.runExternalCode === undefined ||
|
|
210
|
+
typeof value.runExternalCode === "boolean")
|
|
211
|
+
);
|
|
212
|
+
}
|
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import { DEFAULT_FILESYSTEM_OPERATIONS } from "../transform/filesystem/DEFAULT_FILESYSTEM_OPERATIONS";
|
|
4
4
|
import type { TtscTransformFilesystemOperations } from "../transform/filesystem/TtscTransformFilesystemOperations";
|
|
5
5
|
import type { HostWatchBridge } from "./HostWatchBridge";
|
|
6
|
+
import { projectRecordArgumentsMatch } from "./projectRecordArgumentsMatch";
|
|
6
7
|
import { projectRecordMoved } from "./projectRecordMoved";
|
|
7
8
|
import { projectRecordWatchInputs } from "./projectRecordWatchInputs";
|
|
8
9
|
import { readProjectRecordFile } from "./readProjectRecordFile";
|
|
@@ -16,7 +17,8 @@ import { signalProjectRecordFile } from "./signalProjectRecordFile";
|
|
|
16
17
|
* A host restoring a module from its cache never runs the adapter for it, so
|
|
17
18
|
* the adapter cannot learn at delivery that an input moved, a root file
|
|
18
19
|
* appeared, or a tsconfig vanished while the host was stopped. It learns here:
|
|
19
|
-
*
|
|
20
|
+
* the captured compiler invocation must match the active context, then each
|
|
21
|
+
* recorded input is proven against the disk the way a delivery proves it
|
|
20
22
|
* (`watchInputEvidenceMatchesDisk`), and the walk is run again under the
|
|
21
23
|
* recorded policy and its digest compared. One mismatch moves the record
|
|
22
24
|
* (`signalProjectRecordFile`); the host, which recorded the file as a
|
|
@@ -69,6 +71,7 @@ export function refreshProjectRecordFile(
|
|
|
69
71
|
file: string,
|
|
70
72
|
bridge?: HostWatchBridge,
|
|
71
73
|
filesystem: TtscTransformFilesystemOperations = DEFAULT_FILESYSTEM_OPERATIONS,
|
|
74
|
+
compilerArgumentsIdentity?: string,
|
|
72
75
|
): void {
|
|
73
76
|
const record = readProjectRecordFile(file);
|
|
74
77
|
// A record that cannot be read proves nothing, and is moved as a proof that
|
|
@@ -98,6 +101,10 @@ export function refreshProjectRecordFile(
|
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
100
103
|
if (bridge !== undefined) {
|
|
104
|
+
if (!projectRecordArgumentsMatch(record, compilerArgumentsIdentity)) {
|
|
105
|
+
signalProjectRecordFile(file);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
101
108
|
bridge.register(file, projectRecordWatchInputs(record));
|
|
102
109
|
return;
|
|
103
110
|
}
|
|
@@ -106,7 +113,7 @@ export function refreshProjectRecordFile(
|
|
|
106
113
|
// a record the next proof can run over.
|
|
107
114
|
let moved: string | undefined;
|
|
108
115
|
try {
|
|
109
|
-
moved = projectRecordMoved(record, filesystem);
|
|
116
|
+
moved = projectRecordMoved(record, filesystem, compilerArgumentsIdentity);
|
|
110
117
|
} catch {
|
|
111
118
|
moved = record.root;
|
|
112
119
|
}
|
|
@@ -58,6 +58,7 @@ export function refreshProjectRecordFiles(
|
|
|
58
58
|
toolDirectory: string,
|
|
59
59
|
bridge?: HostWatchBridge,
|
|
60
60
|
filesystem: TtscTransformFilesystemOperations = DEFAULT_FILESYSTEM_OPERATIONS,
|
|
61
|
+
compilerArgumentsIdentity?: string,
|
|
61
62
|
): void {
|
|
62
63
|
const directory = path.join(toolDirectory, PROJECT_RECORD_DIRECTORY);
|
|
63
64
|
let names: string[];
|
|
@@ -68,6 +69,11 @@ export function refreshProjectRecordFiles(
|
|
|
68
69
|
}
|
|
69
70
|
for (const name of names) {
|
|
70
71
|
if (name.endsWith(".json"))
|
|
71
|
-
refreshProjectRecordFile(
|
|
72
|
+
refreshProjectRecordFile(
|
|
73
|
+
path.join(directory, name),
|
|
74
|
+
bridge,
|
|
75
|
+
filesystem,
|
|
76
|
+
compilerArgumentsIdentity,
|
|
77
|
+
);
|
|
72
78
|
}
|
|
73
79
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { collectProjectInputHashSnapshot } from "./transform/project/collectProj
|
|
|
27
27
|
export { isProjectWalkPath } from "./transform/project/isProjectWalkPath";
|
|
28
28
|
export type { TtscProjectInputHashSnapshot } from "./transform/project/TtscProjectInputHashSnapshot";
|
|
29
29
|
export { transformTtsc } from "./transform/transformTtsc";
|
|
30
|
+
export { compilerEnvironmentIdentity } from "./transform/tsconfig/compilerEnvironmentIdentity";
|
|
31
|
+
export { resolveCompilerEnvironment } from "./transform/tsconfig/resolveCompilerEnvironment";
|
|
30
32
|
export { captureWatchInputBaseline } from "./transform/watch/captureWatchInputBaseline";
|
|
31
33
|
export { captureWatchInputFileBaseline } from "./transform/watch/captureWatchInputFileBaseline";
|
|
32
34
|
export { isWatchInputKeyBaseline } from "./transform/watch/isWatchInputKeyBaseline";
|
package/src/core/next/next.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { refreshProjectRecordFiles } from "../bridge/refreshProjectRecordFiles";
|
|
|
8
8
|
import type { TtscUnpluginOptions } from "../options/TtscUnpluginOptions";
|
|
9
9
|
import { TYPESCRIPT_TURBOPACK_RULE_GLOBS } from "../source/TYPESCRIPT_TURBOPACK_RULE_GLOBS";
|
|
10
10
|
import { openTtscTransformSession } from "../transform/session/openTtscTransformSession";
|
|
11
|
+
import { captureCompilerArguments } from "../transform/tsconfig/captureCompilerArguments";
|
|
12
|
+
import { resolveCompilerEnvironment } from "../transform/tsconfig/resolveCompilerEnvironment";
|
|
11
13
|
import type { TtscTurbopackLoaderOptions } from "../turbopack/TtscTurbopackLoaderOptions";
|
|
12
14
|
import { unplugin } from "../unplugin";
|
|
13
15
|
import type { NextLikeConfig } from "./NextLikeConfig";
|
|
@@ -99,11 +101,25 @@ export function next(
|
|
|
99
101
|
// Before either compiler validates a module against the cache below
|
|
100
102
|
// `.next`: a project whose state moved while nothing ran is heard through
|
|
101
103
|
// its record, which only a proof here can move.
|
|
102
|
-
|
|
104
|
+
const compilerArguments = captureCompilerArguments(
|
|
105
|
+
resolveCompilerEnvironment(options?.runExternalCode),
|
|
106
|
+
).identity;
|
|
107
|
+
refreshProjectRecordFiles(
|
|
108
|
+
hostToolDirectory(process.cwd()),
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
compilerArguments,
|
|
112
|
+
);
|
|
103
113
|
// And where webpack's records live when that directory cannot be written
|
|
104
114
|
// (samchon/ttsc#1480); Turbopack's loader proves its own.
|
|
105
115
|
const fallback = fallbackToolDirectory(process.cwd());
|
|
106
|
-
if (fallback !== undefined)
|
|
116
|
+
if (fallback !== undefined)
|
|
117
|
+
refreshProjectRecordFiles(
|
|
118
|
+
fallback,
|
|
119
|
+
undefined,
|
|
120
|
+
undefined,
|
|
121
|
+
compilerArguments,
|
|
122
|
+
);
|
|
107
123
|
return {
|
|
108
124
|
...nextConfig,
|
|
109
125
|
turbopack: withTtscTurbopackRules(nextConfig.turbopack, options),
|
|
@@ -43,6 +43,9 @@ export interface ResolvedTtscUnpluginOptions {
|
|
|
43
43
|
/** Compiler-options overlay applied on top of the discovered tsconfig. */
|
|
44
44
|
compilerOptions: TtscUnpluginCompilerOptionsJson;
|
|
45
45
|
|
|
46
|
+
/** Explicit invocation permission; omission retains inherited arguments. */
|
|
47
|
+
runExternalCode?: boolean;
|
|
48
|
+
|
|
46
49
|
/**
|
|
47
50
|
* Resolved plugin list; mirrors the semantics of
|
|
48
51
|
* `TtscUnpluginOptions.plugins`.
|
|
@@ -69,6 +69,15 @@ export interface TtscUnpluginOptions {
|
|
|
69
69
|
*/
|
|
70
70
|
compilerOptions?: TtscUnpluginCompilerOptionsJson;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Allow the selected TypeScript 7.1 compiler to execute content mappers.
|
|
74
|
+
*
|
|
75
|
+
* This invocation's explicit value overrides inherited `TTSC_TSGO_ARGS`
|
|
76
|
+
* permission without changing `process.env`. Omission retains inherited
|
|
77
|
+
* arguments. TypeScript 7.0 rejects this option's compiler flag.
|
|
78
|
+
*/
|
|
79
|
+
runExternalCode?: boolean;
|
|
80
|
+
|
|
72
81
|
/**
|
|
73
82
|
* `ttsc` plugin entries.
|
|
74
83
|
*
|
|
@@ -11,9 +11,10 @@ const defaultOptions: ResolvedTtscUnpluginOptions = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Normalise raw user-supplied options into {@link ResolvedTtscUnpluginOptions}.
|
|
13
13
|
*
|
|
14
|
-
* Merges provided values with defaults
|
|
15
|
-
*
|
|
16
|
-
* `plugins: false` (disable
|
|
14
|
+
* Merges provided values with defaults, preserving an explicit false mapper
|
|
15
|
+
* permission. The `plugins` field uses an explicit `"plugins" in options`
|
|
16
|
+
* presence check rather than a falsy guard so that `plugins: false` (disable
|
|
17
|
+
* all plugins) is preserved as-is.
|
|
17
18
|
*
|
|
18
19
|
* @evidence contracts/common.md#principled-implementation
|
|
19
20
|
* Nullish defaults normalize the overlay and project; a presence check
|
|
@@ -48,6 +49,7 @@ export function resolveOptions(
|
|
|
48
49
|
precompile:
|
|
49
50
|
options.precompile === undefined ? undefined : [...options.precompile],
|
|
50
51
|
compilerOptions: { ...(options.compilerOptions ?? {}) },
|
|
52
|
+
runExternalCode: options.runExternalCode,
|
|
51
53
|
plugins: "plugins" in options ? options.plugins : defaultOptions.plugins,
|
|
52
54
|
project: options.project ?? defaultOptions.project,
|
|
53
55
|
projectRoot: options.projectRoot ?? defaultOptions.projectRoot,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
3
|
import type { ResolvedTtscUnpluginOptions } from "../options/ResolvedTtscUnpluginOptions";
|
|
4
|
+
import { compilerEnvironmentIdentity } from "../transform/tsconfig/compilerEnvironmentIdentity";
|
|
5
|
+
import { resolveCompilerEnvironment } from "../transform/tsconfig/resolveCompilerEnvironment";
|
|
4
6
|
import { hashText } from "../transform/utils/hashText";
|
|
5
7
|
import { stableStringify } from "../transform/utils/stableStringify";
|
|
6
8
|
|
|
@@ -9,11 +11,11 @@ import { stableStringify } from "../transform/utils/stableStringify";
|
|
|
9
11
|
* the module carries into Rollup's cache (`TtscRollupDelivery`).
|
|
10
12
|
*
|
|
11
13
|
* The identity records alias mappings, compiler overlay, plugin payloads and
|
|
12
|
-
* configured project
|
|
13
|
-
* represented separately by the delivery's
|
|
14
|
-
* resolves under the same native cwd rule
|
|
15
|
-
* canonicalized to a physical alias or made
|
|
16
|
-
* different cwd spellings.
|
|
14
|
+
* configured project/source-root selection and effective compiler argument
|
|
15
|
+
* transport. Tsconfig input state is represented separately by the delivery's
|
|
16
|
+
* project record. A configured project resolves under the same native cwd rule
|
|
17
|
+
* as explicit selection; it is not canonicalized to a physical alias or made
|
|
18
|
+
* process-independent across different cwd spellings.
|
|
17
19
|
*
|
|
18
20
|
* Compiler options, plugin payloads and alias mappings preserve their actual
|
|
19
21
|
* JSON order. Their consumers can observe declaration order; the host cannot
|
|
@@ -41,11 +43,13 @@ import { stableStringify } from "../transform/utils/stableStringify";
|
|
|
41
43
|
export function rollupDeliveryOptions(
|
|
42
44
|
options: ResolvedTtscUnpluginOptions,
|
|
43
45
|
aliasPaths: Record<string, string[]>,
|
|
46
|
+
compilerEnvironment = resolveCompilerEnvironment(options.runExternalCode),
|
|
44
47
|
): string {
|
|
45
48
|
return hashText(
|
|
46
49
|
stableStringify({
|
|
47
50
|
aliasPaths: JSON.stringify(aliasPaths),
|
|
48
51
|
compilerOptions: JSON.stringify(options.compilerOptions),
|
|
52
|
+
compilerEnvironment: compilerEnvironmentIdentity(compilerEnvironment),
|
|
49
53
|
plugins: JSON.stringify(options.plugins),
|
|
50
54
|
project:
|
|
51
55
|
options.project === undefined ? null : path.resolve(options.project),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TtscCompilerMembershipHint } from "../generation/TtscCompilerMembershipHint";
|
|
2
|
+
import type { TtscTransformCache } from "./TtscTransformCache";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Qualified native root hint per invocation key, retained across generation
|
|
6
|
+
* disposal. Its config-policy basis must match before priming a new walk;
|
|
7
|
+
* neither the match nor report proves current filesystem state. Entries live
|
|
8
|
+
* until the cache is collected; distinct invocation keys and their path bytes
|
|
9
|
+
* have no independent cap.
|
|
10
|
+
*/
|
|
11
|
+
export const TRANSFORM_CACHE_MEMBERSHIP_POLICIES = new WeakMap<
|
|
12
|
+
TtscTransformCache,
|
|
13
|
+
Map<string, TtscCompilerMembershipHint>
|
|
14
|
+
>();
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ITtscCompilerTransformation } from "ttsc";
|
|
2
2
|
|
|
3
3
|
import type { ITtscProjectMembershipPolicy } from "../../tsconfig/ITtscProjectMembershipPolicy";
|
|
4
|
+
import type { TtscCompilerMembershipHint } from "../generation/TtscCompilerMembershipHint";
|
|
4
5
|
import type { TtscProjectDirectorySnapshot } from "../project/TtscProjectDirectorySnapshot";
|
|
5
6
|
import type { TtscProjectMutationTracker } from "../tracker/TtscProjectMutationTracker";
|
|
7
|
+
import type { TtscCompilerArgumentsWitness } from "../tsconfig/TtscCompilerArgumentsWitness";
|
|
6
8
|
import type { TtscHostInputValidation } from "../validation/TtscHostInputValidation";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -42,6 +44,11 @@ import type { TtscHostInputValidation } from "../validation/TtscHostInputValidat
|
|
|
42
44
|
* retained state at runtime.
|
|
43
45
|
*/
|
|
44
46
|
export interface TtscCachedProjectTransform {
|
|
47
|
+
/** Native settings learned under this capture's validated config-policy basis. */
|
|
48
|
+
compilerMembership?: TtscCompilerMembershipHint;
|
|
49
|
+
|
|
50
|
+
/** Actual captured invocation, retained for persisted host-cache proofs. */
|
|
51
|
+
compilerArguments?: TtscCompilerArgumentsWitness;
|
|
45
52
|
/** Predicate-preserving compiler proofs for external candidate spellings. */
|
|
46
53
|
externalInputObservations?: Record<
|
|
47
54
|
string,
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import type { ResolvedTtscUnpluginOptions } from "../../options/ResolvedTtscUnpluginOptions";
|
|
4
4
|
import { createHostPathIdentityContext } from "../filesystem/createHostPathIdentityContext";
|
|
5
5
|
import { pathIdentityKey } from "../filesystem/pathIdentityKey";
|
|
6
|
+
import { compilerEnvironmentIdentity } from "../tsconfig/compilerEnvironmentIdentity";
|
|
6
7
|
import { stableStringify } from "../utils/stableStringify";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -10,13 +11,14 @@ import { stableStringify } from "../utils/stableStringify";
|
|
|
10
11
|
*
|
|
11
12
|
* The declared compile configuration is represented by: the selected tsconfig's
|
|
12
13
|
* filesystem identity, common source-root identity, compiler overlay, plugin
|
|
13
|
-
* list, and translated aliases. Two
|
|
14
|
-
*
|
|
15
|
-
* spellings resolving to one config
|
|
16
|
-
* encode current filesystem content or
|
|
17
|
-
* plugin payloads and alias mappings retain
|
|
18
|
-
* compiler path patterns and arbitrary
|
|
19
|
-
* host-owned outer manifest is
|
|
14
|
+
* list, effective compiler argument transport, and translated aliases. Two
|
|
15
|
+
* adapter configurations that have different supported JSON representations
|
|
16
|
+
* therefore receive different keys; native spellings resolving to one config
|
|
17
|
+
* identity may share a key. A key does not encode current filesystem content or
|
|
18
|
+
* prove freshness. Compiler overlays, plugin payloads and alias mappings retain
|
|
19
|
+
* their JSON declaration order: tied compiler path patterns and arbitrary
|
|
20
|
+
* plugin payloads can observe it. Only the host-owned outer manifest is
|
|
21
|
+
* serialized with sorted keys.
|
|
20
22
|
*
|
|
21
23
|
* @evidence contracts/common.md#principled-implementation Native config and source-root identities plus actual JSON representations of compiler overlays, plugin payloads and alias mappings distinguish requested compiles, retaining declaration order that path-pattern ties or plugins can observe.
|
|
22
24
|
* @evidence contracts/common.md#clear-and-simple-design Existing path identity and stable JSON encoding define the key; filesystem state remains the generation validator's responsibility.
|
|
@@ -25,7 +27,7 @@ import { stableStringify } from "../utils/stableStringify";
|
|
|
25
27
|
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Returns a string and retains nothing.
|
|
26
28
|
* @evidence contracts/performance.md#efficient-algorithms
|
|
27
29
|
* Three payload serializations preserve supported JSON order; the outer
|
|
28
|
-
*
|
|
30
|
+
* fixed-field manifest sorts only its own keys and serializes their text
|
|
29
31
|
* again, with escaping/output space proportional to the payload text.
|
|
30
32
|
* One path-identity transaction for config and root observes uncached native
|
|
31
33
|
* aliases, ancestors and directory case policy; that work is not constant
|
|
@@ -43,6 +45,8 @@ import { stableStringify } from "../utils/stableStringify";
|
|
|
43
45
|
export function createTransformCacheKey(props: {
|
|
44
46
|
aliasPaths: Record<string, string[]>;
|
|
45
47
|
compilerOptions: Record<string, unknown>;
|
|
48
|
+
/** Effective compiler argument snapshot selected before cache lookup. */
|
|
49
|
+
compilerEnvironment?: NodeJS.ProcessEnv;
|
|
46
50
|
plugins?: ResolvedTtscUnpluginOptions["plugins"];
|
|
47
51
|
/** Common source root; omission defaults to the config directory. */
|
|
48
52
|
projectRoot?: string;
|
|
@@ -52,6 +56,7 @@ export function createTransformCacheKey(props: {
|
|
|
52
56
|
return stableStringify({
|
|
53
57
|
aliasPaths: JSON.stringify(props.aliasPaths),
|
|
54
58
|
compilerOptions: JSON.stringify(props.compilerOptions),
|
|
59
|
+
compilerEnvironment: compilerEnvironmentIdentity(props.compilerEnvironment),
|
|
55
60
|
plugins: JSON.stringify(props.plugins),
|
|
56
61
|
projectRoot: pathIdentityKey(
|
|
57
62
|
props.projectRoot ?? path.dirname(props.tsconfig),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ITtscCompilerTransformation } from "ttsc";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A provisional native root report tied to the config policy that learned it.
|
|
5
|
+
* It predicts a later walk's settings and carries no filesystem reuse proof.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation A config-policy identity prevents a previously learned CLI report from overriding newly read JSON settings; capture qualifies the report against config and graph observations.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One pair keeps the prediction and its premise together across attempts and cache generations.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The hint is optional and does not replace the current compiler report or snapshot proof.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation Members distinguish the config identity from the native prediction and state their authority limit.
|
|
11
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation This carrier interprets no path, platform or process value.
|
|
12
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms This type declares no runtime computation.
|
|
13
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work This type coordinates no work; the primer and capture own prediction validity.
|
|
14
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This type owns no handle or retained population.
|
|
15
|
+
*/
|
|
16
|
+
export interface TtscCompilerMembershipHint {
|
|
17
|
+
/** Digest of the fresh JSON and overlay policy before native projection. */
|
|
18
|
+
basis: string;
|
|
19
|
+
|
|
20
|
+
/** Qualified native settings, subject to the next compiler's report. */
|
|
21
|
+
report: NonNullable<
|
|
22
|
+
ITtscCompilerTransformation.IReferenceGraph["membership"]
|
|
23
|
+
>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ITtscCompilerTransformation } from "ttsc";
|
|
2
|
+
|
|
3
|
+
import type { ITtscProjectMembershipPolicy } from "../../tsconfig/ITtscProjectMembershipPolicy";
|
|
4
|
+
import { flattenDirectoryExclusionOrigins } from "../../tsconfig/flattenDirectoryExclusionOrigins";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Apply a native root report without reinterpreting its resolved paths as JSON.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/common.md#principled-implementation Effective native suffixes replace the provisional extension population; parsed output paths replace only implicit output exclusions while authored explicit excludes survive.
|
|
10
|
+
* @evidence contracts/common.md#clear-and-simple-design One projection serves both priming from a previous report and adopting the current compiler report.
|
|
11
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Native paths are already resolved and are not passed through configDir substitution again; an absent report leaves the policy unchanged.
|
|
12
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose distinguishes resolved compiler paths, JSON interpretation and report absence.
|
|
13
|
+
* @evidence contracts/portability.md#os-neutral-implementation Absolute native output spellings pass through unchanged; this owner performs no path lookup or case folding of filesystem names.
|
|
14
|
+
* @evidence contracts/performance.md#efficient-algorithms Copies the exclusion origins and extension list once, then flattens the existing explicit and implicit directory population; storage follows those names and paths.
|
|
15
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work The caller owns report lifetime and reuse permission; this projection retains no prior result.
|
|
16
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned policy transfers to the caller and acquires no handle or history.
|
|
17
|
+
*/
|
|
18
|
+
export function applyCompilerMembership(
|
|
19
|
+
policy: ITtscProjectMembershipPolicy,
|
|
20
|
+
report: ITtscCompilerTransformation.IReferenceGraph["membership"],
|
|
21
|
+
): ITtscProjectMembershipPolicy {
|
|
22
|
+
if (report === undefined) return policy;
|
|
23
|
+
const origins: {
|
|
24
|
+
exclude: readonly string[];
|
|
25
|
+
useImplicitOutputExclusions?: boolean;
|
|
26
|
+
outDir?: string;
|
|
27
|
+
declarationDir?: string;
|
|
28
|
+
} = {
|
|
29
|
+
...(policy.directoryExclusionOrigins ?? {
|
|
30
|
+
exclude: policy.excludedDirectories,
|
|
31
|
+
useImplicitOutputExclusions: true,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
for (const key of ["outDir", "declarationDir"] as const) {
|
|
35
|
+
if (report[key] === null) delete origins[key];
|
|
36
|
+
else origins[key] = report[key];
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...policy,
|
|
40
|
+
directoryExclusionOrigins: origins,
|
|
41
|
+
excludedDirectories: flattenDirectoryExclusionOrigins(origins),
|
|
42
|
+
inputExtensions: [...report.inputExtensions],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -33,6 +33,7 @@ import { createHostInputMutationTracker } from "../tracker/createHostInputMutati
|
|
|
33
33
|
import { createProjectMutationTracker } from "../tracker/createProjectMutationTracker";
|
|
34
34
|
import { settleMutationTrackers } from "../tracker/settleMutationTrackers";
|
|
35
35
|
import { trackedInputScopes } from "../tracker/trackedInputScopes";
|
|
36
|
+
import { captureCompilerArguments } from "../tsconfig/captureCompilerArguments";
|
|
36
37
|
import { compilerProjectSpelling } from "../tsconfig/compilerProjectSpelling";
|
|
37
38
|
import { createTransformScratchDirectory } from "../tsconfig/createTransformScratchDirectory";
|
|
38
39
|
import { createTransformTsconfig } from "../tsconfig/createTransformTsconfig";
|
|
@@ -47,10 +48,12 @@ import { walkSnapshotComplete } from "../validation/walkSnapshotComplete";
|
|
|
47
48
|
import { witnessExternalDependencies } from "../validation/witnessExternalDependencies";
|
|
48
49
|
import { TRANSFORM_FAILED_GENERATION_VALIDATIONS } from "./TRANSFORM_FAILED_GENERATION_VALIDATIONS";
|
|
49
50
|
import { TRANSFORM_GENERATION_FAILURES } from "./TRANSFORM_GENERATION_FAILURES";
|
|
51
|
+
import type { TtscCompilerMembershipHint } from "./TtscCompilerMembershipHint";
|
|
50
52
|
import { captureFailedGenerationInputStates } from "./captureFailedGenerationInputStates";
|
|
51
53
|
import { captureTransformSourceHashes } from "./captureTransformSourceHashes";
|
|
52
54
|
import { createGenerationProofFailures } from "./createGenerationProofFailures";
|
|
53
55
|
import { mergeGenerationProofFailures } from "./mergeGenerationProofFailures";
|
|
56
|
+
import { primeCompilerMembership } from "./primeCompilerMembership";
|
|
54
57
|
import { projectWalkFailureFingerprint } from "./projectWalkFailureFingerprint";
|
|
55
58
|
import { projectWalkStable } from "./projectWalkStable";
|
|
56
59
|
import { recordGenerationProofFailure } from "./recordGenerationProofFailure";
|
|
@@ -121,6 +124,14 @@ export async function captureTransformGeneration(props: {
|
|
|
121
124
|
/** Compiler options overlaid on the project without editing its source config. */
|
|
122
125
|
compilerOptions: Record<string, unknown>;
|
|
123
126
|
|
|
127
|
+
/** Detached environment paired with the requesting generation's cache key. */
|
|
128
|
+
compilerEnvironment?: NodeJS.ProcessEnv;
|
|
129
|
+
/** Explicit override that produced the effective compiler environment. */
|
|
130
|
+
runExternalCode?: boolean;
|
|
131
|
+
|
|
132
|
+
/** Learned native root settings used only to prime this attempt's walk. */
|
|
133
|
+
compilerMembership?: TtscCompilerMembershipHint;
|
|
134
|
+
|
|
124
135
|
/** Native source path whose host delivery initiated the attempt. */
|
|
125
136
|
currentFile: string;
|
|
126
137
|
|
|
@@ -242,7 +253,10 @@ export async function captureTransformGeneration(props: {
|
|
|
242
253
|
);
|
|
243
254
|
const temporaryTsconfig =
|
|
244
255
|
configured.path === props.tsconfig ? undefined : configured.path;
|
|
245
|
-
const compilerEnvironment = transformScratchEnvironment(
|
|
256
|
+
const compilerEnvironment = transformScratchEnvironment(
|
|
257
|
+
scratchDirectory,
|
|
258
|
+
props.compilerEnvironment,
|
|
259
|
+
);
|
|
246
260
|
if (temporaryTsconfig === undefined) {
|
|
247
261
|
delete compilerEnvironment[TTSC_SEMANTIC_CONFIG_PATH];
|
|
248
262
|
} else {
|
|
@@ -255,11 +269,15 @@ export async function captureTransformGeneration(props: {
|
|
|
255
269
|
// relative `outDir` is anchored at the config that declares it, and the
|
|
256
270
|
// generated config lives in a system temp directory. The caller's
|
|
257
271
|
// compiler-options overlay still wins, since it wins for the compile too.
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
const membershipPrimer = primeCompilerMembership(
|
|
273
|
+
mergeMembershipPolicyOverlay(
|
|
274
|
+
tsconfigState.membershipPolicy,
|
|
275
|
+
props.compilerOptions,
|
|
276
|
+
path.dirname(props.tsconfig),
|
|
277
|
+
),
|
|
278
|
+
props.compilerMembership,
|
|
262
279
|
);
|
|
280
|
+
const mergedPolicy = membershipPrimer.policy;
|
|
263
281
|
// The walk before the compile matches root specs under the case policy an
|
|
264
282
|
// earlier compile reported, or a provisional cache-root approximation
|
|
265
283
|
// under this attempt's environment. The approximation does not observe
|
|
@@ -432,7 +450,7 @@ export async function captureTransformGeneration(props: {
|
|
|
432
450
|
undefined,
|
|
433
451
|
projectRoot,
|
|
434
452
|
);
|
|
435
|
-
const { membershipPolicy,
|
|
453
|
+
const { membershipPolicy, membershipPolicyLearned } =
|
|
436
454
|
selectReportedMembershipPolicy(primedPolicy, result);
|
|
437
455
|
TRANSFORM_RESULT_MEMBERSHIP.set(result, {
|
|
438
456
|
// Only the actual complete directory walk authorizes replacing a listing
|
|
@@ -440,7 +458,7 @@ export async function captureTransformGeneration(props: {
|
|
|
440
458
|
// unreadable directory was enumerated, and a changed compiler comparison
|
|
441
459
|
// answer means the primed walk used another admission policy.
|
|
442
460
|
enumeratedDirectories:
|
|
443
|
-
before.directoryComplete && !
|
|
461
|
+
before.directoryComplete && !membershipPolicyLearned
|
|
444
462
|
? new Set(before.projectDirectories.map((snapshot) => snapshot.path))
|
|
445
463
|
: new Set(),
|
|
446
464
|
policy: membershipPolicy,
|
|
@@ -623,7 +641,7 @@ export async function captureTransformGeneration(props: {
|
|
|
623
641
|
// published.
|
|
624
642
|
await settleMutationTrackers([tracker, hostInputTracker, candidateTracker]);
|
|
625
643
|
const walkStable =
|
|
626
|
-
!
|
|
644
|
+
!membershipPolicyLearned &&
|
|
627
645
|
projectWalkStable({
|
|
628
646
|
before,
|
|
629
647
|
configStable,
|
|
@@ -657,6 +675,10 @@ export async function captureTransformGeneration(props: {
|
|
|
657
675
|
: undefined;
|
|
658
676
|
const projectInputHashes = { ...inputSnapshot.hashes };
|
|
659
677
|
const cached: TtscCachedProjectTransform = {
|
|
678
|
+
compilerArguments: captureCompilerArguments(
|
|
679
|
+
compilerEnvironment,
|
|
680
|
+
props.runExternalCode,
|
|
681
|
+
),
|
|
660
682
|
// The pass this compile was started for. Its snapshot describes the
|
|
661
683
|
// project as of this compile, so it is settled for this pass and any
|
|
662
684
|
// later pass must re-prove it.
|
|
@@ -750,10 +772,10 @@ export async function captureTransformGeneration(props: {
|
|
|
750
772
|
path: props.tsconfig,
|
|
751
773
|
});
|
|
752
774
|
}
|
|
753
|
-
if (
|
|
775
|
+
if (membershipPolicyLearned) {
|
|
754
776
|
recordGenerationProofFailure(failures, {
|
|
755
777
|
domain: "project",
|
|
756
|
-
kind: "
|
|
778
|
+
kind: "membership-policy-learned",
|
|
757
779
|
path: props.tsconfig,
|
|
758
780
|
});
|
|
759
781
|
} else if (!walkStable) {
|
|
@@ -788,6 +810,17 @@ export async function captureTransformGeneration(props: {
|
|
|
788
810
|
mergeGenerationProofFailures(failures, universalInputCapture.failures);
|
|
789
811
|
const graphProofs =
|
|
790
812
|
graphFailures.entries.length === 0 && graphFailures.omitted === 0;
|
|
813
|
+
if (
|
|
814
|
+
configStable &&
|
|
815
|
+
graphProofs &&
|
|
816
|
+
adoptionFailure === undefined &&
|
|
817
|
+
result.type !== "exception" &&
|
|
818
|
+
result.graph?.membership !== undefined
|
|
819
|
+
)
|
|
820
|
+
cached.compilerMembership = {
|
|
821
|
+
basis: membershipPrimer.basis,
|
|
822
|
+
report: result.graph.membership,
|
|
823
|
+
};
|
|
791
824
|
const universalInputs = universalInputCapture.validation !== undefined;
|
|
792
825
|
const stableProjectSnapshot =
|
|
793
826
|
walkStable &&
|