@shapeshift-labs/frontier-lang-compiler 0.2.149 → 0.2.151
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 +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-patch-bundle-composition.d.ts +62 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +32 -0
- package/dist/index.js +6 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticPatchBundleComposition.js +166 -0
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-context.js +1 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-plan.js +3 -1
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +171 -172
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
3
|
+
|
|
4
|
+
function syntheticFile(file, context, sourceText, operation) {
|
|
5
|
+
return compactRecord({
|
|
6
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
7
|
+
version: 1,
|
|
8
|
+
sourcePath: file.sourcePath,
|
|
9
|
+
language: context.language,
|
|
10
|
+
status: 'merged',
|
|
11
|
+
operation,
|
|
12
|
+
outputSourceText: sourceText,
|
|
13
|
+
outputHash: hashText(sourceText),
|
|
14
|
+
baseHash: hashText(file.baseSourceText),
|
|
15
|
+
workerHash: hashText(file.workerSourceText),
|
|
16
|
+
headHash: hashText(file.headSourceText),
|
|
17
|
+
conflicts: [],
|
|
18
|
+
admission: admittedSyntheticAdmission(operation),
|
|
19
|
+
summary: { conflicts: 0, synthetic: true },
|
|
20
|
+
conflictKeys: [`source#${file.sourcePath}`]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function blockedFile(file, context, reasonCode) {
|
|
25
|
+
const conflict = {
|
|
26
|
+
code: reasonCode,
|
|
27
|
+
gateId: 'project-file-presence',
|
|
28
|
+
message: `Project file cannot be safely merged: ${reasonCode}.`,
|
|
29
|
+
sourcePath: file.sourcePath,
|
|
30
|
+
details: { sourcePath: file.sourcePath }
|
|
31
|
+
};
|
|
32
|
+
return compactRecord({
|
|
33
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
34
|
+
version: 1,
|
|
35
|
+
sourcePath: file.sourcePath,
|
|
36
|
+
language: context.language,
|
|
37
|
+
status: 'blocked',
|
|
38
|
+
operation: 'blocked-file-presence',
|
|
39
|
+
conflicts: [conflict],
|
|
40
|
+
admission: blockedAdmission(reasonCode),
|
|
41
|
+
summary: { conflicts: 1, synthetic: true },
|
|
42
|
+
conflictKeys: [`source#${file.sourcePath ?? 'unknown'}`]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function policyForFile(input, sourcePath) {
|
|
47
|
+
if (input.policyByPath?.[sourcePath]) return input.policyByPath[sourcePath];
|
|
48
|
+
if (input.mergePolicyByPath?.[sourcePath]) return input.mergePolicyByPath[sourcePath];
|
|
49
|
+
return input.policy ?? input.mergePolicy;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function sourceLedgersForFile(input, sourcePath) {
|
|
53
|
+
const byPath = input.sourceLedgersByPath?.[sourcePath] ?? input.sourceLedgers?.[sourcePath];
|
|
54
|
+
return byPath ?? (input.sourceLedgers?.base || input.sourceLedgers?.worker || input.sourceLedgers?.head ? input.sourceLedgers : undefined);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function admittedSyntheticAdmission(operation) {
|
|
58
|
+
return {
|
|
59
|
+
status: 'auto-merge-candidate',
|
|
60
|
+
action: operation === 'head-only' ? 'preserve-head' : 'apply',
|
|
61
|
+
reviewRequired: false,
|
|
62
|
+
autoApplyCandidate: true,
|
|
63
|
+
autoMergeClaim: false,
|
|
64
|
+
semanticEquivalenceClaim: false,
|
|
65
|
+
reasonCodes: []
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function blockedAdmission(reasonCode) {
|
|
70
|
+
return {
|
|
71
|
+
status: 'blocked',
|
|
72
|
+
action: 'human-review',
|
|
73
|
+
reviewRequired: true,
|
|
74
|
+
autoApplyCandidate: false,
|
|
75
|
+
autoMergeClaim: false,
|
|
76
|
+
semanticEquivalenceClaim: false,
|
|
77
|
+
reasonCodes: [reasonCode]
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hashText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
|
|
82
|
+
function safeId(value) { return String(value ?? 'unknown').replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'file'; }
|
|
83
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
84
|
+
|
|
85
|
+
export { blockedFile, hashText, policyForFile, safeId, sourceLedgersForFile, syntheticFile, uniqueStrings };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
|
|
3
|
+
function cssModuleUseSiteBlockerConflicts(blockers = []) {
|
|
4
|
+
return blockers.map(cssModuleUseSiteBlockerConflict);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function cssModuleUseSiteBlockerConflict(blocker) {
|
|
8
|
+
const reasonCode = blocker.reasonCode ?? 'css-module-use-site-proof-blocked';
|
|
9
|
+
return {
|
|
10
|
+
code: 'project-css-module-use-site-proof-blocked',
|
|
11
|
+
gateId: 'project-css-module-use-site-graph',
|
|
12
|
+
message: `Output project graph has unproved CSS Module use-site evidence: ${reasonCode}.`,
|
|
13
|
+
sourcePath: blocker.sourcePath,
|
|
14
|
+
details: compactRecord({
|
|
15
|
+
reasonCode,
|
|
16
|
+
conflictKey: cssModuleUseSiteBlockerConflictKey(blocker),
|
|
17
|
+
sourcePath: blocker.sourcePath,
|
|
18
|
+
sourceSpan: blocker.sourceSpan,
|
|
19
|
+
moduleSpecifier: blocker.moduleSpecifier,
|
|
20
|
+
localName: blocker.localName,
|
|
21
|
+
cssModuleImportBindingId: blocker.cssModuleImportBindingId,
|
|
22
|
+
cssModuleSourcePath: blocker.cssModuleSourcePath,
|
|
23
|
+
expressionText: blocker.expressionText,
|
|
24
|
+
writeOperation: blocker.writeOperation,
|
|
25
|
+
jsxPropRecordId: blocker.jsxPropRecordId,
|
|
26
|
+
failClosed: blocker.failClosed === true,
|
|
27
|
+
semanticEquivalenceClaim: blocker.semanticEquivalenceClaim === true
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function cssModuleUseSiteBlockerConflictKey(blocker) {
|
|
33
|
+
return [
|
|
34
|
+
'css-module-use-site',
|
|
35
|
+
blocker.cssModuleSourcePath ?? blocker.moduleSpecifier ?? 'unknown-module',
|
|
36
|
+
blocker.sourcePath ?? 'unknown-source',
|
|
37
|
+
blocker.localName ?? 'unknown-local',
|
|
38
|
+
blocker.reasonCode ?? 'unknown-reason',
|
|
39
|
+
spanKey(blocker.sourceSpan),
|
|
40
|
+
blocker.expressionText
|
|
41
|
+
].map((part) => String(part ?? '')).join('#');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isResolvedCssModuleImportEdge(edge) {
|
|
45
|
+
return isCssModulePath(edge?.resolvedModulePath ?? edge?.moduleSpecifier)
|
|
46
|
+
&& Boolean(edge?.targetDocumentId)
|
|
47
|
+
&& typeof edge?.resolutionKind === 'string'
|
|
48
|
+
&& edge.resolutionKind.endsWith('-source');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isCssModulePath(path) {
|
|
52
|
+
return /\.module\.css(?:[?#].*)?$/i.test(String(path ?? ''));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function spanKey(span) {
|
|
56
|
+
if (!span) return '';
|
|
57
|
+
return [span.path, span.start, span.end].map((part) => String(part ?? '')).join(':');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { cssModuleUseSiteBlockerConflicts, isResolvedCssModuleImportEdge };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import { createJsTsProjectMergeDeclarationGate } from './js-ts-safe-project-merge-declarations.js';
|
|
4
|
+
|
|
5
|
+
const DeclarationEmitParityKind = 'typescript-checker-public-api-declaration-emit-parity';
|
|
6
|
+
const DeclarationEmitParityProofLevel = 'typescript-checker-public-api-declaration-output-boundary';
|
|
7
|
+
|
|
8
|
+
function createJsTsProjectMergeDeclarationEmitParityProof(input = {}, files = [], outputFiles = [], id = 'js_ts_project_safe_merge') {
|
|
9
|
+
const suppliedProof = input.declarationEmitParityProof ?? input.outputDeclarationEmitParityProof;
|
|
10
|
+
if (suppliedProof) return normalizeDeclarationEmitParityProof(suppliedProof, id);
|
|
11
|
+
if (!shouldCreateDeclarationEmitParityProof(input)) return undefined;
|
|
12
|
+
const stageFiles = declarationParityStageFiles(files, outputFiles, input);
|
|
13
|
+
const gateInput = declarationParityGateInput(input);
|
|
14
|
+
const gates = Object.fromEntries(Object.entries(stageFiles).map(([stage, stageOutputFiles]) => [
|
|
15
|
+
stage,
|
|
16
|
+
createJsTsProjectMergeDeclarationGate(gateInput, stageOutputFiles, `${id}_${stage}`)
|
|
17
|
+
]));
|
|
18
|
+
return declarationEmitParityProof(input, id, gates);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function shouldCreateDeclarationEmitParityProof(input) {
|
|
22
|
+
return input.includeDeclarationOutput === true
|
|
23
|
+
|| input.requireDeclarationOutput === true
|
|
24
|
+
|| input.requirePublicApiDeclarationEmitParity === true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function declarationParityStageFiles(files, outputFiles, input) {
|
|
28
|
+
return {
|
|
29
|
+
worker: files.map((file) => stageFile(file, workerStageSourceText(file), input)).filter(Boolean),
|
|
30
|
+
head: files.map((file) => stageFile(file, headStageSourceText(file), input)).filter(Boolean),
|
|
31
|
+
output: outputFiles
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function declarationParityGateInput(input) {
|
|
36
|
+
return {
|
|
37
|
+
...input,
|
|
38
|
+
includeDeclarationOutput: true,
|
|
39
|
+
requireDeclarationOutput: true,
|
|
40
|
+
outputDeclarations: undefined,
|
|
41
|
+
outputDeclarationFiles: undefined
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function declarationEmitParityProof(input, id, gates) {
|
|
46
|
+
const boundaries = Object.fromEntries(Object.entries(gates).map(([stage, gate]) => [stage, declarationBoundary(gate)]));
|
|
47
|
+
const reasonCodes = declarationEmitParityReasonCodes(gates, boundaries);
|
|
48
|
+
const status = reasonCodes.length ? 'failed' : 'passed';
|
|
49
|
+
const outputFiles = boundaries.output?.files ?? [];
|
|
50
|
+
const core = {
|
|
51
|
+
kind: DeclarationEmitParityKind,
|
|
52
|
+
version: 1,
|
|
53
|
+
schema: 'frontier.lang.typescriptDeclarationEmitParityProof.v1',
|
|
54
|
+
id: `${id}_declaration_emit_parity`,
|
|
55
|
+
status,
|
|
56
|
+
proofLevel: DeclarationEmitParityProofLevel,
|
|
57
|
+
workerDeclarationBoundaryHash: boundaries.worker?.hash,
|
|
58
|
+
headDeclarationBoundaryHash: boundaries.head?.hash,
|
|
59
|
+
outputDeclarationBoundaryHash: boundaries.output?.hash,
|
|
60
|
+
declarationFileCount: outputFiles.length,
|
|
61
|
+
declarationFiles: outputFiles,
|
|
62
|
+
compilerOptionsHash: compilerOptionsHash(input),
|
|
63
|
+
diagnosticsHash: diagnosticsHash(gates),
|
|
64
|
+
missingSignals: reasonCodes,
|
|
65
|
+
reasonCodes,
|
|
66
|
+
autoMergeClaim: false,
|
|
67
|
+
semanticEquivalenceClaim: false
|
|
68
|
+
};
|
|
69
|
+
return { ...compactRecord(core), hash: hashSemanticValue(core) };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function declarationEmitParityReasonCodes(gates, boundaries) {
|
|
73
|
+
const reasonCodes = [];
|
|
74
|
+
for (const [stage, gate] of Object.entries(gates)) {
|
|
75
|
+
if (!gate) reasonCodes.push(`typescript-public-api-declaration-emit-${stage}-missing`);
|
|
76
|
+
if (gate?.status !== 'passed') reasonCodes.push(stage === 'output'
|
|
77
|
+
? 'typescript-public-api-declaration-emit-output-missing'
|
|
78
|
+
: 'typescript-public-api-declaration-emit-proof-missing');
|
|
79
|
+
if ((gate?.diagnostics ?? []).some((diagnostic) => diagnostic.severity === 'error')) {
|
|
80
|
+
reasonCodes.push('typescript-public-api-declaration-emit-diagnostics-blocked');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!boundaries.worker?.hash || !boundaries.head?.hash || !boundaries.output?.hash) {
|
|
84
|
+
reasonCodes.push('typescript-compiler-declaration-output-public-boundary-hash-missing');
|
|
85
|
+
} else if (boundaries.worker.hash !== boundaries.head.hash || boundaries.worker.hash !== boundaries.output.hash) {
|
|
86
|
+
reasonCodes.push('typescript-public-api-declaration-emit-parity-mismatch');
|
|
87
|
+
}
|
|
88
|
+
return uniqueStrings(reasonCodes);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function declarationBoundary(gate) {
|
|
92
|
+
if (!gate || gate.status !== 'passed') return undefined;
|
|
93
|
+
const files = [...(gate.declarationFiles ?? [])]
|
|
94
|
+
.map((file) => compactRecord({
|
|
95
|
+
sourcePath: file.sourcePath,
|
|
96
|
+
sourceHash: file.sourceHash,
|
|
97
|
+
bytes: file.bytes,
|
|
98
|
+
source: file.source
|
|
99
|
+
}))
|
|
100
|
+
.sort((a, b) => String(a.sourcePath).localeCompare(String(b.sourcePath)));
|
|
101
|
+
return {
|
|
102
|
+
files,
|
|
103
|
+
hash: hashSemanticValue({ kind: 'frontier.lang.typescriptDeclarationBoundary', files })
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function missingDeclarationEmitParityEvidence(proof, options = {}) {
|
|
108
|
+
if (options.requireDeclarationEmitParity !== true) return undefined;
|
|
109
|
+
if (!proof) {
|
|
110
|
+
return {
|
|
111
|
+
reasonCode: 'typescript-public-api-declaration-emit-proof-missing',
|
|
112
|
+
requiredEvidence: DeclarationEmitParityKind,
|
|
113
|
+
proofLevel: DeclarationEmitParityProofLevel,
|
|
114
|
+
missingSignals: ['typescript-public-api-declaration-emit-proof-missing']
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (proof.status === 'passed') return undefined;
|
|
118
|
+
const missingSignals = uniqueStrings(proof.reasonCodes ?? proof.missingSignals ?? ['typescript-public-api-declaration-emit-parity-mismatch']);
|
|
119
|
+
return compactRecord({
|
|
120
|
+
reasonCode: missingSignals[0],
|
|
121
|
+
requiredEvidence: DeclarationEmitParityKind,
|
|
122
|
+
proofLevel: DeclarationEmitParityProofLevel,
|
|
123
|
+
status: proof.status,
|
|
124
|
+
missingSignals,
|
|
125
|
+
workerDeclarationBoundaryHash: proof.workerDeclarationBoundaryHash,
|
|
126
|
+
headDeclarationBoundaryHash: proof.headDeclarationBoundaryHash,
|
|
127
|
+
outputDeclarationBoundaryHash: proof.outputDeclarationBoundaryHash,
|
|
128
|
+
declarationFileCount: proof.declarationFileCount,
|
|
129
|
+
compilerOptionsHash: proof.compilerOptionsHash,
|
|
130
|
+
diagnosticsHash: proof.diagnosticsHash,
|
|
131
|
+
autoMergeClaim: false,
|
|
132
|
+
semanticEquivalenceClaim: false
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function normalizeDeclarationEmitParityProof(proof, id) {
|
|
137
|
+
const core = compactRecord({
|
|
138
|
+
...proof,
|
|
139
|
+
kind: proof.kind ?? DeclarationEmitParityKind,
|
|
140
|
+
version: proof.version ?? 1,
|
|
141
|
+
id: proof.id ?? `${id}_declaration_emit_parity`,
|
|
142
|
+
proofLevel: proof.proofLevel ?? DeclarationEmitParityProofLevel,
|
|
143
|
+
status: proof.status ?? 'failed',
|
|
144
|
+
reasonCodes: uniqueStrings(proof.reasonCodes ?? proof.missingSignals ?? []),
|
|
145
|
+
missingSignals: uniqueStrings(proof.missingSignals ?? proof.reasonCodes ?? []),
|
|
146
|
+
autoMergeClaim: false,
|
|
147
|
+
semanticEquivalenceClaim: false
|
|
148
|
+
});
|
|
149
|
+
return { ...core, hash: proof.hash ?? hashSemanticValue(core) };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function workerStageSourceText(file) {
|
|
153
|
+
if (file.workerDeleted) return undefined;
|
|
154
|
+
return file.workerSourceText ?? file.baseSourceText;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function headStageSourceText(file) {
|
|
158
|
+
if (file.headDeleted) return undefined;
|
|
159
|
+
return file.headSourceText ?? file.baseSourceText;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function stageFile(file, sourceText, input) {
|
|
163
|
+
if (typeof sourceText !== 'string' || !file.sourcePath) return undefined;
|
|
164
|
+
return compactRecord({ sourcePath: file.sourcePath, language: file.language ?? input.language, sourceText });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function compilerOptionsHash(input) {
|
|
168
|
+
return hashSemanticValue({
|
|
169
|
+
compilerOptions: input.compilerOptions,
|
|
170
|
+
typescriptCompilerOptions: input.typescriptCompilerOptions,
|
|
171
|
+
declarationCompilerOptions: input.declarationCompilerOptions,
|
|
172
|
+
typescriptDeclarationCompilerOptions: input.typescriptDeclarationCompilerOptions,
|
|
173
|
+
tsconfig: input.tsconfig,
|
|
174
|
+
moduleResolution: input.moduleResolution,
|
|
175
|
+
projectReferences: input.projectReferences ?? input.typescriptProjectReferences ?? input.tsconfigProjectReferences
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function diagnosticsHash(gates) {
|
|
180
|
+
return hashSemanticValue(Object.fromEntries(Object.entries(gates).map(([stage, gate]) => [stage, gate?.diagnostics ?? []])));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
createJsTsProjectMergeDeclarationEmitParityProof,
|
|
185
|
+
missingDeclarationEmitParityEvidence
|
|
186
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import {
|
|
4
|
+
createJsTsVirtualTypeScriptProgram,
|
|
5
|
+
normalizePath,
|
|
6
|
+
normalizeSuppliedDiagnostics,
|
|
7
|
+
normalizeTypeScriptDiagnostic,
|
|
8
|
+
sourceMapMatch
|
|
9
|
+
} from './js-ts-safe-project-merge-ts-program.js';
|
|
10
|
+
|
|
11
|
+
function createJsTsProjectMergeDeclarationGate(input = {}, outputFiles = [], id = 'js_ts_project_safe_merge') {
|
|
12
|
+
const declarationOutput = input.outputDeclarations || input.outputDeclarationFiles
|
|
13
|
+
? normalizeSuppliedDeclarationOutput(input.outputDeclarations ?? input.outputDeclarationFiles)
|
|
14
|
+
: collectTypeScriptDeclarationOutput(input, outputFiles);
|
|
15
|
+
if (!declarationOutput && shouldSkipDeclarationGate(input)) return undefined;
|
|
16
|
+
if (!declarationOutput) return unavailableGate(input, id);
|
|
17
|
+
const diagnostics = declarationOutput.diagnostics ?? [];
|
|
18
|
+
const conflicts = diagnostics
|
|
19
|
+
.filter((diagnostic) => diagnostic.severity === 'error')
|
|
20
|
+
.map((diagnostic) => declarationConflict(input, diagnostic));
|
|
21
|
+
const requireFiles = input.requireDeclarationOutput === true;
|
|
22
|
+
if (requireFiles && declarationOutput.declarationFiles.length === 0) conflicts.push(missingDeclarationsConflict(input));
|
|
23
|
+
const status = conflicts.length ? 'blocked' : 'passed';
|
|
24
|
+
const core = {
|
|
25
|
+
kind: 'frontier.lang.jsTsProjectMergeDeclarationGate',
|
|
26
|
+
version: 1,
|
|
27
|
+
schema: 'frontier.lang.jsTsProjectMergeDeclarationGate.v1',
|
|
28
|
+
id: `${id}_declaration_output`,
|
|
29
|
+
status,
|
|
30
|
+
sourcePaths: outputFiles.map((file) => file.sourcePath).filter(Boolean),
|
|
31
|
+
declarationFiles: declarationOutput.declarationFiles,
|
|
32
|
+
diagnostics,
|
|
33
|
+
conflicts,
|
|
34
|
+
admission: {
|
|
35
|
+
status: status === 'passed' ? 'auto-merge-candidate' : 'blocked',
|
|
36
|
+
action: status === 'passed' ? 'accept-declarations' : 'human-review',
|
|
37
|
+
reviewRequired: status !== 'passed',
|
|
38
|
+
autoApplyCandidate: status === 'passed',
|
|
39
|
+
autoMergeClaim: false,
|
|
40
|
+
semanticEquivalenceClaim: false,
|
|
41
|
+
reasonCodes: uniqueStrings(conflicts.map((conflict) => conflict.code))
|
|
42
|
+
},
|
|
43
|
+
summary: declarationSummary(declarationOutput.declarationFiles, diagnostics, conflicts),
|
|
44
|
+
evidence: [declarationEvidence(id, status, declarationOutput, diagnostics, conflicts, input)]
|
|
45
|
+
};
|
|
46
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function shouldSkipDeclarationGate(input) {
|
|
50
|
+
return input.includeDeclarationOutput !== true && input.requireDeclarationOutput !== true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function collectTypeScriptDeclarationOutput(input, outputFiles) {
|
|
54
|
+
const emitted = new Map();
|
|
55
|
+
const created = createJsTsVirtualTypeScriptProgram(input, outputFiles, {
|
|
56
|
+
compilerOptions: {
|
|
57
|
+
noEmit: false,
|
|
58
|
+
declaration: true,
|
|
59
|
+
emitDeclarationOnly: true,
|
|
60
|
+
outDir: input.declarationOutDir ?? '__frontier_declarations__',
|
|
61
|
+
...(input.declarationCompilerOptions ?? input.typescriptDeclarationCompilerOptions ?? {})
|
|
62
|
+
},
|
|
63
|
+
writeFile(fileName, text) {
|
|
64
|
+
emitted.set(normalizePath(fileName), String(text));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (!created) return undefined;
|
|
68
|
+
const { ts, program, sourceMap } = created;
|
|
69
|
+
const projectRoot = normalizePath(input.projectRoot ?? '');
|
|
70
|
+
if (!program) return { declarationFiles: [], diagnostics: [] };
|
|
71
|
+
const preEmitDiagnostics = ts.getPreEmitDiagnostics
|
|
72
|
+
? ts.getPreEmitDiagnostics(program)
|
|
73
|
+
: fallbackPreEmitDiagnostics(program);
|
|
74
|
+
const emitResult = program.emit(undefined, undefined, undefined, true);
|
|
75
|
+
const diagnostics = uniqueDiagnostics([...preEmitDiagnostics, ...(emitResult.diagnostics ?? [])]
|
|
76
|
+
.map((diagnostic) => normalizeTypeScriptDiagnostic(ts, diagnostic))
|
|
77
|
+
.filter((diagnostic) => diagnostic.sourcePath ? Boolean(sourceMapMatch(sourceMap, diagnostic.sourcePath, projectRoot)) : false));
|
|
78
|
+
return {
|
|
79
|
+
declarationFiles: [...emitted.entries()].map(([sourcePath, sourceText]) => declarationFile(sourcePath, sourceText, 'typescript-compiler-api')),
|
|
80
|
+
diagnostics
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function fallbackPreEmitDiagnostics(program) {
|
|
85
|
+
const diagnostics = [];
|
|
86
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
87
|
+
diagnostics.push(...(program.getSyntacticDiagnostics?.(sourceFile) ?? []));
|
|
88
|
+
diagnostics.push(...(program.getSemanticDiagnostics?.(sourceFile) ?? []));
|
|
89
|
+
}
|
|
90
|
+
return diagnostics;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function uniqueDiagnostics(diagnostics) {
|
|
94
|
+
const seen = new Set();
|
|
95
|
+
return diagnostics.filter((diagnostic) => {
|
|
96
|
+
const key = `${diagnostic.code}:${diagnostic.sourcePath ?? ''}:${diagnostic.start ?? ''}:${diagnostic.message}`;
|
|
97
|
+
if (seen.has(key)) return false;
|
|
98
|
+
seen.add(key);
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function normalizeSuppliedDeclarationOutput(value) {
|
|
104
|
+
const entries = value instanceof Map
|
|
105
|
+
? [...value.entries()].map(([sourcePath, sourceText]) => ({ sourcePath, sourceText }))
|
|
106
|
+
: Array.isArray(value) ? value
|
|
107
|
+
: typeof value === 'object' && value ? Object.entries(value).map(([sourcePath, sourceText]) => ({ sourcePath, sourceText }))
|
|
108
|
+
: [];
|
|
109
|
+
return {
|
|
110
|
+
declarationFiles: entries.map((entry) => declarationFile(
|
|
111
|
+
entry.sourcePath ?? entry.path,
|
|
112
|
+
entry.sourceText ?? entry.text ?? '',
|
|
113
|
+
entry.source ?? 'supplied'
|
|
114
|
+
)),
|
|
115
|
+
diagnostics: normalizeSuppliedDiagnostics(value?.diagnostics ?? [])
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function declarationFile(sourcePath, sourceText, source) {
|
|
120
|
+
const text = String(sourceText ?? '');
|
|
121
|
+
return compactRecord({
|
|
122
|
+
sourcePath: normalizePath(sourcePath),
|
|
123
|
+
sourceText: text,
|
|
124
|
+
sourceHash: hashSemanticValue(text),
|
|
125
|
+
source,
|
|
126
|
+
bytes: byteLength(text)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function unavailableGate(input, id) {
|
|
131
|
+
const conflict = input.requireDeclarationOutput === true ? missingCompilerConflict(input) : undefined;
|
|
132
|
+
const conflicts = [conflict].filter(Boolean);
|
|
133
|
+
const status = conflict ? 'blocked' : 'skipped';
|
|
134
|
+
const core = {
|
|
135
|
+
kind: 'frontier.lang.jsTsProjectMergeDeclarationGate',
|
|
136
|
+
version: 1,
|
|
137
|
+
schema: 'frontier.lang.jsTsProjectMergeDeclarationGate.v1',
|
|
138
|
+
id: `${id}_declaration_output`,
|
|
139
|
+
status,
|
|
140
|
+
sourcePaths: [],
|
|
141
|
+
declarationFiles: [],
|
|
142
|
+
diagnostics: [],
|
|
143
|
+
conflicts,
|
|
144
|
+
admission: {
|
|
145
|
+
status,
|
|
146
|
+
action: conflict ? 'human-review' : 'skip-declarations',
|
|
147
|
+
reviewRequired: Boolean(conflict),
|
|
148
|
+
autoApplyCandidate: !conflict,
|
|
149
|
+
autoMergeClaim: false,
|
|
150
|
+
semanticEquivalenceClaim: false,
|
|
151
|
+
reasonCodes: uniqueStrings(conflicts.map((entry) => entry.code))
|
|
152
|
+
},
|
|
153
|
+
summary: declarationSummary([], [], conflicts),
|
|
154
|
+
evidence: [{
|
|
155
|
+
id: `${id}_declaration_output_evidence`,
|
|
156
|
+
kind: 'js-ts-project-declaration-output',
|
|
157
|
+
status: conflict ? 'failed' : 'skipped',
|
|
158
|
+
summary: conflict ? conflict.message : 'Declaration output was requested but no TypeScript compiler API or supplied declarations were provided.',
|
|
159
|
+
metadata: { declarationFiles: 0, conflicts: conflicts.length, declarationSource: 'missing' }
|
|
160
|
+
}]
|
|
161
|
+
};
|
|
162
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function missingCompilerConflict(input) {
|
|
166
|
+
return {
|
|
167
|
+
code: 'project-declaration-output-unavailable',
|
|
168
|
+
gateId: 'project-declaration-output',
|
|
169
|
+
message: 'Project declaration output is required but no TypeScript compiler API or supplied declarations were provided.',
|
|
170
|
+
details: { required: input.requireDeclarationOutput === true }
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function missingDeclarationsConflict(input) {
|
|
175
|
+
return {
|
|
176
|
+
code: 'project-declaration-output-empty',
|
|
177
|
+
gateId: 'project-declaration-output',
|
|
178
|
+
message: 'Project declaration output is required but no declaration files were emitted.',
|
|
179
|
+
details: { projectRoot: input.projectRoot }
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function declarationConflict(input, diagnostic) {
|
|
184
|
+
return compactRecord({
|
|
185
|
+
code: 'project-declaration-diagnostic',
|
|
186
|
+
gateId: 'project-declaration-output',
|
|
187
|
+
message: `Project declaration diagnostic ${diagnostic.code}: ${diagnostic.message}`,
|
|
188
|
+
sourcePath: diagnostic.sourcePath,
|
|
189
|
+
details: { diagnostic, projectRoot: input.projectRoot }
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function declarationSummary(declarationFiles, diagnostics, conflicts) {
|
|
194
|
+
return {
|
|
195
|
+
declarationFiles: declarationFiles.length,
|
|
196
|
+
declarationBytes: declarationFiles.reduce((total, file) => total + Number(file.bytes ?? 0), 0),
|
|
197
|
+
diagnostics: diagnostics.length,
|
|
198
|
+
conflicts: conflicts.length,
|
|
199
|
+
errors: diagnostics.filter((diagnostic) => diagnostic.severity === 'error').length,
|
|
200
|
+
warnings: diagnostics.filter((diagnostic) => diagnostic.severity === 'warning').length
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function declarationEvidence(id, status, declarationOutput, diagnostics, conflicts, input) {
|
|
205
|
+
return {
|
|
206
|
+
id: `${id}_declaration_output_evidence`,
|
|
207
|
+
kind: 'js-ts-project-declaration-output',
|
|
208
|
+
status: status === 'passed' ? 'passed' : 'failed',
|
|
209
|
+
summary: status === 'passed'
|
|
210
|
+
? `Emitted ${declarationOutput.declarationFiles.length} declaration file(s) for JS/TS project output.`
|
|
211
|
+
: `Blocked JS/TS project merge on ${conflicts.length} declaration output conflict(s).`,
|
|
212
|
+
metadata: {
|
|
213
|
+
declarationFiles: declarationOutput.declarationFiles.length,
|
|
214
|
+
diagnostics: diagnostics.length,
|
|
215
|
+
conflicts: conflicts.length,
|
|
216
|
+
declarationSource: input.outputDeclarations || input.outputDeclarationFiles ? 'supplied' : 'typescript-compiler-api',
|
|
217
|
+
autoMergeClaim: false,
|
|
218
|
+
semanticEquivalenceClaim: false
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function byteLength(text) {
|
|
224
|
+
return typeof TextEncoder === 'function' ? new TextEncoder().encode(text).length : String(text).length;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export { createJsTsProjectMergeDeclarationGate };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
import { describeJsTsProjectCompilerInputs, sourceMapMatch } from './js-ts-safe-project-merge-ts-program.js';
|
|
3
|
+
|
|
4
|
+
const projectReferenceDiagnosticCodes = new Set([6053, 6305, 6306, 6310, 6311]);
|
|
5
|
+
|
|
6
|
+
export function optionDiagnosticSource(diagnostic, metadata = {}) {
|
|
7
|
+
return metadata.projectReferenceCount && projectReferenceDiagnosticCodes.has(diagnostic.code)
|
|
8
|
+
? 'typescript-project-references'
|
|
9
|
+
: 'typescript-compiler-options';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function keepDiagnostic(diagnostic, sourceMap, projectRoot) {
|
|
13
|
+
if (!diagnostic.sourcePath) return true;
|
|
14
|
+
if (diagnostic.source === 'typescript-compiler-options' || diagnostic.source === 'typescript-project-references') return true;
|
|
15
|
+
return Boolean(sourceMapMatch(sourceMap, diagnostic.sourcePath, projectRoot));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function uniqueDiagnostics(diagnostics) {
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
return diagnostics.filter((diagnostic) => {
|
|
21
|
+
const key = `${diagnostic.source ?? ''}:${diagnostic.code}:${diagnostic.sourcePath ?? ''}:${diagnostic.start ?? ''}:${diagnostic.message}`;
|
|
22
|
+
if (seen.has(key)) return false;
|
|
23
|
+
seen.add(key);
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function diagnosticsMetadata(compilerMetadata, rootNames, sourceMap, diagnosticSource) {
|
|
29
|
+
return compactRecord({
|
|
30
|
+
...compilerMetadata,
|
|
31
|
+
diagnosticSource,
|
|
32
|
+
rootNames,
|
|
33
|
+
sourceFiles: sourceMap.size
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function diagnosticsGateMetadata(input, diagnosticsResult) {
|
|
38
|
+
return compactRecord({
|
|
39
|
+
...(diagnosticsResult?.metadata ?? describeJsTsProjectCompilerInputs(input)),
|
|
40
|
+
diagnosticSource: diagnosticsResult?.metadata?.diagnosticSource ?? 'missing'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
import {
|
|
3
|
+
diagnosticsMetadata,
|
|
4
|
+
keepDiagnostic,
|
|
5
|
+
optionDiagnosticSource,
|
|
6
|
+
uniqueDiagnostics
|
|
7
|
+
} from './js-ts-safe-project-merge-diagnostics-metadata.js';
|
|
8
|
+
import {
|
|
9
|
+
createJsTsVirtualTypeScriptProgram,
|
|
10
|
+
normalizePath,
|
|
11
|
+
normalizeTypeScriptDiagnostic,
|
|
12
|
+
sourceMapMatch
|
|
13
|
+
} from './js-ts-safe-project-merge-ts-program.js';
|
|
14
|
+
|
|
15
|
+
export function collectTypeScriptDiagnostics(input, outputFiles) {
|
|
16
|
+
const created = createJsTsVirtualTypeScriptProgram(input, outputFiles);
|
|
17
|
+
if (!created) return undefined;
|
|
18
|
+
const { ts, sourceMap, program, compilerOptionDiagnostics = [], compilerMetadata = {}, rootNames = [] } = created;
|
|
19
|
+
const projectRoot = normalizePath(input.projectRoot ?? '');
|
|
20
|
+
const options = input.diagnosticOptions ?? input.typescriptDiagnosticOptions ?? {};
|
|
21
|
+
const diagnostics = [...compilerOptionDiagnostics];
|
|
22
|
+
if (!program) {
|
|
23
|
+
return {
|
|
24
|
+
diagnostics: uniqueDiagnostics(diagnostics),
|
|
25
|
+
metadata: diagnosticsMetadata(compilerMetadata, rootNames, sourceMap, 'typescript-compiler-api')
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (options.options !== false && program.getOptionsDiagnostics) {
|
|
29
|
+
diagnostics.push(...program.getOptionsDiagnostics().map((diagnostic) => (
|
|
30
|
+
normalizeTypeScriptDiagnostic(ts, diagnostic, optionDiagnosticSource(diagnostic, compilerMetadata))
|
|
31
|
+
)));
|
|
32
|
+
}
|
|
33
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
34
|
+
if (!sourceMapMatch(sourceMap, sourceFile.fileName, projectRoot)) continue;
|
|
35
|
+
if (options.syntactic !== false && program.getSyntacticDiagnostics) {
|
|
36
|
+
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile).map((diagnostic) => ({
|
|
37
|
+
diagnostic,
|
|
38
|
+
phase: 'syntax'
|
|
39
|
+
})));
|
|
40
|
+
}
|
|
41
|
+
if (options.semantic !== false && program.getSemanticDiagnostics) {
|
|
42
|
+
diagnostics.push(...program.getSemanticDiagnostics(sourceFile).map((diagnostic) => ({
|
|
43
|
+
diagnostic,
|
|
44
|
+
phase: 'semantic'
|
|
45
|
+
})));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
diagnostics: uniqueDiagnostics(diagnostics.map((entry) => (
|
|
50
|
+
entry?.diagnostic
|
|
51
|
+
? withDiagnosticPhase(normalizeTypeScriptDiagnostic(ts, entry.diagnostic), entry.phase)
|
|
52
|
+
: withDiagnosticPhase(entry, entry.phase)
|
|
53
|
+
)).filter((diagnostic) => keepDiagnostic(diagnostic, sourceMap, projectRoot))),
|
|
54
|
+
metadata: diagnosticsMetadata(compilerMetadata, rootNames, sourceMap, 'typescript-compiler-api')
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function withDiagnosticPhase(diagnostic, phase) {
|
|
59
|
+
const normalizedPhase = normalizeDiagnosticPhase(phase);
|
|
60
|
+
return compactRecord({
|
|
61
|
+
...diagnostic,
|
|
62
|
+
phase: normalizedPhase,
|
|
63
|
+
syntax: diagnostic.syntax === true || normalizedPhase === 'syntax' ? true : undefined
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function normalizeDiagnosticPhase(value) {
|
|
68
|
+
if (typeof value !== 'string') return undefined;
|
|
69
|
+
const lowered = value.toLowerCase();
|
|
70
|
+
if (lowered.includes('syntax') || lowered.includes('syntactic') || lowered.includes('parse')) return 'syntax';
|
|
71
|
+
if (lowered.includes('semantic') || lowered.includes('type')) return 'semantic';
|
|
72
|
+
return value;
|
|
73
|
+
}
|