@shapeshift-labs/frontier-lang-compiler 0.2.149 → 0.2.151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) 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-patch-bundle-composition.d.ts +62 -0
  52. package/dist/declarations/semantic-sidecar.d.ts +3 -2
  53. package/dist/declarations/semantic-structural-diff.d.ts +94 -0
  54. package/dist/declarations/source-preservation.d.ts +32 -1
  55. package/dist/declarations/target-adapters.d.ts +22 -2
  56. package/dist/index.d.ts +32 -0
  57. package/dist/index.js +6 -0
  58. package/dist/internal/index-impl/compileNativeSource.js +53 -5
  59. package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
  60. package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
  61. package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
  62. package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
  63. package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
  64. package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
  65. package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
  66. package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
  67. package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
  68. package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
  69. package/dist/internal/index-impl/importNativeSource.js +2 -3
  70. package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
  71. package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
  72. package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
  73. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
  74. package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
  75. package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
  76. package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
  77. package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
  78. package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
  79. package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
  80. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
  81. package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
  82. package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
  83. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
  84. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
  85. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
  86. package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
  87. package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
  88. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
  89. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
  90. package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
  91. package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
  92. package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
  93. package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
  94. package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
  95. package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
  96. package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
  97. package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
  98. package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
  99. package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
  100. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
  101. package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
  102. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
  103. package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
  104. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
  105. package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
  106. package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
  107. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
  108. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
  109. package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
  110. package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
  111. package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
  112. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
  113. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
  114. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
  115. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
  116. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
  117. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
  118. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
  119. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
  120. package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
  121. package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
  122. package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
  123. package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
  124. package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
  125. package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
  126. package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
  127. package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
  128. package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
  129. package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
  130. package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
  131. package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
  132. package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
  133. package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
  134. package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
  135. package/dist/internal/index-impl/semanticEditScripts.js +42 -5
  136. package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
  137. package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
  138. package/dist/internal/index-impl/semanticPatchBundleComposition.js +166 -0
  139. package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
  140. package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
  141. package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
  142. package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
  143. package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
  144. package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
  145. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
  146. package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
  147. package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
  148. package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
  149. package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
  150. package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
  151. package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
  152. package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
  153. package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
  154. package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
  155. package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
  156. package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
  157. package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
  158. package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
  159. package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
  160. package/dist/js-ts-safe-member-class-invariants.js +247 -0
  161. package/dist/js-ts-safe-member-merge-result.js +23 -3
  162. package/dist/js-ts-safe-member-merge.js +28 -4
  163. package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
  164. package/dist/js-ts-safe-merge-context.js +1 -0
  165. package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
  166. package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
  167. package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
  168. package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
  169. package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
  170. package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
  171. package/dist/js-ts-safe-merge-parse-statements.js +8 -0
  172. package/dist/js-ts-safe-merge-plan.js +3 -1
  173. package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
  174. package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -1
  175. package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
  176. package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
  177. package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
  178. package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
  179. package/dist/js-ts-safe-merge.js +136 -0
  180. package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
  181. package/dist/js-ts-safe-project-merge-admission.js +161 -0
  182. package/dist/js-ts-safe-project-merge-ambient.js +110 -0
  183. package/dist/js-ts-safe-project-merge-core.js +85 -0
  184. package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
  185. package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
  186. package/dist/js-ts-safe-project-merge-declarations.js +227 -0
  187. package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
  188. package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
  189. package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
  190. package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
  191. package/dist/js-ts-safe-project-merge-files.js +70 -0
  192. package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
  193. package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
  194. package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
  195. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
  196. package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
  197. package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
  198. package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
  199. package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
  200. package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
  201. package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
  202. package/dist/js-ts-safe-project-merge-graph.js +37 -5
  203. package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
  204. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
  205. package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
  206. package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
  207. package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
  208. package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
  209. package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
  210. package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
  211. package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
  212. package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
  213. package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
  214. package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
  215. package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
  216. package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
  217. package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
  218. package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
  219. package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
  220. package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
  221. package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
  222. package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
  223. package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
  224. package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
  225. package/dist/js-ts-safe-project-merge-summary.js +320 -0
  226. package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
  227. package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
  228. package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
  229. package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
  230. package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
  231. package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
  232. package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
  233. package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
  234. package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
  235. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
  236. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
  237. package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
  238. package/dist/js-ts-safe-project-merge.js +171 -172
  239. package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
  240. package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
  241. package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
  242. package/dist/js-ts-semantic-scope-use-def.js +217 -0
  243. package/dist/lightweight-dependency-effects.js +28 -4
  244. package/dist/lightweight-dependency-relations.js +13 -7
  245. package/dist/lightweight-dependency-top-level.js +63 -0
  246. package/dist/native-import-language-profiles.js +27 -1
  247. package/dist/native-js-ts-importers.js +9 -5
  248. package/dist/native-parser-ast-format-profiles.js +12 -0
  249. package/dist/native-parser-html-css-format-profiles.js +85 -0
  250. package/dist/native-region-scanner-core.js +5 -3
  251. package/dist/native-region-scanner-js-commonjs.js +155 -0
  252. package/dist/native-region-scanner-js-imports.js +51 -13
  253. package/dist/native-region-scanner-js-reexports.js +79 -0
  254. package/dist/native-region-scanner-js-ts-helpers.js +23 -0
  255. package/dist/native-source-ledger-helpers.js +1 -1
  256. package/dist/native-source-ledger.js +24 -10
  257. package/dist/native-source-maps-ecma426.js +316 -0
  258. package/dist/native-source-maps.js +36 -6
  259. package/dist/native-source-preservation-ownership.js +292 -0
  260. package/dist/native-source-preservation-scanner.js +63 -25
  261. package/dist/native-source-preservation-types.d.ts +3 -0
  262. package/dist/semantic-import-effect-occurrences.js +242 -0
  263. package/dist/semantic-import-effect-regions.js +95 -58
  264. package/dist/semantic-import-graph-layers.js +224 -0
  265. package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
  266. package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
  267. package/dist/semantic-import-runtime-exit-evidence.js +32 -0
  268. package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
  269. package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
  270. package/dist/semantic-import-runtime-order-evidence.js +318 -0
  271. package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
  272. package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
  273. package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
  274. package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
  275. package/dist/semantic-import-runtime-switch-evidence.js +304 -0
  276. package/dist/semantic-import-runtime-throw-evidence.js +44 -0
  277. package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
  278. package/dist/semantic-import-sidecar-entry.js +4 -0
  279. package/dist/semantic-import-source-preservation.js +6 -2
  280. package/package.json +1 -1
