@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8

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 (380) 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 +28 -2
  29. package/api/docs/_adapter.mjs +249 -10
  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 +132 -1
  79. package/api/theme/build/build.mjs +482 -157
  80. package/api/theme/build/core-interception.d.mts +10 -0
  81. package/api/theme/build/core-interception.mjs +10 -0
  82. package/api/theme/build/font-warning.d.mts +44 -5
  83. package/api/theme/build/font-warning.mjs +118 -10
  84. package/api/theme/build/icon-imports.mjs +51 -9
  85. package/api/theme/theme.type.d.mts +10 -0
  86. package/api/theme/theme.type.mjs +7 -1
  87. package/api/theme-edit/_adapter.d.mts +115 -4
  88. package/api/theme-edit/_adapter.mjs +997 -83
  89. package/api/theme-edit/_catalog.d.mts +20 -2
  90. package/api/theme-edit/_catalog.mjs +50 -10
  91. package/api/theme-edit/_check.d.mts +75 -24
  92. package/api/theme-edit/_check.mjs +2672 -422
  93. package/api/theme-edit/_color.d.mts +10 -0
  94. package/api/theme-edit/_color.mjs +54 -1
  95. package/api/theme-edit/_compiler.d.mts +1 -0
  96. package/api/theme-edit/_compiler.mjs +133 -15
  97. package/api/theme-edit/_context.d.mts +14 -3
  98. package/api/theme-edit/_context.mjs +225 -65
  99. package/api/theme-edit/_css.d.mts +14 -0
  100. package/api/theme-edit/_css.mjs +46 -1
  101. package/api/theme-edit/_edit.d.mts +54 -4
  102. package/api/theme-edit/_edit.mjs +2966 -286
  103. package/api/theme-edit/_how-commands.d.mts +72 -1
  104. package/api/theme-edit/_how-commands.mjs +770 -9
  105. package/api/theme-edit/_how-question.d.mts +82 -5
  106. package/api/theme-edit/_how-question.mjs +6983 -701
  107. package/api/theme-edit/_how.d.mts +2 -1
  108. package/api/theme-edit/_how.mjs +237 -41
  109. package/api/theme-edit/_importers.d.mts +38 -0
  110. package/api/theme-edit/_importers.mjs +188 -0
  111. package/api/theme-edit/_marks.d.mts +31 -5
  112. package/api/theme-edit/_marks.mjs +57 -5
  113. package/api/theme-edit/_name-rule.d.mts +11 -0
  114. package/api/theme-edit/_name-rule.mjs +12 -0
  115. package/api/theme-edit/_normal.d.mts +303 -0
  116. package/api/theme-edit/_normal.mjs +1517 -0
  117. package/api/theme-edit/_palette.d.mts +12 -0
  118. package/api/theme-edit/_palette.mjs +37 -4
  119. package/api/theme-edit/_part-words.d.mts +31 -0
  120. package/api/theme-edit/_part-words.mjs +126 -0
  121. package/api/theme-edit/_parts.d.mts +28 -2
  122. package/api/theme-edit/_parts.mjs +267 -31
  123. package/api/theme-edit/_preview-app.d.mts +7 -13
  124. package/api/theme-edit/_preview-app.mjs +814 -406
  125. package/api/theme-edit/_preview.d.mts +116 -16
  126. package/api/theme-edit/_preview.mjs +649 -152
  127. package/api/theme-edit/_project.d.mts +22 -1
  128. package/api/theme-edit/_project.mjs +83 -3
  129. package/api/theme-edit/_settings.d.mts +467 -42
  130. package/api/theme-edit/_settings.mjs +3527 -468
  131. package/api/theme-edit/_tables.d.mts +21 -0
  132. package/api/theme-edit/_tables.mjs +97 -3
  133. package/api/theme-edit/_vet.d.mts +31 -0
  134. package/api/theme-edit/_vet.mjs +114 -8
  135. package/api/theme-edit/theme-edit.type.d.mts +16 -2
  136. package/api/theme-edit/theme-edit.type.mjs +6 -3
  137. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  138. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  139. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  140. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  141. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  142. package/api/upgrade/run/run.mjs +4 -3
  143. package/assets/codemods/integration-discovery.mjs +2 -1
  144. package/assets/codemods/run-codemod.mjs +87 -7
  145. package/assets/codemods/transforms/next/index.mjs +11 -1
  146. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  147. package/assets/component-list.generated.json +1 -0
  148. package/assets/docs/author-a-theme.doc.mjs +1 -0
  149. package/assets/docs/theme.doc.dense.mjs +2 -2
  150. package/assets/docs/theme.doc.mjs +1 -1
  151. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  152. package/assets/docs/tree/checks.doc.mjs +1 -1
  153. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  154. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  155. package/assets/docs/tree/share-a-page.doc.mjs +157 -0
  156. package/assets/docs/tree/single-component.doc.mjs +4 -0
  157. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  158. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  159. package/assets/docs/use-a-theme.doc.mjs +1 -1
  160. package/assets/docs.generated.json +2 -2
  161. package/assets/search-catalog.generated.json +2 -0
  162. package/assets/self-audit.generated.json +1 -1
  163. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  164. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  165. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  166. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  167. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  168. package/assets/templates/components.generated.json +1 -1
  169. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  170. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
  171. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  172. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  173. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  174. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  175. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  176. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  177. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  178. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  179. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  180. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  181. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  182. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  183. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  184. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  185. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  186. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  187. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  188. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  189. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  190. package/assets/templates/pages/ide/page.tsx +24 -2
  191. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  192. package/assets/templates/pages/library/template.doc.mjs +4 -1
  193. package/assets/templates/pages/login/template.doc.mjs +2 -1
  194. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  195. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  196. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  197. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  198. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  199. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  200. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  201. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  202. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  203. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  204. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  205. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  206. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  207. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  208. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  209. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  210. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  211. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  212. package/assets/theme.template.ts +6 -0
  213. package/authoring/debug/parse.d.mts +3 -3
  214. package/authoring/doctypes/_schema.d.mts +3 -3
  215. package/authoring/doctypes/command/command.doc.mjs +1 -1
  216. package/authoring/doctypes/component/categories.d.mts +37 -0
  217. package/authoring/doctypes/component/categories.mjs +54 -0
  218. package/authoring/doctypes/template/template.doc.mjs +1 -1
  219. package/authoring/doctypes/template/type.ts +9 -0
  220. package/authoring/example/example.doc.d.mts +12 -0
  221. package/authoring/example/example.doc.mjs +69 -0
  222. package/authoring/example/preview.d.mts +92 -0
  223. package/authoring/example/preview.mjs +994 -0
  224. package/authoring/example/type.ts +102 -0
  225. package/authoring/index.d.mts +1 -0
  226. package/authoring/index.d.ts +12 -0
  227. package/authoring/index.mjs +3 -1
  228. package/clients/cli/bin/astryx.mjs +6 -9
  229. package/clients/cli/build-id.generated.json +1 -1
  230. package/clients/cli/commands/component.doc.mjs +1 -1
  231. package/clients/cli/commands/component.mjs +22 -3
  232. package/clients/cli/commands/docs.doc.mjs +7 -1
  233. package/clients/cli/commands/docs.mjs +3 -1
  234. package/clients/cli/commands/doctor.mjs +32 -14
  235. package/clients/cli/commands/experimental/render.mjs +42 -1
  236. package/clients/cli/commands/experimental/theme.mjs +573 -119
  237. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  238. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  239. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  240. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  241. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  242. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  243. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  244. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  245. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  246. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  247. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  248. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  249. package/clients/cli/commands/search.doc.mjs +2 -1
  250. package/clients/cli/commands/search.mjs +6 -1
  251. package/clients/cli/commands/template.mjs +4 -2
  252. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  253. package/clients/cli/commands/theme.doc.mjs +1 -1
  254. package/clients/cli/commands/theme.mjs +718 -438
  255. package/clients/cli/commands/upgrade.mjs +42 -7
  256. package/clients/cli/index.mjs +1 -1
  257. package/clients/cli/lib/cli-error.mjs +2 -1
  258. package/clients/cli/lib/component-format.mjs +205 -98
  259. package/clients/cli/lib/hook-format.mjs +9 -19
  260. package/clients/cli/lib/json-shim.mjs +132 -24
  261. package/clients/cli/lib/manifest.mjs +3 -2
  262. package/clients/cli/manifest.generated.json +1 -1
  263. package/foundation/agent-docs/agent-docs.mjs +1 -1
  264. package/foundation/config/theme-state.d.mts +13 -1
  265. package/foundation/config/theme-state.mjs +47 -7
  266. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  267. package/foundation/discovery/component-discovery.d.mts +11 -0
  268. package/foundation/discovery/component-discovery.mjs +56 -8
  269. package/foundation/discovery/component-replacement.mjs +130 -1
  270. package/foundation/discovery/copied-passages.mjs +2 -1
  271. package/foundation/discovery/core-component-docs.d.mts +29 -0
  272. package/foundation/discovery/core-component-docs.mjs +83 -0
  273. package/foundation/discovery/doc-types.mjs +4 -3
  274. package/foundation/discovery/entry-name-files.d.mts +43 -0
  275. package/foundation/discovery/entry-name-files.mjs +264 -0
  276. package/foundation/discovery/hook-discovery.d.mts +8 -2
  277. package/foundation/discovery/hook-discovery.mjs +22 -8
  278. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  279. package/foundation/discovery/icon-set-checks.mjs +2 -1
  280. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  281. package/foundation/discovery/integration-doc-files.mjs +2 -1
  282. package/foundation/discovery/package-exports.d.mts +10 -0
  283. package/foundation/discovery/package-exports.mjs +56 -3
  284. package/foundation/discovery/prop-drift.mjs +9 -9
  285. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  286. package/foundation/discovery/runner-allowlist.mjs +2 -0
  287. package/foundation/discovery/stored-component-list.d.mts +43 -0
  288. package/foundation/discovery/stored-component-list.mjs +90 -0
  289. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  290. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  291. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  292. package/foundation/discovery/stored-self-audit.mjs +38 -18
  293. package/foundation/discovery/template-adapter.d.mts +53 -1
  294. package/foundation/discovery/template-adapter.mjs +176 -12
  295. package/foundation/discovery/template-icons.mjs +2 -1
  296. package/foundation/discovery/theme-discovery.mjs +31 -4
  297. package/foundation/discovery/theme-imports.d.mts +14 -0
  298. package/foundation/discovery/theme-imports.mjs +43 -1
  299. package/foundation/discovery/theming-targets.d.mts +6 -5
  300. package/foundation/discovery/theming-targets.mjs +31 -47
  301. package/foundation/doc-compiler/import.mjs +7 -1
  302. package/foundation/doc-compiler/inputs.mjs +3 -2
  303. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  304. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  305. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  306. package/foundation/env/semver.mjs +3 -1
  307. package/foundation/fonts/font-stylesheet.d.mts +38 -0
  308. package/foundation/fonts/font-stylesheet.mjs +141 -0
  309. package/foundation/fs/cache-eviction.d.mts +21 -0
  310. package/foundation/fs/cache-eviction.mjs +73 -0
  311. package/foundation/fs/exact-codec.d.mts +12 -2
  312. package/foundation/fs/exact-codec.mjs +23 -6
  313. package/foundation/fs/file-protection.mjs +4 -3
  314. package/foundation/fs/gather-cache.d.mts +62 -4
  315. package/foundation/fs/gather-cache.mjs +517 -91
  316. package/foundation/fs/jiti-cache.d.mts +19 -1
  317. package/foundation/fs/jiti-cache.mjs +130 -6
  318. package/foundation/fs/kept-tree.d.mts +60 -0
  319. package/foundation/fs/kept-tree.mjs +154 -0
  320. package/foundation/fs/listing-cache.d.mts +7 -0
  321. package/foundation/fs/listing-cache.mjs +10 -0
  322. package/foundation/fs/module-loader.d.mts +24 -2
  323. package/foundation/fs/module-loader.mjs +94 -21
  324. package/foundation/fs/paths.d.mts +18 -0
  325. package/foundation/fs/paths.mjs +15 -2
  326. package/foundation/fs/read-record.d.mts +9 -0
  327. package/foundation/fs/read-record.mjs +19 -11
  328. package/foundation/fs/stop-cleanup.d.mts +12 -0
  329. package/foundation/fs/stop-cleanup.mjs +66 -0
  330. package/foundation/identity/provider-identity.d.mts +6 -0
  331. package/foundation/identity/provider-identity.mjs +10 -1
  332. package/foundation/integrations/contribution-inventory.mjs +4 -3
  333. package/foundation/integrations/example-code.d.mts +63 -0
  334. package/foundation/integrations/example-code.mjs +416 -0
  335. package/foundation/integrations/public-imports.d.mts +9 -0
  336. package/foundation/integrations/public-imports.mjs +3 -2
  337. package/foundation/integrations/validate-contributions.mjs +17 -45
  338. package/foundation/render/embedded-files.d.mts +6 -0
  339. package/foundation/render/embedded-files.mjs +25 -5
  340. package/foundation/render/embedded-imports.d.mts +39 -7
  341. package/foundation/render/embedded-imports.mjs +66 -27
  342. package/foundation/render/file-header.d.mts +66 -0
  343. package/foundation/render/file-header.mjs +118 -0
  344. package/foundation/render/host-answer.d.mts +18 -0
  345. package/foundation/render/host-answer.mjs +46 -0
  346. package/foundation/render/host-exit.d.mts +1 -0
  347. package/foundation/render/host-exit.mjs +6 -1
  348. package/foundation/render/html-reader.d.mts +55 -2
  349. package/foundation/render/html-reader.mjs +145 -26
  350. package/foundation/render/markup-edits.d.mts +57 -0
  351. package/foundation/render/markup-edits.mjs +182 -0
  352. package/foundation/render/page-host.mjs +29 -12
  353. package/foundation/render/page-worker.mjs +121 -13
  354. package/foundation/render/picture-chrome.d.mts +4 -0
  355. package/foundation/render/picture-chrome.mjs +185 -0
  356. package/foundation/render/picture-playwright.d.mts +4 -0
  357. package/foundation/render/picture-playwright.mjs +34 -0
  358. package/foundation/render/rebuild.mjs +2 -1
  359. package/foundation/render/render-page.d.mts +35 -3
  360. package/foundation/render/render-page.mjs +641 -96
  361. package/foundation/render/source-block.d.mts +85 -6
  362. package/foundation/render/source-block.mjs +211 -20
  363. package/foundation/render/ts-paths.d.mts +69 -6
  364. package/foundation/render/ts-paths.mjs +326 -40
  365. package/foundation/response/error-codes.d.mts +3 -1
  366. package/foundation/response/error-codes.d.ts +1 -0
  367. package/foundation/response/error-codes.doc.mjs +12 -1
  368. package/foundation/response/error-codes.mjs +11 -1
  369. package/foundation/response/response-types.doc.mjs +2 -2
  370. package/foundation/text/compare-text.d.mts +14 -0
  371. package/foundation/text/compare-text.mjs +68 -0
  372. package/foundation/text/css-escape.d.mts +18 -0
  373. package/foundation/text/css-escape.mjs +35 -0
  374. package/foundation/text/string-utils.d.mts +3 -2
  375. package/foundation/text/string-utils.mjs +18 -4
  376. package/foundation/text/suggest-order.d.mts +9 -0
  377. package/foundation/text/suggest-order.mjs +15 -1
  378. package/foundation/xle/expand.mjs +2 -1
  379. package/host/index.mjs +8 -6
  380. package/package.json +7 -6
