code-auditor-mcp 5.0.2 → 5.2.0

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 (336) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +184 -3
  3. package/README.md +24 -2
  4. package/configs/hhra-compat.json +12 -118
  5. package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
  6. package/dist/analyzers/cross-language/DependencyGraphBuilder.js +11 -1
  7. package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
  8. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
  9. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +57 -52
  10. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
  11. package/dist/analyzers/provenance.d.ts +9 -4
  12. package/dist/analyzers/provenance.d.ts.map +1 -1
  13. package/dist/analyzers/provenance.js +8 -25
  14. package/dist/analyzers/provenance.js.map +1 -1
  15. package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
  16. package/dist/analyzers/reactAnalyzer.js +0 -5
  17. package/dist/analyzers/reactAnalyzer.js.map +1 -1
  18. package/dist/analyzers/ruleRegistry.js +4 -4
  19. package/dist/analyzers/ruleRegistry.js.map +1 -1
  20. package/dist/analyzers/ruleTiming.d.ts +1 -1
  21. package/dist/analyzers/ruleTiming.js +2 -2
  22. package/dist/analyzers/ruleTiming.js.map +1 -1
  23. package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
  24. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +22 -26
  25. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
  26. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts +32 -15
  27. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
  28. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +189 -115
  29. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
  30. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +0 -2
  31. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
  32. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +0 -5
  33. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
  34. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +2 -10
  35. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
  36. package/dist/analyzers/universal/UniversalStylesAnalyzer.js +7 -49
  37. package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
  38. package/dist/analyzers/universal/schema/config.d.ts.map +1 -1
  39. package/dist/analyzers/universal/schema/config.js +0 -2
  40. package/dist/analyzers/universal/schema/config.js.map +1 -1
  41. package/dist/analyzers/universal/schema/types.d.ts +0 -2
  42. package/dist/analyzers/universal/schema/types.d.ts.map +1 -1
  43. package/dist/analyzers/vendorSurfaces.d.ts +126 -0
  44. package/dist/analyzers/vendorSurfaces.d.ts.map +1 -0
  45. package/dist/analyzers/vendorSurfaces.js +580 -0
  46. package/dist/analyzers/vendorSurfaces.js.map +1 -0
  47. package/dist/auditRunner.d.ts.map +1 -1
  48. package/dist/auditRunner.js +136 -142
  49. package/dist/auditRunner.js.map +1 -1
  50. package/dist/churn/churnExtractor.d.ts +0 -1
  51. package/dist/churn/churnExtractor.d.ts.map +1 -1
  52. package/dist/churn/churnExtractor.js +2 -4
  53. package/dist/churn/churnExtractor.js.map +1 -1
  54. package/dist/cli.d.ts +1 -1
  55. package/dist/cli.d.ts.map +1 -1
  56. package/dist/cli.js +195 -26
  57. package/dist/cli.js.map +1 -1
  58. package/dist/codeIndex/migrations.d.ts.map +1 -1
  59. package/dist/codeIndex/migrations.js +4 -3
  60. package/dist/codeIndex/migrations.js.map +1 -1
  61. package/dist/codeIndexDB.d.ts +11 -2
  62. package/dist/codeIndexDB.d.ts.map +1 -1
  63. package/dist/codeIndexDB.js +27 -2
  64. package/dist/codeIndexDB.js.map +1 -1
  65. package/dist/config/configLoader.d.ts +60 -7
  66. package/dist/config/configLoader.d.ts.map +1 -1
  67. package/dist/config/configLoader.js +252 -60
  68. package/dist/config/configLoader.js.map +1 -1
  69. package/dist/config/defaults.d.ts +77 -18
  70. package/dist/config/defaults.d.ts.map +1 -1
  71. package/dist/config/defaults.js +105 -43
  72. package/dist/config/defaults.js.map +1 -1
  73. package/dist/constants.d.ts +2 -1
  74. package/dist/constants.d.ts.map +1 -1
  75. package/dist/constants.js +4 -0
  76. package/dist/constants.js.map +1 -1
  77. package/dist/daemon/main.d.ts +0 -1
  78. package/dist/daemon/main.d.ts.map +1 -1
  79. package/dist/daemon/main.js +11 -4
  80. package/dist/daemon/main.js.map +1 -1
  81. package/dist/dataPaths.d.ts +17 -11
  82. package/dist/dataPaths.d.ts.map +1 -1
  83. package/dist/dataPaths.js +51 -16
  84. package/dist/dataPaths.js.map +1 -1
  85. package/dist/hookLog.d.ts +54 -0
  86. package/dist/hookLog.d.ts.map +1 -0
  87. package/dist/hookLog.js +105 -0
  88. package/dist/hookLog.js.map +1 -0
  89. package/dist/hookLogPath.generated.d.ts +3 -0
  90. package/dist/hookLogPath.generated.d.ts.map +1 -0
  91. package/dist/hookLogPath.generated.js +8 -0
  92. package/dist/hookLogPath.generated.js.map +1 -0
  93. package/dist/index.d.ts +0 -5
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +0 -7
  96. package/dist/index.js.map +1 -1
  97. package/dist/installConfig.d.ts +15 -2
  98. package/dist/installConfig.d.ts.map +1 -1
  99. package/dist/installConfig.js +17 -2
  100. package/dist/installConfig.js.map +1 -1
  101. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
  102. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +18 -3
  103. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
  104. package/dist/mcp-tools/workflowGuide.js +8 -8
  105. package/dist/mcp-tools/workflowGuide.js.map +1 -1
  106. package/dist/mcp-tools-shared.d.ts.map +1 -1
  107. package/dist/mcp-tools-shared.js +5 -2
  108. package/dist/mcp-tools-shared.js.map +1 -1
  109. package/dist/mcp-ui-simple.d.ts +5 -0
  110. package/dist/mcp-ui-simple.d.ts.map +1 -1
  111. package/dist/mcp-ui-simple.js +9 -2
  112. package/dist/mcp-ui-simple.js.map +1 -1
  113. package/dist/mcp.d.ts +0 -1
  114. package/dist/mcp.d.ts.map +1 -1
  115. package/dist/mcp.js +36 -33
  116. package/dist/mcp.js.map +1 -1
  117. package/dist/mcpAuditJobs.d.ts +10 -0
  118. package/dist/mcpAuditJobs.d.ts.map +1 -1
  119. package/dist/mcpAuditJobs.js +10 -1
  120. package/dist/mcpAuditJobs.js.map +1 -1
  121. package/dist/mcpAutoIndex.d.ts.map +1 -1
  122. package/dist/mcpAutoIndex.js +2 -1
  123. package/dist/mcpAutoIndex.js.map +1 -1
  124. package/dist/phase/colorMath.d.ts +18 -5
  125. package/dist/phase/colorMath.d.ts.map +1 -1
  126. package/dist/phase/colorMath.js +88 -5
  127. package/dist/phase/colorMath.js.map +1 -1
  128. package/dist/phase/dataAccessCallsCandidates.js +1 -1
  129. package/dist/phase/dataAccessCallsCandidates.js.map +1 -1
  130. package/dist/phase/goFunctionAnalysis.d.ts +2 -2
  131. package/dist/phase/goFunctionAnalysis.js +2 -2
  132. package/dist/phase/goFunctions.d.ts +2 -2
  133. package/dist/phase/goFunctions.js +2 -2
  134. package/dist/phase/goImports.d.ts +2 -2
  135. package/dist/phase/goImports.js +2 -2
  136. package/dist/phase/goSwitches.d.ts +2 -2
  137. package/dist/phase/goSwitches.js +2 -2
  138. package/dist/phase/loopQueryCandidates.js +1 -1
  139. package/dist/phase/loopQueryCandidates.js.map +1 -1
  140. package/dist/phase/phaseModel.d.ts +37 -8
  141. package/dist/phase/phaseModel.d.ts.map +1 -1
  142. package/dist/phase/phaseModel.js +33 -8
  143. package/dist/phase/phaseModel.js.map +1 -1
  144. package/dist/phase/producers.d.ts.map +1 -1
  145. package/dist/phase/producers.js +24 -17
  146. package/dist/phase/producers.js.map +1 -1
  147. package/dist/phase/reachability.d.ts +44 -1
  148. package/dist/phase/reachability.d.ts.map +1 -1
  149. package/dist/phase/reachability.js +79 -0
  150. package/dist/phase/reachability.js.map +1 -1
  151. package/dist/phase/rules/crossDomain.d.ts.map +1 -1
  152. package/dist/phase/rules/crossDomain.js +16 -6
  153. package/dist/phase/rules/crossDomain.js.map +1 -1
  154. package/dist/phase/rules/dry.d.ts.map +1 -1
  155. package/dist/phase/rules/dry.js +0 -1
  156. package/dist/phase/rules/dry.js.map +1 -1
  157. package/dist/phase/rules/goRules.d.ts +2 -2
  158. package/dist/phase/rules/goRules.js +2 -2
  159. package/dist/phase/rules/secrets.d.ts +22 -8
  160. package/dist/phase/rules/secrets.d.ts.map +1 -1
  161. package/dist/phase/rules/secrets.js +48 -67
  162. package/dist/phase/rules/secrets.js.map +1 -1
  163. package/dist/phase/rules/styles.d.ts +23 -9
  164. package/dist/phase/rules/styles.d.ts.map +1 -1
  165. package/dist/phase/rules/styles.js +47 -15
  166. package/dist/phase/rules/styles.js.map +1 -1
  167. package/dist/phase/rules/unreferencedModule.d.ts.map +1 -1
  168. package/dist/phase/rules/unreferencedModule.js +16 -5
  169. package/dist/phase/rules/unreferencedModule.js.map +1 -1
  170. package/dist/phase/runner.d.ts +16 -7
  171. package/dist/phase/runner.d.ts.map +1 -1
  172. package/dist/phase/runner.js +32 -20
  173. package/dist/phase/runner.js.map +1 -1
  174. package/dist/phase/stylesCss.d.ts.map +1 -1
  175. package/dist/phase/stylesCss.js +4 -0
  176. package/dist/phase/stylesCss.js.map +1 -1
  177. package/dist/phase/stylesMarkup.d.ts.map +1 -1
  178. package/dist/phase/stylesMarkup.js +4 -0
  179. package/dist/phase/stylesMarkup.js.map +1 -1
  180. package/dist/phase/stylesSource.d.ts.map +1 -1
  181. package/dist/phase/stylesSource.js +6 -0
  182. package/dist/phase/stylesSource.js.map +1 -1
  183. package/dist/phase/testProgram.d.ts +57 -0
  184. package/dist/phase/testProgram.d.ts.map +1 -0
  185. package/dist/phase/testProgram.js +244 -0
  186. package/dist/phase/testProgram.js.map +1 -0
  187. package/dist/phase/typeDeclarations.d.ts +2 -2
  188. package/dist/phase/typeDeclarations.js +2 -2
  189. package/dist/phase/types.d.ts +46 -0
  190. package/dist/phase/types.d.ts.map +1 -1
  191. package/dist/pipelineAdapters.d.ts +1 -171
  192. package/dist/pipelineAdapters.d.ts.map +1 -1
  193. package/dist/pipelineAdapters.js +47 -1281
  194. package/dist/pipelineAdapters.js.map +1 -1
  195. package/dist/reporting/csvReportGenerator.d.ts.map +1 -1
  196. package/dist/reporting/csvReportGenerator.js +0 -6
  197. package/dist/reporting/csvReportGenerator.js.map +1 -1
  198. package/dist/reporting/htmlReportGenerator.d.ts.map +1 -1
  199. package/dist/reporting/htmlReportGenerator.js +0 -4
  200. package/dist/reporting/htmlReportGenerator.js.map +1 -1
  201. package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
  202. package/dist/reporting/jsonReportGenerator.js +0 -1
  203. package/dist/reporting/jsonReportGenerator.js.map +1 -1
  204. package/dist/reporting/sarifReportGenerator.d.ts.map +1 -1
  205. package/dist/reporting/sarifReportGenerator.js +0 -7
  206. package/dist/reporting/sarifReportGenerator.js.map +1 -1
  207. package/dist/sqlite/driver.d.ts +17 -1
  208. package/dist/sqlite/driver.d.ts.map +1 -1
  209. package/dist/sqlite/driver.js +28 -5
  210. package/dist/sqlite/driver.js.map +1 -1
  211. package/dist/styles/cssInJsHarvest.d.ts +36 -0
  212. package/dist/styles/cssInJsHarvest.d.ts.map +1 -0
  213. package/dist/styles/cssInJsHarvest.js +78 -0
  214. package/dist/styles/cssInJsHarvest.js.map +1 -0
  215. package/dist/styles/definedClasses.d.ts +95 -0
  216. package/dist/styles/definedClasses.d.ts.map +1 -0
  217. package/dist/styles/definedClasses.js +129 -0
  218. package/dist/styles/definedClasses.js.map +1 -0
  219. package/dist/styles/markupStyleHarvest.d.ts +33 -0
  220. package/dist/styles/markupStyleHarvest.d.ts.map +1 -0
  221. package/dist/styles/markupStyleHarvest.js +73 -0
  222. package/dist/styles/markupStyleHarvest.js.map +1 -0
  223. package/dist/styles/styleExtractor.d.ts +37 -0
  224. package/dist/styles/styleExtractor.d.ts.map +1 -1
  225. package/dist/styles/styleExtractor.js +89 -33
  226. package/dist/styles/styleExtractor.js.map +1 -1
  227. package/dist/styles/styleIndexer.d.ts.map +1 -1
  228. package/dist/styles/styleIndexer.js +11 -10
  229. package/dist/styles/styleIndexer.js.map +1 -1
  230. package/dist/styles/tailwindExpander.d.ts.map +1 -1
  231. package/dist/styles/tailwindExpander.js +31 -10
  232. package/dist/styles/tailwindExpander.js.map +1 -1
  233. package/dist/telemetry.d.ts +67 -1
  234. package/dist/telemetry.d.ts.map +1 -1
  235. package/dist/telemetry.js +100 -20
  236. package/dist/telemetry.js.map +1 -1
  237. package/dist/types/crossLanguage.d.ts +1 -0
  238. package/dist/types/crossLanguage.d.ts.map +1 -1
  239. package/dist/types.d.ts +23 -56
  240. package/dist/types.d.ts.map +1 -1
  241. package/dist/types.js +4 -4
  242. package/dist/types.js.map +1 -1
  243. package/dist/version.generated.d.ts +1 -1
  244. package/dist/version.generated.js +1 -1
  245. package/examples/.auditrc.example.json +7 -22
  246. package/examples/.auditrc.json +12 -155
  247. package/examples/.code-auditor.json +8 -51
  248. package/examples/nextjs.auditrc.json +7 -34
  249. package/examples/node-api.auditrc.json +6 -46
  250. package/examples/react.auditrc.json +8 -25
  251. package/examples/tolerant-solid.auditrc.json +12 -44
  252. package/package.json +6 -5
  253. package/plugin/.claude-plugin/manifest.json +10 -9
  254. package/plugin/.claude-plugin/plugin.json +1 -1
  255. package/plugin/hooks/hooks.json +4 -4
  256. package/plugin/scripts/hook-audit.sh +9 -0
  257. package/plugin/scripts/hook-common.sh +8 -2
  258. package/plugin/scripts/hook-drift-check.sh +10 -1
  259. package/plugin/scripts/hook-log-path.sh +7 -0
  260. package/plugin/scripts/hook-self-audit.sh +9 -0
  261. package/plugin/scripts/hook-warm.sh +17 -11
  262. package/plugin/skills/code-auditor/SKILL.md +26 -3
  263. package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts +0 -6
  264. package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts.map +0 -1
  265. package/dist/__tests__/fixtures/spec-20/scripts/tool.js +0 -12
  266. package/dist/__tests__/fixtures/spec-20/scripts/tool.js.map +0 -1
  267. package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts +0 -7
  268. package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts.map +0 -1
  269. package/dist/__tests__/fixtures/spec-20/src/demo-module.js +0 -13
  270. package/dist/__tests__/fixtures/spec-20/src/demo-module.js.map +0 -1
  271. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts +0 -14
  272. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts.map +0 -1
  273. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js +0 -16
  274. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js.map +0 -1
  275. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts +0 -15
  276. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts.map +0 -1
  277. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js +0 -17
  278. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js.map +0 -1
  279. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts +0 -14
  280. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts.map +0 -1
  281. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js +0 -19
  282. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js.map +0 -1
  283. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts +0 -18
  284. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts.map +0 -1
  285. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js +0 -19
  286. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js.map +0 -1
  287. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts +0 -19
  288. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts.map +0 -1
  289. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js +0 -19
  290. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js.map +0 -1
  291. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts +0 -17
  292. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts.map +0 -1
  293. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js +0 -19
  294. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js.map +0 -1
  295. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts +0 -25
  296. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts.map +0 -1
  297. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js +0 -21
  298. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js.map +0 -1
  299. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts +0 -15
  300. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts.map +0 -1
  301. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js +0 -19
  302. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js.map +0 -1
  303. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts +0 -14
  304. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts.map +0 -1
  305. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js +0 -14
  306. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js.map +0 -1
  307. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts +0 -15
  308. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts.map +0 -1
  309. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js +0 -16
  310. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js.map +0 -1
  311. package/dist/languages/go/analyzer-darwin-amd64 +0 -0
  312. package/dist/languages/go/analyzer-darwin-arm64 +0 -0
  313. package/dist/languages/go/analyzer-linux-amd64 +0 -0
  314. package/dist/languages/go/analyzer-linux-arm64 +0 -0
  315. package/dist/languages/go/analyzer-src/analyzer.go +0 -643
  316. package/dist/languages/go/analyzer-src/dataaccess.go +0 -388
  317. package/dist/languages/go/analyzer-src/go.mod +0 -3
  318. package/dist/languages/go/analyzer-src/indexer.go +0 -268
  319. package/dist/languages/go/analyzer-src/parser.go +0 -461
  320. package/dist/languages/go/analyzer-src/solid.go +0 -311
  321. package/dist/languages/go/analyzer-src/testconventions.go +0 -25
  322. package/dist/languages/go/analyzer-src/types.go +0 -156
  323. package/dist/languages/go/analyzer-windows-amd64.exe +0 -0
  324. package/dist/languages/go/go.mod +0 -7
  325. package/dist/languages/go/main.go +0 -203
  326. package/dist/native/ast-grep-napi.darwin-arm64.node +0 -0
  327. package/dist/native/ast-grep-napi.darwin-x64.node +0 -0
  328. package/dist/native/ast-grep-napi.linux-arm64-gnu.node +0 -0
  329. package/dist/native/ast-grep-napi.linux-arm64-musl.node +0 -0
  330. package/dist/native/ast-grep-napi.linux-x64-gnu.node +0 -0
  331. package/dist/native/ast-grep-napi.linux-x64-musl.node +0 -0
  332. package/dist/native/ast-grep-napi.win32-x64-msvc.node +0 -0
  333. package/dist/native-bootstrap.d.ts +0 -15
  334. package/dist/native-bootstrap.d.ts.map +0 -1
  335. package/dist/native-bootstrap.js +0 -75
  336. package/dist/native-bootstrap.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/sqlite/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,uEAAuE;AACvE,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,SAAS,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAO9C;AAoBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAyClF"}
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/sqlite/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,uEAAuE;AACvE,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,SAAS,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAE1D;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAU9C;AAoBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAyClF"}
@@ -27,18 +27,41 @@ export const DB_BUSY_TIMEOUT_MS = 30_000;
27
27
  export function getActiveBackend() {
28
28
  return activeBackend;
29
29
  }
