@md-code/follow-architecture 0.1.0 → 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 (436) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +597 -126
  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 +62 -19
  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 -82
  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 -95
  435. package/report.js +0 -73
  436. package/utils.js +0 -104
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetEngine = exports.engine = exports.structureOf = exports.utilityFacts = exports.classFacts = void 0;
4
+ // Tailwind is CSS written in an attribute: `className="flex p-4 text-sm"` is a
5
+ // declaration list that happens to live in a string. So it is read here, in the
6
+ // CSS facet, and not by the React facet — a Vue template has the same attribute
7
+ // and must produce the same facts.
8
+ //
9
+ // What is read is deliberately structural, not a Tailwind build:
10
+ // variant `md:hover:` — the conditions the utility applies under
11
+ // utility `p-4` — the part that names the property
12
+ // value `4` — with `[13px]` kept as `arbitrary`, because an arbitrary value
13
+ // is exactly the hardcoded literal a design system wants to own
14
+ // properties what Tailwind's own generator says the class SETS
15
+ // (`p-4` → `padding`), so "is this a colour utility" is a question
16
+ // about facts, answered in the architecture config
17
+ //
18
+ // Updating Tailwind is `pnpm update`: new classes appear here by themselves,
19
+ // because nothing in this file enumerates them.
20
+ const tokenize_1 = require("../../../utils/tokenize");
21
+ const notices_1 = require("../../../report/notices");
22
+ const reason_1 = require("../../../utils/reason");
23
+ const split_1 = require("../../../utils/split");
24
+ const tailwind_engine_1 = require("./tailwind-engine");
25
+ let loaded = null;
26
+ // What a token SETS, read off the CSS Tailwind generated for it. Declarations
27
+ // only — `@media (min-width: …)` is a condition, not a property the utility
28
+ // assigns. One cache per run: the same class is read hundreds of times.
29
+ const propertiesReader = (context) => {
30
+ const generate = (0, tailwind_engine_1.loadGenerate)();
31
+ const cache = new Map();
32
+ return (candidate) => {
33
+ const cached = cache.get(candidate);
34
+ if (cached)
35
+ return cached;
36
+ let properties = [];
37
+ try {
38
+ const props = new Set();
39
+ for (const [, rule] of generate.generateRules([candidate], context)) {
40
+ rule.walkDecls((decl) => {
41
+ props.add(decl.prop);
42
+ });
43
+ }
44
+ properties = [...props].sort();
45
+ }
46
+ catch (error) {
47
+ // A token Tailwind throws on is a token it does not know — said out loud,
48
+ // because "no properties" and "could not ask" are different answers.
49
+ const e = error;
50
+ (0, notices_1.notice)(`the Tailwind class \`${candidate}\` could not be read`, (0, reason_1.reasonOf)(e));
51
+ properties = [];
52
+ }
53
+ cache.set(candidate, properties);
54
+ return properties;
55
+ };
56
+ };
57
+ const engine = () => {
58
+ if (loaded !== null)
59
+ return loaded;
60
+ try {
61
+ const context = (0, tailwind_engine_1.loadSetup)().createContext((0, tailwind_engine_1.baseConfig)());
62
+ loaded = { version: (0, tailwind_engine_1.loadVersion)(), propertiesOf: propertiesReader(context) };
63
+ }
64
+ catch (error) {
65
+ // Every class fact below is UNKNOWN — never a guess — and the reason is
66
+ // reported, so a silently empty class list cannot pass for a clean one.
67
+ const e = error;
68
+ (0, notices_1.notice)("Tailwind could not be loaded, so class facts are unknown", (0, reason_1.reasonOf)(e));
69
+ loaded = false;
70
+ }
71
+ return loaded;
72
+ };
73
+ exports.engine = engine;
74
+ // The value a utility names: an arbitrary `[13px]` is kept whole, a `p-4` gives
75
+ // `4`, a bare `flex` gives nothing. One helper, no nested ternary.
76
+ const utilityValue = (utility, arbitrary, dashIndex) => {
77
+ if (arbitrary !== null)
78
+ return arbitrary;
79
+ if (dashIndex === -1)
80
+ return null;
81
+ return utility.slice(dashIndex + 1);
82
+ };
83
+ // `md:hover:p-[13px]` → { raw, variants: ["md","hover"], utility: "p-[13px]", base: "p", value: "13px", arbitrary: true, negative: false }
84
+ const structureOf = (raw) => {
85
+ const text = String(raw);
86
+ // A class token is cut by `:` the same way a path is cut by `/` — the shared
87
+ // split core; the parts before the last are the variants, the last is the utility.
88
+ const { head: variants, last: utility } = (0, split_1.partsOf)(text, ":");
89
+ const arbitraryMatch = utility.match(/^(.*?)-\[(.+)\]$/);
90
+ const dashIndex = utility.indexOf("-");
91
+ return {
92
+ raw: text,
93
+ variants,
94
+ utility,
95
+ base: dashIndex === -1 ? utility : utility.slice(0, dashIndex),
96
+ value: utilityValue(utility, arbitraryMatch ? arbitraryMatch[2] : null, dashIndex),
97
+ arbitrary: Boolean(arbitraryMatch),
98
+ negative: utility.startsWith("-"),
99
+ };
100
+ };
101
+ exports.structureOf = structureOf;
102
+ // One token as a fact. `known` is `null` when Tailwind is absent — the
103
+ // difference between "not a Tailwind class" and "nobody asked Tailwind".
104
+ const utilityFacts = (raw) => {
105
+ const structure = structureOf(raw);
106
+ const tailwind = engine();
107
+ if (!tailwind)
108
+ return { ...structure, known: null, properties: [] };
109
+ const properties = tailwind.propertiesOf(structure.raw);
110
+ return { ...structure, known: properties.length > 0, properties };
111
+ };
112
+ exports.utilityFacts = utilityFacts;
113
+ const classFacts = (text) => (0, tokenize_1.tokenize)(text).map(utilityFacts);
114
+ exports.classFacts = classFacts;
115
+ const resetEngine = () => {
116
+ loaded = null;
117
+ };
118
+ exports.resetEngine = resetEngine;
@@ -0,0 +1,86 @@
1
+ import type { Span } from "./pieces";
2
+ interface CssLocation {
3
+ start: {
4
+ offset: number;
5
+ line: number;
6
+ column: number;
7
+ };
8
+ end: {
9
+ offset: number;
10
+ line: number;
11
+ column: number;
12
+ };
13
+ }
14
+ interface CssNode {
15
+ type: string;
16
+ name?: string;
17
+ value?: string;
18
+ unit?: string | null;
19
+ children?: {
20
+ first: CssNode | null;
21
+ forEach: (visit: (node: CssNode) => void) => void;
22
+ } | null;
23
+ loc?: CssLocation | null;
24
+ }
25
+ interface MatchError {
26
+ message?: string;
27
+ rawMessage?: string;
28
+ offset?: number;
29
+ mismatchOffset?: number;
30
+ mismatchLength?: number;
31
+ }
32
+ interface TypeSyntaxNode {
33
+ type?: string;
34
+ name?: string;
35
+ terms?: readonly TypeSyntaxNode[];
36
+ term?: TypeSyntaxNode;
37
+ syntax?: TypeSyntaxNode;
38
+ }
39
+ type TypeDefinition = TypeSyntaxNode & {
40
+ name: string;
41
+ syntax: TypeSyntaxNode;
42
+ };
43
+ interface PropertyResult {
44
+ custom: boolean;
45
+ basename: string;
46
+ name: string;
47
+ }
48
+ interface ParseOptions {
49
+ context?: string;
50
+ positions?: boolean;
51
+ }
52
+ interface WalkOptions {
53
+ enter?: (node: CssNode) => void;
54
+ leave?: (node: CssNode) => void;
55
+ }
56
+ interface CssTree {
57
+ lexer: {
58
+ properties: Record<string, object>;
59
+ types: Record<string, TypeDefinition>;
60
+ getType: (name: string) => TypeDefinition | null;
61
+ matchType: (type: string, value: string) => {
62
+ error: MatchError | null;
63
+ };
64
+ matchProperty: (property: string, value: string) => {
65
+ error: MatchError | null;
66
+ };
67
+ };
68
+ property: (raw: string) => PropertyResult;
69
+ parse: (text: string, options?: ParseOptions) => CssNode;
70
+ walk: (ast: CssNode, options: WalkOptions) => void;
71
+ generate: (node: CssNode) => string;
72
+ }
73
+ declare const cssTree: CssTree;
74
+ type ProblemKind = "math" | "property" | "unknown";
75
+ type ValueProblem = {
76
+ kind: ProblemKind;
77
+ span: Span;
78
+ detail: string | null;
79
+ };
80
+ type Verdict = {
81
+ valid: boolean | null;
82
+ problems: ValueProblem[];
83
+ };
84
+ declare const checkValue: (property: string, value: string) => Verdict;
85
+ export { cssTree, checkValue };
86
+ export type { CssNode, CssLocation, MatchError, TypeDefinition, TypeSyntaxNode, PropertyResult, ParseOptions, WalkOptions, CssTree, Span, ProblemKind, ValueProblem, Verdict };
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkValue = exports.cssTree = void 0;
4
+ // THE SYNTAX VERDICT on one concrete value, as STRUCTURED facts — never a
5
+ // sentence — together with the TYPED view of the grammar it asks. css-tree ships
6
+ // no declarations, so its surface is modelled here once (the value grammar:
7
+ // `parse`, `walk`, `generate`, and the property/type dictionaries); the verdict
8
+ // below is the one reading every value resolver asks for.
9
+ //
10
+ // css-tree owns the property grammar and the math-function grammar; the one gap
11
+ // its property matcher leaves is that it accepts a broken math function
12
+ // (`calc(2+)`, `min()`, `clamp(1px)`) — it parses `calc()` lazily and never looks
13
+ // inside. So every MATH function call is walked and matched against the grammar
14
+ // of its own function type (`calc()`, `min()`, `max()`, `clamp()`, … — whatever
15
+ // css-tree defines as a math function), and only then is the whole value matched
16
+ // against the property.
17
+ //
18
+ // A problem carries a KIND and a SPAN into the value; the report layer composes
19
+ // the sentence. An unknown property, or a custom property, has no property
20
+ // verdict: `valid: null` (custom: `true`) says "not checkable", which is
21
+ // different from "wrong".
22
+ const node_module_1 = require("node:module");
23
+ const text_1 = require("../../utils/text");
24
+ const requireModule = (0, node_module_1.createRequire)(__filename);
25
+ const cssTree = requireModule("css-tree");
26
+ exports.cssTree = cssTree;
27
+ const wholeValue = (value) => ({ start: 0, end: value.length });
28
+ // Does a grammar syntax tree (transitively) build on `calc-sum`? That is the
29
+ // grammar's OWN word for "a math function", so recognising one needs no list of
30
+ // names: `calc`, `min`, `max`, `clamp`, `round`, `hypot`, `abs`, `sin` … all
31
+ // reference `calc-sum`; `blur`, `rgb`, `var` do not. A new math function in the
32
+ // grammar is recognised the moment css-tree knows it.
33
+ const referencesCalcSum = (node, seen = new Set()) => {
34
+ if (seen.has(node))
35
+ return false;
36
+ seen.add(node);
37
+ if (node.type === "Type" && node.name === "calc-sum")
38
+ return true;
39
+ return [node.term, node.syntax, ...(node.terms ?? [])].some((child) => child !== undefined && referencesCalcSum(child, seen));
40
+ };
41
+ // The math function names, read once from the grammar's type dictionary.
42
+ let mathNames = null;
43
+ const mathFunctionNames = () => {
44
+ if (mathNames)
45
+ return mathNames;
46
+ const names = new Set();
47
+ for (const [typeName, definition] of Object.entries(cssTree.lexer.types ?? {})) {
48
+ if (typeName.endsWith("()") && referencesCalcSum(definition.syntax))
49
+ names.add(typeName.slice(0, -2));
50
+ }
51
+ mathNames = names;
52
+ return names;
53
+ };
54
+ const spanOfNode = (node, value) => {
55
+ const loc = node.loc;
56
+ if (!loc)
57
+ return wholeValue(value);
58
+ return { start: loc.start.offset, end: loc.end.offset };
59
+ };
60
+ // Walk the parsed value: every math function call is matched against its OWN
61
+ // function-type grammar. The property matcher accepts a broken call — this is
62
+ // the gap that fills. A call mentioning `var()` has an argument only
63
+ // substitution can settle, so it is left unjudged; a broken call is not
64
+ // descended into (the spanning problem already covers everything inside it).
65
+ const mathProblems = (node, value, out) => {
66
+ if (node.type === "Function" && node.name && mathFunctionNames().has(node.name)) {
67
+ const text = cssTree.generate(node);
68
+ if (!text.includes("var(")) {
69
+ const match = cssTree.lexer.matchType(`${node.name}()`, text);
70
+ if (match.error) {
71
+ out.push({ kind: "math", span: spanOfNode(node, value), detail: (0, text_1.firstLine)(match.error.message ?? "") });
72
+ return;
73
+ }
74
+ }
75
+ }
76
+ node.children?.forEach((child) => mathProblems(child, value, out));
77
+ };
78
+ // The span a property mismatch points at: `mismatchOffset`/`mismatchLength`
79
+ // bound the offending token; a grammar that names no token spans the value.
80
+ const mismatchSpan = (error, value) => {
81
+ const start = Math.min(Math.max(error.mismatchOffset ?? error.offset ?? 0, 0), value.length);
82
+ const length = Math.max(error.mismatchLength ?? 0, 0);
83
+ const end = length > 0 ? Math.min(start + length, value.length) : value.length;
84
+ return { start, end };
85
+ };
86
+ const parseValue = (value) => {
87
+ try {
88
+ return cssTree.parse(value, { context: "value", positions: true });
89
+ }
90
+ catch {
91
+ return null;
92
+ }
93
+ };
94
+ // Check one concrete value against CSS syntax. A custom property has no property
95
+ // verdict (`valid: true`) but its math calls are still checked. An unknown
96
+ // property is "not checkable" (`valid: null`), reported as an `unknown` problem
97
+ // so the fact is explicit — never guessed in either direction.
98
+ const checkValue = (property, value) => {
99
+ const text = String(value);
100
+ const problems = [];
101
+ const ast = parseValue(text);
102
+ if (ast)
103
+ mathProblems(ast, text, problems);
104
+ if (problems.length)
105
+ return { valid: false, problems };
106
+ if (property.startsWith("--"))
107
+ return { valid: true, problems: [] };
108
+ try {
109
+ const match = cssTree.lexer.matchProperty(property, text);
110
+ if (!match.error)
111
+ return { valid: true, problems: [] };
112
+ const detail = (0, text_1.firstLine)(match.error.message ?? "");
113
+ if (/unknown property|not applicable/i.test(detail))
114
+ return { valid: null, problems: [{ kind: "unknown", span: wholeValue(text), detail }] };
115
+ return { valid: false, problems: [{ kind: "property", span: mismatchSpan(match.error, text), detail }] };
116
+ }
117
+ catch (error) {
118
+ const detail = (0, text_1.firstLine)(error instanceof Error ? error.message : String(error));
119
+ return { valid: null, problems: [{ kind: "unknown", span: wholeValue(text), detail }] };
120
+ }
121
+ };
122
+ exports.checkValue = checkValue;
@@ -0,0 +1,7 @@
1
+ import { Node } from "ts-morph";
2
+ import { type ObjectReading, type Bindings, type ValueResult } from "../pieces";
3
+ import type { Scope } from "../scope";
4
+ declare const ARITHMETIC: Map<string, (left: number, right: number) => number>;
5
+ declare const arithmeticValues: (op: string, left: readonly ObjectReading[], right: readonly ObjectReading[]) => ObjectReading[] | null;
6
+ declare const binaryValue: (node: Node, scope: Scope, bindings: Bindings) => ValueResult;
7
+ export { binaryValue, arithmeticValues, ARITHMETIC };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ARITHMETIC = exports.arithmeticValues = exports.binaryValue = void 0;
4
+ // ARITHMETIC reads: `a + b` (strings concatenate, two numbers add), `a - b`,
5
+ // `a * b`, `a / b` (numbers only), and the dispatch to the logical operators
6
+ // before the arithmetic ones. Anything else is not folded — it is reported.
7
+ const ts_morph_1 = require("ts-morph");
8
+ const conditional_1 = require("./conditional");
9
+ const index_1 = require("./index");
10
+ const pieces_1 = require("../pieces");
11
+ const text_1 = require("../../../utils/text");
12
+ // Folding arithmetic over readings. `+` concatenates (or adds two numbers); the
13
+ // arithmetic operators fold two NUMBERS only (a rhythm is `origin * 2`). The
14
+ // operator table is the one place the operators are named; anything not in it is
15
+ // handled by `sumOrConcat` (for `+`) or is a guess, so the caller reports it.
16
+ const ARITHMETIC = new Map([
17
+ ["-", (left, right) => left - right],
18
+ ["*", (left, right) => left * right],
19
+ ["/", (left, right) => left / right],
20
+ ]);
21
+ exports.ARITHMETIC = ARITHMETIC;
22
+ // Two numeric spellings add; anything else is a concatenation (`` `${n}` + "px" ``).
23
+ const sumOrConcat = (a, b) => {
24
+ const numeric = a.trim() !== "" && b.trim() !== "" && Number.isFinite(Number(a)) && Number.isFinite(Number(b));
25
+ return numeric ? String(Number(a) + Number(b)) : a + b;
26
+ };
27
+ // The numeric result of `a <op> b` over two readings, or null when either side
28
+ // is not a number (a string `+` is concatenation, not arithmetic).
29
+ const numericReading = (left, right, combineNumbers) => {
30
+ const a = Number(left.text.trim());
31
+ const b = Number(right.text.trim());
32
+ if (left.text.trim() === "" || right.text.trim() === "" || !Number.isFinite(a) || !Number.isFinite(b))
33
+ return null;
34
+ return { text: String(combineNumbers(a, b)), origin: left.origin ?? right.origin, dynamic: left.dynamic || right.dynamic };
35
+ };
36
+ // The readings `a <op> b` reaches, from the readings each side produced. Null
37
+ // when no pair of readings can be combined.
38
+ const arithmeticValues = (op, left, right) => {
39
+ const combineNumbers = ARITHMETIC.get(op);
40
+ const values = left.flatMap((a) => right.flatMap((b) => {
41
+ if (!combineNumbers)
42
+ return [{ text: sumOrConcat(a.text, b.text), origin: a.origin ?? b.origin, dynamic: a.dynamic || b.dynamic }];
43
+ const numeric = numericReading(a, b, combineNumbers);
44
+ return numeric ? [numeric] : [];
45
+ }));
46
+ return values.length ? values : null;
47
+ };
48
+ exports.arithmeticValues = arithmeticValues;
49
+ // `a + b`: strings concatenate, two numbers add. Anything else is a guess, so it
50
+ // is reported instead.
51
+ const binaryValue = (node, scope, bindings) => {
52
+ if (!ts_morph_1.Node.isBinaryExpression(node))
53
+ return (0, pieces_1.noValue)({ kind: "unresolved-expr", text: (0, text_1.firstLine)(node.getText()) });
54
+ const op = node.getOperatorToken().getText();
55
+ const logical = (0, conditional_1.logicalValue)(op, node, scope, bindings);
56
+ if (logical)
57
+ return logical;
58
+ if (op !== "+" && !ARITHMETIC.has(op))
59
+ return (0, pieces_1.noValue)({ kind: "unresolved-expr", text: (0, text_1.firstLine)(node.getText()) });
60
+ const left = (0, index_1.expressionValue)(node.getLeft(), scope, bindings);
61
+ const right = (0, index_1.expressionValue)(node.getRight(), scope, bindings);
62
+ if (left.problems.length || right.problems.length)
63
+ return { values: [], problems: [...left.problems, ...right.problems] };
64
+ const values = arithmeticValues(op, left.values, right.values);
65
+ if (!values)
66
+ return (0, pieces_1.noValue)({ kind: "unresolved-expr", text: (0, text_1.firstLine)(node.getText()) });
67
+ return { values, problems: [], dynamic: values.some((value) => value.dynamic) ? true : undefined };
68
+ };
69
+ exports.binaryValue = binaryValue;
@@ -0,0 +1,9 @@
1
+ import { Node, type Block } from "ts-morph";
2
+ import { type Bindings, type ValueResult } from "../pieces";
3
+ import type { Scope } from "../scope";
4
+ declare const firstReturnExpression: (body: Block) => Node | undefined;
5
+ declare const blockValue: (body: Block, scope: Scope, bindings: Bindings) => ValueResult;
6
+ declare const functionValue: (node: Node, scope: Scope, bindings: Bindings) => ValueResult;
7
+ declare const nameRootOf: (node: Node) => Node | null;
8
+ declare const isDirective: (node: Node, seen?: Set<Node>) => boolean;
9
+ export { isDirective, nameRootOf, functionValue, blockValue, firstReturnExpression };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.firstReturnExpression = exports.blockValue = exports.functionValue = exports.nameRootOf = exports.isDirective = void 0;
4
+ // An expression whose meaning is a nested STYLE BLOCK rather than a value, and
5
+ // the folding of a function-valued expression to its return value. The check
6
+ // follows the SAME names the value resolver follows: a tagged template is a
7
+ // block; a name is whatever its initializer is; a short-circuit/conditional whose
8
+ // arm is a block is a block. A plain template literal is a VALUE (a media query,
9
+ // a concatenation), never a block.
10
+ const ts_morph_1 = require("ts-morph");
11
+ const node_1 = require("../object/node");
12
+ const pieces_1 = require("../pieces");
13
+ const index_1 = require("./index");
14
+ const firstReturnExpression = (body) => {
15
+ const statement = body.getStatements().find((candidate) => ts_morph_1.Node.isReturnStatement(candidate));
16
+ if (!statement || !ts_morph_1.Node.isReturnStatement(statement))
17
+ return undefined;
18
+ return statement.getExpression() ?? undefined;
19
+ };
20
+ exports.firstReturnExpression = firstReturnExpression;
21
+ // A function body that returns a template BLOCK is not a value — its
22
+ // declarations are read as a template of their own, not guessed.
23
+ const blockValue = (body, scope, bindings) => {
24
+ const expression = firstReturnExpression(body);
25
+ if (!expression)
26
+ return (0, pieces_1.noValue)({ kind: "no-return" });
27
+ if (ts_morph_1.Node.isTemplateExpression(expression) || ts_morph_1.Node.isNoSubstitutionTemplateLiteral(expression))
28
+ return (0, pieces_1.noValue)({ kind: "template-block" });
29
+ return (0, index_1.expressionValue)(expression, scope, bindings);
30
+ };
31
+ exports.blockValue = blockValue;
32
+ // The body of a function-like expression, if it has one.
33
+ const bodyOf = (node) => {
34
+ if (ts_morph_1.Node.isArrowFunction(node) || ts_morph_1.Node.isFunctionExpression(node))
35
+ return node.getBody();
36
+ return null;
37
+ };
38
+ // A function expression used in value position: its return value is the value.
39
+ const functionValue = (node, scope, bindings) => {
40
+ const body = bodyOf(node);
41
+ if (!body)
42
+ return (0, pieces_1.noValue)({ kind: "not-a-value" });
43
+ if (ts_morph_1.Node.isBlock(body))
44
+ return blockValue(body, scope, bindings);
45
+ return (0, index_1.expressionValue)(body, scope, bindings);
46
+ };
47
+ exports.functionValue = functionValue;
48
+ const DIRECTIVE_OPERATORS = new Set(["&&", "||", "??"]);
49
+ // The identifier a member chain starts from, when the whole chain is a static
50
+ // path (`sizes.desktop.width` → `sizes`); otherwise there is no name to follow.
51
+ const nameRootOf = (node) => {
52
+ const path = (0, node_1.chainPath)(node);
53
+ const root = (0, node_1.rootIdentifierOf)(node);
54
+ return path && ts_morph_1.Node.isIdentifier(root) ? root : null;
55
+ };
56
+ exports.nameRootOf = nameRootOf;
57
+ const directiveOfFunction = (node, seen) => {
58
+ const body = ts_morph_1.Node.isArrowFunction(node) || ts_morph_1.Node.isFunctionExpression(node) ? node.getBody() : null;
59
+ return body === null ? false : !ts_morph_1.Node.isBlock(body) && isDirective(body, seen);
60
+ };
61
+ const directiveOfBinary = (node, seen) => {
62
+ if (!ts_morph_1.Node.isBinaryExpression(node) || !DIRECTIVE_OPERATORS.has(node.getOperatorToken().getText()))
63
+ return false;
64
+ return isDirective(node.getLeft(), seen) || isDirective(node.getRight(), seen);
65
+ };
66
+ const directiveOfConditional = (node, seen) => ts_morph_1.Node.isConditionalExpression(node) && (isDirective(node.getWhenTrue(), seen) || isDirective(node.getWhenFalse(), seen));
67
+ const directiveOfName = (node, seen) => {
68
+ const root = nameRootOf(node);
69
+ const initializer = root === null ? null : (0, node_1.initializerOf)(root);
70
+ return initializer !== null && isDirective(initializer, seen);
71
+ };
72
+ // Which reader answers which node kind. A tagged template is the block itself;
73
+ // the others either contain one or name one.
74
+ const DIRECTIVE_READERS = new Map([
75
+ ["TaggedTemplateExpression", () => true],
76
+ ["ArrowFunction", directiveOfFunction],
77
+ ["FunctionExpression", directiveOfFunction],
78
+ ["BinaryExpression", directiveOfBinary],
79
+ ["ConditionalExpression", directiveOfConditional],
80
+ ["Identifier", directiveOfName],
81
+ ["PropertyAccessExpression", directiveOfName],
82
+ ["ElementAccessExpression", directiveOfName],
83
+ ]);
84
+ const isDirective = (node, seen = new Set()) => {
85
+ const current = (0, node_1.unwrap)(node);
86
+ if (seen.has(current))
87
+ return false;
88
+ const reader = DIRECTIVE_READERS.get(current.getKindName());
89
+ return reader ? reader(current, new Set([...seen, current])) : false;
90
+ };
91
+ exports.isDirective = isDirective;
@@ -0,0 +1,8 @@
1
+ import { Node, type ConditionalExpression } from "ts-morph";
2
+ import { type Bindings, type ValueResult } from "../pieces";
3
+ import type { Scope } from "../scope";
4
+ declare const fallbackValue: (left: Node, right: Node, scope: Scope, bindings: Bindings) => ValueResult;
5
+ declare const andValue: (left: Node, right: Node, scope: Scope, bindings: Bindings) => ValueResult;
6
+ declare const conditionalValue: (node: ConditionalExpression, scope: Scope, bindings: Bindings) => ValueResult;
7
+ declare const logicalValue: (op: string, node: Node, scope: Scope, bindings: Bindings) => ValueResult | null;
8
+ export { conditionalValue, fallbackValue, andValue, logicalValue };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logicalValue = exports.andValue = exports.fallbackValue = exports.conditionalValue = void 0;
4
+ // CONDITIONAL reads: `cond ? a : b` (both arms reachable, enumerated) and the
5
+ // logical chain (`a && b`, `a ?? b`, `a || b`). The condition is runtime data and
6
+ // is not evaluated — only the consequences are read.
7
+ const ts_morph_1 = require("ts-morph");
8
+ const index_1 = require("./index");
9
+ const pieces_1 = require("../pieces");
10
+ // `a ?? b` / `a || b`: the LEFT reading wins when it reaches anything; only an
11
+ // unreadable or empty left falls through to the right. A fallback COVERS the
12
+ // object literals the left branch is `absent` in (a missing key falls back to the
13
+ // zone), so the absent list is dropped here — never reported as an incomplete
14
+ // literal when the fallback paints it.
15
+ const fallbackValue = (left, right, scope, bindings) => {
16
+ const first = (0, index_1.expressionValue)(left, scope, bindings);
17
+ // A dynamic left is not a reading to keep (its placeholder is a shape, not a
18
+ // value): the fallback is still read, and the dynamic arm stays beside it.
19
+ if (first.dynamic)
20
+ return (0, pieces_1.combine)((0, index_1.expressionValue)(right, scope, bindings), first);
21
+ if (first.values.length)
22
+ return { values: first.values, problems: [], absent: first.absent };
23
+ return (0, index_1.expressionValue)(right, scope, bindings);
24
+ };
25
+ exports.fallbackValue = fallbackValue;
26
+ // `a && b`: the RIGHT side when `a` is a readable value (both readings possible),
27
+ // or the right side alone when `a` is the runtime condition (`$x && spec.color`
28
+ // — `$x` picks whether a colour is painted, it is not the colour).
29
+ const andValue = (left, right, scope, bindings) => {
30
+ const first = (0, index_1.expressionValue)(left, scope, bindings);
31
+ const second = (0, index_1.expressionValue)(right, scope, bindings);
32
+ if (first.values.length)
33
+ return { values: [...first.values, ...second.values], problems: second.problems, absent: first.absent };
34
+ return second;
35
+ };
36
+ exports.andValue = andValue;
37
+ // `cond ? a : b` — BOTH arms are reachable, so both are enumerated (recursively:
38
+ // nested conditionals flatten into their leaves). The condition is runtime and is
39
+ // not evaluated; only its consequences are read.
40
+ const conditionalValue = (node, scope, bindings) => (0, pieces_1.combine)((0, index_1.expressionValue)(node.getWhenTrue(), scope, bindings), (0, index_1.expressionValue)(node.getWhenFalse(), scope, bindings));
41
+ exports.conditionalValue = conditionalValue;
42
+ // The logical operators, whose arms are alternatives: a fallback covers the
43
+ // objects its left arm is absent in, `&&` reads both sides' values.
44
+ const logicalValue = (op, node, scope, bindings) => {
45
+ if (!ts_morph_1.Node.isBinaryExpression(node))
46
+ return null;
47
+ if (op === "??" || op === "||")
48
+ return fallbackValue(node.getLeft(), node.getRight(), scope, bindings);
49
+ if (op === "&&")
50
+ return andValue(node.getLeft(), node.getRight(), scope, bindings);
51
+ return null;
52
+ };
53
+ exports.logicalValue = logicalValue;
@@ -0,0 +1,5 @@
1
+ import { Node } from "ts-morph";
2
+ import { type Bindings, type ValueResult } from "../pieces";
3
+ import type { Scope } from "../scope";
4
+ declare const expressionValue: (node: Node, scope: Scope, bindings?: Bindings) => ValueResult;
5
+ export { expressionValue };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expressionValue = void 0;
4
+ // ONE TypeScript expression, folded to concrete text. A template may quote a
5
+ // path into an object, a local `const`, a literal, a template of its own, a
6
+ // string concatenation — each is read the same way: the concrete value, or the
7
+ // reason it has none. A call is never guessed.
8
+ //
9
+ // An expression may also BRANCH: a conditional, a logical chain, arithmetic, or
10
+ // a `.map(...)` over a static array. Every reachable leaf is ENUMERATED — the
11
+ // branch chosen at runtime is not the resolver's business, so all of them are
12
+ // readings. The branch kinds live beside this file (`./conditional`,
13
+ // `./arithmetic`, `./map`, `./block`); this module is the dispatch between them.
14
+ const ts_morph_1 = require("ts-morph");
15
+ const block_1 = require("./block");
16
+ const conditional_1 = require("./conditional");
17
+ const arithmetic_1 = require("./arithmetic");
18
+ const map_1 = require("./map");
19
+ const object_1 = require("../object");
20
+ const node_1 = require("../object/node");
21
+ const pieces_1 = require("../pieces");
22
+ const text_1 = require("../../../utils/text");
23
+ // Fold a template literal that is itself an expression (`` `${n}px` ``): every
24
+ // quoted expression is resolved, then the values are concatenated. A span that
25
+ // resolves through several readings multiplies the readings; a span that resolves
26
+ // to nothing fails the whole template (a composition needs every part).
27
+ const templateExpressionValue = (node, scope, bindings) => {
28
+ if (!ts_morph_1.Node.isTemplateExpression(node))
29
+ return (0, pieces_1.noValue)({ kind: "unresolved-expr", text: (0, text_1.firstLine)(node.getText()) });
30
+ let values = [{ text: node.getHead().getLiteralText(), origin: null }];
31
+ const problems = [];
32
+ for (const span of node.getTemplateSpans()) {
33
+ const reading = expressionValue(span.getExpression(), scope, bindings);
34
+ if (!reading.values.length)
35
+ return (0, pieces_1.noValue)(reading.problems[0] ?? { kind: "unresolved-expr", text: (0, text_1.firstLine)(span.getExpression().getText()) });
36
+ problems.push(...reading.problems);
37
+ const literal = span.getLiteral().getLiteralText();
38
+ values = values.flatMap((left) => reading.values.map((right) => ({ text: left.text + right.text + literal, origin: left.origin ?? right.origin, dynamic: left.dynamic || right.dynamic })));
39
+ }
40
+ return { values, problems, dynamic: values.some((value) => value.dynamic) ? true : undefined };
41
+ };
42
+ // The branch/collection shapes, tried before the plain path walk: a conditional,
43
+ // logical or arithmetic expression, a template literal, or a `.map`/`.join`
44
+ // collection. Null when the node names none of them.
45
+ const branchValue = (node, scope, bindings) => {
46
+ if (ts_morph_1.Node.isConditionalExpression(node))
47
+ return (0, conditional_1.conditionalValue)(node, scope, bindings);
48
+ if (ts_morph_1.Node.isBinaryExpression(node))
49
+ return (0, arithmetic_1.binaryValue)(node, scope, bindings);
50
+ if (ts_morph_1.Node.isTemplateExpression(node))
51
+ return templateExpressionValue(node, scope, bindings);
52
+ return (0, map_1.mapValues)(node, scope, bindings) ?? (0, map_1.joinValue)(node, scope, bindings);
53
+ };
54
+ // One expression, folded to concrete text. A nested block is answered as such; a
55
+ // function-valued expression by its return value; a literal as itself; otherwise
56
+ // the branch shapes (conditional, logical, arithmetic, map/join) are enumerated
57
+ // before the plain path walk.
58
+ const expressionValue = (node, scope, bindings = pieces_1.NO_BINDINGS) => {
59
+ const current = (0, node_1.unwrap)(node);
60
+ if ((0, block_1.isDirective)(current))
61
+ return (0, pieces_1.blockResult)();
62
+ if (ts_morph_1.Node.isArrowFunction(current) || ts_morph_1.Node.isFunctionExpression(current))
63
+ return (0, block_1.functionValue)(current, scope, bindings);
64
+ const literal = (0, node_1.literalTextOf)(current);
65
+ if (literal !== null)
66
+ return (0, pieces_1.oneValue)(literal);
67
+ return branchValue(current, scope, bindings) ?? (0, object_1.pathValue)(current, scope, bindings);
68
+ };
69
+ exports.expressionValue = expressionValue;
@@ -0,0 +1,7 @@
1
+ import { Node } from "ts-morph";
2
+ import { type Bindings, type ValueResult } from "../pieces";
3
+ import type { Scope } from "../scope";
4
+ declare const staticElements: (node: Node) => string[] | null;
5
+ declare const mapValues: (node: Node, scope: Scope, bindings: Bindings) => ValueResult | null;
6
+ declare const joinValue: (node: Node, scope: Scope, bindings: Bindings) => ValueResult | null;
7
+ export { mapValues, joinValue, staticElements };