@@ -0,0 +1,102 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Types for reading a doc example as a module that runs on its own.
5
+ * @input Nothing; types only.
6
+ * @output ExampleScope, PreviewableExample, ExampleProblem and the names they
7
+ * compose from.
8
+ * @position packages/cli/authoring/example — the contract `preview.mjs`
9
+ * implements and `example.doc.mjs` documents.
10
+ */
11
+
12
+ /**
13
+ * Why an example that is not `kind: 'setup'` cannot run on its own.
14
+ * - `example_does_not_compile`: the code is not a TSX module (a top-level
15
+ * `return`, code that stops partway, a syntax error).
16
+ * - `example_renders_nothing`: no default export, no component, and no JSX
17
+ * at the end.
18
+ * - `example_undefined_name`: a name the example never defines or imports
19
+ * and its scope does not provide.
20
+ * - `example_server_only`: it imports code that runs only on a server,
21
+ * renders an async server component, or reads `process.env`.
22
+ * - `example_import_unresolvable`: it imports a relative path, or a package
23
+ * its package does not declare.
24
+ */
25
+ export type ExampleProblemCode =
26
+ | 'example_does_not_compile'
27
+ | 'example_renders_nothing'
28
+ | 'example_undefined_name'
29
+ | 'example_server_only'
30
+ | 'example_import_unresolvable';
31
+
32
+ /** One reason an example cannot preview, with what to change. */
33
+ export interface ExampleProblem {
34
+ code: ExampleProblemCode;
35
+ /** What is wrong and what it breaks, as one clause. */
36
+ message: string;
37
+ /** What to change, as one or two sentences. */
38
+ fix: string;
39
+ /**
40
+ * The names an `example_undefined_name` problem found, in order of use, or
41
+ * the server component an `example_server_only` problem found.
42
+ */
43
+ names?: string[];
44
+ /** The import an import problem is about. */
45
+ specifier?: string;
46
+ /** Where a `example_does_not_compile` problem is, 1-based. */
47
+ line?: number;
48
+ /** Where a `example_does_not_compile` problem is, 0-based. */
49
+ column?: number;
50
+ }
51
+
52
+ /** A name an example may use without importing it, and where it comes from. */
53
+ export interface ExampleScopeName {
54
+ name: string;
55
+ /** The module specifier an app imports the name from. */
56
+ import: string;
57
+ }
58
+
59
+ /**
60
+ * What an example may use without importing it, and what it may import, as
61
+ * JSON: one tool can build it (`integrationExampleScope` in
62
+ * `@astryxdesign/cli/api`) and store it, and another read examples with it.
63
+ * When two lists give one name, the package's own wins over Core's, and
64
+ * Core's over React's.
65
+ */
66
+ export interface ExampleScope {
67
+ /** The package the example documents. It may import itself. */
68
+ packageName: string;
69
+ /** Each component the package documents. */
70
+ packageNames: ReadonlyArray<ExampleScopeName>;
71
+ /** Each component and hook Core documents. */
72
+ coreNames: ReadonlyArray<ExampleScopeName>;
73
+ /** React's named exports. `React` itself is the namespace. */
74
+ reactNames: ReadonlyArray<string>;
75
+ /**
76
+ * The packages the package declares in `dependencies`,
77
+ * `peerDependencies` and `optionalDependencies`. React and Core may always
78
+ * be imported.
79
+ */
80
+ dependencies: ReadonlyArray<string>;
81
+ /**
82
+ * The package's own import specifiers whose module runs only on a server
83
+ * (it imports `server-only`), such as `'@acme/widgets/server'`. Every scope
84
+ * also counts `server-only`, `next/headers`, `next/server`, `next/cache` and
85
+ * a Node built-in the package does not install.
86
+ */
87
+ serverOnlyModules?: ReadonlyArray<string>;
88
+ /**
89
+ * The package's documented components that only a server renders: async
90
+ * function components. An example that renders one is server-only.
91
+ */
92
+ serverComponents?: ReadonlyArray<string>;
93
+ }
94
+
95
+ /**
96
+ * An example read as a module. A previewable example's `module` imports
97
+ * every scope name it uses and default-exports what it renders.
98
+ */
99
+ export type PreviewableExample =
100
+ | {previewable: true; module: string}
101
+ | {previewable: false; setup: true}
102
+ | {previewable: false; setup: false; problems: ExampleProblem[]};
@@ -19,5 +19,6 @@ export { parseNamespace } from "./doctypes/namespace/parse.mjs";
19
19
  export { parseTheme } from "./doctypes/theme/parse.mjs";