30
+ /**
31
+ * The `CODE_AUDITOR_SQLITE_BACKEND` override, raw. Single read site: both
32
+ * `describeSqliteBackend` (report surface) and `openSqlite` (enforcement
33
+ * surface) consume this, so they can never disagree on *what* the override is —
34
+ * only on what to do with it (report names the invalid value as invalid;
35
+ * enforcement throws).
36
+ */
37
+ export function sqliteBackendOverride() {
38
+ return process.env.CODE_AUDITOR_SQLITE_BACKEND;
39
+ }
40
+ /** True when `v` is one of the two supported backend names. */
41
+ export function isSqliteBackend(v) {
42
+ return v === 'node-sqlite' || v === 'better-sqlite3';
43
+ }
30
44
  /**
31
45
  * Human-readable backend for `--version`. Reports the forced override when set,
32
46
  * otherwise the last backend an {@link openSqlite} selected, otherwise a
33
47
  * capability probe (which builtin is actually loadable on this Node). "none"
34
48
  * when neither backend can load.
35
49
  *
36
- * @returns The active (or likely) backend name, or "none".
50
+ * An override that is not one of the two supported names is reported *as
51
+ * invalid*, not silently probed past: `openSqlite` throws on the same value, so
52
+ * a diagnostic that named a plausible backend would be a wrong answer on the
53
+ * surface people check first.
54
+ *
55
+ * @returns The active (or likely) backend name, "none", or a string naming the
56
+ * invalid override and the two accepted values.
37
57
  */
