@md-code/follow-architecture 0.1.1 → 0.3.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 (437) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +584 -141
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +61 -18
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -101
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -96
  435. package/plugin.js +0 -5
  436. package/report.js +0 -73
  437. package/utils.js +0 -104
@@ -0,0 +1,82 @@
1
+ import { RULE_SCHEMA } from "./config-options";
2
+ declare const plugin: {
3
+ meta: {
4
+ name: string;
5
+ version: string;
6
+ };
7
+ rules: {
8
+ "follow-architecture": {
9
+ meta: {
10
+ type: string;
11
+ docs: {
12
+ description: string;
13
+ };
14
+ schema: {
15
+ anyOf: ({
16
+ type: string;
17
+ properties?: undefined;
18
+ additionalProperties?: undefined;
19
+ } | {
20
+ type: string;
21
+ properties: {
22
+ config: {
23
+ type: string;
24
+ };
25
+ configs: {
26
+ type: string;
27
+ };
28
+ include: {
29
+ type: string;
30
+ };
31
+ exts: {
32
+ type: string;
33
+ };
34
+ similarity: {
35
+ type: string;
36
+ };
37
+ ignoreDirs: {
38
+ type: string;
39
+ };
40
+ ignores: {
41
+ type: string;
42
+ };
43
+ exportPath: {
44
+ anyOf: {
45
+ type: string;
46
+ }[];
47
+ description: string;
48
+ };
49
+ };
50
+ additionalProperties: boolean;
51
+ })[];
52
+ }[];
53
+ };
54
+ create: (context: {
55
+ options: (string | import("./config-options").RuleOptions)[];
56
+ filename?: string;
57
+ getFilename: () => string;
58
+ report: (descriptor: {
59
+ node?: {
60
+ [x: string]: never;
61
+ };
62
+ message: string;
63
+ loc?: {
64
+ start: {
65
+ line: number;
66
+ column: number;
67
+ };
68
+ end: {
69
+ line: number;
70
+ column: number;
71
+ };
72
+ };
73
+ }) => void;
74
+ }) => Record<string, (node: {
75
+ [x: string]: never;
76
+ }) => void>;
77
+ };
78
+ };
79
+ };
80
+ declare const ruleOptions: () => typeof RULE_SCHEMA;
81
+ export { plugin, ruleOptions };
82
+ export { openProject } from "./config-project";
package/dist/config.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openProject = exports.ruleOptions = exports.plugin = void 0;
4
+ // The ESLint plugin: the rule, its options schema, and the project loader the
5
+ // CLI shares. The halves live in their own modules — the rule's wiring
6
+ // (`config-rule`), the per-repo state (`config-state`), the report accumulation
7
+ // (`config-report`), the option contract (`config-options`), the project loader
8
+ // (`config-project`) — re-exported here so every consumer keeps importing
9
+ // `config`.
10
+ const node_module_1 = require("node:module");
11
+ const config_rule_1 = require("./config-rule");
12
+ const config_options_1 = require("./config-options");
13
+ // This package's own manifest, from either layout: the compiled tree lives in
14
+ // `dist/`, so the manifest is one level up; in the source tree it sits next to
15
+ // this file. The require is taken at run time (the same way the sibling
16
+ // packages read it), so the resolution follows the compiled layout.
17
+ const requireModule = (0, node_module_1.createRequire)(__filename);
18
+ const readOwnManifest = () => {
19
+ try {
20
+ const manifest = requireModule("../package.json");
21
+ return manifest;
22
+ }
23
+ catch {
24
+ const manifest = requireModule("./package.json");
25
+ return manifest;
26
+ }
27
+ };
28
+ const pkg = readOwnManifest();
29
+ const plugin = {
30
+ meta: { name: pkg.name, version: pkg.version },
31
+ rules: { "follow-architecture": config_rule_1.rule },
32
+ };
33
+ exports.plugin = plugin;
34
+ // What the rule ACCEPTS is part of its contract, not an implementation detail.
35
+ const ruleOptions = () => config_options_1.RULE_SCHEMA;
36
+ exports.ruleOptions = ruleOptions;
37
+ var config_project_1 = require("./config-project");
38
+ Object.defineProperty(exports, "openProject", { enumerable: true, get: function () { return config_project_1.openProject; } });
@@ -0,0 +1,27 @@
1
+ import type { SourceFile, TaggedTemplateExpression } from "ts-morph";
2
+ import type { Candidate } from "../entities/facts";
3
+ import { tokenize } from "../utils/tokenize";
4
+ import { hostOf } from "../utils/host";
5
+ import { type LeadingComment } from "./syntax/styled/template";
6
+ import type { DocumentFacts } from "./syntax/styled/document";
7
+ import { type ObjectLiteral } from "./value/scope";
8
+ import { type FieldValue } from "../utils/field";
9
+ import * as syntax from "./syntax/language";
10
+ declare const materialiseResolution: (template: {
11
+ declarations?: FieldValue;
12
+ }, objects: readonly ObjectLiteral[]) => void;
13
+ declare const templateFacts: (node: TaggedTemplateExpression, options?: {
14
+ objects?: readonly ObjectLiteral[];
15
+ }) => DocumentFacts & {
16
+ tag: string;
17
+ line: number | null;
18
+ startLine: number | null;
19
+ comment: LeadingComment;
20
+ };
21
+ type TemplateFact = ReturnType<typeof templateFacts>;
22
+ declare const stylesheetFacts: (rel: string, text: string) => DocumentFacts | null;
23
+ declare const attachToCandidates: (candidates: Candidate[], { sf }: {
24
+ sf: SourceFile;
25
+ }) => Candidate[];
26
+ export { attachToCandidates, stylesheetFacts, templateFacts, materialiseResolution, hostOf, tokenize, syntax };
27
+ export type { TemplateFact };
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.syntax = exports.tokenize = exports.hostOf = exports.materialiseResolution = exports.templateFacts = exports.stylesheetFacts = exports.attachToCandidates = void 0;
27
+ const tree_1 = require("../entities/ast/tree");
28
+ const configError = __importStar(require("../report/configErrors"));
29
+ const markup_1 = require("./syntax/styled/markup");
30
+ const tokenize_1 = require("../utils/tokenize");
31
+ Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return tokenize_1.tokenize; } });
32
+ const host_1 = require("../utils/host");
33
+ Object.defineProperty(exports, "hostOf", { enumerable: true, get: function () { return host_1.hostOf; } });
34
+ const template_1 = require("./syntax/styled/template");
35
+ const resolve_1 = require("./value/resolve");
36
+ const scope_1 = require("./value/scope");
37
+ const field_1 = require("../utils/field");
38
+ const gate_1 = require("./syntax/css/gate");
39
+ const syntax = __importStar(require("./syntax/language"));
40
+ exports.syntax = syntax;
41
+ // The language that reads a substituted template: whatever is registered under
42
+ // `css`, so a consumer that replaces the language replaces the reading too.
43
+ const cssLanguage = () => {
44
+ const language = syntax.byId("css");
45
+ if (!language)
46
+ throw configError.styleLanguageIncomplete();
47
+ return language;
48
+ };
49
+ // Every declaration of a document gets its RESOLUTION: the concrete value(s) it
50
+ // reaches with `var()`, `$var` and `${expression}` walked to the bottom, the
51
+ // object literal and media variant each reading belongs to, the grammar's verdict,
52
+ // and what could not be read. Nothing is dropped silently.
53
+ const withResolutions = (facts, context) => ({
54
+ ...facts,
55
+ declarations: facts.declarations.map((declaration) => ({ ...declaration, resolution: (0, resolve_1.resolveDeclaration)(declaration, context) })),
56
+ });
57
+ const RESOLUTIONS = new WeakMap();
58
+ const objectSignature = (objects) => objects.map((object) => `${object.name}|${object.node.getSourceFile().getFilePath()}|${object.node.getStart()}`).join(",");
59
+ // Resolve one template fact against an explicit object set (cached by that set)
60
+ // and write the readings onto the fact's declarations — the fact an invariant's
61
+ // filter reads. Idempotent: asking twice reuses the cached readings.
62
+ const materialiseResolution = (template, objects) => {
63
+ const entry = RESOLUTIONS.get(template);
64
+ if (!entry)
65
+ return;
66
+ const key = objectSignature(objects);
67
+ let resolved = entry.cache.get(key);
68
+ if (!resolved) {
69
+ resolved = entry.resolve(objects);
70
+ entry.cache.set(key, resolved);
71
+ }
72
+ const declarations = template.declarations;
73
+ if (!(0, field_1.isList)(declarations))
74
+ return;
75
+ // Facts are plain, freshly built data; the declarations carry an open index
76
+ // the filter engine reads, so the resolution is written onto them in place.
77
+ declarations.forEach((declaration, index) => {
78
+ if ((0, field_1.isObj)(declaration))
79
+ Object.assign(declaration, { resolution: resolved?.declarations[index]?.resolution });
80
+ });
81
+ };
82
+ exports.materialiseResolution = materialiseResolution;
83
+ // Facts for one styled/CSS template held by a candidate. The substituted template
84
+ // is plain CSS, so it is read by the `css` language whatever file it sits in.
85
+ // RESOLUTION is NOT computed here: classification and the raw readings never need
86
+ // it, so it is attached only when an invariant asks (`materialiseResolution`). A
87
+ // caller that already knows its objects (a unit test) may pass them to resolve
88
+ // eagerly.
89
+ const templateFacts = (node, options) => {
90
+ const { text, exprs } = (0, template_1.templateSource)(node);
91
+ const facts = cssLanguage().facts(text, { exprs });
92
+ // The expressions the template quoted, by index — the way a blank in the
93
+ // substituted text gets back to its TypeScript question.
94
+ const expressions = (0, template_1.expressionNodesOf)(node.getTemplate());
95
+ const sourceFile = node.getSourceFile();
96
+ // Declaration lines are numbered INSIDE the template text (postcss counts
97
+ // from 1 at the first character after the backtick). `startLine` is the
98
+ // template's own line in the FILE, so a consumer can place any declaration
99
+ // on the file's line grid: startLine + decl.line - 1.
100
+ const startLine = node.getStartLineNumber();
101
+ const fact = { tag: node.getTag().getText(), line: startLine, startLine, comment: (0, template_1.leadingCommentOf)(node), ...facts };
102
+ const resolve = (objects) => withResolutions(facts, { scope: (0, scope_1.withObjects)((0, scope_1.scopeFromProject)(sourceFile), objects), expression: (index) => expressions[index] ?? null });
103
+ RESOLUTIONS.set(fact, { resolve, cache: new Map() });
104
+ if (options?.objects)
105
+ materialiseResolution(fact, options.objects);
106
+ return fact;
107
+ };
108
+ exports.templateFacts = templateFacts;
109
+ // Facts for a whole stylesheet file — the same shape, so one rule reads both. The
110
+ // language is chosen by extension; a syntax nobody registered produces nothing
111
+ // instead of being read as CSS. A stylesheet has no TypeScript expressions and
112
+ // reads no object literals, so it resolves eagerly against its own variables.
113
+ const stylesheetFacts = (rel, text) => {
114
+ const language = syntax.forFile(rel);
115
+ if (!language)
116
+ return null;
117
+ const facts = language.facts(text);
118
+ return withResolutions(facts, { scope: (0, scope_1.scopeFromFacts)(facts), expression: () => null });
119
+ };
120
+ exports.stylesheetFacts = stylesheetFacts;
121
+ // Every CSS template in the file, as its own fact set. ANY tagged template is
122
+ // offered to the grammar: the ones whose substituted text reads as CSS become
123
+ // facts, the rest (SQL, GraphQL, prose, …) do not. The tag's name is recorded
124
+ // as a fact, never used as the gate.
125
+ const styledTemplates = (sf) => sf.getDescendantsOfKind(tree_1.SK.TaggedTemplateExpression).filter((node) => (0, gate_1.isStylesheet)((0, template_1.templateSource)(node).text));
126
+ // The one entry point the pipeline calls: attach `css.*` to the candidates —
127
+ // templates first, then the class lists (CSS written in an attribute rather than
128
+ // in a template). Same facet, same call: a caller attaches `css.*` once.
129
+ const attachToCandidates = (candidates, { sf }) => {
130
+ for (const template of styledTemplates(sf).map((node) => templateFacts(node))) {
131
+ const host = (0, host_1.hostOf)(candidates, template.line);
132
+ if (!host)
133
+ continue;
134
+ host.css = host.css && Array.isArray(host.css.templates) ? host.css : { templates: [] };
135
+ host.css.templates?.push(template);
136
+ }
137
+ (0, markup_1.attachClasses)(candidates, { sf });
138
+ return candidates;
139
+ };
140
+ exports.attachToCandidates = attachToCandidates;
@@ -0,0 +1,2 @@
1
+ declare const isStylesheet: (text: string) => boolean;
2
+ export { isStylesheet };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isStylesheet = void 0;
4
+ const check_1 = require("../../value/check");
5
+ const gate_1 = require("../../../utils/gate");
6
+ const try_read_1 = require("../../../utils/try-read");
7
+ const read_when_1 = require("../../../utils/read-when");
8
+ const language_1 = require("../language");
9
+ // A property is CSS when the grammar knows it: a custom property (`--x`), or a
10
+ // name (vendor prefix and hack stripped by the parser) in css-tree's dictionary.
11
+ const knownProperty = (raw) => {
12
+ if (/^--[\w-]+$/.test(raw))
13
+ return true;
14
+ if (raw.startsWith("$"))
15
+ return false;
16
+ try {
17
+ const parsed = check_1.cssTree.property(raw);
18
+ if (parsed.custom)
19
+ return true;
20
+ const properties = check_1.cssTree.lexer.properties ?? {};
21
+ return Object.hasOwn(properties, parsed.basename);
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ };
27
+ // What one document walk counts: the structure, and how much of it the grammar
28
+ // recognises. An empty selector, or one opening with a brace/quote/bracket, is a
29
+ // data format's block (JSON, an INI section) — not a CSS selector.
30
+ const shapeOf = (root) => {
31
+ const shape = { declarations: 0, known: 0, rules: 0, badSelector: 0 };
32
+ root.walkDecls((decl) => {
33
+ shape.declarations += 1;
34
+ if (knownProperty(decl.prop))
35
+ shape.known += 1;
36
+ });
37
+ root.walkRules((rule) => {
38
+ shape.rules += 1;
39
+ const selector = String(rule.selector ?? "").trim();
40
+ if (!selector || /^[[{"']/.test(selector))
41
+ shape.badSelector += 1;
42
+ });
43
+ return shape;
44
+ };
45
+ // The verdicts over the counted shape: nothing structured is not a stylesheet
46
+ // (an empty template, a comment); a data-format selector is another language;
47
+ // declarations the grammar does not know at all (YAML, a variable-only fragment)
48
+ // are a different syntax's business, not this facet's. The decision ("admit when
49
+ // none rejects") is the shared gate; the verdicts are CSS's own.
50
+ const noStructure = ({ declarations, rules }) => !declarations && !rules;
51
+ const hasBadSelector = ({ badSelector }) => badSelector > 0;
52
+ const noKnownProperty = ({ declarations, known }) => declarations > 0 && known === 0;
53
+ const isStylesheetShape = (shape) => (0, gate_1.admitsWhenNoneReject)(shape, [noStructure, hasBadSelector, noKnownProperty]);
54
+ // One document's parse: the shared guarded read (a text the parser rejects is
55
+ // simply not CSS — silence, because a SQL template reaching here is normal).
56
+ const parseOrNull = (text) => {
57
+ const language = (0, language_1.byId)("css");
58
+ if (!language)
59
+ return null;
60
+ return (0, try_read_1.readOrFallback)(text, language.parse, null);
61
+ };
62
+ // A document is read only when it parsed — the shared qualified read; the shape
63
+ // verdicts are CSS's own. The registered `css` language does the parsing, so a
64
+ // consumer that replaces the language replaces the gate's reading too.
65
+ const isStylesheet = (text) => {
66
+ const root = parseOrNull(text);
67
+ return (0, read_when_1.readWhen)(root, (parsed) => parsed !== null, (parsed) => isStylesheetShape(shapeOf(parsed)), false);
68
+ };
69
+ exports.isStylesheet = isStylesheet;
@@ -0,0 +1,7 @@
1
+ import type { Root } from "postcss";
2
+ import { type DocumentFacts, type DocumentOptions } from "../styled/document";
3
+ declare const id = "css";
4
+ declare const exts: string[];
5
+ declare const parse: (text: string) => Root;
6
+ declare const facts: (text: string, options?: DocumentOptions) => DocumentFacts;
7
+ export { id, exts, parse, facts };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.facts = exports.parse = exports.exts = exports.id = void 0;
27
+ // Plain CSS. The reference language: it is only a parser plus the shared
28
+ // document reading, so everything it reports is available to every other syntax.
29
+ const postcss = __importStar(require("postcss"));
30
+ const document_1 = require("../styled/document");
31
+ const id = "css";
32
+ exports.id = id;
33
+ const exts = [".css"];
34
+ exports.exts = exts;
35
+ const parse = (text) => postcss.parse(text, { from: undefined });
36
+ exports.parse = parse;
37
+ // A CSS custom property (`--x`) is this syntax's variable declaration; a plain
38
+ // `color` is not. The name kept is exactly what a `var(--x)` reference names.
39
+ const variableName = (prop) => (prop.startsWith("--") ? prop : null);
40
+ const facts = (text, options = {}) => (0, document_1.documentFacts)(text, { ...options, parse, syntax: id, variableNameOf: variableName });
41
+ exports.facts = facts;
@@ -0,0 +1,3 @@
1
+ import type { VariableToken } from "../language";
2
+ declare const references: (text: string) => VariableToken | null;
3
+ export { references };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.references = void 0;
4
+ // How a CSS value REFERS to a variable: `var(--x)`. The reader is the language's
5
+ // own — the substitution walk only asks every registered language for its next
6
+ // reference and takes the earliest. A reference may carry a fallback
7
+ // (`var(--x, 4px)`), which is used only when the name is undeclared.
8
+ const text_1 = require("../../../utils/text");
9
+ const CSS_VARIABLE_RE = /\bvar\(\s*(--[\w-]+)/;
10
+ const cssToken = (text, match) => {
11
+ const open = text.indexOf("(", match.index);
12
+ const close = (0, text_1.closingParen)(text, open);
13
+ if (close < 0)
14
+ return { name: match[1], start: match.index, end: text.length, fallback: null, broken: { kind: "unterminated-var" } };
15
+ const inner = text.slice(open + 1, close);
16
+ const comma = (0, text_1.topLevelComma)(inner);
17
+ return { name: match[1], start: match.index, end: close + 1, fallback: comma < 0 ? null : inner.slice(comma + 1).trim(), broken: null };
18
+ };
19
+ // The next `var(--x)` in the text, or null.
20
+ const references = (text) => {
21
+ const match = CSS_VARIABLE_RE.exec(text);
22
+ return match ? cssToken(text, match) : null;
23
+ };
24
+ exports.references = references;
@@ -0,0 +1,25 @@
1
+ import type { Root } from "postcss";
2
+ import type { DocumentFacts, DocumentOptions } from "./styled/document";
3
+ import type { BranchProblem, Span } from "../value/pieces";
4
+ type VariableToken = Span & {
5
+ name: string;
6
+ fallback: string | null;
7
+ broken: BranchProblem | null;
8
+ };
9
+ type ReferenceTokenizer = (text: string) => VariableToken | null;
10
+ interface StyleLanguage {
11
+ id: string;
12
+ exts: string[];
13
+ parse: (text: string) => Root;
14
+ facts: (text: string, options?: DocumentOptions) => DocumentFacts;
15
+ referenceTokens?: ReferenceTokenizer[];
16
+ }
17
+ declare const register: (language: StyleLanguage) => StyleLanguage;
18
+ declare const list: () => StyleLanguage[];
19
+ declare const byId: (id: string) => StyleLanguage | null;
20
+ declare const forExt: (ext: string | null | undefined) => StyleLanguage | null;
21
+ declare const forFile: (rel: string | null | undefined) => StyleLanguage | null;
22
+ declare const referenceTokenizers: () => ReferenceTokenizer[];
23
+ declare const reset: () => void;
24
+ export { register, list, byId, forExt, forFile, referenceTokenizers, reset };
25
+ export type { StyleLanguage, ReferenceTokenizer, VariableToken };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.reset = exports.referenceTokenizers = exports.forFile = exports.forExt = exports.byId = exports.list = exports.register = void 0;
27
+ const configError = __importStar(require("../../report/configErrors"));
28
+ const cssLanguage = __importStar(require("./css"));
29
+ const sassLanguage = __importStar(require("./scss"));
30
+ const reference_1 = require("./css/reference");
31
+ const reference_2 = require("./scss/reference");
32
+ const languages = new Map();
33
+ const register = (language) => {
34
+ if (!language?.id || typeof language.facts !== "function")
35
+ throw configError.styleLanguageIncomplete();
36
+ languages.set(language.id, { exts: [], ...language });
37
+ return language;
38
+ };
39
+ exports.register = register;
40
+ const list = () => [...languages.values()];
41
+ exports.list = list;
42
+ const byId = (id) => languages.get(id) ?? null;
43
+ exports.byId = byId;
44
+ // Which language claims a file: by extension. No language, no facts — a syntax
45
+ // nobody registered is not silently read as CSS.
46
+ const forExt = (ext) => {
47
+ const wanted = String(ext ?? "").toLowerCase();
48
+ return list().find((language) => language.exts.includes(wanted)) ?? null;
49
+ };
50
+ exports.forExt = forExt;
51
+ const forFile = (rel) => {
52
+ const ext = String(rel ?? "").toLowerCase().match(/\.[a-z0-9]+$/)?.[0] ?? "";
53
+ return forExt(ext);
54
+ };
55
+ exports.forFile = forFile;
56
+ // Every registered language's reference tokenizers, flattened — what the
57
+ // substitution walk asks for, so it takes the earliest match of all notations.
58
+ const referenceTokenizers = () => list().flatMap((language) => language.referenceTokens ?? []);
59
+ exports.referenceTokenizers = referenceTokenizers;
60
+ // Test hook and extension point: the built-ins are registered on load, and a
61
+ // consumer may register its own or replace one.
62
+ const reset = () => {
63
+ languages.clear();
64
+ register({ ...cssLanguage, referenceTokens: [reference_1.references] });
65
+ register({ ...sassLanguage, referenceTokens: [reference_2.references] });
66
+ };
67
+ exports.reset = reset;
68
+ register({ ...cssLanguage, referenceTokens: [reference_1.references] });
69
+ register({ ...sassLanguage, referenceTokens: [reference_2.references] });
@@ -0,0 +1,25 @@
1
+ import type { Root } from "postcss";
2
+ import { type DocumentFacts, type DocumentOptions } from "../styled/document";
3
+ import type { Located } from "../../../entities/facts";
4
+ declare const id = "scss";
5
+ declare const exts: string[];
6
+ declare const parse: (text: string) => Root;
7
+ declare const variablesOf: (root: Root) => (Located & {
8
+ name: string;
9
+ line: number | null;
10
+ value: string;
11
+ })[];
12
+ type ScssVariable = ReturnType<typeof variablesOf>[number];
13
+ declare const mixinsOf: (root: Root) => (Located & {
14
+ name: string;
15
+ line: number | null;
16
+ kind: string;
17
+ })[];
18
+ type ScssMixin = ReturnType<typeof mixinsOf>[number];
19
+ declare const facts: (text: string, options?: DocumentOptions) => DocumentFacts & {
20
+ variables: ScssVariable[];
21
+ mixins: ScssMixin[];
22
+ };
23
+ type ScssFacts = ReturnType<typeof facts>;
24
+ export { id, exts, parse, facts };
25
+ export type { ScssFacts, ScssVariable, ScssMixin };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.facts = exports.parse = exports.exts = exports.id = void 0;
27
+ // SCSS: the same document, read with a parser that understands `$vars`, nesting
28
+ // and `//` comments — PLUS the facts only this syntax has.
29
+ //
30
+ // This language is the proof that the facet is extensible: it adds two things
31
+ // (`variables`, `mixins`) and inherits every rule written against
32
+ // `css.declarations`, `css.rules`, `css.literals`. Nothing in the engine knows
33
+ // SCSS exists; a rule that asks about `$gap` asks because THIS file says the
34
+ // syntax has variables.
35
+ const postcssScss = __importStar(require("postcss-scss"));
36
+ const document_1 = require("../styled/document");
37
+ const id = "scss";
38
+ exports.id = id;
39
+ const exts = [".scss", ".sass"];
40
+ exports.exts = exts;
41
+ const parse = (text) => postcssScss.parse(text, { from: undefined });
42
+ exports.parse = parse;
43
+ // `$gap: 4px;` is a declaration whose prop is a variable. Both readings below
44
+ // are what a "values live in variables" rule needs. A named, located thing —
45
+ // the canonical `Located` shape, plus the value a variable holds.
46
+ const variablesOf = (root) => {
47
+ const variables = [];
48
+ root.walkDecls((decl) => {
49
+ if (!decl.prop.startsWith("$"))
50
+ return;
51
+ variables.push({ name: decl.prop.slice(1), value: String(decl.value), line: decl.source?.start?.line ?? null });
52
+ });
53
+ return variables;
54
+ };
55
+ // `@mixin x` / `@function x` are at-rules that declare a reusable block. A named,
56
+ // located thing, plus which kind of block it is.
57
+ const mixinsOf = (root) => {
58
+ const mixins = [];
59
+ root.walkAtRules((atRule) => {
60
+ if (atRule.name !== "mixin" && atRule.name !== "function")
61
+ return;
62
+ mixins.push({ kind: atRule.name, name: String(atRule.params).trim(), line: atRule.source?.start?.line ?? null });
63
+ });
64
+ return mixins;
65
+ };
66
+ // An SCSS `$var` (or a CSS custom property, which SCSS also allows) is this
67
+ // syntax's variable declaration. The name kept is exactly what the `$gap` /
68
+ // `var(--x)` reference names, so the resolver looks it up in one map by name.
69
+ const variableName = (prop) => (prop.startsWith("$") || prop.startsWith("--") ? prop : null);
70
+ // `$gap` is a variable reference in a value, not a `var()` call — the reading
71
+ // says so, the rule decides whether that is allowed.
72
+ const SCSS_VAR_RE = /\$([\w-]+)/g;
73
+ const valueVars = (facts) => facts.declarations.flatMap((decl) => [...String(decl.value).matchAll(SCSS_VAR_RE)].map((m) => `$${m[1]}`));
74
+ // The SCSS fact set: the shared document facts plus what only this syntax has.
75
+ const facts = (text, options = {}) => {
76
+ const base = (0, document_1.documentFacts)(text, { ...options, parse, syntax: id, variableNameOf: variableName });
77
+ const root = parse(text);
78
+ return {
79
+ ...base,
80
+ variables: variablesOf(root),
81
+ mixins: mixinsOf(root),
82
+ vars: [...new Set([...base.vars, ...valueVars(base)])],
83
+ };
84
+ };
85
+ exports.facts = facts;
@@ -0,0 +1,3 @@
1
+ import type { VariableToken } from "../language";
2
+ declare const references: (text: string) => VariableToken | null;
3
+ export { references };