@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.
Files changed (276) hide show
  1. package/README.md +315 -9
  2. package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
  3. package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
  4. package/bench/real-repo-corpus-command-execution.mjs +314 -0
  5. package/bench/real-repo-corpus-evidence.mjs +165 -0
  6. package/bench/real-repo-corpus-suite.mjs +273 -0
  7. package/bench/smoke.mjs +109 -7
  8. package/dist/declarations/import-adapter-core.d.ts +4 -3
  9. package/dist/declarations/import-adapter-options-native.d.ts +21 -0
  10. package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
  11. package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
  12. package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
  13. package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
  14. package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
  15. package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
  16. package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
  17. package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
  18. package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
  19. package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
  20. package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
  21. package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
  22. package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
  23. package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
  24. package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
  25. package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
  26. package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
  27. package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
  28. package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
  29. package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
  30. package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
  31. package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
  32. package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
  33. package/dist/declarations/native-project-css-modules.d.ts +90 -0
  34. package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
  35. package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
  36. package/dist/declarations/native-project-module-declarations.d.ts +52 -0
  37. package/dist/declarations/native-project-module-resolution.d.ts +76 -1
  38. package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
  39. package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
  40. package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
  41. package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
  42. package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
  43. package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
  44. package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
  45. package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
  46. package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
  47. package/dist/declarations/native-project-source-evidence.d.ts +8 -0
  48. package/dist/declarations/native-project.d.ts +40 -39
  49. package/dist/declarations/semantic-edit-script.d.ts +10 -8
  50. package/dist/declarations/semantic-graph-layers.d.ts +79 -0
  51. package/dist/declarations/semantic-sidecar.d.ts +3 -2
  52. package/dist/declarations/semantic-structural-diff.d.ts +94 -0
  53. package/dist/declarations/source-preservation.d.ts +32 -1
  54. package/dist/declarations/target-adapters.d.ts +22 -2
  55. package/dist/index.d.ts +31 -0
  56. package/dist/index.js +5 -0
  57. package/dist/internal/index-impl/compileNativeSource.js +53 -5
  58. package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
  59. package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
  60. package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
  61. package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
  62. package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
  63. package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
  64. package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
  65. package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
  66. package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
  67. package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
  68. package/dist/internal/index-impl/importNativeSource.js +2 -3
  69. package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
  70. package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
  71. package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
  72. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
  73. package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
  74. package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
  75. package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
  76. package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
  77. package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
  78. package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
  79. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
  80. package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
  81. package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
  82. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
  83. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
  84. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
  85. package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
  86. package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
  87. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
  88. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
  89. package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
  90. package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
  91. package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
  92. package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
  93. package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
  94. package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
  95. package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
  96. package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
  97. package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
  98. package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
  99. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
  100. package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
  101. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
  102. package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
  103. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
  104. package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
  105. package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
  106. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
  107. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
  108. package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
  109. package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
  110. package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
  111. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
  112. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
  113. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
  114. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
  115. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
  116. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
  117. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
  118. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
  119. package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
  120. package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
  121. package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
  122. package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
  123. package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
  124. package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
  125. package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
  126. package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
  127. package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
  128. package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
  129. package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
  130. package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
  131. package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
  132. package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
  133. package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
  134. package/dist/internal/index-impl/semanticEditScripts.js +42 -5
  135. package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
  136. package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
  137. package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
  138. package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
  139. package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
  140. package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
  141. package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
  142. package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
  143. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
  144. package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
  145. package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
  146. package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
  147. package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
  148. package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
  149. package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
  150. package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
  151. package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
  152. package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
  153. package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
  154. package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
  155. package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
  156. package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
  157. package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
  158. package/dist/js-ts-safe-member-class-invariants.js +247 -0
  159. package/dist/js-ts-safe-member-merge-result.js +23 -3
  160. package/dist/js-ts-safe-member-merge.js +28 -4
  161. package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
  162. package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
  163. package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
  164. package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
  165. package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
  166. package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
  167. package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
  168. package/dist/js-ts-safe-merge-parse-statements.js +8 -0
  169. package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
  170. package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
  171. package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
  172. package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
  173. package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
  174. package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
  175. package/dist/js-ts-safe-merge.js +136 -0
  176. package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
  177. package/dist/js-ts-safe-project-merge-admission.js +161 -0
  178. package/dist/js-ts-safe-project-merge-ambient.js +110 -0
  179. package/dist/js-ts-safe-project-merge-core.js +85 -0
  180. package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
  181. package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
  182. package/dist/js-ts-safe-project-merge-declarations.js +227 -0
  183. package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
  184. package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
  185. package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
  186. package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
  187. package/dist/js-ts-safe-project-merge-files.js +70 -0
  188. package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
  189. package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
  190. package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
  191. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
  192. package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
  193. package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
  194. package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
  195. package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
  196. package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
  197. package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
  198. package/dist/js-ts-safe-project-merge-graph.js +37 -5
  199. package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
  200. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
  201. package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
  202. package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
  203. package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
  204. package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
  205. package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
  206. package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
  207. package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
  208. package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
  209. package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
  210. package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
  211. package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
  212. package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
  213. package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
  214. package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
  215. package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
  216. package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
  217. package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
  218. package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
  219. package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
  220. package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
  221. package/dist/js-ts-safe-project-merge-summary.js +320 -0
  222. package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
  223. package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
  224. package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
  225. package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
  226. package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
  227. package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
  228. package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
  229. package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
  230. package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
  231. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
  232. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
  233. package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
  234. package/dist/js-ts-safe-project-merge.js +170 -171
  235. package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
  236. package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
  237. package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
  238. package/dist/js-ts-semantic-scope-use-def.js +217 -0
  239. package/dist/lightweight-dependency-effects.js +28 -4
  240. package/dist/lightweight-dependency-relations.js +13 -7
  241. package/dist/lightweight-dependency-top-level.js +63 -0
  242. package/dist/native-import-language-profiles.js +27 -1
  243. package/dist/native-js-ts-importers.js +9 -5
  244. package/dist/native-parser-ast-format-profiles.js +12 -0
  245. package/dist/native-parser-html-css-format-profiles.js +85 -0
  246. package/dist/native-region-scanner-core.js +5 -3
  247. package/dist/native-region-scanner-js-commonjs.js +155 -0
  248. package/dist/native-region-scanner-js-imports.js +51 -13
  249. package/dist/native-region-scanner-js-reexports.js +79 -0
  250. package/dist/native-region-scanner-js-ts-helpers.js +23 -0
  251. package/dist/native-source-ledger-helpers.js +1 -1
  252. package/dist/native-source-ledger.js +24 -10
  253. package/dist/native-source-maps-ecma426.js +316 -0
  254. package/dist/native-source-maps.js +36 -6
  255. package/dist/native-source-preservation-ownership.js +292 -0
  256. package/dist/native-source-preservation-scanner.js +63 -25
  257. package/dist/native-source-preservation-types.d.ts +3 -0
  258. package/dist/semantic-import-effect-occurrences.js +242 -0
  259. package/dist/semantic-import-effect-regions.js +95 -58
  260. package/dist/semantic-import-graph-layers.js +224 -0
  261. package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
  262. package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
  263. package/dist/semantic-import-runtime-exit-evidence.js +32 -0
  264. package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
  265. package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
  266. package/dist/semantic-import-runtime-order-evidence.js +318 -0
  267. package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
  268. package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
  269. package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
  270. package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
  271. package/dist/semantic-import-runtime-switch-evidence.js +304 -0
  272. package/dist/semantic-import-runtime-throw-evidence.js +44 -0
  273. package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
  274. package/dist/semantic-import-sidecar-entry.js +4 -0
  275. package/dist/semantic-import-source-preservation.js +6 -2
  276. package/package.json +1 -1
