@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,217 @@
1
+ import { collectBindings } from './js-ts-semantic-scope-use-def-bindings.js';
2
+ import {
3
+ createBraceDepthIndex,
4
+ isPropertyAccess,
5
+ likelyTypeReference,
6
+ maskNonCode,
7
+ tokenize
8
+ } from './js-ts-semantic-scope-use-def-scan.js';
9
+ import {
10
+ LexicalUseDefReasonCodes,
11
+ compactRecord,
12
+ identifierRegExp,
13
+ lineNumber,
14
+ namespaceOverlap,
15
+ namespacesForDeclarationKind,
16
+ namespacesForImportRemoval,
17
+ normalizeNamespaces,
18
+ normalizeRanges,
19
+ rangeAllowed,
20
+ rangeKey,
21
+ spanRange,
22
+ uniqueStrings
23
+ } from './js-ts-semantic-scope-use-def-utils.js';
24
+
25
+ function analyzeTopLevelRenameUseDefEvidence(input) {
26
+ const namespaces = namespacesForDeclarationKind(input.declarationKind);
27
+ return lexicalEvidenceRecord({
28
+ operation: 'top-level-rename',
29
+ sourcePath: input.sourcePath,
30
+ bindingName: input.fromName,
31
+ targetName: input.toName,
32
+ namespaces,
33
+ checks: [
34
+ check(input.baseSourceText, input, 'base-from-binding', input.fromName, namespaces, [spanRange(input.fromEntry)]),
35
+ check(input.headSourceText, input, 'head-from-binding', input.fromName, namespaces, [spanRange(input.headEntry ?? input.fromEntry)]),
36
+ check(input.workerSourceText, input, 'worker-old-binding', input.fromName, namespaces),
37
+ check(input.baseSourceText, input, 'base-target-name', input.toName, namespaces),
38
+ check(input.headSourceText, input, 'head-target-name', input.toName, namespaces),
39
+ check(input.workerSourceText, input, 'worker-target-binding', input.toName, namespaces, [spanRange(input.toEntry)])
40
+ ]
41
+ });
42
+ }
43
+
44
+ function analyzeImportRemovalUseDefEvidence(input) {
45
+ const namespaces = namespacesForImportRemoval(input);
46
+ return lexicalEvidenceRecord({
47
+ operation: 'import-specifier-removal',
48
+ sourcePath: input.sourcePath,
49
+ bindingName: input.localName,
50
+ importedName: input.importedName,
51
+ removedSpecifier: input.removedSpecifier,
52
+ moduleSpecifier: input.moduleSpecifier,
53
+ namespaces,
54
+ checks: [check(input.sourceText, input, 'worker-import-removal', input.localName, namespaces)]
55
+ });
56
+ }
57
+
58
+ function check(sourceText, input, phase, bindingName, namespaces, allowedBindingRanges) {
59
+ return analyzeJsTsLexicalBindingReferences(sourceText, {
60
+ sourcePath: input.sourcePath,
61
+ phase,
62
+ bindingName,
63
+ namespaces,
64
+ allowedBindingRanges
65
+ });
66
+ }
67
+
68
+ function analyzeJsTsLexicalBindingReferences(sourceText, input = {}) {
69
+ const bindingName = String(input.bindingName ?? input.name ?? '');
70
+ const namespaces = normalizeNamespaces(input.namespaces ?? input.namespace);
71
+ if (!identifierRegExp.test(bindingName)) return blockedCheck(input, bindingName, namespaces, [LexicalUseDefReasonCodes.invalidIdentifier]);
72
+
73
+ const masked = maskNonCode(sourceText);
74
+ const tokens = tokenize(masked.code);
75
+ const depthAt = createBraceDepthIndex(masked.code);
76
+ const bindings = collectBindings(masked.code, tokens, depthAt);
77
+ const bindingKeys = new Set(bindings.map((binding) => rangeKey(binding)));
78
+ const allowedRanges = normalizeRanges(input.allowedBindingRanges);
79
+ const matchingBindings = bindings.filter((binding) => binding.name === bindingName && namespaceOverlap(binding.namespaces, namespaces));
80
+ const nonAllowedBindings = matchingBindings.filter((binding) => !rangeAllowed(binding, allowedRanges));
81
+ const namespaceConflicts = bindings.filter((binding) => binding.name === bindingName
82
+ && !namespaceOverlap(binding.namespaces, namespaces)
83
+ && !rangeAllowed(binding, allowedRanges));
84
+ const references = tokens
85
+ .map((token, index) => ({ ...token, index, depth: depthAt[token.start] ?? 0 }))
86
+ .filter((token) => token.value === bindingName)
87
+ .filter((token) => !bindingKeys.has(rangeKey(token)))
88
+ .filter((token) => !isPropertyAccess(masked.code, token.start))
89
+ .map((token) => referenceRecord(sourceText, masked, tokens, token, namespaces));
90
+
91
+ const reasonCodes = uniqueStrings([
92
+ ...(masked.unsupportedTemplateLiteral ? [LexicalUseDefReasonCodes.templateLiteralUnsupported] : []),
93
+ ...(references.length ? [LexicalUseDefReasonCodes.liveReference] : []),
94
+ ...(references.some((reference) => reference.closure) ? [LexicalUseDefReasonCodes.closureReference] : []),
95
+ ...(nonAllowedBindings.some((binding) => binding.depth > 0 || binding.kind === 'param') ? [LexicalUseDefReasonCodes.shadowedBinding] : []),
96
+ ...(nonAllowedBindings.some((binding) => binding.depth === 0 && binding.kind !== 'param') ? [LexicalUseDefReasonCodes.bindingConflict] : []),
97
+ ...(namespaceConflicts.length ? [LexicalUseDefReasonCodes.typeValueNamespaceConflict] : [])
98
+ ]);
99
+ const status = reasonCodes.length ? 'blocked' : 'no-live-references';
100
+ return compactRecord({
101
+ kind: 'frontier.lang.jsTsLexicalUseDefCheck',
102
+ version: 1,
103
+ status,
104
+ phase: input.phase,
105
+ sourcePath: input.sourcePath,
106
+ bindingName,
107
+ namespaces,
108
+ reasonCodes: status === 'blocked' ? reasonCodes : [LexicalUseDefReasonCodes.noLiveReferences],
109
+ summary: checkSummary(references, nonAllowedBindings, namespaceConflicts),
110
+ references: references.slice(0, 12),
111
+ shadowedBindings: filteredBindings(nonAllowedBindings, true).map(bindingRecord),
112
+ bindingConflicts: filteredBindings(nonAllowedBindings, false).map(bindingRecord),
113
+ namespaceConflicts: namespaceConflicts.slice(0, 12).map(bindingRecord)
114
+ });
115
+ }
116
+
117
+ function lexicalEvidenceRecord(input) {
118
+ const blockedReasonCodes = uniqueStrings(input.checks
119
+ .filter((item) => item.status === 'blocked')
120
+ .flatMap((item) => item.reasonCodes ?? [])
121
+ .filter((code) => code !== LexicalUseDefReasonCodes.noLiveReferences));
122
+ const status = blockedReasonCodes.length ? 'blocked' : 'no-live-references';
123
+ return compactRecord({
124
+ kind: 'frontier.lang.jsTsLexicalUseDefEvidence',
125
+ version: 1,
126
+ operation: input.operation,
127
+ status,
128
+ sourcePath: input.sourcePath,
129
+ bindingName: input.bindingName,
130
+ targetName: input.targetName,
131
+ importedName: input.importedName,
132
+ removedSpecifier: input.removedSpecifier,
133
+ moduleSpecifier: input.moduleSpecifier,
134
+ namespaces: input.namespaces,
135
+ reasonCodes: status === 'blocked' ? blockedReasonCodes : [LexicalUseDefReasonCodes.noLiveReferences],
136
+ summary: evidenceSummary(input.checks),
137
+ checks: input.checks
138
+ });
139
+ }
140
+
141
+ function checkSummary(references, bindings, namespaceConflicts) {
142
+ return {
143
+ references: references.length,
144
+ closureReferences: references.filter((reference) => reference.closure).length,
145
+ templateLiteralReferences: references.filter((reference) => reference.templateLiteralInterpolation).length,
146
+ shadowedBindings: filteredBindings(bindings, true).length,
147
+ bindingConflicts: filteredBindings(bindings, false).length,
148
+ namespaceConflicts: namespaceConflicts.length
149
+ };
150
+ }
151
+
152
+ function evidenceSummary(checks) {
153
+ return {
154
+ checks: checks.length,
155
+ references: sum(checks, 'references'),
156
+ closureReferences: sum(checks, 'closureReferences'),
157
+ templateLiteralReferences: sum(checks, 'templateLiteralReferences'),
158
+ shadowedBindings: sum(checks, 'shadowedBindings'),
159
+ bindingConflicts: sum(checks, 'bindingConflicts'),
160
+ namespaceConflicts: sum(checks, 'namespaceConflicts')
161
+ };
162
+ }
163
+
164
+ function referenceRecord(sourceText, masked, tokens, token, namespaces) {
165
+ const templateExpression = templateExpressionRangeForOffset(masked.templateExpressionRanges, token.start);
166
+ return compactRecord({
167
+ name: token.value,
168
+ start: token.start,
169
+ end: token.end,
170
+ line: lineNumber(sourceText, token.start),
171
+ namespace: likelyTypeReference(masked.code, tokens, token.index) ? 'type' : 'value',
172
+ namespaces,
173
+ referenceKind: templateExpression ? 'template-literal-interpolation' : undefined,
174
+ templateLiteralInterpolation: templateExpression ? true : undefined,
175
+ templateExpressionStart: templateExpression?.start,
176
+ templateExpressionEnd: templateExpression?.end,
177
+ closure: token.depth > 0,
178
+ depth: token.depth
179
+ });
180
+ }
181
+
182
+ function bindingRecord(binding) {
183
+ return { kind: binding.kind, name: binding.name, start: binding.start, end: binding.end, depth: binding.depth, namespaces: binding.namespaces };
184
+ }
185
+
186
+ function filteredBindings(bindings, shadowed) {
187
+ return bindings.filter((binding) => shadowed ? binding.depth > 0 || binding.kind === 'param' : binding.depth === 0 && binding.kind !== 'param').slice(0, 12);
188
+ }
189
+
190
+ function sum(checks, field) {
191
+ return checks.reduce((total, item) => total + (item.summary?.[field] ?? 0), 0);
192
+ }
193
+
194
+ function blockedCheck(input, bindingName, namespaces, reasonCodes) {
195
+ return {
196
+ kind: 'frontier.lang.jsTsLexicalUseDefCheck',
197
+ version: 1,
198
+ status: 'blocked',
199
+ phase: input.phase,
200
+ sourcePath: input.sourcePath,
201
+ bindingName,
202
+ namespaces,
203
+ reasonCodes,
204
+ summary: { references: 0, closureReferences: 0, templateLiteralReferences: 0, shadowedBindings: 0, bindingConflicts: 0, namespaceConflicts: 0 }
205
+ };
206
+ }
207
+
208
+ function templateExpressionRangeForOffset(ranges = [], offset) {
209
+ return ranges.find((range) => offset >= range.start && offset < range.end);
210
+ }
211
+
212
+ export {
213
+ LexicalUseDefReasonCodes,
214
+ analyzeImportRemovalUseDefEvidence,
215
+ analyzeJsTsLexicalBindingReferences,
216
+ analyzeTopLevelRenameUseDefEvidence
217
+ };
@@ -1,8 +1,13 @@
1
1
  function lightweightEffectKinds(line) {
2
2
  const kinds = [];
3
- if (/\bawait\b|import\s*\(/.test(line)) kinds.push('async');
3
+ if (hasTaggedTemplate(line)) kinds.push('tagged-template');
4
+ else if (hasTemplateInterpolation(line)) kinds.push('template-interpolation');
5
+ else if (hasTemplateLiteral(line)) kinds.push('template-literal');
6
+ if (/\b(await|async)\b|import\s*\(/.test(line)) kinds.push('async');
7
+ if (/\byield\b|\bfunction\s*\*/.test(line)) kinds.push('generator');
4
8
  if (hasGlobalNetworkCall(line)) kinds.push('network');
5
9
  if (/\b(localStorage|sessionStorage|indexedDB|caches|cookie)\b/.test(line)) kinds.push('storage');
10
+ if (hasImportMetaHostContext(line)) kinds.push('host-context');
6
11
  if (hasGlobalSchedulerCall(line)) kinds.push('scheduler');
7
12
  if (/\b(console|process|Deno|Bun)\s*\./.test(line)) kinds.push('host');
8
13
  if (hasBrowserEffect(line)) kinds.push('browser');
@@ -32,20 +37,39 @@ function hasGlobalSchedulerCall(line) {
32
37
  }
33
38
 
34
39
  function hasBrowserEffect(line) {
35
- return /\b(document|window|navigator|location|history)\s*\./.test(line)
40
+ return /\b(document|window|navigator|location|history)\s*(?:\.|\?\.|\[)/.test(line)
36
41
  || hasGlobalConstructorCall(line, ['Worker', 'SharedWorker']);
37
42
  }
38
43
 
44
+ function hasImportMetaHostContext(line) { return /\bimport\s*\.\s*meta\b/.test(line); }
45
+
46
+ function hasTaggedTemplate(line) {
47
+ const tick = String(line ?? '').indexOf('`');
48
+ if (tick < 0) return false;
49
+ const match = /([A-Za-z_$][\w$]*(?:(?:\s*\.\s*[A-Za-z_$][\w$]*)|\s*\[[^\]]+\])*)$/.exec(line.slice(0, tick).trimEnd());
50
+ return Boolean(match && !templatePrefixKeywords.has(match[1].trim()));
51
+ }
52
+
53
+ function hasTemplateInterpolation(line) {
54
+ return /`[^`]*\$\{/.test(line);
55
+ }
56
+
57
+ function hasTemplateLiteral(line) {
58
+ return /`/.test(line);
59
+ }
60
+
39
61
  function hasBareCall(line, names) {
40
- return names.some((name) => new RegExp(`(?:^|[^\\w$.])${name}\\s*\\(`).test(line));
62
+ return names.some((name) => new RegExp(`(?:^|[^\\w$.])${name}\\s*(?:\\?\\.)?\\s*\\(`).test(line));
41
63
  }
42
64
 
43
65
  function hasGlobalPropertyCall(line, names) {
44
- return names.some((name) => new RegExp(`\\b(?:window|globalThis|self)\\s*\\.\\s*${name}\\s*\\(`).test(line));
66
+ return names.some((name) => new RegExp(`\\b(?:window|globalThis|self)\\s*(?:(?:\\.|\\?\\.)\\s*${name}|(?:\\?\\.)?\\s*\\[\\s*['"\`]${name}['"\`]\\s*\\])\\s*(?:\\?\\.)?\\s*\\(`).test(line));
45
67
  }
46
68
 
47
69
  function hasGlobalConstructorCall(line, names) {
48
70
  return names.some((name) => new RegExp(`(?:^|[^\\w$.])new\\s+(?:(?:window|globalThis|self)\\s*\\.\\s*)?${name}\\s*\\(`).test(line));
49
71
  }
50
72
 
73
+ const templatePrefixKeywords = new Set(['return', 'yield', 'await', 'throw', 'case', 'delete', 'typeof', 'void', 'new']);
74
+
51
75
  export { lightweightEffectKinds };
@@ -8,6 +8,7 @@ import {
8
8
  maskDependencyLine
9
9
  } from './lightweight-dependency-language.js';
10
10
  import { lightweightEffectKinds } from './lightweight-dependency-effects.js';
11
+ import { lightweightTopLevelRuntimeFacts } from './lightweight-dependency-top-level.js';
11
12
  import { sourceLines } from './native-region-scanner-core.js';
12
13
 
13
14
  export function lightweightDependencyRelations(input, declarations, documentId) {
@@ -18,6 +19,7 @@ export function lightweightDependencyRelations(input, declarations, documentId)
18
19
  for (const scan of dependencyScanRanges(input, declarations, lines)) {
19
20
  scanDeclarationDependencies(input, documentId, scan, identifiers, lines, records);
20
21
  }
22
+ records.facts.push(...lightweightTopLevelRuntimeFacts(input, documentId, lines));
21
23
  return {
22
24
  relations: records.relations,
23
25
  occurrences: records.occurrences,
@@ -71,8 +73,9 @@ function scanDeclarationDependencies(input, documentId, scan, identifiers, lines
71
73
  const state = { inBlockComment: false };
72
74
  const factState = { braceDepth: 0, pendingSwitch: false, switchDepth: 0 };
73
75
  for (let lineNumber = scan.startLine; lineNumber <= scan.endLine; lineNumber += 1) {
74
- const scanLine = maskDependencyLine(input, lines[lineNumber - 1]?.line ?? '', state);
75
- addLightweightSemanticFacts(input, documentId, scan.declaration, scanLine, lineNumber, records, factState);
76
+ const rawLine = lines[lineNumber - 1]?.line ?? '';
77
+ const scanLine = maskDependencyLine(input, rawLine, state);
78
+ addLightweightSemanticFacts(input, documentId, scan.declaration, scanLine, lineNumber, records, factState, rawLine);
76
79
  for (const match of scanLine.matchAll(/[A-Za-z_$][\w$]*/g)) {
77
80
  const name = match[0];
78
81
  if (!isDependencyIdentifier(name) || !identifiers.has(name)) continue;
@@ -90,17 +93,17 @@ function scanDeclarationDependencies(input, documentId, scan, identifiers, lines
90
93
  }
91
94
  }
92
95
 
93
- function addLightweightSemanticFacts(input, documentId, declaration, line, lineNumber, records, factState) {
96
+ function addLightweightSemanticFacts(input, documentId, declaration, line, lineNumber, records, factState, rawLine) {
94
97
  if (!shouldScanRuntimeFacts(input, declaration)) return;
95
98
  const text = String(line ?? '').trim();
96
99
  if (!text) return;
97
100
  for (const item of lightweightControlFlowKinds(text, factState)) {
98
101
  addFactRecord(input, documentId, declaration, 'controlFlow', item, lineNumber, records);
99
102
  }
100
- for (const item of lightweightEffectKinds(text)) {
103
+ for (const item of lightweightEffectKinds(rawLine ?? text)) {
101
104
  addFactRecord(input, documentId, declaration, 'effect', item, lineNumber, records);
102
105
  }
103
- for (const item of lightweightMutationKinds(text)) {
106
+ for (const item of lightweightMutationKinds(text, rawLine ?? text)) {
104
107
  addFactRecord(input, documentId, declaration, 'mutation', item, lineNumber, records);
105
108
  }
106
109
  updateLightweightFactState(text, factState);
@@ -149,17 +152,20 @@ function lightweightControlFlowKinds(line, state = {}) {
149
152
  if (hasBranchSyntax(line, state)) kinds.push('branch');
150
153
  if (/\b(for|while|do)\b/.test(line)) kinds.push('loop');
151
154
  if (/\b(return|yield)\b/.test(line)) kinds.push('exit');
155
+ if (/\b(break|continue)\b/.test(line)) kinds.push('transfer');
152
156
  if (/\b(throw|catch|finally|try)\b/.test(line)) kinds.push('exception');
153
157
  if (/\b(await|async)\b/.test(line)) kinds.push('async');
154
158
  return kinds;
155
159
  }
156
160
 
157
- function lightweightMutationKinds(line) {
161
+ function lightweightMutationKinds(line, rawLine = line) {
158
162
  const kinds = [];
163
+ const sourceLine = String(rawLine ?? line);
159
164
  if (/\bdelete\s+[A-Za-z_$][\w$.[\]]*/.test(line)) kinds.push('delete');
160
165
  if (hasRuntimeAssignment(line)) kinds.push('assignment');
161
166
  if (/\+\+|--|(?:\+=|-=|\*=|\/=|%=|\|\|=|&&=|\?\?=)/.test(line)) kinds.push('update');
162
- if (/\.(?:push|pop|shift|unshift|splice|sort|reverse|set|add|delete|clear)\s*\(/.test(line)) kinds.push('mutating-call');
167
+ if (/(?:\.|\?\.)\s*(?:push|pop|shift|unshift|splice|sort|reverse|set|add|delete|clear)\s*(?:\?\.)?\s*\(/.test(line)
168
+ || /(?:\?\.|\b[A-Za-z_$][\w$]*(?:\s*(?:\.|\?\.)\s*[A-Za-z_$][\w$]*|\s*\[[^\]]+\])*)\s*\[\s*(['"`])(?:push|pop|shift|unshift|splice|sort|reverse|set|add|delete|clear)\1\s*\]\s*(?:\?\.)?\s*\(/.test(sourceLine)) kinds.push('mutating-call');
163
169
  return kinds;
164
170
  }
165
171
 
@@ -0,0 +1,63 @@
1
+ import { idFragment } from './native-import-utils.js';
2
+ import { lightweightEffectKinds } from './lightweight-dependency-effects.js';
3
+ import { maskDependencyLine } from './lightweight-dependency-language.js';
4
+
5
+ function lightweightTopLevelRuntimeFacts(input, documentId, lines) {
6
+ if (!isJavaScriptLike(input)) return [];
7
+ const records = [];
8
+ const state = { inBlockComment: false };
9
+ let braceDepth = 0;
10
+ for (const { line, number } of lines ?? []) {
11
+ const scanLine = maskDependencyLine(input, line, state);
12
+ const text = scanLine.trim();
13
+ if (braceDepth === 0 && hasTopLevelAwait(text)) {
14
+ for (const kind of ['async', ...lightweightEffectKinds(line).filter((item) => item !== 'async')]) {
15
+ records.push(topLevelFact(input, documentId, 'effect', kind, number));
16
+ }
17
+ records.push(topLevelFact(input, documentId, 'controlFlow', 'async', number));
18
+ }
19
+ braceDepth = Math.max(0, braceDepth + braceDelta(scanLine));
20
+ }
21
+ return records;
22
+ }
23
+
24
+ function topLevelFact(input, documentId, predicate, kind, lineNumber) {
25
+ const subjectId = `symbol:${input.language ?? 'javascript'}:module:${idFragment(documentId)}`;
26
+ return {
27
+ id: `fact_${idFragment(subjectId)}_${predicate}_${idFragment(kind)}_${lineNumber}`,
28
+ predicate,
29
+ subjectId,
30
+ value: {
31
+ kind,
32
+ line: lineNumber,
33
+ sourcePath: input.sourcePath,
34
+ documentId,
35
+ confidence: 'lexical-source-scan',
36
+ runtimeScope: 'module',
37
+ subjectName: '<module>',
38
+ topLevelAwait: true
39
+ }
40
+ };
41
+ }
42
+
43
+ function hasTopLevelAwait(text) {
44
+ const index = String(text ?? '').search(/\bawait\b/);
45
+ if (index < 0) return false;
46
+ const before = text.slice(0, index);
47
+ return !/\bfunction\b|=>/.test(before) && braceDelta(before) === 0;
48
+ }
49
+
50
+ function braceDelta(text) {
51
+ let delta = 0;
52
+ for (const char of String(text ?? '')) {
53
+ if (char === '{') delta += 1;
54
+ else if (char === '}') delta -= 1;
55
+ }
56
+ return delta;
57
+ }
58
+
59
+ function isJavaScriptLike(input) {
60
+ return ['javascript', 'typescript'].includes(String(input?.language ?? '').toLowerCase());
61
+ }
62
+
63
+ export { lightweightTopLevelRuntimeFacts };
@@ -33,6 +33,30 @@ export const NativeImportLanguageProfiles = Object.freeze([
33
33
  '.tsx sources are classified as typescript for declaration scanning; JSX element trees remain opaque without host parser evidence'
34
34
  ]
35
35
  }),
36
+ nativeImportLanguageProfile('html', {
37
+ aliases: ['htm'],
38
+ extensions: ['.html', '.htm'],
39
+ supportsLightweightScan: false,
40
+ defaultReadiness: 'blocked',
41
+ parserAdapters: ['parse5', 'htmlparser2', 'rehype', 'tree-sitter-html'],
42
+ lossKinds: ['declarationOnlyCoverage', 'opaqueNative', 'sourceMapApproximation', 'sourcePreservation', 'browserRuntime', 'hydrationRuntime'],
43
+ notes: [
44
+ 'HTML semantic merge evidence is tree/attribute/source-span oriented; browser DOM normalization, custom elements, slots, templates, and hydration remain host-owned evidence',
45
+ 'layout/render equivalence requires browser evidence and should remain fail-closed when only parser evidence is present'
46
+ ]
47
+ }),
48
+ nativeImportLanguageProfile('css', {
49
+ extensions: ['.css'],
50
+ supportsLightweightScan: false,
51
+ defaultReadiness: 'blocked',
52
+ parserAdapters: ['postcss', 'csstree', 'css-tree', 'lightningcss', 'tree-sitter-css'],
53
+ lossKinds: ['declarationOnlyCoverage', 'opaqueNative', 'sourceMapApproximation', 'sourcePreservation', 'cascadeRuntime', 'browserRuntime', 'cssModuleTransform', 'cssModuleUseSiteGraph'],
54
+ notes: [
55
+ 'CSS semantic merge evidence is selector/declaration/cascade oriented; computed style, inheritance, layout, and browser-specific normalization remain host-owned evidence',
56
+ 'CSS Modules require exported local class, ICSS, composes, generated class-name, and JS/TS/JSX use-site graph evidence before equivalence can be claimed',
57
+ 'cascade/render equivalence requires browser evidence and should remain fail-closed when only parser evidence is present'
58
+ ]
59
+ }),
36
60
  nativeImportLanguageProfile('python', {
37
61
  aliases: ['py'],
38
62
  extensions: ['.py', '.pyi'],
@@ -100,7 +124,7 @@ function nativeImportLanguageProfile(language, input = {}) {
100
124
 
101
125
 
102
126
  export function normalizeProjectionMatrixTargets(targets) {
103
- const canonicalTargets = { ts: 'typescript', js: 'javascript', rs: 'rust', py: 'python', h: 'c' };
127
+ const canonicalTargets = { ts: 'typescript', js: 'javascript', rs: 'rust', py: 'python', h: 'c', htm: 'html' };
104
128
  return uniqueStrings((Array.isArray(targets) ? targets : [targets])
105
129
  .map((target) => {
106
130
  if (target === undefined || target === null) return undefined;
@@ -115,6 +139,8 @@ export function nativeLanguageCompileTarget(language, aliases = []) {
115
139
  const ids = [language, ...aliases].map(normalizeNativeLanguageId);
116
140
  if (ids.includes('typescript')) return 'typescript';
117
141
  if (ids.includes('javascript')) return 'javascript';
142
+ if (ids.includes('html')) return 'html';
143
+ if (ids.includes('css')) return 'css';
118
144
  if (ids.includes('rust')) return 'rust';
119
145
  if (ids.includes('python')) return 'python';
120
146
  if (ids.includes('c')) return 'c';
@@ -12,19 +12,19 @@ function createJavaScriptSyntaxImporterAdapter(options, deps) {
12
12
  language: options.language,
13
13
  parser: options.parser,
14
14
  version: options.version,
15
- capabilities: uniqueStrings(['nativeAst', 'semanticIndex', 'sourceMaps', 'diagnostics', ...(options.capabilities ?? [])]),
15
+ capabilities: uniqueStrings(['nativeAst', 'semanticIndex', 'sourceMaps', 'diagnostics', 'tokens', 'trivia', 'parserTriviaExactness', ...(options.capabilities ?? [])]),
16
16
  coverage: nativeImporterAdapterCoverage({
17
17
  exactness: 'exact-parser-ast',
18
18
  exactAst: true,
19
- tokens: false,
20
- trivia: false,
19
+ tokens: true,
20
+ trivia: true,
21
21
  diagnostics: true,
22
22
  sourceRanges: true,
23
23
  generatedRanges: false,
24
24
  semanticCoverage: declarationSemanticCoverage(),
25
25
  notes: [
26
26
  'Normalizes a caller-owned ESTree/Babel-compatible AST into native AST nodes and declaration-level semantic index records.',
27
- 'The wrapper ignores parser token/trivia/comment arrays unless a host adapter explicitly maps them into preservation evidence.'
27
+ 'When parser token/comment arrays include exact ranges for the current source, they become exact source-preservation evidence.'
28
28
  ]
29
29
  }, options.coverage),
30
30
  supportedExtensions: options.supportedExtensions,
@@ -43,7 +43,11 @@ function createJavaScriptSyntaxImporterAdapter(options, deps) {
43
43
  parser: options.parser,
44
44
  astFormat: options.astFormat,
45
45
  maxNodes: options.maxNodes,
46
- diagnostics: parseDiagnostics
46
+ diagnostics: parseDiagnostics,
47
+ includeTokens: options.includeTokens,
48
+ includeTrivia: options.includeTrivia,
49
+ maxTokens: options.maxTokens,
50
+ maxTrivia: options.maxTrivia
47
51
  });
48
52
  }
49
53
  };
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  uniqueStrings
3
3
  } from './native-import-utils.js';
4
+ import {
5
+ HtmlCssNativeParserAstFormatProfileInputs
6
+ } from './native-parser-html-css-format-profiles.js';
4
7
 
5
8
  export const NativeParserFeatureCategories = Object.freeze([
6
9
  'syntax',
@@ -55,6 +58,7 @@ export const NativeParserAstFormatProfiles = Object.freeze([
55
58
  supportsErrorRecovery: true,
56
59
  notes: ['TypeScript SourceFile trees can be parsed without a full Program; richer type/checker evidence remains host-owned.']
57
60
  }),
61
+ ...HtmlCssNativeParserAstFormatProfileInputs.map(([id, input]) => nativeParserAstFormatProfile(id, input)),
58
62
  nativeParserAstFormatProfile('python-ast', {
59
63
  kind: 'abstract-ast',
60
64
  languages: ['python'],
@@ -241,6 +245,14 @@ export function normalizeParserAstFormatId(format) {
241
245
  export function parserAstFormatIdForParser(parser) {
242
246
  const text = normalizeParserAstFormatId(parser);
243
247
  if (text.includes('typescript')) return 'typescript-compiler-api';
248
+ if (text.includes('parse5')) return 'parse5';
249
+ if (text.includes('htmlparser') || text.includes('domhandler')) return 'htmlparser2';
250
+ if (text.includes('rehype') || text === 'hast' || text.includes('unified-rehype')) return 'rehype';
251
+ if (text.includes('tree-sitter-html') || text.includes('treesitter-html')) return 'tree-sitter-html';
252
+ if (text.includes('postcss')) return 'postcss';
253
+ if (text.includes('csstree') || text.includes('css-tree')) return 'csstree';
254
+ if (text.includes('lightningcss') || text.includes('lightning-css')) return 'lightningcss';
255
+ if (text.includes('tree-sitter-css') || text.includes('treesitter-css')) return 'tree-sitter-css';
244
256
  if (text.includes('python') && text.includes('ast')) return 'python-ast';
245
257
  if (text === 'syn' || text.includes('rust-syn')) return 'rust-syn';
246
258
  if (text.includes('rust-analyzer') || text.includes('rowan')) return 'rust-analyzer-rowan';
@@ -0,0 +1,85 @@
1
+ export const HtmlCssNativeParserAstFormatProfileInputs = Object.freeze([
2
+ ['parse5', {
3
+ aliases: ['parse5-html', 'html-parse5'],
4
+ kind: 'concrete-syntax-tree',
5
+ languages: ['html'],
6
+ parserAdapters: ['parse5'],
7
+ exactness: 'parser-tree',
8
+ sourceRangeModel: 'source-code-location-info',
9
+ preservesTrivia: true,
10
+ supportsErrorRecovery: true,
11
+ notes: ['parse5 exposes spec-oriented HTML tree construction and source locations; rendered DOM, custom elements, templates, slots, scripts, styles, and hydration remain host-owned evidence.']
12
+ }],
13
+ ['htmlparser2', {
14
+ aliases: ['htmlparser', 'domhandler'],
15
+ kind: 'concrete-syntax-tree',
16
+ languages: ['html'],
17
+ parserAdapters: ['htmlparser2'],
18
+ exactness: 'parser-tree',
19
+ sourceRangeModel: 'start-end-index',
20
+ supportsErrorRecovery: true,
21
+ notes: ['htmlparser2/DOMHandler trees provide fast HTML element and text structure; spec tree-construction edge cases, trivia, and browser DOM normalization remain host-owned evidence.']
22
+ }],
23
+ ['rehype', {
24
+ aliases: ['hast', 'unified-rehype'],
25
+ kind: 'concrete-syntax-tree',
26
+ languages: ['html'],
27
+ parserAdapters: ['rehype', 'hast'],
28
+ exactness: 'parser-tree',
29
+ sourceRangeModel: 'unist-position',
30
+ preservesTrivia: true,
31
+ supportsErrorRecovery: true,
32
+ notes: ['rehype/HAST is useful for HTML/MDX-like tree transforms; browser semantics, scripts/styles, and hydration boundaries remain host-owned evidence.']
33
+ }],
34
+ ['tree-sitter-html', {
35
+ aliases: ['treesitter-html'],
36
+ kind: 'concrete-syntax-tree',
37
+ languages: ['html'],
38
+ parserAdapters: ['tree-sitter-html'],
39
+ exactness: 'parser-tree',
40
+ sourceRangeModel: 'row-column',
41
+ supportsIncremental: true,
42
+ supportsErrorRecovery: true,
43
+ notes: ['Tree-sitter HTML exposes incremental concrete syntax for HTML files; browser DOM construction, templates, slots, scripts/styles, and hydration remain host-owned evidence.']
44
+ }],
45
+ ['postcss', {
46
+ kind: 'concrete-syntax-tree',
47
+ languages: ['css'],
48
+ parserAdapters: ['postcss'],
49
+ exactness: 'parser-tree',
50
+ sourceRangeModel: 'line-column',
51
+ preservesTrivia: true,
52
+ supportsErrorRecovery: true,
53
+ notes: ['PostCSS exposes CSS rule/declaration structure and source locations; cascade resolution, browser normalization, layout, and computed style remain host-owned evidence.']
54
+ }],
55
+ ['csstree', {
56
+ aliases: ['css-tree', 'css-tree-ast'],
57
+ kind: 'concrete-syntax-tree',
58
+ languages: ['css'],
59
+ parserAdapters: ['csstree', 'css-tree'],
60
+ exactness: 'parser-tree',
61
+ sourceRangeModel: 'offset-line-column',
62
+ supportsErrorRecovery: true,
63
+ notes: ['CSSTree provides detailed CSS grammar ASTs; cascade layers, browser normalization, and computed/rendered effects remain host-owned evidence.']
64
+ }],
65
+ ['lightningcss', {
66
+ aliases: ['lightning-css'],
67
+ kind: 'compiler-ast',
68
+ languages: ['css'],
69
+ parserAdapters: ['lightningcss', 'lightning-css'],
70
+ exactness: 'loss-aware-native-ast',
71
+ sourceRangeModel: 'source-location',
72
+ notes: ['Lightning CSS can parse and transform CSS with browser-target lowering; transformation settings, minification, and rendered cascade equivalence remain host-owned evidence.']
73
+ }],
74
+ ['tree-sitter-css', {
75
+ aliases: ['treesitter-css'],
76
+ kind: 'concrete-syntax-tree',
77
+ languages: ['css'],
78
+ parserAdapters: ['tree-sitter-css'],
79
+ exactness: 'parser-tree',
80
+ sourceRangeModel: 'row-column',
81
+ supportsIncremental: true,
82
+ supportsErrorRecovery: true,
83
+ notes: ['Tree-sitter CSS exposes incremental concrete syntax for CSS files; cascade resolution, browser normalization, and computed/rendered effects remain host-owned evidence.']
84
+ }]
85
+ ]);
@@ -1,4 +1,4 @@
1
- import { idFragment } from './native-import-utils.js';
1
+ import { caseSensitiveIdFragment, idFragment } from './native-import-utils.js';
2
2
 
3
3
  function nativeDeclaration(input, lineNumber, languageKind, symbolKind, name, fields = {}, hasBody = false, options = {}) {
4
4
  const nodeId = `native_${idFragment(languageKind)}_${lineNumber}_${idFragment(name)}`;
@@ -43,7 +43,7 @@ function nativeImportDeclaration(input, lineNumber, importPath, languageKind, sy
43
43
  languageKind: `${input.language}.${languageKind}`,
44
44
  name,
45
45
  symbolKind,
46
- symbolId: options.symbolId ?? `symbol:${input.language}:import:${idFragment(name)}`,
46
+ symbolId: options.symbolId ?? `symbol:${input.language}:import:${idFragment(symbolKind === 'module' ? `${languageKind}:${lineNumber}:${name}` : name)}`,
47
47
  role: options.role ?? 'import',
48
48
  importPath: String(importPath),
49
49
  span: options.span ?? spanForLine(input, lineNumber),
@@ -59,13 +59,14 @@ function nativeImportBindingDeclaration(input, lineNumber, importPath, binding,
59
59
  const importKind = binding.importKind ?? 'named';
60
60
  return nativeImportDeclaration(input, lineNumber, importPath, options.languageKind ?? 'ImportBinding', binding.symbolKind ?? 'import', {
61
61
  name: localName,
62
- symbolId: options.symbolId ?? `symbol:${input.language}:import:${idFragment(`${importPath}:${localName}`)}`,
62
+ symbolId: options.symbolId ?? `symbol:${input.language}:import:${caseSensitiveIdFragment(`${importPath}:${localName}:${importedName}`)}`,
63
63
  span: options.span,
64
64
  fields: {
65
65
  localName,
66
66
  importedName,
67
67
  importKind,
68
68
  importPath: String(importPath),
69
+ ...(binding.namespace ? { namespace: binding.namespace } : {}),
69
70
  ...(binding.exportedName ? { exportedName: binding.exportedName } : {}),
70
71
  ...(binding.typeOnly ? { typeOnly: true } : {})
71
72
  },
@@ -76,6 +77,7 @@ function nativeImportBindingDeclaration(input, lineNumber, importPath, binding,
76
77
  localName,
77
78
  importedName,
78
79
  importKind,
80
+ ...(binding.namespace ? { namespace: binding.namespace } : {}),
79
81
  ...(binding.exportedName ? { exportedName: binding.exportedName } : {}),
80
82
  ...(binding.typeOnly ? { typeOnly: true } : {}),
81
83
  ...options.metadata