@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,320 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { isJsxComponentTag, isJsxSpreadAttribute, jsxContextProviderBoundary, parseJsxTags } from '../../js-ts-safe-merge-jsx-attribute-parser.js';
3
+ import { jsxSameFileMemberComponentOwnerIndex } from './projectSymbolGraphJsxMemberComponents.js';
4
+
5
+ function jsxComponentPropRenderFlowBoundary(tag, attribute, valueEvidence, context = {}) {
6
+ if (isJsxSpreadAttribute(attribute) || !isJsxComponentTag(tag.tagName) || jsxContextProviderBoundary(tag.tagName)) return undefined;
7
+ const { targetName, targetKind, owners } = componentPropRenderFlowTarget(tag, context);
8
+ if (owners.length !== 1) return unsupportedComponentPropRenderFlow(tag, attribute, {
9
+ reasonCode: 'jsx-render-component-prop-flow-unsupported',
10
+ targetName,
11
+ targetKind,
12
+ targetOwnerCount: owners.length
13
+ });
14
+ const owner = owners[0];
15
+ const lookupScope = String(owner.componentProviderLookupScope ?? '');
16
+ const sameFileDirect = owner.sourcePath === context.sourcePath && !lookupScope.startsWith('project-import-');
17
+ const projectImport = lookupScope.startsWith('project-import-');
18
+ if (!sameFileDirect && !projectImport) return unsupportedComponentPropRenderFlow(tag, attribute, {
19
+ reasonCode: 'jsx-render-component-prop-flow-unsupported',
20
+ targetName,
21
+ targetKind,
22
+ targetOwnerName: owner.name,
23
+ targetSourcePath: owner.sourcePath,
24
+ targetLookupScope: owner.componentProviderLookupScope,
25
+ targetLookupStatus: owner.componentCallLookupStatus
26
+ });
27
+ if (!staticComponentPropCallsiteValue(valueEvidence)) return unsupportedComponentPropRenderFlow(tag, attribute, {
28
+ reasonCode: 'jsx-render-component-prop-flow-dynamic-value-unsupported',
29
+ targetName,
30
+ targetKind,
31
+ targetOwnerName: owner.name,
32
+ targetSourcePath: owner.sourcePath,
33
+ targetLookupScope: owner.componentProviderLookupScope,
34
+ targetLookupStatus: owner.componentCallLookupStatus,
35
+ dynamicBlockerReasonCode: valueEvidence?.dynamicBlockerReasonCode
36
+ });
37
+ const flowRecord = (owner.componentPropRenderFlowRecords ?? []).find((record) => record.componentPropName === attribute.name);
38
+ if (!flowRecord) return unsupportedComponentPropRenderFlow(tag, attribute, {
39
+ reasonCode: 'jsx-render-component-prop-flow-unsupported',
40
+ targetName,
41
+ targetKind,
42
+ targetOwnerName: owner.name,
43
+ targetSourcePath: owner.sourcePath,
44
+ targetLookupScope: owner.componentProviderLookupScope,
45
+ targetLookupStatus: owner.componentCallLookupStatus
46
+ });
47
+ const targetLookupHash = componentPropFlowLookupHash(tag, targetName, owner);
48
+ return compactRecord({
49
+ status: 'static-component-prop-render-flow-evidence',
50
+ reasonCode: 'jsx-render-component-prop-flow-static-passthrough-evidence',
51
+ claim: true,
52
+ claimScope: 'static-prop-passthrough-only',
53
+ renderEquivalenceClaim: false,
54
+ scope: componentPropRenderFlowScope(flowRecord.scope, lookupScope),
55
+ targetName,
56
+ targetOwnerName: owner.name,
57
+ targetSourcePath: owner.sourcePath,
58
+ targetLookupStatus: owner.componentCallLookupStatus,
59
+ targetLookupScope: owner.componentProviderLookupScope,
60
+ importEdgeId: owner.componentCallImportEdgeId,
61
+ importKind: owner.componentCallImportKind,
62
+ importedName: owner.componentCallImportedName,
63
+ localName: owner.componentCallLocalName,
64
+ targetExportName: owner.componentCallTargetExportName,
65
+ reExportEdgeId: owner.componentCallReExportEdgeId,
66
+ reExportSourcePath: owner.componentCallReExportSourcePath,
67
+ reExportExportedName: owner.componentCallReExportExportedName,
68
+ reExportLocalName: owner.componentCallReExportLocalName,
69
+ reExportTargetSourcePath: owner.componentCallReExportTargetSourcePath,
70
+ reExportKind: owner.componentCallReExportKind,
71
+ reExportIdentityId: owner.componentCallReExportIdentityId,
72
+ targetLookupHash,
73
+ memberObjectName: owner.componentCallMemberObjectName,
74
+ memberPropertyName: owner.componentCallMemberPropertyName,
75
+ memberLocalName: owner.componentCallMemberLocalName,
76
+ memberBindingKind: owner.componentCallMemberBindingKind,
77
+ memberBindingHash: owner.componentCallMemberBindingHash,
78
+ componentPropName: flowRecord.componentPropName,
79
+ renderedTagName: flowRecord.renderedTagName,
80
+ renderedPropName: flowRecord.renderedPropName,
81
+ passthroughExpressionText: flowRecord.passthroughExpressionText,
82
+ bindingKind: flowRecord.bindingKind,
83
+ returnOrdinal: flowRecord.returnOrdinal,
84
+ targetSignatureHash: flowRecord.signatureHash,
85
+ signatureHash: hashSemanticValue({
86
+ kind: 'frontier.lang.projectJsxComponentPropRenderFlowBoundary',
87
+ tagName: tag.tagName,
88
+ tagKey: tag.key,
89
+ propName: attribute.name,
90
+ targetName,
91
+ targetOwnerName: owner.name,
92
+ targetSourcePath: owner.sourcePath,
93
+ targetLookupStatus: owner.componentCallLookupStatus,
94
+ targetLookupScope: owner.componentProviderLookupScope,
95
+ importEdgeId: owner.componentCallImportEdgeId,
96
+ reExportEdgeId: owner.componentCallReExportEdgeId,
97
+ reExportIdentityId: owner.componentCallReExportIdentityId,
98
+ memberBindingHash: owner.componentCallMemberBindingHash,
99
+ targetLookupHash,
100
+ valueSignatureHash: valueEvidence?.signatureHash,
101
+ flowSignatureHash: flowRecord.signatureHash,
102
+ claimScope: 'static-prop-passthrough-only',
103
+ renderEquivalenceClaim: false
104
+ })
105
+ });
106
+ }
107
+
108
+ function unsupportedComponentPropRenderFlow(tag, attribute, options = {}) {
109
+ return compactRecord({
110
+ status: 'component-prop-render-flow-unsupported',
111
+ reasonCode: options.reasonCode ?? 'jsx-render-component-prop-flow-unsupported',
112
+ claim: false,
113
+ renderEquivalenceClaim: false,
114
+ targetName: options.targetName,
115
+ targetKind: options.targetKind ?? (plainComponentTagName(tag.tagName) ? 'plain-component' : 'member-component'),
116
+ targetOwnerName: options.targetOwnerName,
117
+ targetOwnerCount: options.targetOwnerCount,
118
+ targetSourcePath: options.targetSourcePath,
119
+ targetLookupStatus: options.targetLookupStatus,
120
+ targetLookupScope: options.targetLookupScope,
121
+ dynamicBlockerReasonCode: options.dynamicBlockerReasonCode,
122
+ signatureHash: hashSemanticValue({
123
+ kind: 'frontier.lang.projectJsxComponentPropRenderFlowBoundary',
124
+ tagName: tag.tagName,
125
+ tagKey: tag.key,
126
+ propName: attribute.name,
127
+ targetName: options.targetName,
128
+ targetKind: options.targetKind ?? (plainComponentTagName(tag.tagName) ? 'plain-component' : 'member-component'),
129
+ reasonCode: options.reasonCode ?? 'jsx-render-component-prop-flow-unsupported',
130
+ targetLookupStatus: options.targetLookupStatus,
131
+ targetLookupScope: options.targetLookupScope,
132
+ dynamicBlockerReasonCode: options.dynamicBlockerReasonCode
133
+ })
134
+ });
135
+ }
136
+
137
+ function staticComponentPropCallsiteValue(valueEvidence) {
138
+ return valueEvidence?.proofStatus === 'static-literal-jsx-prop-value-evidence' || valueEvidence?.proofStatus === 'static-reference-jsx-prop-value-evidence';
139
+ }
140
+
141
+ function componentPropRenderFlowScope(fallbackScope, lookupScope) {
142
+ if (lookupScope === 'project-import-reexport-member-component') return 'project-import-reexport-member-component-static-prop-passthrough';
143
+ if (lookupScope === 'project-import-member-component') return 'project-import-member-component-static-prop-passthrough';
144
+ if (lookupScope === 'project-import-reexport-component') return 'project-import-reexport-component-static-prop-passthrough';
145
+ if (lookupScope === 'project-import-direct-component') return 'project-import-direct-component-static-prop-passthrough';
146
+ if (lookupScope === 'same-file-member-component') return 'same-file-member-component-static-prop-passthrough';
147
+ return fallbackScope;
148
+ }
149
+
150
+ function componentPropFlowLookupHash(tag, targetName, owner) {
151
+ const scope = String(owner?.componentProviderLookupScope ?? '');
152
+ if (!scope.startsWith('project-import-') && scope !== 'same-file-member-component') return undefined;
153
+ return hashSemanticValue({
154
+ kind: 'frontier.lang.projectJsxComponentPropFlowLookupTarget',
155
+ tagName: tag.tagName,
156
+ targetName,
157
+ ownerName: owner.name,
158
+ scope: owner.componentProviderLookupScope,
159
+ targetSourcePath: owner.componentCallTargetSourcePath ?? owner.sourcePath,
160
+ importEdgeId: owner.componentCallImportEdgeId,
161
+ reExportEdgeId: owner.componentCallReExportEdgeId,
162
+ reExportIdentityId: owner.componentCallReExportIdentityId,
163
+ memberBindingHash: owner.componentCallMemberBindingHash
164
+ });
165
+ }
166
+
167
+ function componentPropRenderFlowTarget(tag, context) {
168
+ const plain = plainComponentTagName(tag.tagName);
169
+ if (plain) return { targetName: plain, targetKind: 'plain-component', owners: context.componentOwners?.get(plain) ?? [] };
170
+ const member = memberComponentTagName(tag.tagName);
171
+ const owners = member ? context.componentMemberOwners?.get(member) ?? [] : [];
172
+ const fallbackOwners = member && !owners.length ? jsxSameFileMemberComponentOwnerIndex(context.sourceText, context.componentOwners).get(member) ?? [] : owners;
173
+ return { targetName: member ?? tag.tagName, targetKind: 'member-component', owners: fallbackOwners };
174
+ }
175
+
176
+ function jsxComponentPropRenderFlowRecords(ownerSourceText, ownerName, renderReturnRecords = []) {
177
+ const binding = componentPropsBinding(ownerSourceText, ownerName);
178
+ if (!binding) return [];
179
+ const singleStaticReturn = renderReturnRecords.length === 1 && renderReturnRecords[0]?.branchControlKind === 'return-statement';
180
+ if (!singleStaticReturn) return [];
181
+ return staticPropPassthroughRecords(renderReturnRecords[0], binding, ownerName);
182
+ }
183
+
184
+ function staticPropPassthroughRecords(returnRecord, binding, ownerName) {
185
+ return parseJsxTags(returnRecord.expressionText).tags.flatMap((tag) => tag.attributes.flatMap((attribute) => {
186
+ if (isJsxSpreadAttribute(attribute)) return [];
187
+ const assigned = jsxAssignedPropValueText(attribute);
188
+ const expressionText = assigned === undefined ? undefined : bracedExpressionText(assigned);
189
+ const reference = expressionText === undefined ? undefined : staticPropReferenceForBinding(expressionText, binding);
190
+ if (!reference) return [];
191
+ return [componentPropRenderFlowRecord({ ownerName, returnRecord, tag, attribute, reference })];
192
+ }));
193
+ }
194
+
195
+ function componentPropRenderFlowRecord(input) {
196
+ const passthroughExpressionText = input.reference.expressionText;
197
+ const signatureHash = hashSemanticValue({
198
+ kind: 'frontier.lang.projectJsxStaticComponentPropPassthrough',
199
+ ownerName: input.ownerName,
200
+ componentPropName: input.reference.propName,
201
+ renderedTagName: input.tag.tagName,
202
+ renderedPropName: input.attribute.name,
203
+ returnOrdinal: input.returnRecord.ordinal,
204
+ passthroughExpressionText,
205
+ bindingKind: input.reference.bindingKind
206
+ });
207
+ return {
208
+ proofStatus: 'static-component-prop-render-flow-evidence',
209
+ reasonCode: 'jsx-render-component-prop-flow-static-passthrough-evidence',
210
+ scope: 'same-file-plain-component-static-prop-passthrough',
211
+ renderEquivalenceClaim: false,
212
+ componentPropName: input.reference.propName,
213
+ renderedTagName: input.tag.tagName,
214
+ renderedPropName: input.attribute.name,
215
+ passthroughExpressionText,
216
+ bindingKind: input.reference.bindingKind,
217
+ returnOrdinal: input.returnRecord.ordinal,
218
+ signatureHash
219
+ };
220
+ }
221
+
222
+ function componentPropsBinding(sourceText, ownerName) {
223
+ const text = String(sourceText ?? '');
224
+ const functionMatch = new RegExp(`\\bfunction\\s+${escapeRegExp(ownerName)}\\s*\\(([^)]*)\\)`).exec(text);
225
+ const arrowMatch = new RegExp(`\\b(?:const|let|var)\\s+${escapeRegExp(ownerName)}\\s*=\\s*(?:\\(([^)]*)\\)|([A-Za-z_$][\\w$]*))\\s*=>`).exec(text);
226
+ const paramsText = functionMatch?.[1] ?? arrowMatch?.[1] ?? arrowMatch?.[2];
227
+ const first = firstParameterText(paramsText);
228
+ if (!first) return undefined;
229
+ if (/^[A-Za-z_$][\w$]*$/.test(first)) return { kind: 'props-identifier', identifier: first };
230
+ if (/^\{[\s\S]*\}$/.test(first)) {
231
+ const props = destructuredPropBindings(first);
232
+ return props.length ? { kind: 'destructured-parameter', props } : undefined;
233
+ }
234
+ return undefined;
235
+ }
236
+
237
+ function firstParameterText(paramsText) {
238
+ const text = String(paramsText ?? '').trim();
239
+ if (!text) return undefined;
240
+ return splitTopLevel(text, ',')[0]?.trim();
241
+ }
242
+
243
+ function destructuredPropBindings(paramText) {
244
+ const inner = String(paramText ?? '').trim().replace(/^\{|\}$/g, '');
245
+ return splitTopLevel(inner, ',').flatMap((part) => {
246
+ const withoutDefault = splitTopLevel(part.trim(), '=')[0]?.trim();
247
+ if (!withoutDefault || withoutDefault.startsWith('...') || /[\[\]{}]/.test(withoutDefault)) return [];
248
+ const alias = /^([A-Za-z_$][\w$]*)\s*:\s*([A-Za-z_$][\w$]*)$/.exec(withoutDefault);
249
+ if (alias) return [{ propName: alias[1], localName: alias[2] }];
250
+ const direct = /^([A-Za-z_$][\w$]*)$/.exec(withoutDefault);
251
+ return direct ? [{ propName: direct[1], localName: direct[1] }] : [];
252
+ });
253
+ }
254
+
255
+ function staticPropReferenceForBinding(expressionText, binding) {
256
+ const normalized = normalizedMemberExpression(expressionText);
257
+ if (!normalized) return undefined;
258
+ if (binding.kind === 'props-identifier') {
259
+ const prefix = `${binding.identifier}.`;
260
+ if (!normalized.startsWith(prefix)) return undefined;
261
+ const propName = normalized.slice(prefix.length);
262
+ return /^[A-Za-z_$][\w$]*$/.test(propName)
263
+ ? { propName, expressionText: normalized, bindingKind: 'props-identifier' }
264
+ : undefined;
265
+ }
266
+ if (binding.kind === 'destructured-parameter') {
267
+ const prop = binding.props.find((candidate) => candidate.localName === normalized);
268
+ return prop ? { propName: prop.propName, expressionText: normalized, bindingKind: 'destructured-parameter' } : undefined;
269
+ }
270
+ return undefined;
271
+ }
272
+
273
+ function normalizedMemberExpression(text) {
274
+ const value = normalizedText(text).replace(/\s*\.\s*/g, '.').replace(/\s+/g, '');
275
+ return /^(?:[A-Za-z_$][\w$]*)(?:\.[A-Za-z_$][\w$]*)*$/.test(value) ? value : undefined;
276
+ }
277
+
278
+ function splitTopLevel(text, delimiter) {
279
+ const value = String(text ?? '');
280
+ const parts = [];
281
+ let quote;
282
+ let depth = 0;
283
+ let start = 0;
284
+ for (let index = 0; index < value.length; index += 1) {
285
+ const char = value[index];
286
+ if (quote) {
287
+ if (char === '\\') index += 1;
288
+ else if (char === quote) quote = undefined;
289
+ continue;
290
+ }
291
+ if (char === '"' || char === "'" || char === '`') quote = char;
292
+ else if (char === '(' || char === '[' || char === '{') depth += 1;
293
+ else if (char === ')' || char === ']' || char === '}') depth = Math.max(0, depth - 1);
294
+ else if (depth === 0 && value.slice(index, index + delimiter.length) === delimiter) {
295
+ parts.push(value.slice(start, index));
296
+ start = index + delimiter.length;
297
+ index += delimiter.length - 1;
298
+ }
299
+ }
300
+ parts.push(value.slice(start));
301
+ return parts;
302
+ }
303
+
304
+ function jsxAssignedPropValueText(attribute) {
305
+ const match = /^[A-Za-z_$][\w$:-]*\s*=\s*([\s\S]*)$/.exec(String(attribute?.text ?? '').trim());
306
+ return match ? normalizedText(match[1]) : undefined;
307
+ }
308
+
309
+ function bracedExpressionText(text) {
310
+ const match = /^\{\s*([\s\S]*?)\s*\}$/.exec(String(text ?? '').trim());
311
+ return match ? normalizedText(match[1]) : undefined;
312
+ }
313
+
314
+ function escapeRegExp(text) { return String(text ?? '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
315
+ function plainComponentTagName(tagName) { return /^[A-Z][A-Za-z0-9_$]*$/.test(String(tagName ?? '')) ? String(tagName) : undefined; }
316
+ function memberComponentTagName(tagName) { return /^[A-Z][A-Za-z0-9_$]*(?:\.[A-Z][A-Za-z0-9_$]*)+$/.test(String(tagName ?? '')) ? String(tagName) : undefined; }
317
+ function normalizedText(text) { return String(text ?? '').trim().replace(/\s+/g, ' '); }
318
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
319
+
320
+ export { jsxComponentPropRenderFlowBoundary, jsxComponentPropRenderFlowRecords };
@@ -0,0 +1,145 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { isJsxSpreadAttribute } from '../../js-ts-safe-merge-jsx-attribute-parser.js';
3
+ import { staticOptionalMemberReference } from './staticOptionalMemberReference.js';
4
+
5
+ function jsxPropValueEvidence(tag, attribute) {
6
+ if (isJsxSpreadAttribute(attribute)) return undefined;
7
+ const assignedValueText = jsxAssignedPropValueText(attribute);
8
+ const evidence = assignedValueText === undefined
9
+ ? staticPropValueEvidence('boolean-shorthand', 'true', 'true')
10
+ : jsxAssignedPropValueEvidence(assignedValueText);
11
+ return compactRecord({
12
+ ...evidence,
13
+ expressionHash: hashSemanticValue({
14
+ kind: 'frontier.lang.projectJsxPropValueExpression',
15
+ tagName: tag.tagName,
16
+ tagKey: tag.key,
17
+ propName: attribute.name,
18
+ expressionText: evidence.expressionText ?? evidence.valueText ?? evidence.dynamicText
19
+ }),
20
+ signatureHash: hashSemanticValue({
21
+ kind: 'frontier.lang.projectJsxPropValue',
22
+ tagName: tag.tagName,
23
+ tagKey: tag.key,
24
+ propName: attribute.name,
25
+ propKind: propKind(attribute),
26
+ proofStatus: evidence.proofStatus,
27
+ reasonCode: evidence.reasonCode,
28
+ valueKind: evidence.valueKind,
29
+ valueText: evidence.valueText,
30
+ expressionText: evidence.expressionText,
31
+ referenceRoot: evidence.referenceRoot,
32
+ referencePath: evidence.referencePath,
33
+ optionalReference: evidence.optionalReference,
34
+ optionalReferenceSegments: evidence.optionalReferenceSegments,
35
+ optionalReferenceSegmentIndexes: evidence.optionalReferenceSegmentIndexes,
36
+ optionalNullishBoundaryCount: evidence.optionalNullishBoundaryCount,
37
+ dynamicText: evidence.dynamicText,
38
+ dynamicBlockerReasonCode: evidence.dynamicBlockerReasonCode
39
+ })
40
+ });
41
+ }
42
+
43
+ function jsxAssignedPropValueText(attribute) {
44
+ const match = /^[A-Za-z_$][\w$:-]*\s*=\s*([\s\S]*)$/.exec(String(attribute?.text ?? '').trim());
45
+ return match ? normalizedText(match[1]) : undefined;
46
+ }
47
+
48
+ function jsxAssignedPropValueEvidence(valueText) {
49
+ const text = normalizedText(valueText);
50
+ if (quotedLiteralText(text)) return staticPropValueEvidence('string', text, text);
51
+ const expressionText = bracedExpressionText(text);
52
+ if (expressionText === undefined) return staticPropValueEvidence('unquoted-literal', text, text);
53
+ const literalKind = staticLiteralKind(expressionText);
54
+ if (literalKind) return staticPropValueEvidence(literalKind, expressionText, expressionText);
55
+ const reference = staticPropReference(expressionText);
56
+ if (reference) return staticReferencePropValueEvidence(reference, expressionText);
57
+ const optionalReference = staticOptionalMemberReference(expressionText);
58
+ if (optionalReference) return staticOptionalReferencePropValueEvidence(optionalReference, expressionText);
59
+ return {
60
+ proofStatus: 'dynamic-jsx-prop-value-unsupported',
61
+ reasonCode: 'jsx-render-prop-value-unsupported',
62
+ expressionText,
63
+ dynamicText: expressionText,
64
+ dynamicBlockerReasonCode: jsxPropValueDynamicBlockerReasonCode(expressionText)
65
+ };
66
+ }
67
+
68
+ function staticPropValueEvidence(valueKind, valueText, expressionText) {
69
+ return {
70
+ proofStatus: 'static-literal-jsx-prop-value-evidence',
71
+ reasonCode: 'jsx-render-prop-value-literal-evidence',
72
+ valueKind,
73
+ valueText,
74
+ expressionText
75
+ };
76
+ }
77
+
78
+ function staticReferencePropValueEvidence(reference, expressionText) {
79
+ return {
80
+ proofStatus: 'static-reference-jsx-prop-value-evidence',
81
+ reasonCode: 'jsx-render-prop-value-static-reference-evidence',
82
+ valueKind: 'reference',
83
+ valueText: reference.text,
84
+ expressionText,
85
+ referenceRoot: reference.root,
86
+ referencePath: reference.path
87
+ };
88
+ }
89
+
90
+ function staticOptionalReferencePropValueEvidence(reference, expressionText) {
91
+ return {
92
+ proofStatus: 'static-optional-reference-jsx-prop-value-evidence',
93
+ reasonCode: 'jsx-render-prop-value-static-optional-reference-evidence',
94
+ valueKind: 'optional-reference',
95
+ valueText: reference.text,
96
+ expressionText,
97
+ referenceRoot: reference.root,
98
+ referencePath: reference.path,
99
+ optionalReference: true,
100
+ optionalReferenceSegments: reference.optionalSegments,
101
+ optionalReferenceSegmentIndexes: reference.optionalSegmentIndexes,
102
+ optionalNullishBoundaryCount: reference.optionalSegmentIndexes.length
103
+ };
104
+ }
105
+
106
+ function bracedExpressionText(text) {
107
+ const match = /^\{\s*([\s\S]*?)\s*\}$/.exec(String(text ?? '').trim());
108
+ return match ? normalizedText(match[1]) : undefined;
109
+ }
110
+
111
+ function quotedLiteralText(text) {
112
+ return /^"(?:[^"\\]|\\.)*"$/.test(text) || /^'(?:[^'\\]|\\.)*'$/.test(text);
113
+ }
114
+
115
+ function staticLiteralKind(text) {
116
+ const value = normalizedText(text);
117
+ if (/^(?:true|false)$/.test(value)) return 'boolean';
118
+ if (value === 'null') return 'null';
119
+ if (value === 'undefined') return 'undefined';
120
+ if (/^[-]?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(value)) return 'number';
121
+ if (quotedLiteralText(value)) return 'string';
122
+ return undefined;
123
+ }
124
+
125
+ function staticPropReference(text) {
126
+ const value = normalizedText(text);
127
+ if (!/^(?:this|[A-Za-z_$][\w$]*)(?:\s*\.\s*[A-Za-z_$][\w$]*)*$/.test(value)) return undefined;
128
+ const normalized = value.replace(/\s+/g, '');
129
+ const path = normalized.split('.');
130
+ return { text: normalized, root: path[0], path };
131
+ }
132
+
133
+ function jsxPropValueDynamicBlockerReasonCode(text) {
134
+ const value = normalizedText(text);
135
+ if (/\[[\s\S]*\]/.test(value)) return 'jsx-render-prop-value-computed-reference-unsupported';
136
+ if (/\?\.\s*\(/.test(value) || /\b[A-Za-z_$][\w$]*(?:\s*(?:\.|\?\.)\s*[A-Za-z_$][\w$]*)*\s*\(/.test(value)) return 'jsx-render-prop-value-call-expression-unsupported';
137
+ if (/\?\./.test(value)) return 'jsx-render-prop-value-optional-reference-unsupported';
138
+ return 'jsx-render-prop-value-expression-unsupported';
139
+ }
140
+
141
+ function propKind(attribute) { return isJsxSpreadAttribute(attribute) ? 'spread' : 'named'; }
142
+ function normalizedText(text) { return String(text ?? '').trim().replace(/\s+/g, ' '); }
143
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
144
+
145
+ export { jsxPropValueEvidence };
@@ -0,0 +1,133 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { isJsxComponentTag, jsxContextProviderBoundary, jsxTagTokens } from '../../js-ts-safe-merge-jsx-attribute-parser.js';
3
+
4
+ function jsxProviderFlowRecords(ownerSourceText, ownerName) {
5
+ const text = String(ownerSourceText ?? '');
6
+ const tokens = jsxTagTokens(text);
7
+ return tokens.flatMap((token, index) => {
8
+ if (token.kind !== 'opening' || token.selfClosing) return [];
9
+ const boundary = jsxContextProviderBoundary(token.tagName);
10
+ if (!boundary) return [];
11
+ const close = matchingClose(tokens, index);
12
+ if (!close) return [];
13
+ const children = directChildrenExpression(text.slice(token.end, close.start));
14
+ if (!children) return [];
15
+ return [providerFlowRecord({ ownerName, token, boundary, children })];
16
+ });
17
+ }
18
+
19
+ function jsxProviderFlowAncestorMap(tags, sourceText, componentOwners) {
20
+ const tagsByStart = new Map(tags.map((tag) => [tag.start, tag]));
21
+ const ancestorsByStart = new Map();
22
+ const stack = [];
23
+ for (const token of jsxTagTokens(sourceText)) {
24
+ if (token.kind === 'closing') {
25
+ closeComponentFlowStack(stack, token.tagName);
26
+ continue;
27
+ }
28
+ const tag = tagsByStart.get(token.start);
29
+ if (tag) ancestorsByStart.set(tag.start, stack.flatMap((entry) => entry.flows.map((flow) => ({ ...flow, componentCallTagName: entry.tagName }))));
30
+ const flows = componentProviderFlowsForTag(token.tagName, componentOwners);
31
+ if (flows.length && !token.selfClosing) stack.push({ tagName: token.tagName, flows });
32
+ }
33
+ return ancestorsByStart;
34
+ }
35
+
36
+ function providerFlowRecord(input) {
37
+ const providerFlowHash = hashSemanticValue({
38
+ kind: 'frontier.lang.projectJsxProviderChildrenFlow',
39
+ componentOwnerName: input.ownerName,
40
+ contextName: input.boundary.contextName,
41
+ tagName: input.token.tagName,
42
+ childrenExpressionText: input.children.expressionText
43
+ });
44
+ return {
45
+ providerFlowStatus: 'static-provider-children-flow-evidence',
46
+ providerFlowScope: 'same-file-component-children-flow',
47
+ componentProviderFlowOwnerName: input.ownerName,
48
+ contextName: input.boundary.contextName,
49
+ tagName: input.token.tagName,
50
+ contextProviderLookupTagName: input.token.tagName,
51
+ childrenExpressionText: input.children.expressionText,
52
+ providerFlowHash
53
+ };
54
+ }
55
+
56
+ function componentProviderFlowsForTag(tagName, componentOwners) {
57
+ if (!isJsxComponentTag(tagName) || !/^[A-Z][A-Za-z0-9_$]*$/.test(String(tagName ?? ''))) return [];
58
+ const owners = componentOwners?.get(tagName) ?? [];
59
+ return owners.length === 1 ? providerFlowRecordsForOwner(tagName, owners[0]) : [];
60
+ }
61
+
62
+ function providerFlowRecordsForOwner(tagName, owner) {
63
+ const records = owner?.providerFlowRecords ?? [];
64
+ return records.map((record) => providerFlowRecordForOwner(tagName, owner, record));
65
+ }
66
+
67
+ function providerFlowRecordForOwner(tagName, owner, record) {
68
+ const scope = owner?.componentProviderLookupScope;
69
+ if (!String(scope ?? '').startsWith('project-import-')) return record;
70
+ const componentProviderFlowLookupHash = hashSemanticValue({
71
+ kind: 'frontier.lang.projectJsxProviderFlowComponentLookup',
72
+ tagName,
73
+ ownerName: owner.name,
74
+ scope,
75
+ targetSourcePath: owner.componentCallTargetSourcePath,
76
+ importEdgeId: owner.componentCallImportEdgeId,
77
+ reExportEdgeId: owner.componentCallReExportEdgeId,
78
+ reExportIdentityId: owner.componentCallReExportIdentityId,
79
+ providerFlowHash: record.providerFlowHash
80
+ });
81
+ return compactRecord({
82
+ ...record,
83
+ providerFlowScope: projectImportProviderFlowScope(scope),
84
+ componentProviderFlowLookupStatus: owner.componentCallLookupStatus,
85
+ componentProviderFlowLookupScope: scope,
86
+ componentProviderFlowLookupHash,
87
+ componentProviderFlowComponentTagName: tagName,
88
+ componentProviderFlowTargetOwnerName: owner.name,
89
+ componentProviderFlowTargetSourcePath: owner.componentCallTargetSourcePath,
90
+ componentProviderFlowImportEdgeId: owner.componentCallImportEdgeId,
91
+ componentProviderFlowImportKind: owner.componentCallImportKind,
92
+ componentProviderFlowImportedName: owner.componentCallImportedName,
93
+ componentProviderFlowLocalName: owner.componentCallLocalName,
94
+ componentProviderFlowTargetExportName: owner.componentCallTargetExportName,
95
+ componentProviderFlowReExportEdgeId: owner.componentCallReExportEdgeId,
96
+ componentProviderFlowReExportSourcePath: owner.componentCallReExportSourcePath,
97
+ componentProviderFlowReExportExportedName: owner.componentCallReExportExportedName,
98
+ componentProviderFlowReExportLocalName: owner.componentCallReExportLocalName,
99
+ componentProviderFlowReExportTargetSourcePath: owner.componentCallReExportTargetSourcePath,
100
+ componentProviderFlowReExportKind: owner.componentCallReExportKind,
101
+ componentProviderFlowReExportIdentityId: owner.componentCallReExportIdentityId
102
+ });
103
+ }
104
+
105
+ function directChildrenExpression(text) {
106
+ const match = /\{\s*((?:(?:this\s*\.\s*)?props\s*(?:\.|\?\.)\s*)?children)\s*\}/.exec(String(text ?? ''));
107
+ return match ? { expressionText: match[1].replace(/\s+/g, '') } : undefined;
108
+ }
109
+
110
+ function matchingClose(tokens, openIndex) {
111
+ const tagName = tokens[openIndex]?.tagName;
112
+ let depth = 0;
113
+ for (let index = openIndex + 1; index < tokens.length; index += 1) {
114
+ const token = tokens[index];
115
+ if (token.tagName !== tagName) continue;
116
+ if (token.kind === 'opening' && !token.selfClosing) depth += 1;
117
+ if (token.kind === 'closing' && depth-- === 0) return token;
118
+ }
119
+ return undefined;
120
+ }
121
+
122
+ function closeComponentFlowStack(stack, tagName) {
123
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
124
+ if (stack[index].tagName !== tagName) continue;
125
+ stack.splice(index);
126
+ return;
127
+ }
128
+ }
129
+
130
+ function projectImportProviderFlowScope(scope) { return scope === 'project-import-reexport-component' ? 'project-import-reexport-component-children-flow' : 'project-import-component-children-flow'; }
131
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
132
+
133
+ export { jsxProviderFlowAncestorMap, jsxProviderFlowRecords };