20
20
  export { parseIconDefinition } from "./doctypes/icon-definition/parse.mjs";
21
21
  export { parseLegacyDoc } from "./doctypes/legacy.mjs";
22
+ export { previewableExample } from "./example/preview.mjs";
22
23
  export { parseGapReportHandler, parseGapReportReceipt } from "./gap-report/parse.mjs";
23
24
  export { parseIconSet, parseIconSetData } from "./doctypes/icon-set/parse.mjs";
@@ -88,6 +88,18 @@ export {parseDiscoverCatalog} from './discover/parse.mjs';
88
88
  export {parseCodemod} from './codemod/parse.mjs';
89
89
  export {parseDebugEvent} from './debug/parse.mjs';
90
90
 
91
+ // ═══════════════════════════════════════════════════════════════════════
92
+ // EXAMPLES — whether a doc example runs on its own, as a live preview does.
93
+ // ═══════════════════════════════════════════════════════════════════════
94
+ export {previewableExample} from './example/preview.mjs';
95
+ export type {
96
+ ExampleScope,
97
+ ExampleScopeName,
98
+ PreviewableExample,
99
+ ExampleProblem,
100
+ ExampleProblemCode,
101
+ } from './example/type.js';
102
+
91
103
  // ═══════════════════════════════════════════════════════════════════════
