@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f

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 (354) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +51 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +4 -3
  7. package/api/build/build.type.d.mts +2 -2
  8. package/api/build/build.type.mjs +3 -3
  9. package/api/build/kit/kind.d.mts +2 -1
  10. package/api/build/kit/kind.mjs +199 -10
  11. package/api/build/kit/kit.mjs +6 -4
  12. package/api/build/kit/rank.d.mts +4 -2
  13. package/api/build/kit/rank.mjs +125 -24
  14. package/api/build/kit/start.d.mts +5 -4
  15. package/api/build/kit/start.mjs +12 -8
  16. package/api/build/kit/weights.d.mts +39 -3
  17. package/api/build/kit/weights.json +1 -1
  18. package/api/build/kit/weights.mjs +340 -43
  19. package/api/build/kit/word-model.d.mts +23 -0
  20. package/api/build/kit/word-model.mjs +46 -0
  21. package/api/build/kit/words.d.mts +48 -0
  22. package/api/build/kit/words.mjs +90 -1
  23. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  24. package/api/component/list/list.d.mts +1 -1
  25. package/api/component/list/list.mjs +48 -6
  26. package/api/discover/_adapter.d.mts +1 -1
  27. package/api/discover/search/search.mjs +3 -2
  28. package/api/docs/_adapter.d.mts +26 -2
  29. package/api/docs/_adapter.mjs +219 -6
  30. package/api/docs/docs.d.mts +3 -0
  31. package/api/docs/docs.doc.mjs +7 -1
  32. package/api/docs/docs.mjs +12 -0
  33. package/api/docs/docs.type.d.mts +5 -0
  34. package/api/docs/docs.type.mjs +2 -0
  35. package/api/docs/node/node.mjs +1 -1
  36. package/api/doctor/_adapter.d.mts +27 -5
  37. package/api/doctor/_adapter.mjs +83 -10
  38. package/api/doctor/built-checks.mjs +40 -14
  39. package/api/doctor/doctor.d.mts +4 -3
  40. package/api/doctor/doctor.mjs +14 -7
  41. package/api/doctor/theme-checks.mjs +121 -17
  42. package/api/icon/_records.mjs +2 -1
  43. package/api/index.d.mts +2 -0
  44. package/api/index.mjs +2 -0
  45. package/api/integration/_adapter.d.mts +44 -0
  46. package/api/integration/_adapter.mjs +77 -1
  47. package/api/integration/authoring-checks.mjs +6 -6
  48. package/api/integration/example-scope.d.mts +14 -0
  49. package/api/integration/example-scope.mjs +44 -0
  50. package/api/integration/example-scope.type.d.mts +29 -0
  51. package/api/integration/example-scope.type.mjs +25 -0
  52. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  53. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  54. package/api/integration/validate-integration.mjs +19 -1
  55. package/api/integration/validate-integration.type.d.mts +9 -0
  56. package/api/integration/validate-integration.type.mjs +1 -1
  57. package/api/integration/validateIntegration.doc.mjs +1 -1
  58. package/api/render/_adapter.mjs +591 -195
  59. package/api/render/render.doc.mjs +11 -3
  60. package/api/render/render.type.d.mts +52 -0
  61. package/api/render/render.type.mjs +31 -1
  62. package/api/search/ORDERING.md +1 -1
  63. package/api/search/_adapter.d.mts +9 -0
  64. package/api/search/_adapter.mjs +85 -0
  65. package/api/search/_candidate-score.mjs +51 -32
  66. package/api/search/_fit-order.mjs +3 -3
  67. package/api/search/_gather-components.d.mts +3 -2
  68. package/api/search/_gather-components.mjs +12 -3
  69. package/api/search/_lexical.d.mts +5 -0
  70. package/api/search/_lexical.mjs +8 -2
  71. package/api/search/_result.d.mts +11 -9
  72. package/api/search/_result.mjs +4 -4
  73. package/api/search/_score.d.mts +6 -1
  74. package/api/search/_score.mjs +15 -3
  75. package/api/search/search-index.mjs +7 -1
  76. package/api/search/search.d.mts +1 -1
  77. package/api/theme/_adapter.mjs +12 -1
  78. package/api/theme/build/build.d.mts +75 -0
  79. package/api/theme/build/build.mjs +243 -58
  80. package/api/theme/build/font-warning.d.mts +7 -0
  81. package/api/theme/build/font-warning.mjs +17 -0
  82. package/api/theme/theme.type.d.mts +10 -0
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme-edit/_adapter.d.mts +63 -2
  85. package/api/theme-edit/_adapter.mjs +771 -57
  86. package/api/theme-edit/_check.d.mts +40 -22
  87. package/api/theme-edit/_check.mjs +2029 -336
  88. package/api/theme-edit/_color.d.mts +10 -0
  89. package/api/theme-edit/_color.mjs +49 -1
  90. package/api/theme-edit/_compiler.mjs +9 -0
  91. package/api/theme-edit/_context.d.mts +3 -3
  92. package/api/theme-edit/_context.mjs +111 -48
  93. package/api/theme-edit/_css.d.mts +14 -0
  94. package/api/theme-edit/_css.mjs +46 -1
  95. package/api/theme-edit/_edit.d.mts +18 -4
  96. package/api/theme-edit/_edit.mjs +1685 -155
  97. package/api/theme-edit/_how-commands.d.mts +65 -0
  98. package/api/theme-edit/_how-commands.mjs +633 -1
  99. package/api/theme-edit/_how-question.d.mts +84 -0
  100. package/api/theme-edit/_how-question.mjs +5124 -281
  101. package/api/theme-edit/_how.mjs +140 -29
  102. package/api/theme-edit/_marks.d.mts +31 -5
  103. package/api/theme-edit/_marks.mjs +57 -5
  104. package/api/theme-edit/_name-rule.d.mts +11 -0
  105. package/api/theme-edit/_name-rule.mjs +12 -0
  106. package/api/theme-edit/_normal.d.mts +257 -0
  107. package/api/theme-edit/_normal.mjs +1252 -0
  108. package/api/theme-edit/_palette.mjs +10 -4
  109. package/api/theme-edit/_parts.d.mts +10 -1
  110. package/api/theme-edit/_parts.mjs +179 -3
  111. package/api/theme-edit/_preview-app.d.mts +7 -1
  112. package/api/theme-edit/_preview-app.mjs +515 -148
  113. package/api/theme-edit/_preview.d.mts +100 -14
  114. package/api/theme-edit/_preview.mjs +549 -137
  115. package/api/theme-edit/_settings.d.mts +347 -30
  116. package/api/theme-edit/_settings.mjs +2971 -327
  117. package/api/theme-edit/_tables.d.mts +6 -0
  118. package/api/theme-edit/_tables.mjs +44 -1
  119. package/api/theme-edit/_vet.d.mts +18 -0
  120. package/api/theme-edit/_vet.mjs +32 -0
  121. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  122. package/api/theme-edit/theme-edit.type.mjs +4 -1
  123. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  124. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  125. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  126. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  128. package/api/upgrade/run/run.mjs +4 -3
  129. package/assets/codemods/integration-discovery.mjs +2 -1
  130. package/assets/codemods/run-codemod.mjs +87 -7
  131. package/assets/codemods/transforms/next/index.mjs +11 -1
  132. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  133. package/assets/component-list.generated.json +1 -0
  134. package/assets/docs/author-a-theme.doc.mjs +1 -0
  135. package/assets/docs/theme.doc.dense.mjs +2 -2
  136. package/assets/docs/theme.doc.mjs +1 -1
  137. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  138. package/assets/docs/tree/checks.doc.mjs +1 -1
  139. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  140. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -0
  142. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  143. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  144. package/assets/docs/use-a-theme.doc.mjs +1 -1
  145. package/assets/docs.generated.json +2 -2
  146. package/assets/search-catalog.generated.json +2 -0
  147. package/assets/self-audit.generated.json +1 -1
  148. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  149. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  150. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  151. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  152. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  153. package/assets/templates/components.generated.json +1 -1
  154. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  155. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  156. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  157. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  158. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  159. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  160. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  161. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  162. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  163. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  164. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  165. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  166. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  167. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  168. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  169. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  170. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  171. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  172. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  173. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  174. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  175. package/assets/templates/pages/ide/page.tsx +24 -2
  176. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  177. package/assets/templates/pages/library/template.doc.mjs +4 -1
  178. package/assets/templates/pages/login/template.doc.mjs +2 -1
  179. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  180. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  181. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  182. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  183. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  184. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  185. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  186. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  187. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  188. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  189. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  190. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  191. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  192. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  193. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  194. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  195. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  196. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  197. package/assets/theme.template.ts +6 -0
  198. package/authoring/debug/parse.d.mts +3 -3
  199. package/authoring/doctypes/_schema.d.mts +3 -3
  200. package/authoring/doctypes/command/command.doc.mjs +1 -1
  201. package/authoring/doctypes/component/categories.d.mts +37 -0
  202. package/authoring/doctypes/component/categories.mjs +54 -0
  203. package/authoring/doctypes/template/template.doc.mjs +1 -1
  204. package/authoring/doctypes/template/type.ts +9 -0
  205. package/authoring/example/example.doc.d.mts +12 -0
  206. package/authoring/example/example.doc.mjs +69 -0
  207. package/authoring/example/preview.d.mts +92 -0
  208. package/authoring/example/preview.mjs +994 -0
  209. package/authoring/example/type.ts +102 -0
  210. package/authoring/index.d.mts +1 -0
  211. package/authoring/index.d.ts +12 -0
  212. package/authoring/index.mjs +3 -1
  213. package/clients/cli/bin/astryx.mjs +6 -9
  214. package/clients/cli/build-id.generated.json +1 -1
  215. package/clients/cli/commands/component.doc.mjs +1 -1
  216. package/clients/cli/commands/component.mjs +22 -3
  217. package/clients/cli/commands/docs.doc.mjs +7 -1
  218. package/clients/cli/commands/docs.mjs +3 -1
  219. package/clients/cli/commands/doctor.mjs +32 -14
  220. package/clients/cli/commands/experimental/render.mjs +42 -1
  221. package/clients/cli/commands/experimental/theme.mjs +163 -28
  222. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  223. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  224. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  225. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  226. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  227. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  228. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  229. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  230. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  231. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  233. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  234. package/clients/cli/commands/search.doc.mjs +2 -1
  235. package/clients/cli/commands/search.mjs +6 -1
  236. package/clients/cli/commands/template.mjs +4 -2
  237. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  238. package/clients/cli/commands/theme.doc.mjs +1 -1
  239. package/clients/cli/commands/theme.mjs +209 -8
  240. package/clients/cli/commands/upgrade.mjs +42 -7
  241. package/clients/cli/index.mjs +1 -1
  242. package/clients/cli/lib/cli-error.mjs +2 -1
  243. package/clients/cli/lib/component-format.mjs +205 -98
  244. package/clients/cli/lib/hook-format.mjs +9 -19
  245. package/clients/cli/lib/json-shim.mjs +77 -21
  246. package/clients/cli/lib/manifest.mjs +3 -2
  247. package/clients/cli/manifest.generated.json +1 -1
  248. package/foundation/agent-docs/agent-docs.mjs +1 -1
  249. package/foundation/config/theme-state.d.mts +13 -1
  250. package/foundation/config/theme-state.mjs +47 -7
  251. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  252. package/foundation/discovery/component-discovery.d.mts +11 -0
  253. package/foundation/discovery/component-discovery.mjs +56 -8
  254. package/foundation/discovery/component-replacement.mjs +130 -1
  255. package/foundation/discovery/copied-passages.mjs +2 -1
  256. package/foundation/discovery/doc-types.mjs +4 -3
  257. package/foundation/discovery/entry-name-files.d.mts +43 -0
  258. package/foundation/discovery/entry-name-files.mjs +264 -0
  259. package/foundation/discovery/hook-discovery.d.mts +8 -2
  260. package/foundation/discovery/hook-discovery.mjs +22 -8
  261. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  262. package/foundation/discovery/icon-set-checks.mjs +2 -1
  263. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  264. package/foundation/discovery/integration-doc-files.mjs +2 -1
  265. package/foundation/discovery/package-exports.d.mts +10 -0
  266. package/foundation/discovery/package-exports.mjs +56 -3
  267. package/foundation/discovery/prop-drift.mjs +9 -9
  268. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  269. package/foundation/discovery/runner-allowlist.mjs +2 -0
  270. package/foundation/discovery/stored-component-list.d.mts +43 -0
  271. package/foundation/discovery/stored-component-list.mjs +90 -0
  272. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  273. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  274. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  275. package/foundation/discovery/stored-self-audit.mjs +38 -18
  276. package/foundation/discovery/template-adapter.d.mts +52 -0
  277. package/foundation/discovery/template-adapter.mjs +176 -12
  278. package/foundation/discovery/template-icons.mjs +2 -1
  279. package/foundation/discovery/theme-discovery.mjs +3 -2
  280. package/foundation/discovery/theme-imports.d.mts +14 -0
  281. package/foundation/discovery/theme-imports.mjs +43 -1
  282. package/foundation/discovery/theming-targets.mjs +3 -2
  283. package/foundation/doc-compiler/import.mjs +7 -1
  284. package/foundation/doc-compiler/inputs.mjs +3 -2
  285. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  286. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  287. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  288. package/foundation/env/semver.mjs +3 -1
  289. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  290. package/foundation/fonts/font-stylesheet.mjs +115 -0
  291. package/foundation/fs/cache-eviction.d.mts +21 -0
  292. package/foundation/fs/cache-eviction.mjs +73 -0
  293. package/foundation/fs/file-protection.mjs +4 -3
  294. package/foundation/fs/gather-cache.d.mts +25 -4
  295. package/foundation/fs/gather-cache.mjs +164 -55
  296. package/foundation/fs/jiti-cache.d.mts +19 -1
  297. package/foundation/fs/jiti-cache.mjs +130 -6
  298. package/foundation/fs/kept-tree.d.mts +60 -0
  299. package/foundation/fs/kept-tree.mjs +154 -0
  300. package/foundation/fs/listing-cache.d.mts +7 -0
  301. package/foundation/fs/listing-cache.mjs +10 -0
  302. package/foundation/fs/module-loader.d.mts +24 -2
  303. package/foundation/fs/module-loader.mjs +94 -21
  304. package/foundation/fs/paths.d.mts +18 -0
  305. package/foundation/fs/paths.mjs +15 -2
  306. package/foundation/identity/provider-identity.d.mts +6 -0
  307. package/foundation/identity/provider-identity.mjs +10 -1
  308. package/foundation/integrations/contribution-inventory.mjs +4 -3
  309. package/foundation/integrations/example-code.d.mts +63 -0
  310. package/foundation/integrations/example-code.mjs +416 -0
  311. package/foundation/integrations/public-imports.d.mts +9 -0
  312. package/foundation/integrations/public-imports.mjs +3 -2
  313. package/foundation/integrations/validate-contributions.mjs +17 -45
  314. package/foundation/render/embedded-files.d.mts +6 -0
  315. package/foundation/render/embedded-files.mjs +25 -5
  316. package/foundation/render/embedded-imports.d.mts +39 -7
  317. package/foundation/render/embedded-imports.mjs +66 -27
  318. package/foundation/render/file-header.d.mts +66 -0
  319. package/foundation/render/file-header.mjs +118 -0
  320. package/foundation/render/host-answer.d.mts +18 -0
  321. package/foundation/render/host-answer.mjs +46 -0
  322. package/foundation/render/host-exit.d.mts +1 -0
  323. package/foundation/render/host-exit.mjs +6 -1
  324. package/foundation/render/html-reader.d.mts +55 -2
  325. package/foundation/render/html-reader.mjs +145 -26
  326. package/foundation/render/markup-edits.d.mts +57 -0
  327. package/foundation/render/markup-edits.mjs +182 -0
  328. package/foundation/render/page-host.mjs +29 -12
  329. package/foundation/render/page-worker.mjs +121 -13
  330. package/foundation/render/picture-chrome.d.mts +4 -0
  331. package/foundation/render/picture-chrome.mjs +185 -0
  332. package/foundation/render/picture-playwright.d.mts +4 -0
  333. package/foundation/render/picture-playwright.mjs +34 -0
  334. package/foundation/render/rebuild.mjs +2 -1
  335. package/foundation/render/render-page.d.mts +35 -3
  336. package/foundation/render/render-page.mjs +316 -42
  337. package/foundation/render/source-block.d.mts +85 -6
  338. package/foundation/render/source-block.mjs +211 -20
  339. package/foundation/render/ts-paths.d.mts +69 -6
  340. package/foundation/render/ts-paths.mjs +326 -40
  341. package/foundation/response/error-codes.d.mts +3 -1
  342. package/foundation/response/error-codes.d.ts +1 -0
  343. package/foundation/response/error-codes.doc.mjs +12 -1
  344. package/foundation/response/error-codes.mjs +11 -1
  345. package/foundation/response/response-types.doc.mjs +2 -2
  346. package/foundation/text/compare-text.d.mts +14 -0
  347. package/foundation/text/compare-text.mjs +68 -0
  348. package/foundation/text/string-utils.d.mts +3 -2
  349. package/foundation/text/string-utils.mjs +18 -4
  350. package/foundation/text/suggest-order.d.mts +9 -0
  351. package/foundation/text/suggest-order.mjs +15 -1
  352. package/foundation/xle/expand.mjs +2 -1
  353. package/host/index.mjs +8 -6
  354. package/package.json +7 -6