@@ -0,0 +1,300 @@
1
+ import { uniqueStrings } from './js-ts-safe-merge-context.js';
2
+
3
+ function parseJsxSource(sourceText) {
4
+ const elements = [];
5
+ const allElements = [];
6
+ const reasonCodes = [];
7
+ const ordinals = new Map();
8
+ const stack = [];
9
+ let index = 0;
10
+ while (index < sourceText.length) {
11
+ const start = sourceText.indexOf('<', index);
12
+ if (start === -1) break;
13
+ const closing = parseClosingTag(sourceText, start);
14
+ if (closing) {
15
+ const open = stack.pop();
16
+ if (!open || open.tagName !== closing.tagName) {
17
+ reasonCodes.push('jsx-child-expression-tag-mismatch');
18
+ index = closing.end;
19
+ continue;
20
+ }
21
+ const element = { ...open, closeStart: closing.start, closeEnd: closing.end, closeText: closing.text, text: sourceText.slice(open.start, closing.end) };
22
+ elements.push(element);
23
+ allElements.push(element);
24
+ index = closing.end;
25
+ continue;
26
+ }
27
+ const opening = parseOpeningTag(sourceText, start);
28
+ if (!opening) {
29
+ index = start + 1;
30
+ continue;
31
+ }
32
+ const ordinal = (ordinals.get(opening.tagName) ?? 0) + 1;
33
+ ordinals.set(opening.tagName, ordinal);
34
+ const element = {
35
+ tagName: opening.tagName,
36
+ key: `${opening.tagName}#${ordinal}`,
37
+ start,
38
+ openEnd: opening.end,
39
+ closeStart: opening.selfClosing ? opening.end : undefined,
40
+ closeEnd: opening.selfClosing ? opening.end : undefined,
41
+ openText: opening.text,
42
+ closeText: opening.selfClosing ? '' : undefined,
43
+ selfClosing: opening.selfClosing,
44
+ text: opening.selfClosing ? opening.text : undefined
45
+ };
46
+ if (opening.selfClosing) allElements.push(element);
47
+ else stack.push(element);
48
+ index = opening.end;
49
+ }
50
+ if (stack.length) reasonCodes.push('jsx-child-expression-tag-unclosed');
51
+ allElements.sort((left, right) => left.start - right.start);
52
+ return {
53
+ elements,
54
+ allElements,
55
+ byKey: new Map(elements.map((element) => [element.key, element])),
56
+ byStart: new Map(allElements.map((element) => [element.start, element])),
57
+ reasonCodes: uniqueStrings(reasonCodes)
58
+ };
59
+ }
60
+
61
+ function parseDirectChildren(sourceText, parsed, element) {
62
+ const tokens = [];
63
+ const reasonCodes = [];
64
+ const start = element.openEnd;
65
+ const end = element.closeStart;
66
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start > end) {
67
+ return { tokens, reasonCodes: ['jsx-child-expression-bounds-unsupported'] };
68
+ }
69
+ let cursor = start;
70
+ while (cursor < end) {
71
+ const childElement = parsed.byStart.get(cursor);
72
+ if (childElement && childElement.closeEnd <= end) {
73
+ tokens.push({
74
+ kind: 'element',
75
+ tagName: childElement.tagName,
76
+ fragmentKind: childElement.fragmentKind,
77
+ start: cursor,
78
+ end: childElement.closeEnd,
79
+ text: sourceText.slice(cursor, childElement.closeEnd),
80
+ ...childElementIdentity(childElement)
81
+ });
82
+ cursor = childElement.closeEnd;
83
+ continue;
84
+ }
85
+ if (sourceText[cursor] === '{') {
86
+ const expressionEnd = bracedValueEnd(sourceText, cursor, end);
87
+ if (expressionEnd === undefined) return { tokens, reasonCodes: ['jsx-child-expression-unterminated'] };
88
+ tokens.push({ kind: 'expression', start: cursor, end: expressionEnd, text: sourceText.slice(cursor, expressionEnd) });
89
+ cursor = expressionEnd;
90
+ continue;
91
+ }
92
+ let next = cursor + 1;
93
+ while (next < end && !parsed.byStart.has(next) && sourceText[next] !== '{') next += 1;
94
+ tokens.push({ kind: 'text', start: cursor, end: next, text: sourceText.slice(cursor, next) });
95
+ cursor = next;
96
+ }
97
+ return { tokens, reasonCodes };
98
+ }
99
+
100
+ function parseOpeningTag(sourceText, start) {
101
+ const afterOpen = start + 1;
102
+ if (sourceText[afterOpen] === '>') {
103
+ return { tagName: 'Fragment', fragmentKind: 'shorthand', start, end: afterOpen + 1, text: '<>', selfClosing: false };
104
+ }
105
+ if (/[/!?>]/.test(sourceText[afterOpen] ?? '')) return undefined;
106
+ const nameMatch = /^[A-Za-z_$][\w$]*(?:[.:][A-Za-z_$][\w$]*|-[\w$]+)*/.exec(sourceText.slice(afterOpen));
107
+ if (!nameMatch) return undefined;
108
+ const tagName = nameMatch[0];
109
+ const end = openingTagEnd(sourceText, afterOpen + tagName.length);
110
+ if (end === undefined) return undefined;
111
+ const text = sourceText.slice(start, end);
112
+ return { tagName, start, end, text, selfClosing: /\/\s*>$/.test(text) };
113
+ }
114
+
115
+ function parseClosingTag(sourceText, start) {
116
+ if (sourceText[start] !== '<' || sourceText[start + 1] !== '/') return undefined;
117
+ const afterSlash = start + 2;
118
+ if (sourceText[afterSlash] === '>') {
119
+ return { tagName: 'Fragment', fragmentKind: 'shorthand', start, end: afterSlash + 1, text: '</>' };
120
+ }
121
+ const nameMatch = /^[A-Za-z_$][\w$]*(?:[.:][A-Za-z_$][\w$]*|-[\w$]+)*/.exec(sourceText.slice(afterSlash));
122
+ if (!nameMatch) return undefined;
123
+ const tagName = nameMatch[0];
124
+ let cursor = afterSlash + tagName.length;
125
+ while (cursor < sourceText.length && /\s/.test(sourceText[cursor])) cursor += 1;
126
+ if (sourceText[cursor] !== '>') return undefined;
127
+ const end = cursor + 1;
128
+ return { tagName, start, end, text: sourceText.slice(start, end) };
129
+ }
130
+
131
+ function openingTagEnd(sourceText, start) {
132
+ let quote;
133
+ let escaped = false;
134
+ let braceDepth = 0;
135
+ for (let index = start; index < sourceText.length; index += 1) {
136
+ const char = sourceText[index];
137
+ if (quote) {
138
+ if (escaped) escaped = false;
139
+ else if (char === '\\') escaped = true;
140
+ else if (char === quote) quote = undefined;
141
+ continue;
142
+ }
143
+ if (char === '"' || char === '\'' || char === '`') quote = char;
144
+ else if (char === '{') braceDepth += 1;
145
+ else if (char === '}') braceDepth = Math.max(0, braceDepth - 1);
146
+ else if (char === '>' && braceDepth === 0) return index + 1;
147
+ }
148
+ return undefined;
149
+ }
150
+
151
+ function bracedValueEnd(sourceText, start, end) {
152
+ let depth = 0;
153
+ let quote;
154
+ let escaped = false;
155
+ for (let cursor = start; cursor < end; cursor += 1) {
156
+ const char = sourceText[cursor];
157
+ if (quote) {
158
+ if (escaped) escaped = false;
159
+ else if (char === '\\') escaped = true;
160
+ else if (char === quote) quote = undefined;
161
+ continue;
162
+ }
163
+ if (char === '"' || char === '\'' || char === '`') quote = char;
164
+ else if (char === '{') depth += 1;
165
+ else if (char === '}') {
166
+ depth -= 1;
167
+ if (depth === 0) return cursor + 1;
168
+ }
169
+ }
170
+ return undefined;
171
+ }
172
+
173
+ function childElementIdentity(element) {
174
+ const key = stableJsxKey(element.openText);
175
+ const hasSpreadProp = /\{\s*\.\.\./.test(String(element.openText ?? ''));
176
+ return {
177
+ keyPropValue: key?.value,
178
+ keyPropText: key?.text,
179
+ stableKey: key?.stable === true,
180
+ childIdentityKey: key?.stable === true ? `key:${key.value}` : undefined,
181
+ hasSpreadProp
182
+ };
183
+ }
184
+
185
+ function stableJsxKey(openText) {
186
+ const text = String(openText ?? '');
187
+ let cursor = 1;
188
+ const tagName = jsxAttributeNameAt(text, cursor);
189
+ if (!tagName) return undefined;
190
+ cursor += tagName.length;
191
+ while (cursor < text.length) {
192
+ while (cursor < text.length && /\s/.test(text[cursor])) cursor += 1;
193
+ if (text[cursor] === '/' || text[cursor] === '>') return undefined;
194
+ if (text[cursor] === '{') {
195
+ const expressionEnd = bracedValueEnd(text, cursor, text.length);
196
+ if (expressionEnd === undefined) return undefined;
197
+ cursor = expressionEnd;
198
+ continue;
199
+ }
200
+ const attrStart = cursor;
201
+ const attrName = jsxAttributeNameAt(text, cursor);
202
+ if (!attrName) {
203
+ cursor += 1;
204
+ continue;
205
+ }
206
+ cursor += attrName.length;
207
+ while (cursor < text.length && /\s/.test(text[cursor])) cursor += 1;
208
+ if (text[cursor] !== '=') continue;
209
+ cursor += 1;
210
+ while (cursor < text.length && /\s/.test(text[cursor])) cursor += 1;
211
+ const quote = text[cursor];
212
+ if (quote === '"' || quote === '\'') {
213
+ const valueStart = cursor + 1;
214
+ const valueEnd = quotedStringEnd(text, cursor);
215
+ if (valueEnd === undefined) return undefined;
216
+ if (attrName === 'key') {
217
+ return { stable: true, value: text.slice(valueStart, valueEnd - 1), text: text.slice(attrStart, valueEnd).trim() };
218
+ }
219
+ cursor = valueEnd;
220
+ continue;
221
+ }
222
+ const valueEnd = skipJsxAttributeValue(text, cursor);
223
+ if (valueEnd === undefined) return undefined;
224
+ cursor = valueEnd;
225
+ }
226
+ return undefined;
227
+ }
228
+
229
+ function jsxAttributeNameAt(text, cursor) {
230
+ const match = /^[A-Za-z_$][\w$]*(?:[-:.][A-Za-z_$][\w$]*)*/.exec(text.slice(cursor));
231
+ return match?.[0];
232
+ }
233
+
234
+ function quotedStringEnd(text, start) {
235
+ const quote = text[start];
236
+ let escaped = false;
237
+ for (let cursor = start + 1; cursor < text.length; cursor += 1) {
238
+ const char = text[cursor];
239
+ if (escaped) escaped = false;
240
+ else if (char === '\\') escaped = true;
241
+ else if (char === quote) return cursor + 1;
242
+ }
243
+ return undefined;
244
+ }
245
+
246
+ function skipJsxAttributeValue(text, cursor) {
247
+ if (text[cursor] === '{') return bracedValueEnd(text, cursor, text.length);
248
+ if (text[cursor] === '"' || text[cursor] === '\'' || text[cursor] === '`') return quotedStringEnd(text, cursor);
249
+ let next = cursor;
250
+ while (next < text.length && !/[\s/>]/.test(text[next])) next += 1;
251
+ return next;
252
+ }
253
+
254
+ function hasConditionalChildExpressionOperator(text) {
255
+ const value = String(text ?? '');
256
+ let quote;
257
+ let escaped = false;
258
+ let lineComment = false;
259
+ let blockComment = false;
260
+ for (let index = 0; index < value.length; index += 1) {
261
+ const char = value[index];
262
+ const next = value[index + 1];
263
+ if (lineComment) {
264
+ if (char === '\n' || char === '\r') lineComment = false;
265
+ continue;
266
+ }
267
+ if (blockComment) {
268
+ if (char === '*' && next === '/') {
269
+ blockComment = false;
270
+ index += 1;
271
+ }
272
+ continue;
273
+ }
274
+ if (quote) {
275
+ if (escaped) escaped = false;
276
+ else if (char === '\\') escaped = true;
277
+ else if (char === quote) quote = undefined;
278
+ continue;
279
+ }
280
+ if (char === '/' && next === '/') {
281
+ lineComment = true;
282
+ index += 1;
283
+ continue;
284
+ }
285
+ if (char === '/' && next === '*') {
286
+ blockComment = true;
287
+ index += 1;
288
+ continue;
289
+ }
290
+ if (char === '"' || char === '\'' || char === '`') {
291
+ quote = char;
292
+ continue;
293
+ }
294
+ if ((char === '&' && next === '&') || (char === '|' && next === '|') || (char === '?' && next === '?')) return true;
295
+ if (char === '?' && next !== '.' && next !== '?') return true;
296
+ }
297
+ return false;
298
+ }
299
+
300
+ export { hasConditionalChildExpressionOperator, parseDirectChildren, parseJsxSource };
@@ -1,14 +1,34 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
1
2
  import { JsTsSafeMergeConflictCodes, identifierRegExp } from './js-ts-safe-merge-constants.js';
2
3
 
3
4
  export function classifyStatement(text, start, end) {
5
+ const directiveInfo = parseDirectiveInfo(text);
6
+ const textHash = hashSemanticValue(text);
7
+ if (directiveInfo) {
8
+ const key = directiveLedgerKey(directiveInfo);
9
+ return {
10
+ kind: 'directive',
11
+ key,
12
+ text,
13
+ start,
14
+ end,
15
+ textHash,
16
+ ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: 'directive', key, textHash, start, end, directiveInfo }),
17
+ directiveInfo,
18
+ names: []
19
+ };
20
+ }
4
21
  const importInfo = parseImportInfo(text);