@@ -0,0 +1,205 @@
1
+ const trackedCompilerOptionKeys = [
2
+ 'allowImportingTsExtensions',
3
+ 'allowJs',
4
+ 'baseUrl',
5
+ 'checkJs',
6
+ 'composite',
7
+ 'declaration',
8
+ 'declarationMap',
9
+ 'emitDeclarationOnly',
10
+ 'jsx',
11
+ 'module',
12
+ 'moduleResolution',
13
+ 'noEmit',
14
+ 'noLib',
15
+ 'outDir',
16
+ 'paths',
17
+ 'rootDir',
18
+ 'skipLibCheck',
19
+ 'strict',
20
+ 'strictNullChecks',
21
+ 'target',
22
+ 'verbatimModuleSyntax'
23
+ ];
24
+
25
+ export function createCompilerOptionState(ts, input, options, projectRoot, normalizeDiagnostic) {
26
+ const defaultCompilerOptions = createDefaultCompilerOptions(ts);
27
+ const sources = compilerOptionSources(input, options);
28
+ const compilerOptions = { ...defaultCompilerOptions };
29
+ const diagnostics = [];
30
+ for (const source of sources) {
31
+ const normalized = normalizeCompilerOptionSource(ts, source.options, projectRoot, normalizeDiagnostic);
32
+ Object.assign(compilerOptions, normalized.options);
33
+ diagnostics.push(...normalized.diagnostics);
34
+ }
35
+ const projectReferences = normalizeProjectReferences(input, options);
36
+ const metadata = compilerInputMetadata(input, options, compilerOptions, sources, projectReferences);
37
+ return { compilerOptions, diagnostics, metadata, projectReferences };
38
+ }
39
+
40
+ export function describeJsTsProjectCompilerInputs(input = {}, options = {}, resolvedCompilerOptions, resolvedSources, resolvedProjectReferences) {
41
+ const sources = resolvedSources ?? compilerOptionSources(input, options);
42
+ const projectReferences = resolvedProjectReferences ?? normalizeProjectReferences(input, options);
43
+ const rawCompilerOptions = resolvedCompilerOptions ?? sources.reduce((merged, source) => Object.assign(merged, source.options), {});
44
+ return compactRecord({
45
+ compilerOptions: trackedCompilerOptions(rawCompilerOptions),
46
+ compilerOptionSources: sources.map((source) => compactRecord({
47
+ source: source.source,
48
+ compilerOptions: trackedCompilerOptions(source.options)
49
+ })),
50
+ projectReferences: projectReferences.map(projectReferenceMetadata),
51
+ projectReferenceCount: projectReferences.length || undefined,
52
+ tsconfigCompilerOptions: trackedCompilerOptions(tsconfigCompilerOptions(input.tsconfig)),
53
+ tsconfigReferences: normalizeProjectReferences({ projectReferences: input.tsconfig?.references }, {}).map(projectReferenceMetadata),
54
+ hasTypescriptCompilerApi: false,
55
+ hasOptionsOverride: isPlainObject(options.compilerOptions) || undefined
56
+ });
57
+ }
58
+
59
+ export function normalizeProjectReferences(input = {}, options = {}) {
60
+ const raw = input.projectReferences
61
+ ?? input.typescriptProjectReferences
62
+ ?? input.references
63
+ ?? input.tsconfigProjectReferences
64
+ ?? input.tsconfig?.references
65
+ ?? options.projectReferences;
66
+ const values = Array.isArray(raw) ? raw : [raw].filter(Boolean);
67
+ return values.map(normalizeProjectReference).filter((reference) => reference.path);
68
+ }
69
+
70
+ function createDefaultCompilerOptions(ts) {
71
+ return {
72
+ noEmit: true,
73
+ noLib: true,
74
+ allowJs: true,
75
+ checkJs: false,
76
+ skipLibCheck: true,
77
+ strict: false,
78
+ target: ts.ScriptTarget?.ESNext ?? ts.ScriptTarget?.Latest ?? 99,
79
+ module: ts.ModuleKind?.ESNext ?? 99,
80
+ moduleResolution: ts.ModuleResolutionKind?.Node10 ?? ts.ModuleResolutionKind?.NodeJs ?? 2,
81
+ jsx: ts.JsxEmit?.ReactJSX ?? ts.JsxEmit?.Preserve ?? 4
82
+ };
83
+ }
84
+
85
+ function compilerOptionSources(input, options = {}) {
86
+ return [
87
+ ['tsconfig.compilerOptions', tsconfigCompilerOptions(input.tsconfig)],
88
+ ['compilerOptions', input.compilerOptions],
89
+ ['typescriptCompilerOptions', input.typescriptCompilerOptions],
90
+ ['diagnostic.compilerOptions', options.compilerOptions]
91
+ ]
92
+ .filter(([, value]) => isPlainObject(value))
93
+ .map(([source, value]) => ({ source, options: { ...value } }));
94
+ }
95
+
96
+ function tsconfigCompilerOptions(tsconfig) {
97
+ if (!isPlainObject(tsconfig)) return undefined;
98
+ if (isPlainObject(tsconfig.compilerOptions)) return tsconfig.compilerOptions;
99
+ const entries = Object.entries(tsconfig).filter(([key]) => trackedCompilerOptionKeys.includes(key));
100
+ return entries.length ? Object.fromEntries(entries) : undefined;
101
+ }
102
+
103
+ function normalizeCompilerOptionSource(ts, value, projectRoot, normalizeDiagnostic) {
104
+ if (!isPlainObject(value)) return { options: {}, diagnostics: [] };
105
+ if (!ts.convertCompilerOptionsFromJson || !containsStringValue(value)) return { options: { ...value }, diagnostics: [] };
106
+ const { jsonOptions, passthroughOptions } = splitJsonCompilerOptions(value);
107
+ if (!Object.keys(jsonOptions).length) return { options: { ...value }, diagnostics: [] };
108
+ const converted = ts.convertCompilerOptionsFromJson(jsonOptions, projectRoot || '.');
109
+ return {
110
+ options: { ...passthroughOptions, ...(converted.options ?? {}) },
111
+ diagnostics: (converted.errors ?? []).map((diagnostic) => normalizeDiagnostic(ts, diagnostic, 'typescript-compiler-options'))
112
+ };
113
+ }
114
+
115
+ function splitJsonCompilerOptions(value) {
116
+ const jsonOptions = {};
117
+ const passthroughOptions = {};
118
+ for (const [key, optionValue] of Object.entries(value)) {
119
+ if (containsStringValue(optionValue)) jsonOptions[key] = optionValue;
120
+ else passthroughOptions[key] = optionValue;
121
+ }
122
+ return { jsonOptions, passthroughOptions };
123
+ }
124
+
125
+ function containsStringValue(value) {
126
+ if (typeof value === 'string') return true;
127
+ if (Array.isArray(value)) return value.some(containsStringValue);
128
+ if (isPlainObject(value)) return Object.values(value).some(containsStringValue);
129
+ return false;
130
+ }
131
+
132
+ function compilerInputMetadata(input, options, compilerOptions, sources, projectReferences) {
133
+ return compactRecord({
134
+ ...describeJsTsProjectCompilerInputs(input, options, compilerOptions, sources, projectReferences),
135
+ hasTypescriptCompilerApi: true,
136
+ hasOptionsOverride: isPlainObject(options.compilerOptions) || undefined
137
+ });
138
+ }
139
+
140
+ function trackedCompilerOptions(value) {
141
+ if (!isPlainObject(value)) return undefined;
142
+ const entries = trackedCompilerOptionKeys
143
+ .filter((key) => value[key] !== undefined)
144
+ .map((key) => [key, metadataValue(value[key])])
145
+ .filter(([, entry]) => entry !== undefined);
146
+ return entries.length ? Object.fromEntries(entries) : undefined;
147
+ }
148
+
149
+ function metadataValue(value, depth = 0) {
150
+ if (value === null || value === undefined) return value;
151
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return value;
152
+ if (Array.isArray(value)) return depth > 3 ? undefined : value.map((entry) => metadataValue(entry, depth + 1)).filter((entry) => entry !== undefined);
153
+ if (isPlainObject(value)) {
154
+ if (depth > 3) return undefined;
155
+ const entries = Object.entries(value)
156
+ .map(([key, entry]) => [key, metadataValue(entry, depth + 1)])
157
+ .filter(([, entry]) => entry !== undefined);
158
+ return entries.length ? Object.fromEntries(entries) : undefined;
159
+ }
160
+ return String(value);
161
+ }
162
+
163
+ function normalizeProjectReference(value) {
164
+ if (typeof value === 'string') return { path: normalizePath(value) };
165
+ if (!isPlainObject(value)) return {};
166
+ return compactRecord({
167
+ path: normalizePath(value.path ?? value.originalPath ?? value.sourcePath ?? ''),
168
+ originalPath: value.originalPath === undefined ? undefined : normalizePath(value.originalPath),
169
+ prepend: value.prepend === true ? true : undefined,
170
+ circular: value.circular === true ? true : undefined
171
+ });
172
+ }
173
+
174
+ function projectReferenceMetadata(reference) {
175
+ return compactRecord({
176
+ path: reference.path,
177
+ originalPath: reference.originalPath,
178
+ prepend: reference.prepend === true ? true : undefined,
179
+ circular: reference.circular === true ? true : undefined
180
+ });
181
+ }
182
+
183
+ function normalizePath(value) {
184
+ const raw = String(value ?? '').replace(/\\/g, '/').replace(/\/+/g, '/');
185
+ const absolute = raw.startsWith('/');
186
+ const parts = [];
187
+ for (const part of raw.split('/')) {
188
+ if (!part || part === '.') continue;
189
+ if (part === '..') {
190
+ if (parts.length && parts[parts.length - 1] !== '..') parts.pop();
191
+ else if (!absolute) parts.push(part);
192
+ continue;
193
+ }
194
+ parts.push(part);
195
+ }
196
+ return `${absolute ? '/' : ''}${parts.join('/')}`;
197
+ }
198
+
199
+ function isPlainObject(value) {
200
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
201
+ }
202
+
203
+ function compactRecord(value) {
204
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([, entry]) => entry !== undefined));
205
+ }
@@ -0,0 +1,268 @@
1
+ import { uniqueStrings } from './js-ts-safe-merge-context.js';
2
+ import {
3
+ createCompilerOptionState,
4
+ describeJsTsProjectCompilerInputs,
5
+ normalizeProjectReferences
6
+ } from './js-ts-safe-project-merge-ts-options.js';
7
+
8
+ function createJsTsVirtualTypeScriptProgram(input = {}, outputFiles = [], options = {}) {
9
+ const ts = input.typescript ?? input.ts ?? input.typescriptModule;
10
+ if (!ts?.createProgram || !ts?.createSourceFile) return undefined;
11
+ const sourceFiles = outputFiles.filter((file) => isJsTsSourcePath(file.sourcePath) && typeof file.sourceText === 'string');
12
+ const projectRoot = normalizePath(input.projectRoot ?? '');
13
+ const compilerState = createCompilerOptionState(ts, input, options, projectRoot, normalizeTypeScriptDiagnostic);
14
+ if (!sourceFiles.length) {
15
+ return {
16
+ ts,
17
+ sourceFiles,
18
+ sourceMap: new Map(),
19
+ rootNames: [],
20
+ program: undefined,
21
+ compilerOptions: compilerState.compilerOptions,
22
+ compilerOptionDiagnostics: compilerState.diagnostics,
23
+ compilerMetadata: compilerState.metadata,
24
+ projectReferences: compilerState.projectReferences
25
+ };
26
+ }
27
+ const sourceMap = new Map(sourceFiles.map((file) => [normalizePath(file.sourcePath), String(file.sourceText)]));
28
+ const rootNames = [...sourceMap.keys()];
29
+ const host = createVirtualCompilerHost(ts, compilerState.compilerOptions, sourceMap, projectRoot, options);
30
+ const program = createVirtualProgram(ts, rootNames, compilerState.compilerOptions, host, compilerState.projectReferences);
31
+ return {
32
+ ts,
33
+ sourceFiles,
34
+ sourceMap,
35
+ rootNames,
36
+ host,
37
+ program,
38
+ compilerOptions: compilerState.compilerOptions,
39
+ compilerOptionDiagnostics: compilerState.diagnostics,
40
+ compilerMetadata: compilerState.metadata,
41
+ projectReferences: compilerState.projectReferences
42
+ };
43
+ }
44
+
45
+ function createVirtualProgram(ts, rootNames, compilerOptions, host, projectReferences) {
46
+ if (!projectReferences.length) return ts.createProgram(rootNames, compilerOptions, host);
47
+ try {
48
+ return ts.createProgram({ rootNames, options: compilerOptions, host, projectReferences });
49
+ } catch {
50
+ return ts.createProgram(rootNames, compilerOptions, host, undefined, undefined, projectReferences);
51
+ }
52
+ }
53
+
54
+ function createVirtualCompilerHost(ts, compilerOptions, sourceMap, projectRoot, options = {}) {
55
+ const defaultHost = ts.createCompilerHost?.(compilerOptions, true);
56
+ return {
57
+ ...defaultHost,
58
+ getCurrentDirectory: () => projectRoot,
59
+ getCanonicalFileName: (fileName) => normalizePath(defaultHost?.getCanonicalFileName?.(fileName) ?? fileName),
60
+ useCaseSensitiveFileNames: () => true,
61
+ getNewLine: () => '\n',
62
+ fileExists(fileName) {
63
+ return Boolean(sourceMapMatch(sourceMap, fileName, projectRoot)) || defaultHost?.fileExists?.(fileName) === true;
64
+ },
65
+ readFile(fileName) {
66
+ const match = sourceMapMatch(sourceMap, fileName, projectRoot);
67
+ return match ? match.sourceText : defaultHost?.readFile?.(fileName);
68
+ },
69
+ getSourceFile(fileName, languageVersion) {
70
+ const match = sourceMapMatch(sourceMap, fileName, projectRoot);
71
+ if (match) {
72
+ return ts.createSourceFile(match.sourcePath, match.sourceText, languageVersion, true, scriptKindForPath(ts, match.sourcePath));
73
+ }
74
+ return defaultHost?.getSourceFile?.(fileName, languageVersion);
75
+ },
76
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
77
+ if (options.writeFile) return options.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
78
+ return defaultHost?.writeFile?.(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
79
+ },
80
+ resolveModuleNames(moduleNames, containingFile) {
81
+ return moduleNames.map((moduleName) => resolveVirtualModule(ts, sourceMap, moduleName, containingFile, projectRoot));
82
+ },
83
+ resolveModuleNameLiterals(moduleLiterals, containingFile) {
84
+ return moduleLiterals.map((moduleLiteral) => ({
85
+ resolvedModule: resolveVirtualModule(ts, sourceMap, moduleLiteral?.text ?? moduleLiteral, containingFile, projectRoot)
86
+ }));
87
+ }
88
+ };
89
+ }
90
+
91
+ function resolveVirtualModule(ts, sourceMap, moduleName, containingFile, projectRoot) {
92
+ const specifier = String(moduleName ?? '');
93
+ if (!specifier.startsWith('.') && !specifier.startsWith('/')) return undefined;
94
+ const baseDir = dirname(normalizePath(containingFile));
95
+ const target = normalizePath(specifier.startsWith('/') ? specifier.slice(1) : `${baseDir}/${specifier}`);
96
+ for (const candidate of moduleCandidates(target)) {
97
+ const match = sourceMapMatch(sourceMap, candidate, projectRoot);
98
+ if (!match) continue;
99
+ return {
100
+ resolvedFileName: match.sourcePath,
101
+ extension: extensionKind(ts, match.sourcePath),
102
+ isExternalLibraryImport: false
103
+ };
104
+ }
105
+ return undefined;
106
+ }
107
+
108
+ function moduleCandidates(target) {
109
+ const withoutExtension = target.replace(/\.(?:mjs|cjs|jsx?|tsx?)$/, '');
110
+ return uniqueStrings([
111
+ target,
112
+ `${target}.ts`,
113
+ `${target}.tsx`,
114
+ `${target}.js`,
115
+ `${target}.jsx`,
116
+ `${withoutExtension}.ts`,
117
+ `${withoutExtension}.tsx`,
118
+ `${withoutExtension}.js`,
119
+ `${withoutExtension}.jsx`,
120
+ `${target}/index.ts`,
121
+ `${target}/index.tsx`,
122
+ `${target}/index.js`,
123
+ `${target}/index.jsx`
124
+ ].map(normalizePath));
125
+ }
126
+
127
+ function normalizeSuppliedDiagnostics(value) {
128
+ const values = Array.isArray(value) ? value : [value].filter(Boolean);
129
+ return values.map((diagnostic, index) => compactRecord({
130
+ id: diagnostic.id ?? `diagnostic_${index + 1}`,
131
+ source: diagnostic.source ?? diagnostic.tool ?? 'supplied',
132
+ code: String(diagnostic.code ?? diagnostic.diagnosticCode ?? 'diagnostic'),
133
+ severity: normalizeSeverity(diagnostic.severity ?? diagnostic.category),
134
+ message: String(diagnostic.message ?? diagnostic.messageText ?? ''),
135
+ sourcePath: normalizeOptionalPath(diagnostic.sourcePath ?? diagnostic.fileName ?? diagnostic.file?.fileName),
136
+ start: numberOrUndefined(diagnostic.start),
137
+ end: numberOrUndefined(diagnostic.end),
138
+ line: numberOrUndefined(diagnostic.line),
139
+ column: numberOrUndefined(diagnostic.column)
140
+ }));
141
+ }
142
+
143
+ function normalizeTypeScriptDiagnostic(ts, diagnostic, source = 'typescript-compiler-api') {
144
+ const sourcePath = diagnostic.file?.fileName ? normalizePath(diagnostic.file.fileName) : undefined;
145
+ const lineInfo = diagnostic.file && Number.isFinite(diagnostic.start)
146
+ ? diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
147
+ : undefined;
148
+ return compactRecord({
149
+ id: `ts_${diagnostic.code}_${sourcePath ?? 'global'}_${diagnostic.start ?? 0}`,
150
+ source,
151
+ code: `TS${diagnostic.code}`,
152
+ severity: diagnostic.category === (ts.DiagnosticCategory?.Error ?? 1) ? 'error' : normalizeSeverity(diagnostic.category),
153
+ message: flattenDiagnosticMessage(ts, diagnostic.messageText),
154
+ sourcePath,
155
+ start: numberOrUndefined(diagnostic.start),
156
+ end: Number.isFinite(diagnostic.start) && Number.isFinite(diagnostic.length)
157
+ ? diagnostic.start + diagnostic.length
158
+ : undefined,
159
+ line: lineInfo ? lineInfo.line + 1 : undefined,
160
+ column: lineInfo ? lineInfo.character + 1 : undefined
161
+ });
162
+ }
163
+
164
+ function flattenDiagnosticMessage(ts, messageText) {
165
+ if (ts.flattenDiagnosticMessageText) return ts.flattenDiagnosticMessageText(messageText, '\n');
166
+ if (typeof messageText === 'string') return messageText;
167
+ return String(messageText?.messageText ?? messageText ?? '');
168
+ }
169
+
170
+ function normalizeSeverity(value) {
171
+ if (typeof value === 'string') {
172
+ const lowered = value.toLowerCase();
173
+ if (lowered.includes('error')) return 'error';
174
+ if (lowered.includes('warn')) return 'warning';
175
+ if (lowered.includes('suggest')) return 'suggestion';
176
+ if (lowered.includes('message')) return 'message';
177
+ }
178
+ if (value === 1) return 'error';
179
+ if (value === 0) return 'warning';
180
+ if (value === 2) return 'suggestion';
181
+ if (value === 3) return 'message';
182
+ return 'error';
183
+ }
184
+
185
+ function scriptKindForPath(ts, sourcePath) {
186
+ if (sourcePath.endsWith('.tsx')) return ts.ScriptKind?.TSX;
187
+ if (sourcePath.endsWith('.ts')) return ts.ScriptKind?.TS;
188
+ if (sourcePath.endsWith('.jsx')) return ts.ScriptKind?.JSX;
189
+ if (sourcePath.endsWith('.js')) return ts.ScriptKind?.JS;
190
+ return undefined;
191
+ }
192
+
193
+ function extensionKind(ts, sourcePath) {
194
+ if (sourcePath.endsWith('.tsx')) return ts.Extension?.Tsx ?? '.tsx';
195
+ if (sourcePath.endsWith('.ts')) return ts.Extension?.Ts ?? '.ts';
196
+ if (sourcePath.endsWith('.jsx')) return ts.Extension?.Jsx ?? '.jsx';
197
+ return ts.Extension?.Js ?? '.js';
198
+ }
199
+
200
+ function isJsTsSourcePath(sourcePath) {
201
+ return /\.(?:mjs|cjs|jsx?|tsx?)$/.test(String(sourcePath ?? ''));
202
+ }
203
+
204
+ function normalizePath(value) {
205
+ const raw = String(value ?? '').replace(/\\/g, '/').replace(/\/+/g, '/');
206
+ const absolute = raw.startsWith('/');
207
+ const parts = [];
208
+ for (const part of raw.split('/')) {
209
+ if (!part || part === '.') continue;
210
+ if (part === '..') {
211
+ if (parts.length && parts[parts.length - 1] !== '..') parts.pop();
212
+ else if (!absolute) parts.push(part);
213
+ continue;
214
+ }
215
+ parts.push(part);
216
+ }
217
+ return `${absolute ? '/' : ''}${parts.join('/')}`;
218
+ }
219
+
220
+ function sourceMapMatch(sourceMap, fileName, projectRoot = '') {
221
+ for (const candidate of sourcePathCandidates(fileName, projectRoot)) {
222
+ if (sourceMap.has(candidate)) return { sourcePath: candidate, sourceText: sourceMap.get(candidate) };
223
+ }
224
+ return undefined;
225
+ }
226
+
227
+ function sourcePathCandidates(fileName, projectRoot) {
228
+ const normalized = normalizePath(fileName);
229
+ const trimmed = normalized.replace(/^\/+/, '');
230
+ const candidates = [normalized, trimmed];
231
+ if (projectRoot) {
232
+ const root = normalizePath(projectRoot).replace(/\/+$/, '');
233
+ const trimmedRoot = root.replace(/^\/+/, '');
234
+ if (normalized.startsWith(`${root}/`)) candidates.push(normalized.slice(root.length + 1));
235
+ if (trimmed.startsWith(`${trimmedRoot}/`)) candidates.push(trimmed.slice(trimmedRoot.length + 1));
236
+ candidates.push(`${root}/${trimmed}`);
237
+ }
238
+ return uniqueStrings(candidates);
239
+ }
240
+
241
+ function normalizeOptionalPath(value) {
242
+ return value === undefined || value === null ? undefined : normalizePath(value);
243
+ }
244
+
245
+ function dirname(sourcePath) {
246
+ const normalized = normalizePath(sourcePath);
247
+ const index = normalized.lastIndexOf('/');
248
+ return index < 0 ? '' : normalized.slice(0, index);
249
+ }
250
+
251
+ function numberOrUndefined(value) {
252
+ return Number.isFinite(value) ? value : undefined;
253
+ }
254
+
255
+ function compactRecord(value) {
256
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([, entry]) => entry !== undefined));
257
+ }
258
+
259
+ export {
260
+ createJsTsVirtualTypeScriptProgram,
261
+ describeJsTsProjectCompilerInputs,
262
+ isJsTsSourcePath,
263
+ normalizePath,
264
+ normalizeProjectReferences,
265
+ normalizeSuppliedDiagnostics,
266
+ normalizeTypeScriptDiagnostic,
267
+ sourceMapMatch
268
+ };
@@ -0,0 +1,69 @@
1
+ import { uniqueStrings } from './js-ts-safe-merge-context.js';
2
+
3
+ function typedPropertyRenameRebaseEvidence(file, analysis) {
4
+ return {
5
+ id: `typed_property_rename_rebase_${safeId(file.sourcePath)}_${safeId(analysis.ownerName)}_${safeId(analysis.fromName)}_${safeId(analysis.toName)}`,
6
+ kind: 'js-ts-project-typed-property-rename-rebase',
7
+ status: 'passed',
8
+ level: 'diagnostics-required-project-rebase',
9
+ scope: 'source-file',
10
+ summary: `Rebased worker changes from ${analysis.ownerName}.${analysis.fromName} to ${analysis.ownerName}.${analysis.toName}; project output diagnostics must still pass.`,
11
+ metadata: {
12
+ sourcePath: file.sourcePath,
13
+ ownerName: analysis.ownerName,
14
+ ownerKind: analysis.ownerKind,
15
+ fromName: analysis.fromName,
16
+ toName: analysis.toName,
17
+ typeText: analysis.typeText,
18
+ workerAddedMembers: analysis.workerAddedMembers.map((member) => member.name),
19
+ workerAddedDeclarations: analysis.workerAddedDeclarations.map((entry) => entry.names?.[0]).filter(Boolean),
20
+ rebasedDeclarations: analysis.rebasedDeclarations,
21
+ requiresOutputDiagnostics: true,
22
+ autoMergeClaim: false,
23
+ semanticEquivalenceClaim: false
24
+ }
25
+ };
26
+ }
27
+
28
+ function unsafePropertyAccessReasons(text, fromName) {
29
+ const property = escapeRegExp(fromName);
30
+ const reasons = [];
31
+ if (new RegExp(`\\[\\s*['"]${property}['"]\\s*\\]`).test(text)) reasons.push('typed-property-rename-rebase-bracket-access-unsupported');
32
+ if (new RegExp(`\\{[^}]*\\b${property}\\b[^}]*\\}`).test(text) && /\b(const|let|var|function)\b/.test(text)) {
33
+ reasons.push('typed-property-rename-rebase-destructuring-unsupported');
34
+ }
35
+ return uniqueStrings(reasons);
36
+ }
37
+
38
+ function stalePropertyAccessReasons(text, fromName) {
39
+ const property = escapeRegExp(fromName);
40
+ return new RegExp(`(\\?\\.|\\.)${property}\\b|\\[\\s*['"]${property}['"]\\s*\\]`).test(text)
41
+ ? ['typed-property-rename-rebase-stale-property-access']
42
+ : [];
43
+ }
44
+
45
+ function renameTypesEqual(left, right) {
46
+ return Boolean(left && right)
47
+ && left.optional === right.optional
48
+ && normalizeTypeText(left.typeText) === normalizeTypeText(right.typeText);
49
+ }
50
+
51
+ function membersByName(members) { return new Map(members.map((member) => [member.name, member])); }
52
+ function entriesByKey(entries) { return new Map(entries.map((entry) => [entry.key, entry])); }
53
+ function normalizeTypeText(value) { return String(value ?? '').replace(/\s+/g, ' ').trim(); }
54
+ function rejected(reasonCode, reasonCodes = [reasonCode]) { return { ok: false, reasonCodes: uniqueStrings(reasonCodes) }; }
55
+ function safeId(value) { return String(value ?? 'unknown').replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'unknown'; }
56
+ function escapeRegExp(value) { return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
57
+
58
+ export {
59
+ entriesByKey,
60
+ escapeRegExp,
61
+ membersByName,
62
+ normalizeTypeText,
63
+ rejected,
64
+ renameTypesEqual,
65
+ safeId,
66
+ stalePropertyAccessReasons,
67
+ typedPropertyRenameRebaseEvidence,
68
+ unsafePropertyAccessReasons
69
+ };