38
58
  export function describeSqliteBackend() {
39
- const override = process.env.CODE_AUDITOR_SQLITE_BACKEND;
40
- if (override === 'node-sqlite' || override === 'better-sqlite3')
59
+ const override = sqliteBackendOverride();
60
+ if (isSqliteBackend(override))
41
61
  return override;
62
+ if (override !== undefined) {
63
+ return `invalid (CODE_AUDITOR_SQLITE_BACKEND="${override}" is not a recognised backend; expected "node-sqlite" or "better-sqlite3")`;
64
+ }
42
65
  if (activeBackend !== undefined)
43
66
  return activeBackend;
44
67
  if (isNodeSqliteAvailable())
@@ -73,8 +96,8 @@ function loudFailure(tried, errors) {
73
96
  * @returns An open database, or throws when no backend is usable.
74
97
  */
75
98
  export function openSqlite(dbPath, opts) {
76
- const override = process.env.CODE_AUDITOR_SQLITE_BACKEND;
77
- if (override !== undefined && override !== 'node-sqlite' && override !== 'better-sqlite3') {
99
+ const override = sqliteBackendOverride();
100
+ if (override !== undefined && !isSqliteBackend(override)) {
78
101
  throw new Error(`Invalid CODE_AUDITOR_SQLITE_BACKEND: "${override}" (expected "node-sqlite" or "better-sqlite3")`);
79
102
  }
80
103
  const construct = (backend) => backend === 'node-sqlite'
@@ -1 +1 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/sqlite/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAErF,IAAI,aAAwC,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,uEAAuE;AACvE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;IACzD,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,gBAAgB;QAAE,OAAO,QAAQ,CAAC;IACjF,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IACtD,IAAI,qBAAqB,EAAE;QAAE,OAAO,aAAa,CAAC;IAClD,IAAI,wBAAwB,EAAE;QAAE,OAAO,gBAAgB,CAAC;IACxD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC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B,CAAC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,IAAI,CAAC,mBAAmB,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,WAAW,CAAC,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Parser-based defined-class harvest for TS/JS CSS-in-JS tagged templates
3
+ * (Spec 45, Piece 3 of the keyframe-pollution fix).
4
+ *
5
+ * The TS/JS source path used to scrape class names out of a declaration's
6
+ * selector `context` with `scanClassNamesFromSelector` — but the CSS-in-JS
7
+ * declaration extractor hardcodes `context: 'styled'` (no class names) and its
8
+ * `{` filter drops every declaration whose line carries a nested block, so a
9
+ * class defined inside a nested CSS-in-JS block never entered the catalog and
10
+ * using it in markup produced a false `styles/undefined-class` finding. This
11
+ * module routes each CSS-in-JS template body through the *same* CSS parser the
12
+ * `.css`/`.scss` and markup paths use (`parseFile` + `extractClassUsageFromCSSAst`),
13
+ * so the discriminant for "is this a keyframes at-rule" is what the parser
14
+ * reports: keyframe selectors (`from`/`to`/percentages) are structurally absent
15
+ * from the `class_name`-under-`class_selector` walk, and there is no
16
+ * hand-maintained at-rule-name list anywhere in the path.
17
+ *
18
+ * The template bodies and their boundaries come from `collectCssInJsBlocks`
19
+ * (`styleExtractor.ts`), the same single source of truth the declaration
20
+ * extractor reads, so the two harvests can never disagree on which templates
21
+ * count as CSS-in-JS or what their CSS body text is.
22
+ */
23
+ import type { AST } from '../languages/types.js';
24
+ import type { DefinedClassRef } from './definedClasses.js';
25
+ /**
26
+ * Harvest the defined classes (`.foo` selectors) from one TS/JS file's CSS-in-JS
27
+ * tagged templates, using the CSS parser rather than a selector pattern.
28
+ *
29
+ * @param filePath The source path (becomes the catalog `file_path`).
30
+ * @param sourceCode The raw TS/JS source.
31
+ * @param ast The parsed TS/JS AST (locates the template nodes); null/absent
32
+ * yields an empty harvest, matching the declaration extractor's `!ast` guard.
33
+ * @returns One entry per distinct (className, filePath) defined selector.
34
+ */
35
+ export declare function harvestCssInJsStyleClasses(filePath: string, sourceCode: string, ast?: AST): DefinedClassRef[];
36
+ //# sourceMappingURL=cssInJsHarvest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssInJsHarvest.d.ts","sourceRoot":"","sources":["../../src/styles/cssInJsHarvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,GAAG,GACR,eAAe,EAAE,CAuCnB"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Parser-based defined-class harvest for TS/JS CSS-in-JS tagged templates
3
+ * (Spec 45, Piece 3 of the keyframe-pollution fix).
4
+ *
5
+ * The TS/JS source path used to scrape class names out of a declaration's
6
+ * selector `context` with `scanClassNamesFromSelector` — but the CSS-in-JS
7
+ * declaration extractor hardcodes `context: 'styled'` (no class names) and its
8
+ * `{` filter drops every declaration whose line carries a nested block, so a
9
+ * class defined inside a nested CSS-in-JS block never entered the catalog and
10
+ * using it in markup produced a false `styles/undefined-class` finding. This
11
+ * module routes each CSS-in-JS template body through the *same* CSS parser the
12
+ * `.css`/`.scss` and markup paths use (`parseFile` + `extractClassUsageFromCSSAst`),
13
+ * so the discriminant for "is this a keyframes at-rule" is what the parser
14
+ * reports: keyframe selectors (`from`/`to`/percentages) are structurally absent
15
+ * from the `class_name`-under-`class_selector` walk, and there is no
16
+ * hand-maintained at-rule-name list anywhere in the path.
17
+ *
18
+ * The template bodies and their boundaries come from `collectCssInJsBlocks`
19
+ * (`styleExtractor.ts`), the same single source of truth the declaration
20
+ * extractor reads, so the two harvests can never disagree on which templates
21
+ * count as CSS-in-JS or what their CSS body text is.
22
+ */
23
+ import { collectCssInJsBlocks } from './styleExtractor.js';
24
+ import { extractClassUsageFromCSSAst } from './cssAstExtractor.js';
25
+ import { parseFile } from '../languages/adapterBridge.js';
26
+ import { LanguageRegistry } from '../languages/LanguageRegistry.js';
27
+ /**
28
+ * Harvest the defined classes (`.foo` selectors) from one TS/JS file's CSS-in-JS
29
+ * tagged templates, using the CSS parser rather than a selector pattern.
30
+ *
31
+ * @param filePath The source path (becomes the catalog `file_path`).
32
+ * @param sourceCode The raw TS/JS source.
33
+ * @param ast The parsed TS/JS AST (locates the template nodes); null/absent
34
+ * yields an empty harvest, matching the declaration extractor's `!ast` guard.
35
+ * @returns One entry per distinct (className, filePath) defined selector.
36
+ */
37
+ export function harvestCssInJsStyleClasses(filePath, sourceCode, ast) {
38
+ if (!ast)
39
+ return [];
40
+ const bodies = collectCssInJsBlocks(ast, sourceCode);
41
+ if (bodies.length === 0)
42
+ return [];
43
+ const registry = LanguageRegistry.getInstance();
44
+ const refs = [];
45
+ const seen = new Set();
46
+ for (const body of bodies) {
47
+ // A synthetic path selects the CSS grammar in `parseFile` and the matching
48
+ // adapter in `getAdapterForFile`. The real TS/JS path is threaded to
49
+ // `extractClassUsageFromCSSAst` as `filePath` so the catalog records the
50
+ // source file, not the synthetic one. CSS-in-JS templates are CSS (not SCSS),
51
+ // so the dialect is fixed to `css` — unlike markup `<style lang="scss">`.
52
+ const syntheticPath = 'embedded.css';
53
+ const adapter = registry.getAdapterForFile(syntheticPath);
54
+ if (!adapter)
55
+ continue;
56
+ const ast2 = parseFile(syntheticPath, body);
57
+ if (!ast2)
58
+ continue;
59
+ try {
60
+ for (const u of extractClassUsageFromCSSAst(ast2, adapter, filePath, body)) {
61
+ if (u.unresolvable)
62
+ continue; // `&`-references are uses, not definitions.
63
+ // `filePath` is the single TS/JS path threaded in above, so `className`
64
+ // alone is a unique key for this file; dedup collapses a class selector
65
+ // that appears in more than one template.
66
+ if (seen.has(u.className))
67
+ continue;
68
+ seen.add(u.className);
69
+ refs.push({ className: u.className, filePath: u.filePath });
70
+ }
71
+ }
72
+ finally {
73
+ ast2.dispose?.();
74
+ }
75
+ }
76
+ return refs;
77
+ }
78
+ //# sourceMappingURL=cssInJsHarvest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssInJsHarvest.js","sourceRoot":"","sources":["../../src/styles/cssInJsHarvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIpE;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAgB,EAChB,UAAkB,EAClB,GAAS;IAET,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IAEpB,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,IAAI,GAAsB,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,2EAA2E;QAC3E,qEAAqE;QACrE,yEAAyE;QACzE,8EAA8E;QAC9E,0EAA0E;QAC1E,MAAM,aAAa,GAAG,cAAc,CAAC;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO;YAAE,SAAS;QAEvB,MAAM,IAAI,GAAG,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI;YAAE,SAAS;QAEpB,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,IAAI,2BAA2B,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC3E,IAAI,CAAC,CAAC,YAAY;oBAAE,SAAS,CAAC,4CAA4C;gBAC1E,wEAAwE;gBACxE,wEAAwE;gBACxE,0CAA0C;gBAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;oBAAE,SAAS;gBACpC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACtB,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The single source of truth for the defined-class catalog (Spec 45) — the set
3
+ * of `.foo` class selectors a stylesheet *defines*, which `styles/undefined-class`
4
+ * resolves candidate class usages against.
5
+ *
6
+ * Every writer of the catalog used to scrape class names out of a declaration's
7
+ * selector `context` with the regex `/\.([a-zA-Z0-9_-]+)/g`. That form is wrong
8
+ * twice: it admits a keyframe percentage like `15.8%` (the `.` before `8` is a
9
+ * decimal point, not a class selector), and it cannot tell a style-rule selector
10
+ * from a keyframe selector. The CSS path already harvests class selectors
11
+ * structurally — `extractClassUsageFromCSSAst` walks `class_name` nodes under
12
+ * `class_selector`, so keyframes (whose selectors are `from`/`to`/percentages,
13
+ * per the CSS grammar) never appear. Every live catalog writer now uses the
14
+ * parser harvest: CSS/SCSS read the parser walk (`classUsage`); markup parses
15
+ * each embedded `<style>` block body with the CSS parser
16
+ * (`harvestMarkupStyleClasses`); TS/JS source parses each CSS-in-JS template
17
+ * body with the same parser (`harvestCssInJsStyleClasses`). No live path scans
18
+ * the selector `context` anymore. The `@keyframes` at-rule discriminant
19
+ * (`isKeyframeVariant`) survives only on the migration-backfill path, which
20
+ * replays legacy `style_declarations` rows whose `variant_context` carried the
21
+ * at-rule — see that function's doc.
22
+ */
23
+ export interface DefinedClassRef {
24
+ className: string;
25
+ filePath: string;
26
+ }
27
+ /** The minimal declaration shape the harvest reads. The phase `StylesDeclaration`,
28
+ * the legacy `NormalizedDeclaration`, and the inline object literals the pipeline
29
+ * adapters pass all satisfy it structurally. */
30
+ interface ClassDeclContext {
31
+ context: string | null;
32
+ variantContext: string | null;
33
+ filePath: string;
34
+ }
35
+ /** The minimal class-usage shape the CSS branch reads (parser harvest). */
36
+ interface ClassUsageContext {
37
+ className: string;
38
+ filePath: string;
39
+ unresolvable: boolean;
40
+ }
41
+ /**
42
+ * Scan a selector string for class names (`.foo`). A class selector's name must
43
+ * begin with an identifier-start character (a letter, `_`, or `-`) — a decimal
44
+ * point in a keyframe percentage like `15.8%` is followed by a digit and so
45
+ * contributes nothing even before the caller's keyframe check. This is the
46
+ * markup/source fallback; the CSS path uses the parser instead of this scanner.
47
+ *
48
+ * @param selector - The CSS selector string to scan (a declaration's `context`).
49
+ * @returns The `.`-prefixed class names in `selector`, in source order.
50
+ */
51
+ export declare function scanClassNamesFromSelector(selector: string): string[];
52
+ /**
53
+ * True when a declaration's variant context names the `@keyframes` at-rule — the
54
+ * one at-rule whose inner selectors are keyframe selectors rather than style-rule
55
+ * class selectors. The name may carry a leading `@` and may be the first or a
56
+ * later at-rule in the stack.
57
+ *
58
+ * Live path: none. Every live catalog writer excludes keyframes structurally —
59
+ * CSS/SCSS via the parser's `class_name`-under-`class_selector` walk, markup via
60
+ * `harvestMarkupStyleClasses`, and TS/JS source via `harvestCssInJsStyleClasses`
61
+ * (both of which route a template body through `parseFile` +
62
+ * `extractClassUsageFromCSSAst`). The only caller that can supply a non-null
63
+ * `variantContext` — and therefore reach this function — is the v11→v12
64
+ * backfill migration (`codeIndex/migrations.ts:1164`), which replays legacy
65
+ * `style_declarations` rows whose `variant_context` came from the CSS AST
66
+ * extractor's at-rule context (`cssAstExtractor.ts:584` writes `@keyframes
67
+ * <name>`; `getVariantContext` at `cssAstExtractor.ts:64` writes the enclosing
68
+ * `@media`/`@supports`/`@layer` stack).
69
+ */
70
+ export declare function isKeyframeVariant(variantContext: string | null): boolean;
71
+ /**
72
+ * The canonical defined-class harvest for one styles file.
73
+ *
74
+ * `isCss` selects the source. CSS/SCSS files carry a parser-harvested
75
+ * `classUsage` (each entry a `.foo` selector; keyframes excluded structurally;
76
+ * SCSS `&`-patterns marked `unresolvable`, which are references rather than
77
+ * definitions). Markup and TS/JS source definitions are harvested separately by
78
+ * `harvestMarkupStyleClasses` and `harvestCssInJsStyleClasses` respectively (the
79
+ * CSS parser over each `<style>` block / CSS-in-JS template body) and are not
80
+ * passed here. The `isCss === false` branch below — the selector-`context` scan
81
+ * — is therefore reached only by the migration-backfill path
82
+ * (`codeIndex/migrations.ts:1164`), which replays legacy rows whose `context`
83
+ * carried a selector string and whose `variant_context` carried the at-rule
84
+ * stack; that is the one remaining consumer of the `isKeyframeVariant` skip.
85
+ *
86
+ * @param declarations - The file's declaration contexts (selector plus the
87
+ * enclosing at-rule stack), the legacy selector-scan source.
88
+ * @param classUsage - The parser-harvested class selectors (the CSS/SCSS source).
89
+ * @param isCss - True when the source is a CSS/SCSS file, so the harvest reads
90
+ * `classUsage`; false selects the legacy selector scan over `declarations`.
91
+ * @returns The file's defined-class references (`className` + `filePath`).
92
+ */
93
+ export declare function harvestDefinedClasses(declarations: readonly ClassDeclContext[], classUsage: readonly ClassUsageContext[], isCss: boolean): DefinedClassRef[];
94
+ export {};
95
+ //# sourceMappingURL=definedClasses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definedClasses.d.ts","sourceRoot":"","sources":["../../src/styles/definedClasses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;iDAEiD;AACjD,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,2EAA2E;AAC3E,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAwBD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAWrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGxE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,SAAS,gBAAgB,EAAE,EACzC,UAAU,EAAE,SAAS,iBAAiB,EAAE,EACxC,KAAK,EAAE,OAAO,GACb,eAAe,EAAE,CAgBnB"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The single source of truth for the defined-class catalog (Spec 45) — the set
3
+ * of `.foo` class selectors a stylesheet *defines*, which `styles/undefined-class`
4
+ * resolves candidate class usages against.
5
+ *
6
+ * Every writer of the catalog used to scrape class names out of a declaration's
7
+ * selector `context` with the regex `/\.([a-zA-Z0-9_-]+)/g`. That form is wrong
8
+ * twice: it admits a keyframe percentage like `15.8%` (the `.` before `8` is a
9
+ * decimal point, not a class selector), and it cannot tell a style-rule selector
10
+ * from a keyframe selector. The CSS path already harvests class selectors
11
+ * structurally — `extractClassUsageFromCSSAst` walks `class_name` nodes under
12
+ * `class_selector`, so keyframes (whose selectors are `from`/`to`/percentages,
13
+ * per the CSS grammar) never appear. Every live catalog writer now uses the
14
+ * parser harvest: CSS/SCSS read the parser walk (`classUsage`); markup parses
15
+ * each embedded `<style>` block body with the CSS parser
16
+ * (`harvestMarkupStyleClasses`); TS/JS source parses each CSS-in-JS template
17
+ * body with the same parser (`harvestCssInJsStyleClasses`). No live path scans
18
+ * the selector `context` anymore. The `@keyframes` at-rule discriminant
19
+ * (`isKeyframeVariant`) survives only on the migration-backfill path, which
20
+ * replays legacy `style_declarations` rows whose `variant_context` carried the
21
+ * at-rule — see that function's doc.
22
+ */
23
+ function isIdentifierStart(c) {
24
+ if (!c)
25
+ return false;
26
+ const code = c.charCodeAt(0);
27
+ return ((code >= 97 && code <= 122) || // a-z
28
+ (code >= 65 && code <= 90) || // A-Z
29
+ c === '_' ||
30
+ c === '-');
31
+ }
32
+ function isIdentifierPart(c) {
33
+ const code = c.charCodeAt(0);
34
+ return ((code >= 97 && code <= 122) || // a-z
35
+ (code >= 65 && code <= 90) || // A-Z
36
+ (code >= 48 && code <= 57) || // 0-9
37
+ c === '_' ||
38
+ c === '-');
39
+ }
40
+ /**
41
+ * Scan a selector string for class names (`.foo`). A class selector's name must
42
+ * begin with an identifier-start character (a letter, `_`, or `-`) — a decimal
43
+ * point in a keyframe percentage like `15.8%` is followed by a digit and so
44
+ * contributes nothing even before the caller's keyframe check. This is the
45
+ * markup/source fallback; the CSS path uses the parser instead of this scanner.
46
+ *
47
+ * @param selector - The CSS selector string to scan (a declaration's `context`).
48
+ * @returns The `.`-prefixed class names in `selector`, in source order.
49
+ */
50
+ export function scanClassNamesFromSelector(selector) {
51
+ const names = [];
52
+ for (let i = 0; i < selector.length; i++) {
53
+ if (selector[i] !== '.')
54
+ continue;
55
+ if (!isIdentifierStart(selector[i + 1]))
56
+ continue;
57
+ let j = i + 2;
58
+ while (j < selector.length && isIdentifierPart(selector[j]))
59
+ j++;
60
+ names.push(selector.slice(i + 1, j));
61
+ i = j - 1;
62
+ }
63
+ return names;
64
+ }
65
+ /**
66
+ * True when a declaration's variant context names the `@keyframes` at-rule — the
67
+ * one at-rule whose inner selectors are keyframe selectors rather than style-rule
68
+ * class selectors. The name may carry a leading `@` and may be the first or a
69
+ * later at-rule in the stack.
70
+ *
71
+ * Live path: none. Every live catalog writer excludes keyframes structurally —
72
+ * CSS/SCSS via the parser's `class_name`-under-`class_selector` walk, markup via
73
+ * `harvestMarkupStyleClasses`, and TS/JS source via `harvestCssInJsStyleClasses`
74
+ * (both of which route a template body through `parseFile` +
75
+ * `extractClassUsageFromCSSAst`). The only caller that can supply a non-null
76
+ * `variantContext` — and therefore reach this function — is the v11→v12
77
+ * backfill migration (`codeIndex/migrations.ts:1164`), which replays legacy
78
+ * `style_declarations` rows whose `variant_context` came from the CSS AST
79
+ * extractor's at-rule context (`cssAstExtractor.ts:584` writes `@keyframes
80
+ * <name>`; `getVariantContext` at `cssAstExtractor.ts:64` writes the enclosing
81
+ * `@media`/`@supports`/`@layer` stack).
82
+ */
83
+ export function isKeyframeVariant(variantContext) {
84
+ if (!variantContext)
85
+ return false;
86
+ return /(^|,)\s*@?keyframes\b/i.test(variantContext);
87
+ }
88
+ /**
89
+ * The canonical defined-class harvest for one styles file.
90
+ *
91
+ * `isCss` selects the source. CSS/SCSS files carry a parser-harvested
92
+ * `classUsage` (each entry a `.foo` selector; keyframes excluded structurally;
93
+ * SCSS `&`-patterns marked `unresolvable`, which are references rather than
94
+ * definitions). Markup and TS/JS source definitions are harvested separately by
95
+ * `harvestMarkupStyleClasses` and `harvestCssInJsStyleClasses` respectively (the
96
+ * CSS parser over each `<style>` block / CSS-in-JS template body) and are not
97
+ * passed here. The `isCss === false` branch below — the selector-`context` scan
98
+ * — is therefore reached only by the migration-backfill path
99
+ * (`codeIndex/migrations.ts:1164`), which replays legacy rows whose `context`
100
+ * carried a selector string and whose `variant_context` carried the at-rule
101
+ * stack; that is the one remaining consumer of the `isKeyframeVariant` skip.
102
+ *
103
+ * @param declarations - The file's declaration contexts (selector plus the
104
+ * enclosing at-rule stack), the legacy selector-scan source.
105
+ * @param classUsage - The parser-harvested class selectors (the CSS/SCSS source).
106
+ * @param isCss - True when the source is a CSS/SCSS file, so the harvest reads
107
+ * `classUsage`; false selects the legacy selector scan over `declarations`.
108
+ * @returns The file's defined-class references (`className` + `filePath`).
109
+ */
110
+ export function harvestDefinedClasses(declarations, classUsage, isCss) {
111
+ if (isCss) {
112
+ return classUsage
113
+ .filter((u) => !u.unresolvable)
114
+ .map((u) => ({ className: u.className, filePath: u.filePath }));
115
+ }
116
+ const out = [];
117
+ for (const d of declarations) {
118
+ const ctx = d.context;
119
+ if (!ctx)
120
+ continue;
121
+ if (isKeyframeVariant(d.variantContext))
122
+ continue;
123
+ for (const className of scanClassNamesFromSelector(ctx)) {
124
+ out.push({ className, filePath: d.filePath });
125
+ }
126
+ }
127
+ return out;
128
+ }
129
+ //# sourceMappingURL=definedClasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definedClasses.js","sourceRoot":"","sources":["../../src/styles/definedClasses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuBH,SAAS,iBAAiB,CAAC,CAAqB;IAC9C,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACrB,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,CACL,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,MAAM;QACrC,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,MAAM;QACpC,CAAC,KAAK,GAAG;QACT,CAAC,KAAK,GAAG,CACV,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,C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cAAc,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAAyC,EACzC,UAAwC,EACxC,KAAc;IAEd,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,UAAU;aACd,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC;QACtB,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,IAAI,iBAAiB,CAAC,CAAC,CAAC,cAAc,CAAC;YAAE,SAAS;QAClD,KAAK,MAAM,SAAS,IAAI,0BAA0B,CAAC,GAAG,CAAC,EAAE,CAAC;YACxD,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Parser-based defined-class harvest for markup `<style>` blocks (Spec 45,
3
+ * Piece 2 of the keyframe-pollution fix).
4
+ *
5
+ * The markup path used to scrape class names out of the regex-scraped selector
6
+ * `context` with `scanClassNamesFromSelector` — a character-minimum pattern that
7
+ * cannot tell a style-rule selector from a keyframe selector and admits decimal
8
+ * points in keyframe percentages as class-selector dots. This module routes each
9
+ * readable embedded `<style>` block body through the *same* CSS parser the
10
+ * `.css`/`.scss` path uses (`parseFile` + `extractClassUsageFromCSSAst`), so the
11
+ * discriminant for "is this a keyframes at-rule" is what the parser reports:
12
+ * keyframe selectors (`from`/`to`/percentages) are structurally absent from the
13
+ * `class_name`-under-`class_selector` walk, and there is no hand-maintained
14
+ * at-rule-name list anywhere in the path.
15
+ *
16
+ * The block boundaries and dialect (`css`/`scss`) come from `collectStyleBlocks`,
17
+ * the same single source of truth the declaration extractor reads, so the two
18
+ * harvests can never disagree. Unread dialects (`sass`/`less`/`styl`/…) are
19
+ * dropped by `collectStyleBlocks` before this function runs — exactly the
20
+ * dialects the regex declaration path also skips, so the catalog never asserts a
21
+ * class defined only in a dialect the tool cannot parse.
22
+ */
23
+ import type { DefinedClassRef } from './definedClasses.js';
24
+ /**
25
+ * Harvest the defined classes (`.foo` selectors) from one markup file's readable
26
+ * embedded `<style>` blocks, using the CSS parser rather than a selector pattern.
27
+ *
28
+ * @param filePath The markup source path (becomes the catalog `file_path`).
29
+ * @param sourceCode The raw markup source.
30
+ * @returns One entry per distinct (className, filePath) defined selector.
31
+ */
32
+ export declare function harvestMarkupStyleClasses(filePath: string, sourceCode: string): DefinedClassRef[];
33
+ //# sourceMappingURL=markupStyleHarvest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupStyleHarvest.d.ts","sourceRoot":"","sources":["../../src/styles/markupStyleHarvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,eAAe,EAAE,CAoCnB"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Parser-based defined-class harvest for markup `<style>` blocks (Spec 45,
3
+ * Piece 2 of the keyframe-pollution fix).
4
+ *
5
+ * The markup path used to scrape class names out of the regex-scraped selector
6
+ * `context` with `scanClassNamesFromSelector` — a character-minimum pattern that
7
+ * cannot tell a style-rule selector from a keyframe selector and admits decimal
8
+ * points in keyframe percentages as class-selector dots. This module routes each
9
+ * readable embedded `<style>` block body through the *same* CSS parser the
10
+ * `.css`/`.scss` path uses (`parseFile` + `extractClassUsageFromCSSAst`), so the
11
+ * discriminant for "is this a keyframes at-rule" is what the parser reports:
12
+ * keyframe selectors (`from`/`to`/percentages) are structurally absent from the
13
+ * `class_name`-under-`class_selector` walk, and there is no hand-maintained
14
+ * at-rule-name list anywhere in the path.
15
+ *
16
+ * The block boundaries and dialect (`css`/`scss`) come from `collectStyleBlocks`,
17
+ * the same single source of truth the declaration extractor reads, so the two
18
+ * harvests can never disagree. Unread dialects (`sass`/`less`/`styl`/…) are
19
+ * dropped by `collectStyleBlocks` before this function runs — exactly the
20
+ * dialects the regex declaration path also skips, so the catalog never asserts a
21
+ * class defined only in a dialect the tool cannot parse.
22
+ */
23
+ import { collectStyleBlocks } from './styleExtractor.js';
24
+ import { extractClassUsageFromCSSAst } from './cssAstExtractor.js';
25
+ import { parseFile } from '../languages/adapterBridge.js';
26
+ import { LanguageRegistry } from '../languages/LanguageRegistry.js';
27
+ /**
28
+ * Harvest the defined classes (`.foo` selectors) from one markup file's readable
29
+ * embedded `<style>` blocks, using the CSS parser rather than a selector pattern.
30
+ *
31
+ * @param filePath The markup source path (becomes the catalog `file_path`).
32
+ * @param sourceCode The raw markup source.
33
+ * @returns One entry per distinct (className, filePath) defined selector.
34
+ */
35
+ export function harvestMarkupStyleClasses(filePath, sourceCode) {
36
+ const blocks = collectStyleBlocks(sourceCode);
37
+ if (blocks.length === 0)
38
+ return [];
39
+ const registry = LanguageRegistry.getInstance();
40
+ const refs = [];
41
+ const seen = new Set();
42
+ for (const block of blocks) {
43
+ // A synthetic path selects the CSS/SCSS grammar in `parseFile` and the
44
+ // matching adapter in `getAdapterForFile`. The real markup path is threaded
45
+ // to `extractClassUsageFromCSSAst` as `filePath` so the catalog records the
46
+ // source file, not the synthetic one.
47
+ const syntheticPath = block.lang === 'scss' ? 'embedded.scss' : 'embedded.css';
48
+ const adapter = registry.getAdapterForFile(syntheticPath);
49
+ if (!adapter)
50
+ continue;
51
+ const ast = parseFile(syntheticPath, block.body);
52
+ if (!ast)
53
+ continue;
54
+ try {
55
+ for (const u of extractClassUsageFromCSSAst(ast, adapter, filePath, block.body)) {
56
+ if (u.unresolvable)
57
+ continue; // SCSS `&`-references are uses, not definitions.
58
+ // `filePath` is the single markup path threaded in above, so `className`
59
+ // alone is a unique key for this file; dedup collapses a class selector
60
+ // that appears in more than one `<style>` block.
61
+ if (seen.has(u.className))
62
+ continue;
63
+ seen.add(u.className);
64
+ refs.push({ className: u.className, filePath: u.filePath });
65
+ }
66
+ }
67
+ finally {
68
+ ast.dispose?.();
69
+ }
70
+ }
71
+ return refs;
72
+ }
73
+ //# sourceMappingURL=markupStyleHarvest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupStyleHarvest.js","sourceRoot":"","sources":["../../src/styles/markupStyleHarvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAgB,EAChB,UAAkB;IAElB,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,IAAI,GAAsB,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,uEAAuE;QACvE,4EAA4E;QAC5E,4EAA4E;QAC5E,sCAAsC;QACtC,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC;QAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO;YAAE,SAAS;QAEvB,MAAM,GAAG,GAAG,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG;YAAE,SAAS;QAEnB,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,IAAI,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChF,IAAI,CAAC,CAAC,YAAY;oBAAE,SAAS,CAAC,iDAAiD;gBAC/E,yEAAyE;gBACzE,wEAAwE;gBACxE,iDAAiD;gBACjD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;oBAAE,SAAS;gBACpC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACtB,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -63,4 +63,41 @@ export declare function extractDeclarationsFromBlock(block: string, declarations
63
63
  variantContext: string | null;
64
64
  baseLine: number;
65
65
  }): void;