5
22
  if (importInfo) {
23
+ const key = importLedgerKey(importInfo);
6
24
  return {
7
25
  kind: 'import',
8
- key: importLedgerKey(importInfo),
26
+ key,
9
27
  text,
10
28
  start,
11
29
  end,
30
+ textHash,
31
+ ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: 'import', key, textHash, start, end }),
12
32
  importInfo,
13
33
  names: importInfo.specifiers.map((specifier) => specifier.localName).filter(Boolean)
14
34
  };
@@ -17,12 +37,15 @@ export function classifyStatement(text, start, end) {
17
37
  if (declarationInfo) {
18
38
  const unsupported = unsupportedDeclarationPolicy(text, declarationInfo);
19
39
  if (unsupported) return { unsupported, text, start, end };
40
+ const key = declarationLedgerKey(declarationInfo);
20
41
  return {
21
42
  kind: declarationInfo.kind,
22
- key: declarationLedgerKey(declarationInfo),
43
+ key,
23
44
  text,
24
45
  start,
25
46
  end,
47
+ textHash,
48
+ ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: declarationInfo.kind, key, textHash, start, end }),
26
49
  declarationInfo,
27
50
  names: declarationInfo.names
28
51
  };
@@ -30,6 +53,17 @@ export function classifyStatement(text, start, end) {
30
53
  return undefined;
31
54
  }