@@ -0,0 +1,264 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Whether a component or hook can carry a name, read without loading
5
+ * any doc: from Core's file and folder names, and from integrations' doc file
6
+ * names and the words in those docs' text. Each is a summary kept between
7
+ * runs while those folders and docs are unchanged (../fs/kept-tree.mjs).
8
+ *
9
+ * @input Core's folder or integrations' components folders, and a name
10
+ * folded as a reader may type it ({@link foldEntryName})
11
+ * @output false only when discovery lists no component or hook there whose
12
+ * folded name is that name; for Core, the top folders that can hold one
13
+ * @position foundation/discovery: lets the docs not-found error skip
14
+ * component and hook discovery for a name no Core file or folder name, and
15
+ * no integration doc's file name or text, carries
16
+ */
17
+
18
+ import * as fs from 'node:fs';
19
+ import * as path from 'node:path';
20
+ import {fileURLToPath} from 'node:url';
21
+ import {hasNameLine, keptTreeSummary, nameLines} from '../fs/kept-tree.mjs';
22
+
23
+ /** A component doc's suffix, as integration discovery reads it. */
24
+ const INTEGRATION_DOC_RE = /\.doc\.(ts|mjs|js)$/;
25
+
26
+ /**
27
+ * A name as a reader may type it: case, spaces and hyphens do not count.
28
+ * @param {string} name
29
+ * @returns {string}
30
+ */
31
+ export function foldEntryName(name) {
32
+ return name.toLowerCase().replace(/[\s-]+/g, '');
33
+ }
34
+
35
+ /**
36
+ * Visit each file and folder under `dir`, outside `node_modules`, until
37
+ * `visit` returns true.
38
+ * @param {string} dir
39
+ * @param {(name: string, dir: string, isDir: boolean) => boolean} visit
40
+ * @returns {boolean} whether a visit returned true
41
+ */
42
+ function walkUntil(dir, visit) {
43
+ let entries;
44
+ try {
45
+ entries = fs.readdirSync(dir, {withFileTypes: true});
46
+ } catch {
47
+ return false;
48
+ }
49
+ for (const entry of entries) {
50
+ if (entry.name === 'node_modules') continue;
51
+ const isDir = entry.isDirectory();
52
+ if (visit(entry.name, dir, isDir)) return true;
53
+ if (isDir && walkUntil(path.join(dir, entry.name), visit)) return true;
54
+ }
55
+ return false;
56
+ }
57
+
58
+ /** This module's own file: its code decides the kept summaries' shape. */
59
+ const OWN_FILE = fileURLToPath(import.meta.url);
60
+
61
+ /**
62
+ * The folded names Core's files and folders give, each with a top folder of
63
+ * `src` that holds one, as lines ({@link nameLines}) of `<kind><name>\t<top>`:
64
+ * kind `t` for a `.tsx` stem (a component), `o` for a `.doc.mjs` stem (a
65
+ * hook), `d` for a folder name (a component). A file directly in `src` is
66
+ * under the top folder `''`, and a top folder under its own name. A folded
67
+ * name holds no white space, so a tab ends it.
68
+ * @param {string} coreDir
69
+ * @returns {string | string[]}
70
+ */
71
+ function coreNameIndex(coreDir) {
72
+ return keptTreeSummary(
73
+ {
74
+ kind: 'core-entry-names',
75
+ roots: [path.join(coreDir, 'src')],
76
+ code: [OWN_FILE],
77
+ skip: name => name === 'node_modules',
78
+ },
79
+ ([{folders}]) => {
80
+ /** @type {string[]} */
81
+ const lines = [];
82
+ for (const {rel, entries} of folders) {
83
+ const top = rel === '' ? '' : rel.split(path.sep)[0];
84
+ for (const {name, isDir} of entries) {
85
+ if (isDir) {
86
+ if (name !== 'node_modules') {
87
+ lines.push(`d${foldEntryName(name)}\t${rel === '' ? name : top}`);
88
+ }
89
+ } else if (name.endsWith('.doc.mjs')) {
90
+ const stem = name.slice(0, -'.doc.mjs'.length);
91
+ lines.push(`o${foldEntryName(stem)}\t${top}`);
92
+ } else if (name.endsWith('.tsx')) {
93
+ lines.push(
94
+ `t${foldEntryName(name.slice(0, -'.tsx'.length))}\t${top}`,
95
+ );
96
+ }
97
+ }
98
+ }
99
+ return nameLines(lines);
100
+ },
101
+ );
102
+ }
103
+
104
+ /**
105
+ * The tops the index lines that start with `prefix` name.
106
+ * @param {string | string[]} lines
107
+ * @param {string} prefix
108
+ * @returns {string[]}
109
+ */
110
+ function topsAfter(lines, prefix) {
111
+ if (typeof lines !== 'string') {
112
+ return lines
113
+ .filter(line => line.startsWith(prefix))
114
+ .map(line => line.slice(prefix.length));
115
+ }
116
+ const needle = `\n${prefix}`;
117
+ const tops = [];
118
+ for (
119
+ let at = lines.indexOf(needle);
120
+ at >= 0;
121
+ at = lines.indexOf(needle, at + 1)
122
+ ) {
123
+ const start = at + needle.length;
124
+ tops.push(lines.slice(start, lines.indexOf('\n', start)));
125
+ }
126
+ return tops;
127
+ }
128
+
129
+ /**
130
+ * Which Core entries can fold to `wanted`. Every Core component takes its
131
+ * name from a `.tsx` file (without an `XDS` prefix) or a folder, and every
132
+ * hook from its doc's file name, so a name no such file carries is neither.
133
+ * @param {string} coreDir
134
+ * @param {string} wanted a folded name
135
+ * @returns {{component: boolean, hook: boolean, componentTops: Set<string>, hookTops: Set<string>}}
136
+ * `hook` also counts a hook named `use` + `wanted`; the tops are the top
137
+ * folders of `src` that hold such a file or folder
138
+ */
139
+ export function coreFilesNaming(coreDir, wanted) {
140
+ const index = coreNameIndex(coreDir);
141
+ const componentTops = new Set([
142
+ ...topsAfter(index, `t${wanted}\t`),
143
+ ...topsAfter(index, `txds${wanted}\t`),
144
+ ...topsAfter(index, `d${wanted}\t`),
145
+ ]);
146
+ const hookTops = new Set([
147
+ ...topsAfter(index, `o${wanted}\t`),
148
+ ...topsAfter(index, `ouse${wanted}\t`),
149
+ ]);
150
+ return {
151
+ component: componentTops.size > 0,
152
+ hook: hookTops.size > 0,
153
+ componentTops,
154
+ hookTops,
155
+ };
156
+ }
157
+
158
+ /** A name a doc's text can spell: a run of word characters. */
159
+ const WORD_RE = /[A-Za-z0-9_$]+/g;
160
+
161
+ /**
162
+ * What each integration's component docs can name: each doc's folded file
163
+ * stem, and each word in its text, in lower case. `unreadable` when a doc
164
+ * could not be read.
165
+ * @param {string[]} componentsDirs
166
+ * @returns {Array<{stems: string | string[], words: string | string[], unreadable: boolean}>}
167
+ */
168
+ function integrationNameIndexes(componentsDirs) {
169
+ return keptTreeSummary(
170
+ {
171
+ kind: 'integration-component-names',
172
+ roots: componentsDirs,
173
+ code: [OWN_FILE],
174
+ // Integration discovery reads no doc in these folders.
175
+ skip: name => name === 'node_modules' || name === '__tests__',
176
+ },
177
+ trees =>
178
+ trees.map(({folders, readText}) => {
179
+ const stems = new Set();
180
+ const words = new Set();
181
+ let unreadable = false;
182
+ for (const {rel, entries} of folders) {
183
+ for (const {name, isDir} of entries) {
184
+ if (isDir || !INTEGRATION_DOC_RE.test(name)) continue;
185
+ stems.add(foldEntryName(name.replace(INTEGRATION_DOC_RE, '')));
186
+ let text;
187
+ try {
188
+ text = readText(rel === '' ? name : path.join(rel, name));
189
+ } catch {
190
+ unreadable = true;
191
+ continue;
192
+ }
193
+ for (const word of text.match(WORD_RE) ?? []) {
194
+ words.add(word.toLowerCase());
195
+ }
196
+ }
197
+ }
198
+ return {stems: nameLines(stems), words: nameLines(words), unreadable};
199
+ }),
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Whether an integration component can fold to `wanted`, for each
205
+ * components folder in order. Integration discovery names a component after
206
+ * its doc's file, or after a name the doc spells out (its export, or a family
207
+ * member), so a doc whose file name and text both lack the name lists no
208
+ * such component.
209
+ * @param {Array<string | undefined>} componentsDirs
210
+ * @param {string} wanted a folded name
211
+ * @returns {boolean[]}
212
+ */
213
+ export function integrationsFilesNaming(componentsDirs, wanted) {
214
+ // A name of word characters alone is a whole word of the text exactly when
215
+ // it is one of the text's words: the kept index answers it.
216
+ if (!/^[a-z0-9_$]+$/.test(wanted)) {
217
+ return componentsDirs.map(dir => !!dir && docsSpell(dir, wanted));
218
+ }
219
+ const dirs = componentsDirs.flatMap(dir => (dir ? [dir] : []));
220
+ const indexes = dirs.length > 0 ? integrationNameIndexes(dirs) : [];
221
+ let at = 0;
222
+ return componentsDirs.map(dir => {
223
+ if (!dir) return false;
224
+ const {stems, words, unreadable} = indexes[at++];
225
+ return (
226
+ unreadable || hasNameLine(stems, wanted) || hasNameLine(words, wanted)
227
+ );
228
+ });
229
+ }
230
+
231
+ /**
232
+ * {@link integrationsFilesNaming} for one components folder.
233
+ * @param {string | undefined} componentsDir
234
+ * @param {string} wanted a folded name
235
+ * @returns {boolean}
236
+ */
237
+ export function integrationFilesNaming(componentsDir, wanted) {
238
+ return integrationsFilesNaming([componentsDir], wanted)[0];
239
+ }
240
+
241
+ /**
242
+ * Whether a component doc under `componentsDir` has a file stem that folds to
243
+ * `wanted`, or text that holds it as a whole word, read from the disk.
244
+ * @param {string} componentsDir
245
+ * @param {string} wanted a folded name
246
+ * @returns {boolean}
247
+ */
248
+ function docsSpell(componentsDir, wanted) {
249
+ const token = new RegExp(
250
+ `(?<![\\w$])${wanted.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w$])`,
251
+ 'i',
252
+ );
253
+ return walkUntil(componentsDir, (name, dir, isDir) => {
254
+ if (isDir || !INTEGRATION_DOC_RE.test(name)) return false;
255
+ if (foldEntryName(name.replace(INTEGRATION_DOC_RE, '')) === wanted) {
256
+ return true;
257
+ }
258
+ try {
259
+ return token.test(fs.readFileSync(path.join(dir, name), 'utf8'));
260
+ } catch {
261
+ return true;
262
+ }
263
+ });
264
+ }
@@ -7,9 +7,13 @@
7
7
  * Categories from HookDoc.category: focus, layout, animation, interaction, data, media, streaming
8
8
  * Hooks without a category go in 'Other'.
9
9
  * @param {string} coreDir
10
+ * @param {(name: string) => boolean} [keep] the hooks to read; the others are
11
+ * left out, and their docs are not read
12
+ * @param {Set<string>} [tops] the top folders of `src` outside `hooks` to
13
+ * read, when only these can hold a hook `keep` accepts
10
14
  * @returns {Record<string, string[]>}
11
15
  */
12
- export function discoverHooks(coreDir: string): Record<string, string[]>;
16
+ export function discoverHooks(coreDir: string, keep?: (name: string) => boolean, tops?: Set<string>): Record<string, string[]>;
13
17
  /**
14
18
  * Find the .doc.mjs file for a hook by name.
15
19
  * Searches hooks/ directory and component directories.
@@ -23,6 +27,8 @@ export function findHookDoc(coreDir: string, name: string): string | null;
23
27
  /**
24
28
  * Get all discovered hook names as a flat array (for fuzzy matching).
25
29
  * @param {string} coreDir
30
+ * @param {(name: string) => boolean} [keep] as for {@link discoverHooks}
31
+ * @param {Set<string>} [tops] as for {@link discoverHooks}
26
32
  * @returns {string[]}
27
33
  */
28
- export function getAllHookNames(coreDir: string): string[];
34
+ export function getAllHookNames(coreDir: string, keep?: (name: string) => boolean, tops?: Set<string>): string[];
@@ -9,6 +9,7 @@ import * as path from 'node:path';
9
9
  import {listDir, listDirEntries, pathExists} from '../fs/listing-cache.mjs';
10
10
  import {existsCaseExact} from '../fs/paths.mjs';
11
11
  import {levenshteinDistance} from '../text/string-utils.mjs';
12
+ import {compareText} from '../text/compare-text.mjs';
12
13
 
13
14
  const SKIP_DIRS = new Set(['utils', '__tests__', 'node_modules']);
14
15
 
@@ -74,9 +75,13 @@ function hookNameFromFile(fileName) {
74
75
  * Categories from HookDoc.category: focus, layout, animation, interaction, data, media, streaming
75
76
  * Hooks without a category go in 'Other'.
76
77
  * @param {string} coreDir
78
+ * @param {(name: string) => boolean} [keep] the hooks to read; the others are
79
+ * left out, and their docs are not read
80
+ * @param {Set<string>} [tops] the top folders of `src` outside `hooks` to
81
+ * read, when only these can hold a hook `keep` accepts
77
82
  * @returns {Record<string, string[]>}
78
83
  */
79
- export function discoverHooks(coreDir) {
84
+ export function discoverHooks(coreDir, keep = () => true, tops) {
80
85
  const srcDir = path.join(coreDir, 'src');
81
86
  const hooksDir = path.join(srcDir, 'hooks');
82
87
 
@@ -90,6 +95,7 @@ export function discoverHooks(coreDir) {
90
95
  if (!entry.isFile()) continue;
91
96
  if (!entry.name.endsWith('.doc.mjs')) continue;
92
97
  const hookName = hookNameFromFile(entry.name);
98
+ if (!keep(hookName)) continue;
93
99
  const docPath = path.join(hooksDir, entry.name);
94
100
  const {category} = readHookMeta(docPath);
95
101
  hookCategories.set(hookName, category || 'Other');
@@ -102,8 +108,9 @@ export function discoverHooks(coreDir) {
102
108
  const topEntries = listDirEntries(srcDir);
103
109
  for (const entry of topEntries) {
104
110
  if (!entry.isDirectory() || SKIP_DIRS.has(entry.name) || entry.name === 'hooks') continue;
111
+ if (tops && !tops.has(entry.name)) continue;
105
112
  const dirPath = path.join(srcDir, entry.name);
106
- scanDirForHookDocs(dirPath, hookCategories);
113
+ scanDirForHookDocs(dirPath, hookCategories, keep);
107
114
  }
108
115
  }
109
116
 
@@ -124,7 +131,7 @@ export function discoverHooks(coreDir) {
124
131
  const sortedEntries = Array.from(groups.entries()).sort((a, b) => {
125
132
  if (a[0] === 'Other') return 1;
126
133
  if (b[0] === 'Other') return -1;
127
- return a[0].localeCompare(b[0]);
134
+ return compareText(a[0], b[0]);
128
135
  });
129
136
 
130
137
  /** @type {Record<string, string[]>} */
@@ -140,17 +147,22 @@ export function discoverHooks(coreDir) {
140
147
  * Recursively scan a directory for use*.doc.mjs files.
141
148
  * @param {string} dirPath
142
149
  * @param {Map<string, string>} hookCategories
150
+ * @param {(name: string) => boolean} keep
143
151
  */
144
- function scanDirForHookDocs(dirPath, hookCategories) {
152
+ function scanDirForHookDocs(dirPath, hookCategories, keep) {
145
153
  if (!pathExists(dirPath)) return;
146
154
  const entries = listDirEntries(dirPath);
147
155
  for (const entry of entries) {
148
156
  if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
149
- scanDirForHookDocs(path.join(dirPath, entry.name), hookCategories);
157
+ scanDirForHookDocs(path.join(dirPath, entry.name), hookCategories, keep);
150
158
  } else if (entry.isFile() && HOOK_DOC_FILE_RE.test(entry.name)) {
151
159
  const hookName = hookNameFromFile(entry.name);
152
160
  const docPath = path.join(dirPath, entry.name);
153
- if (!hookCategories.has(hookName) && !isBesideOwnHook(docPath, hookName)) {
161
+ if (
162
+ keep(hookName) &&
163
+ !hookCategories.has(hookName) &&
164
+ !isBesideOwnHook(docPath, hookName)
165
+ ) {
154
166
  const {category} = readHookMeta(docPath);
155
167
  hookCategories.set(hookName, category || 'Other');
156
168
  }
@@ -258,9 +270,11 @@ function searchDirForHookDoc(dirPath, candidates) {
258
270
  /**
259
271
  * Get all discovered hook names as a flat array (for fuzzy matching).
260
272
  * @param {string} coreDir
273
+ * @param {(name: string) => boolean} [keep] as for {@link discoverHooks}
274
+ * @param {Set<string>} [tops] as for {@link discoverHooks}
261
275
  * @returns {string[]}
262
276
  */
263
- export function getAllHookNames(coreDir) {
264
- const hooks = discoverHooks(coreDir);
277
+ export function getAllHookNames(coreDir, keep, tops) {
278
+ const hooks = discoverHooks(coreDir, keep, tops);
265
279
  return Object.values(hooks).flat();
266
280
  }
@@ -20,6 +20,7 @@ import {parseIconDefinition} from '../../authoring/doctypes/icon-definition/pars
20
20
  import {CLI_ROOT} from '../fs/paths.mjs';
21
21
  import {listDirEntries} from '../fs/listing-cache.mjs';
22
22
  import {readStaticDescriptorValue} from './theme-discovery.mjs';
23
+ import {compareText} from '../text/compare-text.mjs';
23
24
 
24
25
  /** @typedef {import('../../authoring/doctypes/icon-definition/type').IconDefinitionDoc} IconDefinitionDoc */
25
26
 
@@ -60,7 +61,7 @@ export function readDefinitionsDir(dir, owner) {
60
61
  } catch {
61
62
  return {definitions, errors};
62
63
  }
63
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
64
+ for (const entry of entries.sort((a, b) => compareText(a.name, b.name))) {
64
65
  if (!entry.name.endsWith('.doc.mjs')) continue;
65
66
  const file = path.join(dir, entry.name);
66
67
  const label = `Icon definition ${entry.name} in ${owner}`;
@@ -79,6 +79,7 @@ import {
79
79
  issueError,
80
80
  issueWarning,
81
81
  } from '../integrations/validate-contributions.mjs';
82
+ import {compareText} from '../text/compare-text.mjs';
82
83
 
83
84
  /** @typedef {import('../integrations/issue').AstryxIntegrationIssue} Issue */
84
85
  /** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
@@ -1106,7 +1107,7 @@ function lookRewriteCommand(set, variant, origins) {
1106
1107
  if (from) counts.set(from, (counts.get(from) ?? 0) + 1);
1107
1108
  }
1108
1109
  const module = [...counts].sort(
1109
- (a, b) => b[1] - a[1] || a[0].localeCompare(b[0]),
1110
+ (a, b) => b[1] - a[1] || compareText(a[0], b[0]),
1110
1111
  )[0]?.[0];
1111
1112
  return `astryx experimental icon add --variant ${shellArg(variant)} --from ${module ? shellArg(module) : '<module>'} --all --set ${shellArg(set.name)}`;
1112
1113
  }
@@ -34,6 +34,7 @@ import {
34
34
  isIgnoredThemeEntry,
35
35
  readStaticDescriptorValue,
36
36
  } from './theme-discovery.mjs';
37
+ import {compareText} from '../text/compare-text.mjs';
37
38
 
38
39
  /** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
39
40
  /** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetIcon} IconSetIcon */
@@ -149,7 +150,7 @@ export function discoverIconSetDirectory(root, owner) {
149
150
  } catch {
150
151
  return {sets, errors};
151
152
  }
152
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
153
+ for (const entry of entries.sort((a, b) => compareText(a.name, b.name))) {
153
154
  if (isIgnoredThemeEntry(entry.name) || !entry.isDirectory()) continue;
154
155
  // Only a lower-kebab directory is a set (FR1).
155
156
  if (!SET_NAME_RE.test(entry.name)) continue;
@@ -40,6 +40,7 @@ import {discoverIntegrationTemplatesForOne} from './template-adapter.mjs';
40
40
  import {discoverThemeDirectory} from './theme-discovery.mjs';
41
41
  import {discoverIconSetDirectory} from './icon-set-discovery.mjs';
42
42
  import {rootProblem} from '../integrations/validate-contributions.mjs';
43
+ import {compareText} from '../text/compare-text.mjs';
43
44
 
44
45
  /** @typedef {import('./doc-types.mjs').DocFile} DocFile */
45
46
  /** @typedef {import('./doc-types.mjs').DocRoot} DocRoot */
@@ -176,7 +177,7 @@ export async function integrationDocFiles(integration) {
176
177
  return {
177
178
  files: [...owners]
178
179
  .map(([file, {root}]) => ({path: file, root}))
179
- .sort((a, b) => a.path.localeCompare(b.path)),
180
+ .sort((a, b) => compareText(a.path, b.path)),
180
181
  unread,
181
182
  fixtures,
182
183
  };
@@ -1,6 +1,16 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The target one subpath of a package's exports maps to under a list of
6
+ * conditions, its wildcard filled in, as written in the package (`./x`).
7
+ * Null when the package exports no such subpath.
8
+ * @param {unknown} exportsField
9
+ * @param {string} subpath `.` or a `./`-prefixed subpath
10
+ * @param {readonly string[]} conditions
11
+ * @returns {string|null}
12
+ */
13
+ export function conditionalExportTarget(exportsField: unknown, subpath: string, conditions: readonly string[]): string | null;
4
14
  /**
5
15
  * The file a subpath's `source` condition names, when that file is in the
6
16
  * package. A package that ships its source (or a workspace package before it
@@ -8,8 +8,9 @@
8
8
  * their legacy public deep paths and are resolved from files on disk.
9
9
  *
10
10
  * @input Parsed package.json, package directory, and a public subpath
11
- * @output The public specifier and confined target file, when exported, and
12
- * the file a subpath's `source` condition names, when the package has it
11
+ * @output The public specifier and confined target file, when exported, the
12
+ * file a subpath's `source` condition names, when the package has it, and
13
+ * the target a subpath maps to under given conditions
13
14
  * @position packages/cli/foundation/discovery — shared package import metadata
14
15
  */
15
16
 
@@ -61,6 +62,16 @@ function targetString(value) {
61
62
  return null;
62
63
  }
63
64
 
65
+ /**
66
+ * The order Node and TypeScript try export patterns in: the longer part
67
+ * before the `*` first, then the longer key.
68
+ * @param {string} a
69
+ * @param {string} b
70
+ */
71
+ function patternKeyCompare(a, b) {
72
+ return b.indexOf('*') - a.indexOf('*') || b.length - a.length;
73
+ }
74
+
64
75
  /**
65
76
  * Find an exact or one-star subpath mapping and the wildcard value it matched.
66
77
  * @param {Record<string, unknown>} map
@@ -72,7 +83,7 @@ function subpathValue(map, subpath) {
72
83
  }
73
84
  const patterns = Object.keys(map)
74
85
  .filter(key => key.startsWith('./') && key.split('*').length === 2)
75
- .sort((a, b) => b.length - a.length);
86
+ .sort(patternKeyCompare);
76
87
  for (const pattern of patterns) {
77
88
  const star = pattern.indexOf('*');
78
89
  const prefix = pattern.slice(0, star);
@@ -186,6 +197,48 @@ function rawExportValue(exportsField, subpath) {
186
197
  : null;
187
198
  }
188
199
 
200
+ /**
201
+ * Select one string target under a list of conditions, matched in the order
202
+ * the export object lists them, as Node and TypeScript match them; `default`
203
+ * always matches.
204
+ * @param {unknown} value
205
+ * @param {readonly string[]} conditions
206
+ * @returns {string|null}
207
+ */
208
+ function conditionTarget(value, conditions) {
209
+ if (typeof value === 'string') return value;
210
+ if (Array.isArray(value)) {
211
+ for (const item of value) {
212
+ const selected = conditionTarget(item, conditions);
213
+ if (selected) return selected;
214
+ }
215
+ return null;
216
+ }
217
+ if (!isRecord(value)) return null;
218
+ for (const [key, item] of Object.entries(value)) {
219
+ if (key !== 'default' && !conditions.includes(key)) continue;
220
+ const selected = conditionTarget(item, conditions);
221
+ if (selected) return selected;
222
+ }
223
+ return null;
224
+ }
225
+
226
+ /**
227
+ * The target one subpath of a package's exports maps to under a list of
228
+ * conditions, its wildcard filled in, as written in the package (`./x`).
229
+ * Null when the package exports no such subpath.
230
+ * @param {unknown} exportsField
231
+ * @param {string} subpath `.` or a `./`-prefixed subpath
232
+ * @param {readonly string[]} conditions
233
+ * @returns {string|null}
234
+ */
235
+ export function conditionalExportTarget(exportsField, subpath, conditions) {
236
+ const selected = rawExportValue(exportsField, subpath);
237
+ if (!selected) return null;
238
+ const target = conditionTarget(selected.value, conditions);
239
+ return target === null ? null : target.replaceAll('*', selected.wildcard);
240
+ }
241
+
189
242
  /**
190
243
  * The file a subpath's `source` condition names, when that file is in the
191
244
  * package. A package that ships its source (or a workspace package before it
@@ -61,6 +61,7 @@ import {
61
61
  unresolvedGlobals,
62
62
  unresolvedReference,
63
63
  } from './unresolved-references.mjs';
64
+ import {compareText} from '../text/compare-text.mjs';
64
65
 
65
66
  /**
66
67
  * @typedef {'not_in_code' | 'not_in_doc' | 'required_mismatch' | 'type_mismatch' | 'default_mismatch'} PropDriftKind
@@ -762,7 +763,7 @@ function inDeclaredOrder(ts, checker, type, symbol) {
762
763
  /** @type {(t: any) => string} */
763
764
  const text = t => checker.typeToString(t);
764
765
  return [...type.types].sort(
765
- (a, b) => place(a) - place(b) || text(a).localeCompare(text(b)),
766
+ (a, b) => place(a) - place(b) || compareText(text(a), text(b)),
766
767
  );
767
768
  }
768
769
 
@@ -1792,7 +1793,7 @@ export function comparePropTables(tables, options) {
1792
1793
  reason: `the package's TypeScript config has an error, so props were not read (${project.error})`,
1793
1794
  });
1794
1795
  }
1795
- unchecked.sort((a, b) => a.component.localeCompare(b.component));
1796
+ unchecked.sort((a, b) => compareText(a.component, b.component));
1796
1797
  return {
1797
1798
  status: 'checked',
1798
1799
  typescript: version,
@@ -2213,15 +2214,14 @@ export function comparePropTables(tables, options) {
2213
2214
  // sort one component's findings among another's that shares its prefix.
2214
2215
  findings.sort(
2215
2216
  (a, b) =>
2216
- a.component.localeCompare(b.component) ||
2217
- a.prop.localeCompare(b.prop) ||
2218
- a.kind.localeCompare(b.kind),
2217
+ compareText(a.component, b.component) ||
2218
+ compareText(a.prop, b.prop) ||
2219
+ compareText(a.kind, b.kind),
2219
2220
  );
2220
- unchecked.sort((a, b) => a.component.localeCompare(b.component));
2221
+ unchecked.sort((a, b) => compareText(a.component, b.component));
2221
2222
  typesNotCompared.sort(
2222
2223
  (a, b) =>
2223
- a.component.localeCompare(b.component) ||
2224
- a.reason.localeCompare(b.reason),
2224
+ compareText(a.component, b.component) || compareText(a.reason, b.reason),
2225
2225
  );
2226
2226
  return {
2227
2227
  status: 'checked',
@@ -2428,7 +2428,7 @@ export async function comparePropDocs(components, options) {
2428
2428
  return {
2429
2429
  ...report,
2430
2430
  unchecked: [...unchecked, ...report.unchecked].sort((a, b) =>
2431
- a.component.localeCompare(b.component),
2431
+ compareText(a.component, b.component),
2432
2432
  ),
2433
2433
  };
2434
2434
  }
@@ -32,6 +32,7 @@ export const RUNNER_COMMAND_ALLOWLIST: Readonly<{
32
32
  'packages/cli/assets/docs/tree/cli-command.doc.mjs': "explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them";
33
33
  'packages/cli/assets/docs/tree/who-answers.doc.mjs': "explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them";
34
34
  'packages/cli/assets/docs/tree/project-global-or-both.doc.mjs': "compares running the CLI with npx to installing it, and is found by searching for that command";
35
+ 'packages/cli/assets/docs/tree/render-pages.doc.mjs': "quotes the note a rendered file opens with, whose commands are pinned to `npx @astryxdesign/cli@<version>`";
35
36
  'packages/cli/assets/docs/tree/install-once.doc.mjs': "names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version";
36
37
  'packages/cli/assets/docs/tree/doc-syntax.doc.mjs': "shows what each doc token renders as, in every package manager";
37
38
  'packages/cli/assets/docs/tree/add-a-topic.doc.mjs': "shows what a reader sees for a command token, with their runner";
@@ -43,6 +43,8 @@ export const RUNNER_COMMAND_ALLOWLIST = Object.freeze({
43
43
  'explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them',
44
44
  'packages/cli/assets/docs/tree/project-global-or-both.doc.mjs':
45
45
  'compares running the CLI with npx to installing it, and is found by searching for that command',
46
+ 'packages/cli/assets/docs/tree/render-pages.doc.mjs':
47
+ 'quotes the note a rendered file opens with, whose commands are pinned to `npx @astryxdesign/cli@<version>`',
46
48
  'packages/cli/assets/docs/tree/install-once.doc.mjs':
47
49
  'names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version',
48
50
  'packages/cli/assets/docs/tree/doc-syntax.doc.mjs':
@@ -0,0 +1,43 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @typedef {object} StoredComponentList
6
+ * @property {Record<string, string[]>} groups - discoverComponents' answer.
7
+ * @property {Record<string, string>} imports - resolveImportPath's answer
8
+ * for each listed component.
9
+ */
10
+ /**
11
+ * The stored list for the Core in `coreDir`, while every file and folder its
12
+ * work read is unchanged; checked once per operation.
13
+ * @param {string} coreDir
14
+ * @returns {StoredComponentList | null}
15
+ */
16
+ export function storedComponentList(coreDir: string): StoredComponentList | null;
17
+ /**
18
+ * The stored list for `coreDir` when this operation has already checked it,
19
+ * without checking it: one lookup never pays for the check, which costs more
20
+ * than the lookup.
21
+ * @param {string} coreDir
22
+ * @returns {StoredComponentList | null}
23
+ */
24
+ export function checkedComponentList(coreDir: string): StoredComponentList | null;
25
+ /** Where the stored component list is written at `prepack`. */
26
+ export const COMPONENT_LIST_FILE: string;
27
+ /**
28
+ * Folder entries an install adds beside Core's own files: only `node_modules`.
29
+ * Every other name counts, so a file added anywhere the list reads misses the
30
+ * store.
31
+ */
32
+ export const CORE_FOLDER_SKIP: RegExp;
33
+ export type StoredComponentList = {
34
+ /**
35
+ * - discoverComponents' answer.
36
+ */
37
+ groups: Record<string, string[]>;
38
+ /**
39
+ * - resolveImportPath's answer
40
+ * for each listed component.
41
+ */
42
+ imports: Record<string, string>;
43
+ };