66
+ /**
67
+ * Collect every CSS-in-JS template body in a TS/JS AST, in source order. Shared
68
+ * by the defined-class harvest (`harvestCssInJsStyleClasses`), which routes each
69
+ * body through the CSS parser rather than the line-splitting declaration path.
70
+ *
71
+ * @param ast The parsed TS/JS AST to walk for CSS-in-JS templates.
72
+ * @param sourceCode The raw TS/JS source, used to slice each template body.
73
+ * @returns Every CSS-in-JS template body in source order.
74
+ */
75
+ export declare function collectCssInJsBlocks(ast: AST, sourceCode: string): string[];
76
+ /** One embedded `<style>` block whose dialect the extractor can read. */
77
+ export interface StyleBlock {
78
+ body: string;
79
+ lang: 'css' | 'scss';
80
+ /** Index of the first body character in the source (right after the opening
81
+ * `>`), used to map body line numbers back to the source file. */
82
+ bodyStart: number;
83
+ }
84
+ /**
85
+ * Collect the readable embedded `<style>` blocks from a markup source.
86
+ *
87
+ * This is the single source of truth for "which `<style>` blocks exist" — both
88
+ * the declaration extractor (`extractStyleBlocks`) and the parser-based
89
+ * defined-class harvest (`harvestMarkupStyleClasses`) consume it, so the two
90
+ * can never disagree about block boundaries or dialect. The dialect is chosen
91
+ * from the `lang`/`type` attribute:
92
+ * - `css` (or absent) → `css`
93
+ * - `scss` → `scss`
94
+ * - anything else (`sass`, `less`, `styl`, `postcss`, …) → reported to
95
+ * `onUnread` (and excluded), so `undefined-class` never asserts a class
96
+ * defined only in an unread dialect.
97
+ *
98
+ * @param sourceCode The raw markup source.
99
+ * @param onUnread Optional callback receiving an unread dialect name.
100
+ * @returns The readable (`css`/`scss`) style blocks in source order.
101
+ */
102
+ export declare function collectStyleBlocks(sourceCode: string, onUnread?: (lang: string) => void): StyleBlock[];
66
103
  //# sourceMappingURL=styleExtractor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styleExtractor.d.ts","sourceRoot":"","sources":["../../src/styles/styleExtractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAW,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MA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