32
55
 
56
+ function parseDirectiveInfo(text) {
57
+ const trimmed = text.trim();
58
+ const match = trimmed.match(/^(['"])(use\s+(?:strict|client|server))\1\s*;?$/);
59
+ if (!match) return undefined;
60
+ return { kind: 'runtime-directive', value: match[2], quote: match[1] };
61
+ }
62
+
63
+ function directiveLedgerKey(directiveInfo) {
64
+ return ['directive', directiveInfo.kind, directiveInfo.value].join(':');
65
+ }
66
+
33
67
  function parseImportInfo(text) {
34
68
  const trimmed = text.trim();
35
69
  const sideEffect = trimmed.match(/^import\s+(['"])([^'"]+)\1\s*;?$/s);
@@ -271,6 +305,16 @@ function importLedgerKey(importInfo) {
271
305
  ].join(':');
272
306
  }
273
307
 
308
+ function topLevelStatementOwnershipAnchor(input) {
309
+ const identityAnchor = input.kind === 'directive' && input.directiveInfo?.kind === 'runtime-directive' ? 'runtime-directive-prologue' : input.key;
310
+ return {
311
+ schema: 'frontier.lang.jsTsTopLevelStatementOwnershipAnchor.v1', version: 1, mode: 'top-level-ledger-entry',
312
+ key: ['js-ts-top-level', input.kind, identityAnchor].join('#'), identityAnchor, statementKind: input.kind,
313
+ start: input.start, end: input.end, textHash: input.textHash, losslessCst: false,
314
+ parserEvidence: 'frontier-js-ts-narrow-top-level-ledger', reasonCodes: ['top-level-ledger-statement-boundary', 'lossless-cst-unavailable']
315
+ };
316
+ }
317
+
274
318
  export function importSpecifierCanonical(specifier) {
275
319
  return `${specifier.typeOnly ? 'type ' : ''}${specifier.importedName}${specifier.localName === specifier.importedName ? '' : ` as ${specifier.localName}`}`;
276
320
  }
@@ -3,6 +3,10 @@ export function skipTopLevelTrivia(sourceText, offset) {
3
3
  while (index < sourceText.length) {
4
4
  const char = sourceText[index];
5
5
  const next = sourceText[index + 1];
6
+ if (char === '#' && next === '!' && isHashbangAtFileStart(sourceText, index)) {
7
+ index = consumeLineComment(sourceText, index + 2);
8
+ continue;
9
+ }
6
10
  if (/\s/.test(char)) {
7
11
  index += 1;
8
12
  continue;
@@ -22,6 +26,10 @@ export function skipTopLevelTrivia(sourceText, offset) {
22
26
  return { offset: index };
23
27
  }
24
28
 
29
+ function isHashbangAtFileStart(sourceText, offset) {
30
+ return offset === 0 || (offset === 1 && sourceText.charCodeAt(0) === 0xfeff);
31
+ }
32
+
25
33
  function consumeLineComment(sourceText, offset) {
26
34
  const lineEnd = sourceText.indexOf('\n', offset);
27
35
  return lineEnd === -1 ? sourceText.length : lineEnd + 1;
@@ -1,3 +1,4 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
1
2
  import { createSemanticEditScript } from './internal/index-impl/semanticEditScripts.js';
2
3
  import { projectSemanticEditScriptToSource } from './internal/index-impl/projectSemanticEditScriptToSource.js';
3
4
  import { replaySemanticEditProjection } from './internal/index-impl/replaySemanticEditProjection.js';
@@ -150,6 +151,9 @@ function createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallba
150
151
  projection,
151
152
  currentSourceText: replayCurrentSourceText,
152
153
  currentSourcePath: sourcePath,
154
+ currentSourceHash: typeof replayCurrentSourceText === 'string' ? hashSemanticValue(replayCurrentSourceText) : undefined,
155
+ expectedOutputSourceText: projection.sourceText,
156
+ expectedOutputHash: projection.projectedHash,
153
157
  language,
154
158
  parser: input.parser,
155
159
  metadata: stagedFallback?.metadata
@@ -224,11 +228,15 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
224
228
  }
225
229
 
226
230
  function shouldDeferTopLevelRenamePublicContract(input, admission) {
227
- return input.deferTopLevelRenamePublicExportContractToProjectGraph === true
228
- && admission.reasonCodes?.length === 1
229
- && admission.reasonCodes.includes('top-level-rename-public-export-contract')
230
- && admission.summary?.exported !== true
231
- && workerPreservesRenamedExportAlias(input.workerSourceText, admission.summary);
231
+ if (input.deferTopLevelRenamePublicExportContractToProjectGraph !== true
232
+ || admission.reasonCodes?.length !== 1
233
+ || !admission.reasonCodes.includes('top-level-rename-public-export-contract')) {
234
+ return false;
235
+ }
236
+ if (admission.summary?.exported === true) {
237
+ return input.deferDirectExportRenamePublicContractToProjectSymbolRename === true;
238
+ }
239
+ return workerPreservesRenamedExportAlias(input.workerSourceText, admission.summary);
232
240
  }
233
241
 
234
242
  function deferredTopLevelRenameAdmission(admission) {
@@ -1,11 +1,13 @@
1
1
  import { createEnumMemberSemanticFallbackResult } from './js-ts-safe-merge-enum-member-fallback.js';
2
2
  import { createJsxAttributeSemanticFallbackResult } from './js-ts-safe-merge-jsx-attribute-fallback.js';
3
+ import { createJsxChildExpressionSemanticFallbackResult } from './js-ts-safe-merge-jsx-child-expression-fallback.js';
3
4
  import { createVariableDeclaratorSemanticFallbackResult } from './js-ts-safe-merge-variable-declarator-fallback.js';
4
5
 
5
6
  function createSourceShapeSemanticFallbackResult(input, topLevelResult, stagedFallback) {
6
7
  return createVariableDeclaratorSemanticFallbackResult(input, topLevelResult, stagedFallback)
7
8
  ?? createEnumMemberSemanticFallbackResult(input, topLevelResult, stagedFallback)
8
- ?? createJsxAttributeSemanticFallbackResult(input, topLevelResult, stagedFallback);
9
+ ?? createJsxAttributeSemanticFallbackResult(input, topLevelResult, stagedFallback)
10
+ ?? createJsxChildExpressionSemanticFallbackResult(input, topLevelResult, stagedFallback);
9
11
  }
10
12
 
11
13
  export { createSourceShapeSemanticFallbackResult };
@@ -1,6 +1,7 @@
1
1
  import { JsTsSafeMergeConflictCodes } from './js-ts-safe-merge-constants.js';
2
2
  import { createMergeContext, sameStatementText } from './js-ts-safe-merge-context.js';
3
3
  import { scanJsTsTopLevelLedger, validateLedgerUniqueness } from './js-ts-safe-merge-ledger.js';
4
+ import { analyzeTopLevelRenameUseDefEvidence, LexicalUseDefReasonCodes } from './js-ts-semantic-scope-use-def.js';
4
5
  import { uniqueStrings } from './native-import-utils.js';
5
6
 
6
7
  const supportedRenameDeclarationKinds = new Set(['function', 'class', 'type']);
@@ -29,19 +30,42 @@ function analyzeTopLevelRenameAdmission(input, topLevelResult) {
29
30
  if (!candidate) return undefined;
30
31
 
31
32
  const publicContractReasonCodes = publicContractRenameReasonCodes(base, worker, head, candidate);
33
+ const lexicalUseDefEvidence = analyzeTopLevelRenameUseDefEvidence({
34
+ sourcePath: input.sourcePath,
35
+ baseSourceText: input.baseSourceText,
36
+ workerSourceText: input.workerSourceText,
37
+ headSourceText: input.headSourceText,
38
+ ...candidate
39
+ });
32
40
  if (publicContractReasonCodes.length) {
33
41
  return {
34
42
  status: 'blocked',
35
43
  reasonCodes: publicContractReasonCodes,
36
- summary: candidateSummary(candidate, publicContractReasonCodes),
44
+ summary: candidateSummary(candidate, publicContractReasonCodes, lexicalUseDefEvidence),
37
45
  ledgers: { base, worker, head }
38
46
  };
39
47
  }
40
48
 
49
+ const lexicalBlockerReasonCodes = lexicalUseDefEvidence.reasonCodes
50
+ .filter((code) => code !== LexicalUseDefReasonCodes.noLiveReferences);
51
+ if (lexicalBlockerReasonCodes.length) {
52
+ const reasonCodes = uniqueStrings([...publicContractReasonCodes, ...lexicalBlockerReasonCodes]);
53
+ return {
54
+ status: 'blocked',
55
+ reasonCodes,
56
+ summary: candidateSummary(candidate, reasonCodes, lexicalUseDefEvidence),
57
+ ledgers: { base, worker, head }
58
+ };
59
+ }
60
+
61
+ const candidateReasonCodes = [
62
+ 'top-level-rename-source-shape-matches',
63
+ LexicalUseDefReasonCodes.noLiveReferences
64
+ ];
41
65
  return {
42
66
  status: 'candidate',
43
- reasonCodes: ['top-level-rename-source-shape-matches'],
44
- summary: candidateSummary(candidate, ['top-level-rename-source-shape-matches']),
67
+ reasonCodes: candidateReasonCodes,
68
+ summary: candidateSummary(candidate, candidateReasonCodes, lexicalUseDefEvidence),
45
69
  ledgers: { base, worker, head }
46
70
  };
47
71
  }
@@ -79,6 +103,7 @@ function topLevelRenameCandidate(base, worker, head) {
79
103
  return {
80
104
  fromEntry,
81
105
  toEntry,
106
+ headEntry: entriesByKey(head.entries).get(fromEntry.key),
82
107
  fromName,
83
108
  toName,
84
109
  declarationKind: fromEntry.declarationInfo.declarationKind
@@ -124,13 +149,14 @@ function renameDeclarationText(text, declarationKind, fromName, toName) {
124
149
  return undefined;
125
150
  }
126
151
 
127
- function candidateSummary(candidate, reasonCodes) {
152
+ function candidateSummary(candidate, reasonCodes, lexicalUseDefEvidence) {
128
153
  return {
129
154
  fromName: candidate.fromName,
130
155
  toName: candidate.toName,
131
156
  declarationKind: candidate.declarationKind,
132
157
  exported: candidate.fromEntry.declarationInfo?.exported === true || candidate.toEntry.declarationInfo?.exported === true,
133
- reasonCodes: uniqueStrings(reasonCodes)
158
+ reasonCodes: uniqueStrings(reasonCodes),
159
+ lexicalUseDefEvidence
134
160
  };
135
161
  }
136
162
 
@@ -6,10 +6,15 @@ function topLevelRenameBlockedResult(input, topLevelResult, topLevelRenameAdmiss
6
6
  ...(topLevelResult.admission?.reasonCodes ?? []),
7
7
  ...(topLevelRenameAdmission.reasonCodes ?? [])
8
8
  ]);
9
+ const primaryReasonCode = topLevelRenameAdmission.reasonCodes?.[0] ?? JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract;
10
+ const publicContractBlock = topLevelRenameAdmission.reasonCodes
11
+ ?.includes(JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract);
9
12
  const conflict = {
10
- code: JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract,
13
+ code: publicContractBlock ? JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract : primaryReasonCode,
11
14
  gateId: JsTsSafeMergeGateIds.stableExistingDeclarations,
12
- message: 'Top-level rename changes a public export contract without project-level evidence.',
15
+ message: publicContractBlock
16
+ ? 'Top-level rename changes a public export contract without project-level evidence.'
17
+ : 'Top-level rename requires lexical use-def evidence before automatic merge.',
13
18
  side: 'worker',
14
19
  sourcePath: input.sourcePath ?? topLevelResult.sourcePath,
15
20
  details: {