92
104
  // FIELD & SUB-TYPES — the building blocks of the docs above. Import these
93
105
  // only to annotate a part directly (or to read/render docs); you rarely
@@ -5,7 +5,8 @@
5
5
  *
6
6
  * Authoring is a pure data contract: TYPES authors write plain objects against,
7
7
  * and PARSERS the CLI calls to turn `unknown` into the typed shape (or throw a
8
- * readable error) at the load boundary. Zod is an implementation detail sealed
8
+ * readable error) at the load boundary. `previewableExample` reads a doc
9
+ * example as the module a live preview runs, or says why it cannot run. Zod is an implementation detail sealed
9
10
  * inside each parser — it is never exported here and never appears in a public
10
11
  * type. There are no `create*` factories: author a plain object and stamp its
11
12
  * `type` directly.
@@ -39,3 +40,4 @@ export {parseIconSet, parseIconSetData} from './doctypes/icon-set/parse.mjs';
39
40
  /** @experimental Icon definitions may change or be removed in a patch release. */
40
41
  export {parseIconDefinition} from './doctypes/icon-definition/parse.mjs';
41
42
  export {parseLegacyDoc} from './doctypes/legacy.mjs';
43
+ export {previewableExample} from './example/preview.mjs';
@@ -33,10 +33,10 @@ import {
33
33
 
34
34
  // Node's compile cache keeps the compiled form of the CLI's modules between
35
35
  // runs, so a run skips most of their compiling. It lives in a folder of the
36
- // user's own in the system temp folder (node-compile-cache-<uid>). It is used
37
- // only once that folder exists, so a machine's first run just makes it and a
38
- // one-off run never pays to write the cache; and only while it is a real
39
- // folder the user owns that no one else can reach, since a shared folder
36
+ // user's own in the system temp folder (node-compile-cache-<uid>). A machine's
37
+ // first run makes that folder and writes the cache at once, so the next run
38
+ // (most often the same session's next command) reads it. It is used only
39
+ // while it is a real folder the user owns that no one else can reach, since a shared folder
40
40
  // could hold planted cache files (foundation/env/private-dir.mjs, the check
41
41
  // the kept search catalogs use too). Where the system has no user ids
42
42
  // (Windows), ownership cannot be checked, so the cache stays off.
@@ -46,11 +46,8 @@ try {
46
46
  const uid = currentUid();
47
47
  if (!process.env.NODE_DISABLE_COMPILE_CACHE && uid != null) {
48
48
  const cacheDir = join(tmpdir(), `node-compile-cache-${uid}`);
49
- if (!existsSync(cacheDir)) {
50
- mkdirSync(cacheDir, {mode: 0o700});
51
- } else if (isPrivateDir(cacheDir)) {
52
- nodeModule.enableCompileCache?.(cacheDir);
53
- }
49
+ if (!existsSync(cacheDir)) mkdirSync(cacheDir, {mode: 0o700});
50
+ if (isPrivateDir(cacheDir)) nodeModule.enableCompileCache?.(cacheDir);
54
51
  }
55
52
  } catch {
56
53
  // A run without the cache is the same run, only slower.
@@ -1 +1 @@
1
- {"id":"2fd8a67997004e9c76567e608ad5c22de55d671da1515ff9f3a6c2e68b8ca46d"}
1
+ {"id":"99973261604c574472ecc89032cf029049cdcdd382f999e73bee92df8d7eb7a6"}
@@ -51,7 +51,7 @@ export const doc = {
51
51
  {
52
52
  flag: '--props',
53
53
  param: 'options.props',
54
- description: 'Print only the props table',
54
+ description: 'Print only the props list',
55
55
  },
56
56
  {
57
57
  flag: '--source',
@@ -31,6 +31,7 @@ import {Project} from '../../../foundation/config/project.mjs';
31
31
  import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
32
32
  import {doc as componentCommand} from './component.doc.mjs';
33
33
  import {doc as componentFn} from '../../../api/component/component.doc.mjs';
34
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
34
35
 
35
36
  /**
36
37
  * The api layer's component() widens its return to `{type: string, data: unknown}`,
@@ -95,9 +96,16 @@ function summarize(result) {
95
96
  * @param {string} requestedName
96
97
  * @param {'full'|'compact'|'brief'} detail
97
98
  * @param {Awaited<ReturnType<typeof resolveTheme>>} themeData
99
+ * @param {string} [scopePackage] - the `--package` the read was scoped to
98
100
  * @returns {import('../formatters/index.mjs').Block[]}
99
101
  */
100
- function componentDetailBlocks(result, requestedName, detail, themeData) {
102
+ function componentDetailBlocks(
103
+ result,
104
+ requestedName,
105
+ detail,
106
+ themeData,
107
+ scopePackage,
108
+ ) {
101
109
  const requested = (requestedName.split('/').pop() ?? requestedName).replace(
102
110
  /^XDS/,
103
111
  '',
@@ -110,6 +118,12 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
110
118
  result.data.replaces === requested
111
119
  ? result.data.name
112
120
  : requested;
121
+ // The command that prints this read's props whole names the read's own
122
+ // selector and scope, so it resolves to the same component.
123
+ const scope = scopePackage ? ` --package ${scopePackage}` : '';
124
+ const propsCommand = requestedName
125
+ ? `component ${requestedName}${scope} --props`
126
+ : null;
113
127
  switch (result.type) {
114
128
  case 'component.detail': {
115
129
  /** @type {import('../formatters/index.mjs').Block[]} */
@@ -126,12 +140,15 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
126
140
  )
127
141
  : detail === 'compact'
128
142
  ? code(
129
- formatCompact(result.data, resolvedName, result.data.import),
143
+ formatCompact(result.data, resolvedName, result.data.import, {
144
+ propsCommand,
145
+ }),
130
146
  )
131
147
  : code(
132
148
  formatFull(result.data, {
133
149
  themeData,
134
150
  importHint: result.data.import,
151
+ propsCommand,
135
152
  }),
136
153
  ),
137
154
  );
@@ -380,7 +397,7 @@ export function registerComponent(program) {
380
397
  const firstGroup = Object.entries(groups)[0];
381
398
  const entries =
382
399
  options.category && firstGroup ? firstGroup[1] : Object.values(groups).flat();
383
- const sorted = [...entries].sort((a, b) => a.name.localeCompare(b.name));
400
+ const sorted = [...entries].sort((a, b) => compareText(a.name, b.name));
384
401
 
385
402
  emit(
386
403
  options.category && firstGroup
@@ -425,6 +442,7 @@ export function registerComponent(program) {
425
442
  row.selector,
426
443
  detail,
427
444
  themeData,
445
+ options.package,
428
446
  ),
429
447
  );
430
448
  continue;
@@ -472,6 +490,7 @@ export function registerComponent(program) {
472
490
  name ?? '',
473
491
  detail,
474
492
  themeData,
493
+ options.package,
475
494
  ),
476
495
  );
477
496
  break;
@@ -32,6 +32,11 @@ export const doc = {
32
32
  {name: 'section', param: 'section', required: false},
33
33
  ],
34
34
  options: [
35
+ {
36
+ flag: '--list',
37
+ param: 'options.list',
38
+ description: 'List every topic (the same as giving no topic)',
39
+ },
35
40
  {
36
41
  flag: '--index',
37
42
  param: 'options.index',
@@ -51,6 +56,7 @@ export const doc = {
51
56
  ],
52
57
  examples: [
53
58
  {label: 'List topics', cli: 'astryx docs'},
59
+ {label: 'The same list, asked for by flag', cli: 'astryx docs --list'},
54
60
  {label: "A topic's sections", cli: 'astryx docs theme'},
55
61
  {label: 'A whole topic as JSON', cli: 'astryx docs spacing --json'},
56
62
  {label: 'One section', cli: 'astryx docs theme quick-start'},
@@ -72,7 +78,7 @@ export const doc = {
72
78
  {code: 0, when: 'success'},
73
79
  {
74
80
  code: 1,
75
- when: 'unknown topic or route, a section that matches no section or more than one, or a --depth that is not a number of levels or all',
81
+ when: 'unknown topic or route, a section that matches no section or more than one, a --depth that is not a number of levels or all, or --list given a topic or section',
76
82
  },
77
83
  ],
78
84
  related: ['search', 'component', 'hook', 'template'],
@@ -16,6 +16,7 @@
16
16
  *
17
17
  * Usage:
18
18
  * astryx docs List available topics
19
+ * astryx docs --list The same list, asked for by flag
19
20
  * astryx docs <topic> List the topic's sections (a topic
20
21
  * with one section prints whole)
21
22
  * astryx docs <topic> <section> Print one section
@@ -650,7 +651,7 @@ export function registerDocs(program) {
650
651
  action: async (
651
652
  /** @type {string | undefined} */ topic,
652
653
  /** @type {string | undefined} */ sectionName,
653
- /** @type {{index?: boolean, full?: boolean, depth?: string}} */ options = {},
654
+ /** @type {{list?: boolean, index?: boolean, full?: boolean, depth?: string}} */ options = {},
654
655
  ) => {
655
656
  const run = getCliInvocation();
656
657
  const lang = program.opts().lang || null;
@@ -697,6 +698,7 @@ export function registerDocs(program) {
697
698
  lang,
698
699
  zh,
699
700
  dense,
701
+ list: options.list,
700
702
  index: listSections,
701
703
  ...(depth != null ? {depth, detail: childDetail} : {}),
702
704
  });
@@ -22,14 +22,7 @@ import {
22
22
  validateIntegration,
23
23
  } from '../../../api/integration/validate-integration.mjs';
24
24
  import {jsonOut} from '../../../foundation/response/json.mjs';
25
- import {
26
- emit,
27
- list,
28
- section,
29
- record,
30
- records,
31
- text,
32
- } from '../formatters/index.mjs';
25
+ import {emit, list, section, records, text} from '../formatters/index.mjs';
33
26
  import {defineCommand} from '../lib/define-command.mjs';
34
27
  import {doc as doctorCommand} from './doctor.doc.mjs';
35
28
  import {doc as doctorIntegrationGroup} from './doctor-integration.doc.mjs';
@@ -58,6 +51,15 @@ const STATUS = {
58
51
  info: '[info]',
59
52
  };
60
53
 
54
+ /** A doctor check's fields in text order: the status column, then the rest. */
55
+ const CHECK_FIELDS = /** @type {const} */ ([
56
+ 'status',
57
+ 'id',
58
+ 'label',
59
+ 'message',
60
+ 'fix',
61
+ ]);
62
+
61
63
  /** @param {string} status */
62
64
  function statusToken(status) {
63
65
  return STATUS[/** @type {keyof typeof STATUS} */ (status)] ?? status;
@@ -80,15 +82,21 @@ function printHuman(report) {
80
82
  ? 'No failures — but review the [warn] warnings above when you can.'
81
83
  : 'All checks passed. Your Astryx setup looks healthy.';
82
84
 
83
- // Field names are the JSON keys, so text and --json map one to one.
85
+ // One check per line, status first so the counted value stays a column.
86
+ // The legend names each field by its JSON key, so text and --json map one
87
+ // to one.
88
+ const summaryFields = /** @type {const} */ (['pass', 'warn', 'fail', 'info']);
84
89
  emit(
85
- section('astryx doctor — diagnosing your setup'),
90
+ section('astryx doctor', `Each check: ${CHECK_FIELDS.join(', ')}`),
86
91
  records(report.checks, {
87
- fields: ['id', 'status', 'label', 'message', 'fix'],
88
- format: {status: statusToken},
92
+ fields: [...CHECK_FIELDS],
93
+ layout: 'inline',
94
+ format: {status: statusToken, fix: fix => `fix: ${fix}`},
89
95
  }),
90
- section('summary'),
91
- record(report.summary, {fields: ['pass', 'warn', 'fail', 'info']}),
96
+ section(
97
+ 'summary',
98
+ summaryFields.map(key => `${key}: ${report.summary[key]}`).join(', '),
99
+ ),
92
100
  text(closing),
93
101
  );
94
102
  }
@@ -308,6 +316,16 @@ function printIntegrationValidation(data, seen) {
308
316
  }),
309
317
  ]
310
318
  : []),
319
+ ...(data.exampleCode && data.exampleCode.unchecked.length > 0
320
+ ? [
321
+ text(
322
+ `[info] Examples not checked: ${data.exampleCode.unchecked.length}:`,
323
+ ),
324
+ records(data.exampleCode.unchecked, {
325
+ fields: ['file', 'example', 'reason'],
326
+ }),
327
+ ]
328
+ : []),
311
329
  );
312
330
  }
313
331
 
@@ -14,6 +14,7 @@
14
14
  */
15
15
 
16
16
  import {getCliInvocation} from '../../../../foundation/env/package-manager.mjs';
17
+ import {shellArg} from '../../../../foundation/text/shell-arg.mjs';
17
18
  import {jsonOut} from '../../../../foundation/response/json.mjs';
18
19
  import {resultSet} from '../../../../foundation/debug/index.mjs';
19
20
  import {emit, section, text, record, list} from '../../formatters/index.mjs';
@@ -76,11 +77,12 @@ export function registerExperimentalRender(group, program) {
76
77
  ...(d.warnings.length > 0
77
78
  ? [section('Warnings'), list(d.warnings.map(w => w.message))]
78
79
  : []),
79
- text(`Give it back: ${run} experimental render --reverse ${d.output}`),
80
+ text(`Give it back: ${run} experimental render --reverse ${shellArg(d.output)}`),
80
81
  );
81
82
  return answered;
82
83
  }
83
84
  const d = result.data;
85
+ const edits = d.edits ?? [];
84
86
  emit(
85
87
  section(d.mode === 'embedded' ? `Restored ${d.output}` : `Rebuilt ${d.output}`),
86
88
  record({
@@ -90,6 +92,7 @@ export function registerExperimentalRender(group, program) {
90
92
  output: d.output,
91
93
  files: d.files.join(', '),
92
94
  ...(d.missing?.length ? {missing: d.missing.join(', ')} : {}),
95
+ ...(d.aliased ? {aliased: d.aliased.imports.map(a => `${a.import} (${a.file})`).join(', ')} : {}),
93
96
  ...(d.mode === 'rebuilt'
94
97
  ? {
95
98
  components: (d.components ?? []).join(', ') || 'none',
@@ -98,6 +101,12 @@ export function registerExperimentalRender(group, program) {
98
101
  ...(d.unknown?.length ? {unknown: d.unknown.join(', ')} : {}),
99
102
  }
100
103
  : {}),
104
+ ...(d.format === undefined ? {} : {format: d.format}),
105
+ ...(d.renderedBy ? {renderedBy: d.renderedBy} : {}),
106
+ ...(d.packages ? {packages: d.packages.join(', ') || 'none'} : {}),
107
+ ...(d.title === undefined ? {} : {title: d.title}),
108
+ ...(d.edited === undefined ? {} : {edited: d.edited}),
109
+ ...(d.stylesEdited === undefined ? {} : {stylesEdited: d.stylesEdited}),
101
110
  }),
102
111
  ...(d.mode === 'rebuilt'
103
112
  ? [
@@ -106,6 +115,38 @@ export function registerExperimentalRender(group, program) {
106
115
  ),
107
116
  ]
108
117
  : []),
118
+ ...(d.aliased
119
+ ? [
120
+ text(
121
+ `The page imports ${d.aliased.imports.length === 1 ? 'a file' : 'files'} through a path alias this project does not have, so ${d.aliased.imports.length === 1 ? 'it' : 'they'} came back in the page's own layout. To build or render the page again, set the "paths" of ${d.aliased.config} (create it if it is not there) to: ${Object.entries(d.aliased.paths)
122
+ .map(([key, targets]) => `${JSON.stringify(key)}: ${JSON.stringify(targets)}`)
123
+ .join(', ')}.`,
124
+ ),
125
+ ]
126
+ : []),
127
+ ...(d.edited
128
+ ? [
129
+ section('Changed after the render'),
130
+ ...(edits.length > 0
131
+ ? edits.map(edit =>
132
+ record({
133
+ was: edit.was ?? '(added after the render)',
134
+ now: edit.now ?? '(removed after the render)',
135
+ ...(edit.file ? {file: edit.file, line: edit.line} : {}),
136
+ }),
137
+ )
138
+ : [text(d.stylesEdited ? 'Only the styles changed after the render; the text did not.' : 'The markup changed after the render, but its text did not: only attributes, elements or formatting.')]),
139
+ ...(d.moreEdits ? [record({moreEdits: d.moreEdits})] : []),
140
+ text('The restored files are the page as rendered, without these changes: make them in the restored files, then render again.'),
141
+ ]
142
+ : []),
143
+ ...(d.mode === 'embedded'
144
+ ? [
145
+ text(
146
+ `Render it again: ${run} experimental render ${shellArg(d.output)} --out ${shellArg(d.input)}${d.title === undefined ? '' : ` --title ${shellArg(d.title)}`}`,
147
+ ),
148
+ ]
149
+ : []),
109
150
  );
110
151
  return answered;
111
152
  },