@shapeshift-labs/frontier-lang-compiler 0.2.150 → 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-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 +31 -0
- package/dist/index.js +5 -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/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-jsx-attribute-fallback.js +151 -157
- 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-semantic-edit-fallback.js +13 -5
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -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 +170 -171
- 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,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
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import { diagnosticsGateMetadata } from './js-ts-safe-project-merge-diagnostics-metadata.js';
|
|
4
|
+
import { collectTypeScriptDiagnostics } from './js-ts-safe-project-merge-diagnostics-ts.js';
|
|
5
|
+
import {
|
|
6
|
+
collectJsxComponentPropContractsFromFileResults,
|
|
7
|
+
jsxComponentPropContractConflict,
|
|
8
|
+
jsxComponentPropContractEvidence,
|
|
9
|
+
jsxComponentPropContractSummary,
|
|
10
|
+
matchingJsxComponentPropContracts,
|
|
11
|
+
normalizeJsxComponentPropContracts
|
|
12
|
+
} from './js-ts-safe-project-merge-jsx-prop-contracts.js';
|
|
13
|
+
import {
|
|
14
|
+
describeJsTsProjectCompilerInputs,
|
|
15
|
+
normalizeSuppliedDiagnostics
|
|
16
|
+
} from './js-ts-safe-project-merge-ts-program.js';
|
|
17
|
+
|
|
18
|
+
const projectOutputDiagnosticCode = 'project-output-diagnostic';
|
|
19
|
+
const projectOutputSyntaxDiagnosticCode = 'project-output-syntax-diagnostic';
|
|
20
|
+
const projectOutputDiagnosticsUnavailableCode = 'project-output-diagnostics-unavailable';
|
|
21
|
+
const projectOutputSyntaxDiagnosticsUnavailableCode = 'project-output-syntax-diagnostics-unavailable';
|
|
22
|
+
|
|
23
|
+
function createJsTsProjectMergeDiagnosticsGate(input = {}, outputFiles = [], id = 'js_ts_project_safe_merge', context = {}) {
|
|
24
|
+
const jsxComponentPropContracts = normalizeJsxComponentPropContracts(
|
|
25
|
+
input.jsxComponentPropContracts
|
|
26
|
+
?? input.jsxComponentPropContractCandidates
|
|
27
|
+
?? context.jsxComponentPropContracts
|
|
28
|
+
?? collectJsxComponentPropContractsFromFileResults(context.fileResults)
|
|
29
|
+
);
|
|
30
|
+
const suppliedDiagnostics = normalizeSuppliedOutputDiagnostics(input);
|
|
31
|
+
const diagnosticsResult = suppliedDiagnostics !== undefined
|
|
32
|
+
? suppliedDiagnosticsResult(input, suppliedDiagnostics)
|
|
33
|
+
: collectTypeScriptDiagnostics(input, outputFiles);
|
|
34
|
+
const diagnostics = diagnosticsResult?.diagnostics;
|
|
35
|
+
const metadata = diagnosticsGateMetadata(input, diagnosticsResult);
|
|
36
|
+
const syntaxOnly = requiresOutputSyntaxDiagnostics(input) && input.requireOutputDiagnostics !== true && input.outputDiagnostics === undefined;
|
|
37
|
+
if (!diagnostics && input.requireOutputDiagnostics !== true && !requiresOutputSyntaxDiagnostics(input) && !jsxComponentPropContracts.length) return undefined;
|
|
38
|
+
if (!diagnostics) return unavailableGate(input, id, syntaxOnly, metadata, outputFiles, jsxComponentPropContracts);
|
|
39
|
+
const errorDiagnostics = diagnostics.filter((diagnostic) => (
|
|
40
|
+
diagnostic.severity === 'error' && (!syntaxOnly || isSyntaxDiagnostic(diagnostic))
|
|
41
|
+
));
|
|
42
|
+
const conflicts = errorDiagnostics.map((diagnostic) => diagnosticConflict(input, diagnostic, jsxComponentPropContracts));
|
|
43
|
+
const status = conflicts.length ? 'blocked' : 'passed';
|
|
44
|
+
const core = {
|
|
45
|
+
kind: 'frontier.lang.jsTsProjectMergeDiagnosticsGate',
|
|
46
|
+
version: 1,
|
|
47
|
+
schema: 'frontier.lang.jsTsProjectMergeDiagnosticsGate.v1',
|
|
48
|
+
id: `${id}_output_diagnostics`,
|
|
49
|
+
status,
|
|
50
|
+
sourcePaths: outputFiles.map((file) => file.sourcePath).filter(Boolean),
|
|
51
|
+
diagnostics,
|
|
52
|
+
conflicts,
|
|
53
|
+
admission: {
|
|
54
|
+
status: status === 'passed' ? 'auto-merge-candidate' : 'blocked',
|
|
55
|
+
action: status === 'passed' ? 'accept-diagnostics' : 'human-review',
|
|
56
|
+
reviewRequired: status !== 'passed',
|
|
57
|
+
autoApplyCandidate: status === 'passed',
|
|
58
|
+
autoMergeClaim: false,
|
|
59
|
+
semanticEquivalenceClaim: false,
|
|
60
|
+
reasonCodes: uniqueStrings(conflicts.map((conflict) => conflict.code))
|
|
61
|
+
},
|
|
62
|
+
summary: diagnosticsSummary(diagnostics, conflicts, jsxComponentPropContracts),
|
|
63
|
+
metadata,
|
|
64
|
+
evidence: [{
|
|
65
|
+
id: `${id}_output_diagnostics_evidence`,
|
|
66
|
+
kind: 'js-ts-project-output-diagnostics',
|
|
67
|
+
status: status === 'passed' ? 'passed' : 'failed',
|
|
68
|
+
summary: status === 'passed'
|
|
69
|
+
? `Validated ${outputFiles.length} JS/TS output file(s) with no blocking diagnostics.`
|
|
70
|
+
: `Blocked JS/TS project merge on ${conflicts.length} output diagnostic conflict(s).`,
|
|
71
|
+
metadata: {
|
|
72
|
+
diagnostics: diagnostics.length,
|
|
73
|
+
conflicts: conflicts.length,
|
|
74
|
+
diagnosticSource: metadata.diagnosticSource,
|
|
75
|
+
compilerOptions: metadata.compilerOptions,
|
|
76
|
+
compilerOptionSources: metadata.compilerOptionSources,
|
|
77
|
+
projectReferences: metadata.projectReferences,
|
|
78
|
+
projectReferenceCount: metadata.projectReferenceCount,
|
|
79
|
+
jsxComponentPropContractCandidates: jsxComponentPropContracts.length || undefined,
|
|
80
|
+
syntaxOnly,
|
|
81
|
+
autoMergeClaim: false,
|
|
82
|
+
semanticEquivalenceClaim: false
|
|
83
|
+
}
|
|
84
|
+
}, ...jsxComponentPropContractEvidence(id, status, diagnostics, conflicts, metadata.diagnosticSource, jsxComponentPropContracts)]
|
|
85
|
+
};
|
|
86
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function suppliedDiagnosticsResult(input, diagnostics) {
|
|
90
|
+
return {
|
|
91
|
+
diagnostics,
|
|
92
|
+
metadata: {
|
|
93
|
+
...describeJsTsProjectCompilerInputs(input),
|
|
94
|
+
diagnosticSource: diagnosticSource(input),
|
|
95
|
+
hasTypescriptCompilerApi: Boolean(input.typescript ?? input.ts ?? input.typescriptModule)
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function unavailableGate(input, id, syntaxOnly = false, metadata = {}, outputFiles = [], jsxComponentPropContracts = []) {
|
|
101
|
+
const code = syntaxOnly ? projectOutputSyntaxDiagnosticsUnavailableCode : projectOutputDiagnosticsUnavailableCode;
|
|
102
|
+
const diagnosticConflict = {
|
|
103
|
+
code,
|
|
104
|
+
gateId: 'project-output-diagnostics',
|
|
105
|
+
message: syntaxOnly
|
|
106
|
+
? 'Project output syntax diagnostics are required but no TypeScript compiler API or supplied syntax diagnostics were provided.'
|
|
107
|
+
: 'Project output diagnostics are required but no TypeScript compiler API or supplied diagnostics were provided.',
|
|
108
|
+
details: { required: input.requireOutputDiagnostics === true, syntaxRequired: requiresOutputSyntaxDiagnostics(input) }
|
|
109
|
+
};
|
|
110
|
+
const conflicts = [
|
|
111
|
+
...(input.requireOutputDiagnostics === true || requiresOutputSyntaxDiagnostics(input) ? [diagnosticConflict] : []),
|
|
112
|
+
...(jsxComponentPropContracts.length ? [jsxComponentPropContractConflict(jsxComponentPropContracts)] : [])
|
|
113
|
+
];
|
|
114
|
+
const gateConflicts = conflicts.length ? conflicts : [diagnosticConflict];
|
|
115
|
+
const core = {
|
|
116
|
+
kind: 'frontier.lang.jsTsProjectMergeDiagnosticsGate',
|
|
117
|
+
version: 1,
|
|
118
|
+
schema: 'frontier.lang.jsTsProjectMergeDiagnosticsGate.v1',
|
|
119
|
+
id: `${id}_output_diagnostics`,
|
|
120
|
+
status: 'blocked',
|
|
121
|
+
sourcePaths: outputFiles.map((file) => file.sourcePath).filter(Boolean),
|
|
122
|
+
diagnostics: [],
|
|
123
|
+
conflicts: gateConflicts,
|
|
124
|
+
admission: {
|
|
125
|
+
status: 'blocked',
|
|
126
|
+
action: 'human-review',
|
|
127
|
+
reviewRequired: true,
|
|
128
|
+
autoApplyCandidate: false,
|
|
129
|
+
autoMergeClaim: false,
|
|
130
|
+
semanticEquivalenceClaim: false,
|
|
131
|
+
reasonCodes: uniqueStrings(gateConflicts.map((conflict) => conflict.code))
|
|
132
|
+
},
|
|
133
|
+
summary: diagnosticsSummary([], gateConflicts, jsxComponentPropContracts),
|
|
134
|
+
metadata,
|
|
135
|
+
evidence: [{
|
|
136
|
+
id: `${id}_output_diagnostics_evidence`,
|
|
137
|
+
kind: 'js-ts-project-output-diagnostics',
|
|
138
|
+
status: 'failed',
|
|
139
|
+
summary: gateConflicts.map((conflict) => conflict.message).join(' '),
|
|
140
|
+
metadata: {
|
|
141
|
+
diagnostics: 0,
|
|
142
|
+
conflicts: gateConflicts.length,
|
|
143
|
+
diagnosticSource: 'missing',
|
|
144
|
+
compilerOptions: metadata.compilerOptions,
|
|
145
|
+
compilerOptionSources: metadata.compilerOptionSources,
|
|
146
|
+
projectReferences: metadata.projectReferences,
|
|
147
|
+
projectReferenceCount: metadata.projectReferenceCount,
|
|
148
|
+
jsxComponentPropContractCandidates: jsxComponentPropContracts.length || undefined,
|
|
149
|
+
syntaxOnly
|
|
150
|
+
}
|
|
151
|
+
}, ...jsxComponentPropContractEvidence(id, 'blocked', [], gateConflicts, 'missing', jsxComponentPropContracts)]
|
|
152
|
+
};
|
|
153
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function diagnosticConflict(input, diagnostic, jsxComponentPropContracts = []) {
|
|
157
|
+
const syntax = isSyntaxDiagnostic(diagnostic);
|
|
158
|
+
const matchingContracts = matchingJsxComponentPropContracts(diagnostic, jsxComponentPropContracts);
|
|
159
|
+
return compactRecord({
|
|
160
|
+
code: syntax ? projectOutputSyntaxDiagnosticCode : projectOutputDiagnosticCode,
|
|
161
|
+
gateId: 'project-output-diagnostics',
|
|
162
|
+
message: `${syntax ? 'Project output syntax diagnostic' : 'Project output diagnostic'} ${diagnostic.code}: ${diagnostic.message}`,
|
|
163
|
+
sourcePath: diagnostic.sourcePath,
|
|
164
|
+
details: {
|
|
165
|
+
diagnostic,
|
|
166
|
+
syntax,
|
|
167
|
+
projectRoot: input.projectRoot,
|
|
168
|
+
jsxComponentPropContracts: matchingContracts.length ? matchingContracts : undefined
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function diagnosticsSummary(diagnostics, conflicts, jsxComponentPropContracts = []) {
|
|
174
|
+
const bySeverity = {};
|
|
175
|
+
const bySource = {};
|
|
176
|
+
const byPhase = {};
|
|
177
|
+
for (const diagnostic of diagnostics) {
|
|
178
|
+
bySeverity[diagnostic.severity] = (bySeverity[diagnostic.severity] ?? 0) + 1;
|
|
179
|
+
bySource[diagnostic.source ?? 'unknown'] = (bySource[diagnostic.source ?? 'unknown'] ?? 0) + 1;
|
|
180
|
+
byPhase[diagnostic.phase ?? 'unknown'] = (byPhase[diagnostic.phase ?? 'unknown'] ?? 0) + 1;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
diagnostics: diagnostics.length,
|
|
184
|
+
conflicts: conflicts.length,
|
|
185
|
+
errors: diagnostics.filter((diagnostic) => diagnostic.severity === 'error').length,
|
|
186
|
+
warnings: diagnostics.filter((diagnostic) => diagnostic.severity === 'warning').length,
|
|
187
|
+
syntaxErrors: diagnostics.filter((diagnostic) => diagnostic.severity === 'error' && isSyntaxDiagnostic(diagnostic)).length,
|
|
188
|
+
bySeverity,
|
|
189
|
+
bySource,
|
|
190
|
+
byPhase,
|
|
191
|
+
...jsxComponentPropContractSummary(jsxComponentPropContracts)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function normalizeSuppliedOutputDiagnostics(input) {
|
|
196
|
+
const hasOutputDiagnostics = Object.hasOwn(input, 'outputDiagnostics');
|
|
197
|
+
const hasOutputSyntaxDiagnostics = Object.hasOwn(input, 'outputSyntaxDiagnostics')
|
|
198
|
+
|| Object.hasOwn(input, 'mergedOutputSyntaxDiagnostics')
|
|
199
|
+
|| input.syntaxDiagnostics?.output !== undefined
|
|
200
|
+
|| input.syntaxDiagnostics?.merged !== undefined;
|
|
201
|
+
if (!hasOutputDiagnostics && !hasOutputSyntaxDiagnostics) return undefined;
|
|
202
|
+
return [
|
|
203
|
+
...normalizeSuppliedDiagnosticsWithPhase(input.outputDiagnostics, undefined),
|
|
204
|
+
...normalizeSuppliedDiagnosticsWithPhase(input.outputSyntaxDiagnostics, 'syntax'),
|
|
205
|
+
...normalizeSuppliedDiagnosticsWithPhase(input.mergedOutputSyntaxDiagnostics, 'syntax'),
|
|
206
|
+
...normalizeSuppliedDiagnosticsWithPhase(input.syntaxDiagnostics?.output, 'syntax'),
|
|
207
|
+
...normalizeSuppliedDiagnosticsWithPhase(input.syntaxDiagnostics?.merged, 'syntax')
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function normalizeSuppliedDiagnosticsWithPhase(value, fallbackPhase) {
|
|
212
|
+
if (value === undefined) return [];
|
|
213
|
+
const rawDiagnostics = Array.isArray(value) ? value : [value].filter(Boolean);
|
|
214
|
+
const normalized = normalizeSuppliedDiagnostics(value);
|
|
215
|
+
return normalized.map((diagnostic, index) => withDiagnosticPhase(diagnostic, suppliedDiagnosticPhase(rawDiagnostics[index], fallbackPhase)));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function withDiagnosticPhase(diagnostic, phase) {
|
|
219
|
+
const normalizedPhase = normalizeDiagnosticPhase(phase);
|
|
220
|
+
const syntax = diagnostic.syntax === true || normalizedPhase === 'syntax' || isSyntaxDiagnostic(diagnostic);
|
|
221
|
+
return compactRecord({
|
|
222
|
+
...diagnostic,
|
|
223
|
+
phase: normalizedPhase,
|
|
224
|
+
syntax: syntax ? true : undefined
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function suppliedDiagnosticPhase(diagnostic, fallbackPhase) {
|
|
229
|
+
return diagnostic?.phase
|
|
230
|
+
?? diagnostic?.diagnosticPhase
|
|
231
|
+
?? diagnostic?.kind
|
|
232
|
+
?? diagnostic?.type
|
|
233
|
+
?? (diagnostic?.syntax === true ? 'syntax' : undefined)
|
|
234
|
+
?? fallbackPhase;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function requiresOutputSyntaxDiagnostics(input) {
|
|
238
|
+
return input.requireOutputSyntaxDiagnostics === true
|
|
239
|
+
|| input.requireOutputSyntaxGate === true
|
|
240
|
+
|| input.requireMergedOutputSyntaxDiagnostics === true
|
|
241
|
+
|| input.requireSyntaxGate === true;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function isSyntaxDiagnostic(diagnostic) {
|
|
245
|
+
if (diagnostic.syntax === true) return true;
|
|
246
|
+
const text = [
|
|
247
|
+
diagnostic.phase,
|
|
248
|
+
diagnostic.kind,
|
|
249
|
+
diagnostic.category,
|
|
250
|
+
diagnostic.type,
|
|
251
|
+
diagnostic.source,
|
|
252
|
+
diagnostic.ruleId,
|
|
253
|
+
diagnostic.name,
|
|
254
|
+
diagnostic.code
|
|
255
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
256
|
+
return /\bsyntax\b|\bsyntactic\b|\bparse\b|\bparser\b/.test(text) || isTypeScriptSyntaxDiagnosticCode(diagnostic.code);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function isTypeScriptSyntaxDiagnosticCode(code) {
|
|
260
|
+
const match = /^TS(\d+)$/.exec(String(code ?? ''));
|
|
261
|
+
if (!match) return false;
|
|
262
|
+
const numeric = Number(match[1]);
|
|
263
|
+
return numeric >= 1000 && numeric < 2000;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function normalizeDiagnosticPhase(value) {
|
|
267
|
+
if (typeof value !== 'string') return undefined;
|
|
268
|
+
const lowered = value.toLowerCase();
|
|
269
|
+
if (lowered.includes('syntax') || lowered.includes('syntactic') || lowered.includes('parse')) return 'syntax';
|
|
270
|
+
if (lowered.includes('semantic') || lowered.includes('type')) return 'semantic';
|
|
271
|
+
return value;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function diagnosticSource(input) {
|
|
275
|
+
if (input.outputDiagnostics !== undefined && (input.outputSyntaxDiagnostics !== undefined || input.mergedOutputSyntaxDiagnostics !== undefined)) {
|
|
276
|
+
return 'supplied-mixed';
|
|
277
|
+
}
|
|
278
|
+
if (input.outputDiagnostics !== undefined) return 'supplied';
|
|
279
|
+
if (input.outputSyntaxDiagnostics !== undefined || input.mergedOutputSyntaxDiagnostics !== undefined || input.syntaxDiagnostics) return 'supplied-syntax';
|
|
280
|
+
return 'typescript-compiler-api';
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export { createJsTsProjectMergeDiagnosticsGate };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function failedEvidenceMissingItems(evidence = []) {
|
|
2
|
+
return evidence
|
|
3
|
+
.filter((record) => record?.status === 'failed' && isPlainObject(record.metadata?.nextMissingEvidence))
|
|
4
|
+
.map((record) => {
|
|
5
|
+
const nextMissingEvidence = record.metadata.nextMissingEvidence;
|
|
6
|
+
const route = nextMissingEvidence.route;
|
|
7
|
+
return compactRecord({
|
|
8
|
+
...nextMissingEvidence,
|
|
9
|
+
status: nextMissingEvidence.status ?? 'missing-or-failed',
|
|
10
|
+
evidenceId: record.id,
|
|
11
|
+
routeId: nextMissingEvidence.routeId ?? route?.id,
|
|
12
|
+
routeLane: nextMissingEvidence.routeLane ?? route?.lane,
|
|
13
|
+
routeNext: nextMissingEvidence.routeNext ?? route?.next,
|
|
14
|
+
autoMergeClaim: false,
|
|
15
|
+
semanticEquivalenceClaim: false
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function fileAdmissionEvidenceRecords(files = []) {
|
|
21
|
+
return files.flatMap((file) => [
|
|
22
|
+
...recordArraysWithSuffix(file.summary, 'AdmissionEvidence'),
|
|
23
|
+
...recordArraysWithSuffix(file.metadata, 'Admissions')
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function recordArraysWithSuffix(record, suffix) {
|
|
28
|
+
if (!isPlainObject(record)) return [];
|
|
29
|
+
return Object.entries(record)
|
|
30
|
+
.filter(([key, value]) => key.endsWith(suffix) && Array.isArray(value))
|
|
31
|
+
.flatMap(([, value]) => value)
|
|
32
|
+
.filter((value) => value?.kind && value?.id);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isPlainObject(value) { return Boolean(value && typeof value === 'object' && !Array.isArray(value)); }
|
|
36
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
|
|
37
|
+
|
|
38
|
+
export { failedEvidenceMissingItems, fileAdmissionEvidenceRecords };
|