@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,173 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
import { jsxRenderReturnBranchProofAssessment } from './js-ts-safe-project-merge-jsx-render-branch-proof.js';
|
|
3
|
+
import {
|
|
4
|
+
hasRenderRisk,
|
|
5
|
+
jsxChildOrderDetails,
|
|
6
|
+
jsxChildOrderFingerprint,
|
|
7
|
+
jsxChildOrderIdentityKey,
|
|
8
|
+
jsxPropDetails,
|
|
9
|
+
jsxPropFingerprint,
|
|
10
|
+
jsxPropIdentityKey,
|
|
11
|
+
jsxPropLabel,
|
|
12
|
+
jsxRenderRiskDetails,
|
|
13
|
+
jsxRenderRiskFingerprint,
|
|
14
|
+
jsxRenderRiskIdentityKey,
|
|
15
|
+
jsxRenderRiskReasonCodes
|
|
16
|
+
} from './js-ts-safe-project-merge-jsx-graph-conflict-details.js';
|
|
17
|
+
function projectJsxPropDeltaConflicts(projectGraphDelta) {
|
|
18
|
+
const baseGraph = projectGraphDelta?.stages?.base?.projectSymbolGraph;
|
|
19
|
+
const workerGraph = projectGraphDelta?.stages?.worker?.projectSymbolGraph;
|
|
20
|
+
const headGraph = projectGraphDelta?.stages?.head?.projectSymbolGraph;
|
|
21
|
+
const outputGraph = projectGraphDelta?.stages?.output?.projectSymbolGraph;
|
|
22
|
+
if (!baseGraph || !workerGraph || !headGraph) return [];
|
|
23
|
+
const base = publicJsxProps(baseGraph.jsxPropRecords);
|
|
24
|
+
const worker = publicJsxProps(workerGraph.jsxPropRecords);
|
|
25
|
+
const head = publicJsxProps(headGraph.jsxPropRecords);
|
|
26
|
+
const output = publicJsxProps(outputGraph?.jsxPropRecords);
|
|
27
|
+
return uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]).flatMap((identityKey) => {
|
|
28
|
+
const baseRecord = base.get(identityKey);
|
|
29
|
+
const workerRecord = worker.get(identityKey);
|
|
30
|
+
const headRecord = head.get(identityKey);
|
|
31
|
+
const fingerprints = [jsxPropFingerprint(baseRecord), jsxPropFingerprint(workerRecord), jsxPropFingerprint(headRecord)];
|
|
32
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
33
|
+
return [projectJsxPropDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey))];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function projectJsxRenderRiskDeltaConflicts(projectGraphDelta, options = {}) {
|
|
37
|
+
const baseGraph = projectGraphDelta?.stages?.base?.projectSymbolGraph;
|
|
38
|
+
const workerGraph = projectGraphDelta?.stages?.worker?.projectSymbolGraph;
|
|
39
|
+
const headGraph = projectGraphDelta?.stages?.head?.projectSymbolGraph;
|
|
40
|
+
const outputGraph = projectGraphDelta?.stages?.output?.projectSymbolGraph;
|
|
41
|
+
if (!baseGraph || !workerGraph || !headGraph) return [];
|
|
42
|
+
const base = publicJsxRenderRisks(baseGraph.jsxElementRecords);
|
|
43
|
+
const worker = publicJsxRenderRisks(workerGraph.jsxElementRecords);
|
|
44
|
+
const head = publicJsxRenderRisks(headGraph.jsxElementRecords);
|
|
45
|
+
const output = publicJsxRenderRisks(outputGraph?.jsxElementRecords);
|
|
46
|
+
return uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]).flatMap((identityKey) => {
|
|
47
|
+
const baseRecord = base.get(identityKey);
|
|
48
|
+
const workerRecord = worker.get(identityKey);
|
|
49
|
+
const headRecord = head.get(identityKey);
|
|
50
|
+
const fingerprints = [jsxRenderRiskFingerprint(baseRecord), jsxRenderRiskFingerprint(workerRecord), jsxRenderRiskFingerprint(headRecord)];
|
|
51
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
52
|
+
const branchProof = jsxRenderReturnBranchProofAssessment({ identityKey, baseRecord, workerRecord, headRecord, outputRecord: output.get(identityKey) }, options);
|
|
53
|
+
if (branchProof?.status === 'passed') return [];
|
|
54
|
+
return [projectJsxRenderRiskDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey), branchProof)];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function projectJsxChildOrderDeltaConflicts(projectGraphDelta) {
|
|
58
|
+
const baseGraph = projectGraphDelta?.stages?.base?.projectSymbolGraph;
|
|
59
|
+
const workerGraph = projectGraphDelta?.stages?.worker?.projectSymbolGraph;
|
|
60
|
+
const headGraph = projectGraphDelta?.stages?.head?.projectSymbolGraph;
|
|
61
|
+
const outputGraph = projectGraphDelta?.stages?.output?.projectSymbolGraph;
|
|
62
|
+
if (!baseGraph || !workerGraph || !headGraph) return [];
|
|
63
|
+
const base = publicJsxChildOrders(baseGraph.jsxElementRecords);
|
|
64
|
+
const worker = publicJsxChildOrders(workerGraph.jsxElementRecords);
|
|
65
|
+
const head = publicJsxChildOrders(headGraph.jsxElementRecords);
|
|
66
|
+
const output = publicJsxChildOrders(outputGraph?.jsxElementRecords);
|
|
67
|
+
return uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]).flatMap((identityKey) => {
|
|
68
|
+
const baseRecord = base.get(identityKey);
|
|
69
|
+
const workerRecord = worker.get(identityKey);
|
|
70
|
+
const headRecord = head.get(identityKey);
|
|
71
|
+
const fingerprints = [jsxChildOrderFingerprint(baseRecord), jsxChildOrderFingerprint(workerRecord), jsxChildOrderFingerprint(headRecord)];
|
|
72
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
73
|
+
return [projectJsxChildOrderDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey))];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function projectJsxPropDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord) {
|
|
77
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
78
|
+
const label = jsxPropLabel(workerRecord ?? headRecord ?? baseRecord);
|
|
79
|
+
return {
|
|
80
|
+
code: 'project-jsx-public-prop-delta-conflict',
|
|
81
|
+
gateId: 'project-graph-delta',
|
|
82
|
+
message: `Worker and head both changed JSX public ${label} ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
83
|
+
sourcePath,
|
|
84
|
+
details: compactRecord({
|
|
85
|
+
reasonCode: 'project-jsx-public-prop-delta-conflict',
|
|
86
|
+
conflictKey: `project-graph-delta#jsx-prop#${identityKey}`,
|
|
87
|
+
identityKey,
|
|
88
|
+
sourcePath,
|
|
89
|
+
base: jsxPropDetails(baseRecord),
|
|
90
|
+
worker: jsxPropDetails(workerRecord),
|
|
91
|
+
head: jsxPropDetails(headRecord),
|
|
92
|
+
output: jsxPropDetails(outputRecord)
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function projectJsxChildOrderDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord) {
|
|
97
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
98
|
+
return {
|
|
99
|
+
code: 'project-jsx-public-child-order-delta-conflict',
|
|
100
|
+
gateId: 'project-graph-delta',
|
|
101
|
+
message: `Worker and head both changed JSX keyed child order evidence ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
102
|
+
sourcePath,
|
|
103
|
+
details: compactRecord({
|
|
104
|
+
reasonCode: 'project-jsx-public-child-order-delta-conflict',
|
|
105
|
+
conflictKey: `project-graph-delta#jsx-child-order#${identityKey}`,
|
|
106
|
+
identityKey,
|
|
107
|
+
sourcePath,
|
|
108
|
+
base: jsxChildOrderDetails(baseRecord),
|
|
109
|
+
worker: jsxChildOrderDetails(workerRecord),
|
|
110
|
+
head: jsxChildOrderDetails(headRecord),
|
|
111
|
+
output: jsxChildOrderDetails(outputRecord)
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function projectJsxRenderRiskDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord, branchProof) {
|
|
116
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
117
|
+
return {
|
|
118
|
+
code: 'project-jsx-public-render-risk-delta-conflict',
|
|
119
|
+
gateId: 'project-graph-delta',
|
|
120
|
+
message: `Worker and head both changed JSX public render-semantics evidence ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
121
|
+
sourcePath,
|
|
122
|
+
details: compactRecord({
|
|
123
|
+
reasonCode: 'project-jsx-public-render-risk-delta-conflict',
|
|
124
|
+
reasonCodes: uniqueStrings([...jsxRenderRiskReasonCodes(baseRecord, workerRecord, headRecord, outputRecord), ...(branchProof?.reasonCodes ?? [])]),
|
|
125
|
+
conflictKey: `project-graph-delta#jsx-render-risk#${identityKey}`,
|
|
126
|
+
identityKey,
|
|
127
|
+
sourcePath,
|
|
128
|
+
routeId: branchProof?.routeId,
|
|
129
|
+
routeLane: branchProof?.routeLane,
|
|
130
|
+
routeNext: branchProof?.routeNext,
|
|
131
|
+
base: jsxRenderRiskDetails(baseRecord),
|
|
132
|
+
worker: jsxRenderRiskDetails(workerRecord),
|
|
133
|
+
head: jsxRenderRiskDetails(headRecord),
|
|
134
|
+
output: jsxRenderRiskDetails(outputRecord),
|
|
135
|
+
jsxRenderReturnBranchProof: branchProof?.record,
|
|
136
|
+
autoMergeClaim: false,
|
|
137
|
+
semanticEquivalenceClaim: false,
|
|
138
|
+
runtimeEquivalenceClaim: false,
|
|
139
|
+
renderEquivalenceClaim: false
|
|
140
|
+
})
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function publicJsxProps(records = []) {
|
|
144
|
+
const result = new Map();
|
|
145
|
+
for (const record of records) {
|
|
146
|
+
if (!record?.publicContract) continue;
|
|
147
|
+
const key = jsxPropIdentityKey(record);
|
|
148
|
+
if (key && !result.has(key)) result.set(key, record);
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
function publicJsxRenderRisks(records = []) {
|
|
153
|
+
const result = new Map();
|
|
154
|
+
for (const record of records ?? []) {
|
|
155
|
+
if (!record?.publicContract || !hasRenderRisk(record)) continue;
|
|
156
|
+
const key = jsxRenderRiskIdentityKey(record);
|
|
157
|
+
if (key && !result.has(key)) result.set(key, record);
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
function publicJsxChildOrders(records = []) {
|
|
162
|
+
const result = new Map();
|
|
163
|
+
for (const record of records ?? []) {
|
|
164
|
+
if (!record?.publicContract || !record?.keyPropValue) continue;
|
|
165
|
+
const key = jsxChildOrderIdentityKey(record);
|
|
166
|
+
if (key && !result.has(key)) result.set(key, record);
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
172
|
+
|
|
173
|
+
export { projectJsxChildOrderDeltaConflicts, projectJsxPropDeltaConflicts, projectJsxRenderRiskDeltaConflicts };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { compactRecord, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
2
|
+
|
|
3
|
+
export function collectJsxComponentPropContractsFromFileResults(fileResults = []) {
|
|
4
|
+
const contracts = [];
|
|
5
|
+
for (const file of Array.isArray(fileResults) ? fileResults : []) {
|
|
6
|
+
const fallback = file.result?.metadata?.composed?.jsxAttributeFallback;
|
|
7
|
+
const candidates = fallback?.componentPropContracts ?? fallback?.jsxComponentPropContracts ?? [];
|
|
8
|
+
for (const candidate of Array.isArray(candidates) ? candidates : []) {
|
|
9
|
+
contracts.push({ ...candidate, sourcePath: candidate.sourcePath ?? file.sourcePath });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return contracts;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function normalizeJsxComponentPropContracts(value) {
|
|
16
|
+
const values = Array.isArray(value) ? value : [];
|
|
17
|
+
return values.map((contract, index) => {
|
|
18
|
+
const attributes = uniqueStrings((Array.isArray(contract.attributes) ? contract.attributes : [])
|
|
19
|
+
.map((attribute) => String(attribute))
|
|
20
|
+
.filter(Boolean));
|
|
21
|
+
return compactRecord({
|
|
22
|
+
id: contract.id ?? `jsx_component_prop_contract_${index + 1}`,
|
|
23
|
+
sourcePath: stringOrUndefined(contract.sourcePath),
|
|
24
|
+
tagName: stringOrUndefined(contract.tagName),
|
|
25
|
+
tagKey: stringOrUndefined(contract.tagKey),
|
|
26
|
+
attributes: attributes.length ? attributes : undefined,
|
|
27
|
+
attributeCount: numberOrUndefined(contract.attributeCount) ?? attributes.length
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function matchingJsxComponentPropContracts(diagnostic, jsxComponentPropContracts) {
|
|
33
|
+
if (!jsxComponentPropContracts.length) return [];
|
|
34
|
+
const sourcePath = diagnostic.sourcePath;
|
|
35
|
+
if (!sourcePath) return jsxComponentPropContracts;
|
|
36
|
+
return jsxComponentPropContracts.filter((contract) => contract.sourcePath === sourcePath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function jsxComponentPropContractConflict(jsxComponentPropContracts) {
|
|
40
|
+
return {
|
|
41
|
+
code: 'jsx-component-prop-contract-evidence-unavailable',
|
|
42
|
+
gateId: 'jsx-component-prop-contract',
|
|
43
|
+
message: 'JSX component prop changes require TypeScript diagnostics or supplied diagnostics before project admission.',
|
|
44
|
+
sourcePath: jsxComponentPropContracts.length === 1 ? jsxComponentPropContracts[0].sourcePath : undefined,
|
|
45
|
+
details: {
|
|
46
|
+
required: true,
|
|
47
|
+
candidates: jsxComponentPropContracts
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function jsxComponentPropContractEvidence(id, status, diagnostics, conflicts, diagnosticSource, jsxComponentPropContracts) {
|
|
53
|
+
if (!jsxComponentPropContracts.length) return [];
|
|
54
|
+
return [{
|
|
55
|
+
id: `${id}_jsx_component_prop_contract_evidence`,
|
|
56
|
+
kind: 'js-ts-jsx-component-prop-contract-evidence',
|
|
57
|
+
status: status === 'passed' ? 'passed' : 'failed',
|
|
58
|
+
summary: status === 'passed'
|
|
59
|
+
? `Validated ${jsxComponentPropContracts.length} JSX component prop contract candidate(s) with diagnostics evidence.`
|
|
60
|
+
: `Blocked JSX component prop contract candidate(s) on ${conflicts.length} diagnostic or evidence conflict(s).`,
|
|
61
|
+
metadata: {
|
|
62
|
+
candidates: jsxComponentPropContracts.length,
|
|
63
|
+
attributes: jsxComponentPropContracts.reduce((total, contract) => total + (contract.attributeCount ?? 0), 0),
|
|
64
|
+
diagnosticSource,
|
|
65
|
+
diagnostics: diagnostics.length,
|
|
66
|
+
conflicts: conflicts.length,
|
|
67
|
+
contracts: jsxComponentPropContracts
|
|
68
|
+
}
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function jsxComponentPropContractSummary(jsxComponentPropContracts) {
|
|
73
|
+
return {
|
|
74
|
+
jsxComponentPropContractCandidates: jsxComponentPropContracts.length,
|
|
75
|
+
jsxComponentPropContractFiles: uniqueStrings(jsxComponentPropContracts.map((contract) => contract.sourcePath)).length,
|
|
76
|
+
jsxComponentPropContractAttributes: jsxComponentPropContracts.reduce((total, contract) => total + (contract.attributeCount ?? 0), 0)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function stringOrUndefined(value) {
|
|
81
|
+
return value === undefined || value === null ? undefined : String(value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function numberOrUndefined(value) {
|
|
85
|
+
return Number.isFinite(value) ? value : undefined;
|
|
86
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
3
|
+
|
|
4
|
+
const JsxRenderReturnBranchRoute = Object.freeze({
|
|
5
|
+
routeId: 'prove-jsx-render-return-branch-arm-preservation',
|
|
6
|
+
routeLane: 'jsx-static-render-return-branches',
|
|
7
|
+
routeNext: 'supply-jsx-render-return-branch-proof'
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
function jsxRenderReturnBranchProofAssessment(input, options = {}) {
|
|
11
|
+
const delta = jsxRenderReturnBranchDelta(input);
|
|
12
|
+
if (!delta) return undefined;
|
|
13
|
+
const proof = jsxRenderReturnBranchProofFor(delta, options);
|
|
14
|
+
const reasonCodes = [];
|
|
15
|
+
if (!proof) reasonCodes.push('jsx-render-return-branch-proof-missing');
|
|
16
|
+
else {
|
|
17
|
+
if (proof.status !== 'passed' && proof.status !== 'verified') reasonCodes.push('jsx-render-return-branch-proof-status-not-passed');
|
|
18
|
+
if (proof.schema !== 'frontier.lang.jsxRenderReturnBranchProof.v1' && proof.kind !== 'frontier.lang.jsxRenderReturnBranchProof') reasonCodes.push('jsx-render-return-branch-proof-schema-missing');
|
|
19
|
+
if (proof.sourcePath !== delta.sourcePath) reasonCodes.push('jsx-render-return-branch-proof-source-path-mismatch');
|
|
20
|
+
for (const stage of ['base', 'worker', 'head', 'output']) {
|
|
21
|
+
if (proof[`${stage}SourceHash`] !== delta[`${stage}SourceHash`]) reasonCodes.push('jsx-render-return-branch-proof-source-hash-mismatch');
|
|
22
|
+
}
|
|
23
|
+
if (proof.identityKey !== undefined && proof.identityKey !== delta.identityKey) reasonCodes.push('jsx-render-return-branch-proof-identity-mismatch');
|
|
24
|
+
if (proof.publicOwnerName !== delta.publicOwnerName || proof.tagName !== delta.tagName || proof.tagKey !== delta.tagKey) reasonCodes.push('jsx-render-return-branch-proof-identity-mismatch');
|
|
25
|
+
if (proof.returnOrdinal !== delta.returnOrdinal || proof.returnKind !== delta.returnKind || proof.branchControlKind !== delta.branchControlKind) reasonCodes.push('jsx-render-return-branch-proof-branch-kind-unsupported');
|
|
26
|
+
if (delta.nonRenderRiskPresent) reasonCodes.push('jsx-render-return-branch-proof-non-render-risk-present');
|
|
27
|
+
if (delta.branchCountUnsupported) reasonCodes.push('jsx-render-return-branch-proof-branch-count-unsupported');
|
|
28
|
+
reasonCodes.push(...branchReasonCodes(delta, proof));
|
|
29
|
+
if (proof.branchArmPreservationHash !== delta.branchArmPreservationHash) reasonCodes.push('jsx-render-return-branch-proof-output-signature-mismatch');
|
|
30
|
+
if (proof.autoMergeClaim !== false || proof.semanticEquivalenceClaim !== false || proof.runtimeEquivalenceClaim !== false
|
|
31
|
+
|| proof.renderEquivalenceClaim !== false || proof.branchArmPreservationClaim !== true
|
|
32
|
+
|| proof.claimScope !== 'static-render-return-branch-arm-preservation-only') {
|
|
33
|
+
reasonCodes.push('jsx-render-return-branch-proof-claim-flags-missing');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const status = proof && reasonCodes.length === 0 ? 'passed' : proof ? 'failed' : 'missing';
|
|
37
|
+
return {
|
|
38
|
+
status,
|
|
39
|
+
...JsxRenderReturnBranchRoute,
|
|
40
|
+
reasonCodes: uniqueStrings(reasonCodes),
|
|
41
|
+
record: compactRecord({
|
|
42
|
+
schema: 'frontier.lang.jsxRenderReturnBranchProofAssessment.v1',
|
|
43
|
+
status,
|
|
44
|
+
proofStatus: proof?.status,
|
|
45
|
+
proofId: proof?.id,
|
|
46
|
+
proofHash: proof?.proofHash,
|
|
47
|
+
...JsxRenderReturnBranchRoute,
|
|
48
|
+
reasonCodes: uniqueStrings(reasonCodes),
|
|
49
|
+
expected: delta,
|
|
50
|
+
autoMergeClaim: false,
|
|
51
|
+
semanticEquivalenceClaim: false,
|
|
52
|
+
runtimeEquivalenceClaim: false,
|
|
53
|
+
renderEquivalenceClaim: false,
|
|
54
|
+
branchArmPreservationClaim: status === 'passed'
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function jsxRenderReturnBranchDelta({ identityKey, baseRecord, workerRecord, headRecord, outputRecord } = {}) {
|
|
60
|
+
const records = { base: baseRecord, worker: workerRecord, head: headRecord, output: outputRecord };
|
|
61
|
+
const branches = Object.fromEntries(Object.entries(records).map(([stage, record]) => [stage, singleBranch(record)]));
|
|
62
|
+
if (!Object.values(records).some((record) => hasBranchUnsupported(record))) return undefined;
|
|
63
|
+
const outputBranch = branches.output;
|
|
64
|
+
const branchControlKind = firstString(outputBranch?.branchControlKind, branches.worker?.branchControlKind, branches.head?.branchControlKind, branches.base?.branchControlKind);
|
|
65
|
+
if (branchControlKind !== 'conditional-expression' && branchControlKind !== 'logical-expression') return undefined;
|
|
66
|
+
const sourcePath = firstString(outputRecord?.sourcePath, workerRecord?.sourcePath, headRecord?.sourcePath, baseRecord?.sourcePath);
|
|
67
|
+
const delta = compactRecord({
|
|
68
|
+
schema: 'frontier.lang.jsxRenderReturnBranchDelta.v1',
|
|
69
|
+
identityKey,
|
|
70
|
+
sourcePath,
|
|
71
|
+
publicOwnerName: firstString(outputRecord?.publicOwnerName, workerRecord?.publicOwnerName, headRecord?.publicOwnerName, baseRecord?.publicOwnerName),
|
|
72
|
+
tagName: firstString(outputRecord?.tagName, workerRecord?.tagName, headRecord?.tagName, baseRecord?.tagName),
|
|
73
|
+
tagKey: firstString(outputRecord?.tagKey, workerRecord?.tagKey, headRecord?.tagKey, baseRecord?.tagKey),
|
|
74
|
+
baseSourceHash: baseRecord?.sourceHash,
|
|
75
|
+
workerSourceHash: workerRecord?.sourceHash,
|
|
76
|
+
headSourceHash: headRecord?.sourceHash,
|
|
77
|
+
outputSourceHash: outputRecord?.sourceHash,
|
|
78
|
+
returnOrdinal: outputBranch?.ordinal,
|
|
79
|
+
returnKind: outputBranch?.returnKind,
|
|
80
|
+
branchControlKind,
|
|
81
|
+
nonRenderRiskPresent: nonRenderRiskPresent(outputRecord ?? workerRecord ?? headRecord ?? baseRecord) || undefined,
|
|
82
|
+
branchCountUnsupported: Object.values(branches).some((branch) => !branch) || undefined,
|
|
83
|
+
base: branchSummary(branches.base),
|
|
84
|
+
worker: branchSummary(branches.worker),
|
|
85
|
+
head: branchSummary(branches.head),
|
|
86
|
+
output: branchSummary(branches.output)
|
|
87
|
+
});
|
|
88
|
+
return { ...delta, branchArmPreservationHash: jsxRenderReturnBranchProofHash(delta) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function branchReasonCodes(delta, proof) {
|
|
92
|
+
if (delta.branchControlKind === 'conditional-expression') return conditionalBranchReasonCodes(delta, proof);
|
|
93
|
+
if (delta.branchControlKind === 'logical-expression') return logicalBranchReasonCodes(delta, proof);
|
|
94
|
+
return ['jsx-render-return-branch-proof-branch-kind-unsupported'];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function conditionalBranchReasonCodes(delta, proof) {
|
|
98
|
+
const reasons = [];
|
|
99
|
+
if (proof.conditionHash !== delta.base?.conditionHash || proof.outputConditionHash !== delta.output?.conditionHash) reasons.push('jsx-render-return-branch-proof-condition-hash-mismatch');
|
|
100
|
+
if (proof.consequentOrigin === undefined || proof.alternateOrigin === undefined) reasons.push('jsx-render-return-branch-proof-output-arm-origin-missing');
|
|
101
|
+
if (proof.outputConsequentHash !== delta.output?.consequentHash || proof.outputAlternateHash !== delta.output?.alternateHash) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
102
|
+
if (proof.consequentHash !== armHash(delta, proof.consequentOrigin, 'consequentHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
103
|
+
if (proof.alternateHash !== armHash(delta, proof.alternateOrigin, 'alternateHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
104
|
+
if (delta.output?.consequentHash !== armHash(delta, proof.consequentOrigin, 'consequentHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
105
|
+
if (delta.output?.alternateHash !== armHash(delta, proof.alternateOrigin, 'alternateHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
106
|
+
return reasons;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function logicalBranchReasonCodes(delta, proof) {
|
|
110
|
+
const reasons = [];
|
|
111
|
+
if (proof.operator !== delta.output?.operator) reasons.push('jsx-render-return-branch-proof-branch-kind-unsupported');
|
|
112
|
+
if (proof.leftOrigin === undefined || proof.rightOrigin === undefined) reasons.push('jsx-render-return-branch-proof-output-arm-origin-missing');
|
|
113
|
+
if (proof.outputLeftHash !== delta.output?.leftHash || proof.outputRightHash !== delta.output?.rightHash) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
114
|
+
if (proof.leftHash !== armHash(delta, proof.leftOrigin, 'leftHash')) reasons.push('jsx-render-return-branch-proof-logical-guard-hash-mismatch');
|
|
115
|
+
if (proof.rightHash !== armHash(delta, proof.rightOrigin, 'rightHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
116
|
+
if (delta.output?.leftHash !== armHash(delta, proof.leftOrigin, 'leftHash')) reasons.push('jsx-render-return-branch-proof-logical-guard-hash-mismatch');
|
|
117
|
+
if (delta.output?.rightHash !== armHash(delta, proof.rightOrigin, 'rightHash')) reasons.push('jsx-render-return-branch-proof-arm-hash-mismatch');
|
|
118
|
+
return reasons;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function jsxRenderReturnBranchProofFor(delta, options = {}) {
|
|
122
|
+
return [
|
|
123
|
+
options.jsxRenderReturnBranchProof,
|
|
124
|
+
...(Array.isArray(options.jsxRenderReturnBranchProofs) ? options.jsxRenderReturnBranchProofs : [])
|
|
125
|
+
].filter(Boolean).find((proof) => proof.identityKey === delta.identityKey || (
|
|
126
|
+
proof.sourcePath === delta.sourcePath && proof.publicOwnerName === delta.publicOwnerName && proof.tagKey === delta.tagKey
|
|
127
|
+
));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function jsxRenderReturnBranchProofHash(delta) {
|
|
131
|
+
return hashSemanticValue({
|
|
132
|
+
kind: 'frontier.lang.jsxRenderReturnBranchProof.expected.v1',
|
|
133
|
+
identityKey: delta.identityKey,
|
|
134
|
+
sourcePath: delta.sourcePath,
|
|
135
|
+
publicOwnerName: delta.publicOwnerName,
|
|
136
|
+
tagName: delta.tagName,
|
|
137
|
+
tagKey: delta.tagKey,
|
|
138
|
+
baseSourceHash: delta.baseSourceHash,
|
|
139
|
+
workerSourceHash: delta.workerSourceHash,
|
|
140
|
+
headSourceHash: delta.headSourceHash,
|
|
141
|
+
outputSourceHash: delta.outputSourceHash,
|
|
142
|
+
returnOrdinal: delta.returnOrdinal,
|
|
143
|
+
returnKind: delta.returnKind,
|
|
144
|
+
branchControlKind: delta.branchControlKind,
|
|
145
|
+
base: delta.base,
|
|
146
|
+
worker: delta.worker,
|
|
147
|
+
head: delta.head,
|
|
148
|
+
output: delta.output
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function singleBranch(record) {
|
|
153
|
+
const returns = Array.isArray(record?.renderReturnRecords) ? record.renderReturnRecords : [];
|
|
154
|
+
if (returns.length !== 1) return undefined;
|
|
155
|
+
const item = returns[0];
|
|
156
|
+
const branch = item.conditionalBranchRecord ?? item.logicalBranchRecord;
|
|
157
|
+
return branch ? { ...item, ...branch } : undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function branchSummary(branch) {
|
|
161
|
+
if (!branch) return undefined;
|
|
162
|
+
return compactRecord({
|
|
163
|
+
ordinal: branch.ordinal,
|
|
164
|
+
returnKind: branch.returnKind,
|
|
165
|
+
branchControlKind: branch.branchControlKind,
|
|
166
|
+
conditionHash: branch.conditionHash,
|
|
167
|
+
consequentHash: branch.consequentHash,
|
|
168
|
+
alternateHash: branch.alternateHash,
|
|
169
|
+
operator: branch.operator,
|
|
170
|
+
leftHash: branch.leftHash,
|
|
171
|
+
rightHash: branch.rightHash,
|
|
172
|
+
signatureHash: branch.signatureHash
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function nonRenderRiskPresent(record) {
|
|
177
|
+
return (record?.renderRiskKinds ?? []).some((kind) => kind !== 'render-return-boundary' && kind !== 'render-return-branch-control-flow');
|
|
178
|
+
}
|
|
179
|
+
function hasBranchUnsupported(record) { return (record?.renderRiskReasonCodes ?? []).includes('jsx-render-return-branch-unsupported'); }
|
|
180
|
+
function armHash(delta, origin, field) { return ['base', 'worker', 'head', 'output'].includes(origin) ? delta[origin]?.[field] : undefined; }
|
|
181
|
+
function firstString(...values) { return values.find((value) => typeof value === 'string' && value.length > 0); }
|
|
182
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
JsxRenderReturnBranchRoute,
|
|
186
|
+
jsxRenderReturnBranchDelta,
|
|
187
|
+
jsxRenderReturnBranchProofAssessment,
|
|
188
|
+
jsxRenderReturnBranchProofHash
|
|
189
|
+
};
|