@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69

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 (426) hide show
  1. package/README.md +64 -63
  2. package/api/build/_adapter.d.mts +51 -0
  3. package/api/build/_adapter.mjs +122 -6
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.mjs +23 -14
  6. package/api/build/build.type.d.mts +1 -1
  7. package/api/build/build.type.mjs +3 -3
  8. package/api/build/help/help.d.mts +15 -14
  9. package/api/build/help/help.mjs +62 -3
  10. package/api/build/kit/answer.mjs +2 -3
  11. package/api/build/kit/signals.d.mts +10 -0
  12. package/api/build/kit/signals.mjs +15 -2
  13. package/api/component/detail/blocks/blocks.mjs +2 -1
  14. package/api/discover/_adapter.d.mts +57 -6
  15. package/api/discover/_adapter.mjs +278 -49
  16. package/api/discover/_catalog-view.d.mts +7 -0
  17. package/api/discover/_catalog-view.mjs +10 -1
  18. package/api/discover/detail/detail.d.mts +3 -2
  19. package/api/discover/detail/detail.mjs +3 -2
  20. package/api/discover/detail/doc/doc.mjs +1 -1
  21. package/api/discover/discover.d.mts +24 -0
  22. package/api/discover/discover.doc.mjs +1 -1
  23. package/api/discover/discover.mjs +146 -25
  24. package/api/discover/discover.type.d.mts +6 -4
  25. package/api/discover/discover.type.mjs +6 -4
  26. package/api/discover/search/search.d.mts +22 -0
  27. package/api/discover/search/search.mjs +290 -70
  28. package/api/docs/_entry-names.mjs +4 -3
  29. package/api/doctor/_adapter.d.mts +43 -3
  30. package/api/doctor/_adapter.mjs +142 -18
  31. package/api/doctor/built-checks.d.mts +30 -3
  32. package/api/doctor/built-checks.mjs +132 -5
  33. package/api/doctor/doctor.d.mts +93 -6
  34. package/api/doctor/doctor.doc.mjs +2 -2
  35. package/api/doctor/doctor.mjs +524 -33
  36. package/api/doctor/doctor.type.d.mts +2 -1
  37. package/api/doctor/doctor.type.mjs +2 -1
  38. package/api/doctor/theme-checks.d.mts +19 -0
  39. package/api/doctor/theme-checks.mjs +74 -6
  40. package/api/hook/hook.type.d.mts +1 -1
  41. package/api/hook/hook.type.mjs +1 -1
  42. package/api/hook/list/list.mjs +11 -7
  43. package/api/icon/_adapter.d.mts +2 -1
  44. package/api/icon/_adapter.mjs +10 -15
  45. package/api/icon/_records.d.mts +3 -1
  46. package/api/icon/_records.mjs +30 -3
  47. package/api/icon/exportIconIndex.doc.mjs +1 -1
  48. package/api/icon/icon.doc.mjs +3 -3
  49. package/api/icon/icon.type.d.mts +32 -1
  50. package/api/icon/icon.type.mjs +19 -3
  51. package/api/icon/list/list.mjs +4 -1
  52. package/api/icon/rankIconIndex.doc.mjs +1 -1
  53. package/api/icon/search/icon-index.mjs +18 -8
  54. package/api/icon/search/search.d.mts +26 -3
  55. package/api/icon/search/search.mjs +155 -9
  56. package/api/init/_adapter.d.mts +14 -0
  57. package/api/init/_adapter.mjs +26 -4
  58. package/api/init/init.d.mts +1 -1
  59. package/api/init/init.doc.mjs +2 -2
  60. package/api/init/init.mjs +1 -1
  61. package/api/init/init.type.d.mts +29 -1
  62. package/api/init/init.type.mjs +14 -1
  63. package/api/init/run/run.d.mts +11 -1
  64. package/api/init/run/run.mjs +84 -5
  65. package/api/integration/_adapter.d.mts +5 -4
  66. package/api/integration/_adapter.mjs +7 -5
  67. package/api/integration/integrationCheck.doc.mjs +1 -1
  68. package/api/integration/pack-check.mjs +8 -9
  69. package/api/integration/validate-integration.d.mts +1 -1
  70. package/api/integration/validate-integration.mjs +26 -24
  71. package/api/integration/validate-integration.type.d.mts +5 -2
  72. package/api/integration/validate-integration.type.mjs +5 -2
  73. package/api/integration/validateIntegration.doc.mjs +1 -1
  74. package/api/render/_adapter.d.mts +4 -2
  75. package/api/render/_adapter.mjs +62 -21
  76. package/api/render/render.doc.mjs +8 -5
  77. package/api/render/render.mjs +1 -1
  78. package/api/render/render.type.d.mts +2 -0
  79. package/api/render/render.type.mjs +2 -0
  80. package/api/search/ORDERING.md +2 -2
  81. package/api/search/_candidate-score.d.mts +3 -0
  82. package/api/search/_candidate-score.mjs +36 -3
  83. package/api/search/_gather-docs.mjs +29 -2
  84. package/api/search/_gather-templates.mjs +2 -1
  85. package/api/search/_main-searcher.mjs +13 -0
  86. package/api/search/_named-keywords.d.mts +2 -1
  87. package/api/search/_named-keywords.mjs +48 -6
  88. package/api/search/_order.d.mts +36 -1
  89. package/api/search/_order.mjs +141 -3
  90. package/api/swizzle/list/list.mjs +8 -1
  91. package/api/swizzle/swizzle.type.d.mts +1 -1
  92. package/api/swizzle/swizzle.type.mjs +1 -1
  93. package/api/template/copy/copy.mjs +3 -4
  94. package/api/template/list/list.mjs +2 -1
  95. package/api/template/show/show.mjs +2 -1
  96. package/api/template/skeleton/skeleton.mjs +2 -1
  97. package/api/template/template.doc.mjs +1 -1
  98. package/api/template/template.mjs +19 -1
  99. package/api/template/template.type.d.mts +1 -0
  100. package/api/template/template.type.mjs +2 -1
  101. package/api/theme/_adapter.d.mts +1 -0
  102. package/api/theme/_adapter.mjs +3 -5
  103. package/api/theme/_app-provider.d.mts +42 -0
  104. package/api/theme/_app-provider.mjs +61 -27
  105. package/api/theme/build/build.d.mts +4 -10
  106. package/api/theme/build/build.mjs +165 -116
  107. package/api/theme/build/input-fields.d.mts +9 -0
  108. package/api/theme/build/input-fields.mjs +155 -16
  109. package/api/theme/build/radius-values.d.mts +18 -0
  110. package/api/theme/build/radius-values.mjs +76 -0
  111. package/api/theme/build/typography-values.mjs +7 -23
  112. package/api/theme/build/written-values.d.mts +18 -0
  113. package/api/theme/build/written-values.mjs +107 -31
  114. package/api/theme/eject/eject.mjs +6 -1
  115. package/api/theme/palette/generate/generator.mjs +24 -0
  116. package/api/theme/theme.type.d.mts +4 -2
  117. package/api/theme/theme.type.mjs +3 -2
  118. package/api/theme/themeBuild.doc.mjs +2 -2
  119. package/api/theme/themeEject.doc.mjs +1 -1
  120. package/api/theme-edit/_catalog.d.mts +40 -0
  121. package/api/theme-edit/_catalog.mjs +100 -22
  122. package/api/theme-edit/_check.mjs +213 -43
  123. package/api/theme-edit/_color.d.mts +14 -0
  124. package/api/theme-edit/_color.mjs +22 -0
  125. package/api/theme-edit/_compiler.mjs +52 -0
  126. package/api/theme-edit/_context.d.mts +20 -2
  127. package/api/theme-edit/_context.mjs +157 -29
  128. package/api/theme-edit/_edit.mjs +426 -58
  129. package/api/theme-edit/_how-question.d.mts +14 -0
  130. package/api/theme-edit/_how-question.mjs +1541 -127
  131. package/api/theme-edit/_how.mjs +43 -0
  132. package/api/theme-edit/_missed.mjs +107 -27
  133. package/api/theme-edit/_normal.d.mts +18 -4
  134. package/api/theme-edit/_normal.mjs +84 -3
  135. package/api/theme-edit/_palette.d.mts +9 -0
  136. package/api/theme-edit/_palette.mjs +158 -33
  137. package/api/theme-edit/_part-words.mjs +16 -3
  138. package/api/theme-edit/_parts.d.mts +8 -0
  139. package/api/theme-edit/_parts.mjs +120 -36
  140. package/api/theme-edit/_png.d.mts +24 -0
  141. package/api/theme-edit/_png.mjs +99 -0
  142. package/api/theme-edit/_preview-app.d.mts +16 -0
  143. package/api/theme-edit/_preview-app.mjs +52 -18
  144. package/api/theme-edit/_preview.d.mts +44 -26
  145. package/api/theme-edit/_preview.mjs +255 -67
  146. package/api/theme-edit/_project.d.mts +12 -1
  147. package/api/theme-edit/_project.mjs +16 -1
  148. package/api/theme-edit/_settings.d.mts +116 -0
  149. package/api/theme-edit/_settings.mjs +1197 -58
  150. package/api/theme-edit/_tables.d.mts +16 -0
  151. package/api/theme-edit/_tables.mjs +34 -4
  152. package/api/theme-edit/theme-edit.type.d.mts +15 -2
  153. package/api/theme-edit/theme-edit.type.mjs +8 -6
  154. package/api/upgrade/_adapter.d.mts +46 -7
  155. package/api/upgrade/_adapter.mjs +110 -15
  156. package/api/upgrade/registry/registry.d.mts +6 -3
  157. package/api/upgrade/registry/registry.mjs +21 -6
  158. package/api/upgrade/run/run.mjs +23 -11
  159. package/api/upgrade/upgrade.doc.mjs +4 -3
  160. package/assets/component-list.generated.json +1 -1
  161. package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
  162. package/assets/docs/tree/checks.doc.mjs +2 -2
  163. package/assets/docs/tree/host-entry.doc.mjs +4 -0
  164. package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
  165. package/assets/docs/tree/icon-sets.doc.mjs +6 -6
  166. package/assets/docs/tree/problems.doc.mjs +3 -3
  167. package/assets/docs/tree/render-pages.doc.mjs +17 -3
  168. package/assets/docs/tree/share-a-page.doc.mjs +5 -5
  169. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  170. package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
  171. package/assets/docs/tree/updates.doc.mjs +1 -1
  172. package/assets/docs/tree/versioning.doc.mjs +1 -1
  173. package/assets/docs/working-with-ai.doc.mjs +40 -5
  174. package/assets/docs-routes.generated.json +1 -1
  175. package/assets/docs.generated.json +2 -2
  176. package/assets/icons/installed-icon-set.doc.mjs +30 -0
  177. package/assets/search-catalog.generated.json +2 -2
  178. package/assets/self-audit.generated.json +1 -1
  179. package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
  180. package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
  181. package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
  182. package/assets/templates/components.generated.json +1 -1
  183. package/assets/templates/pages/ai-chat/page.tsx +6 -2
  184. package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
  185. package/assets/templates/pages/blank/page.tsx +4 -2
  186. package/assets/templates/pages/canvas-editor/page.tsx +3 -1
  187. package/assets/templates/pages/centered-hero/page.tsx +1 -1
  188. package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
  189. package/assets/templates/pages/classic-gallery/page.tsx +1 -1
  190. package/assets/templates/pages/contact-form/page.tsx +2 -2
  191. package/assets/templates/pages/course-detail/page.tsx +1 -1
  192. package/assets/templates/pages/dashboard/page.tsx +24 -8
  193. package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
  194. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
  195. package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
  196. package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
  197. package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
  198. package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
  199. package/assets/templates/pages/detail-page/page.tsx +22 -5
  200. package/assets/templates/pages/documentation/page.tsx +4 -2
  201. package/assets/templates/pages/documentation-design/page.tsx +5 -2
  202. package/assets/templates/pages/documentation-technical/page.tsx +4 -2
  203. package/assets/templates/pages/editor/page.tsx +28 -9
  204. package/assets/templates/pages/file-explorer/page.tsx +3 -1
  205. package/assets/templates/pages/form-two-column/page.tsx +1 -1
  206. package/assets/templates/pages/form-wizard/page.tsx +1 -1
  207. package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
  208. package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
  209. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  210. package/assets/templates/pages/gallery-hero/page.tsx +1 -1
  211. package/assets/templates/pages/ide/page.tsx +7 -2
  212. package/assets/templates/pages/kanban-board/page.tsx +10 -4
  213. package/assets/templates/pages/library/page.tsx +31 -61
  214. package/assets/templates/pages/login/page.tsx +4 -2
  215. package/assets/templates/pages/login-card/page.tsx +4 -2
  216. package/assets/templates/pages/login-split/page.tsx +3 -2
  217. package/assets/templates/pages/login-sso/page.tsx +4 -4
  218. package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
  219. package/assets/templates/pages/payment-form/page.tsx +1 -1
  220. package/assets/templates/pages/product-detail/page.tsx +16 -4
  221. package/assets/templates/pages/product-gallery/page.tsx +1 -1
  222. package/assets/templates/pages/settings/page.tsx +10 -4
  223. package/assets/templates/pages/settings-dialog/page.tsx +5 -6
  224. package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
  225. package/assets/templates/pages/side-gallery/page.tsx +1 -1
  226. package/assets/templates/pages/table/page.tsx +2 -2
  227. package/assets/templates/pages/table-filter/page.tsx +21 -6
  228. package/assets/templates/pages/table-grouped/page.tsx +23 -2
  229. package/assets/templates/pages/table-inbox/page.tsx +82 -32
  230. package/assets/templates/pages/theme-showcase/page.tsx +3 -2
  231. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
  232. package/assets/templates/themes/butter/butterTheme.ts +197 -4
  233. package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
  234. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
  235. package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
  236. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
  237. package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
  238. package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
  239. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
  240. package/assets/templates/themes/stone/stoneTheme.ts +69 -0
  241. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
  242. package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
  243. package/authoring/codemod/parse.d.mts +0 -36
  244. package/authoring/codemod/parse.mjs +62 -41
  245. package/authoring/config/config.doc.mjs +1 -1
  246. package/authoring/config/parse.d.mts +0 -47
  247. package/authoring/config/parse.mjs +128 -103
  248. package/authoring/config/type.ts +4 -3
  249. package/authoring/debug/parse.d.mts +2 -2
  250. package/authoring/discover/parse.d.mts +2 -2
  251. package/authoring/discover/parse.mjs +52 -38
  252. package/authoring/discover/type.ts +2 -1
  253. package/authoring/doctypes/_schema.d.mts +834 -950
  254. package/authoring/doctypes/_schema.mjs +863 -825
  255. package/authoring/doctypes/command/parse.mjs +2 -2
  256. package/authoring/doctypes/component/parse.mjs +2 -2
  257. package/authoring/doctypes/enum/parse.mjs +2 -2
  258. package/authoring/doctypes/hook/parse.mjs +2 -2
  259. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
  260. package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
  261. package/authoring/doctypes/icon-definition/parse.mjs +59 -43
  262. package/authoring/doctypes/icon-set/parse.d.mts +0 -75
  263. package/authoring/doctypes/icon-set/parse.mjs +239 -210
  264. package/authoring/doctypes/legacy.mjs +3 -3
  265. package/authoring/doctypes/namespace/parse.mjs +2 -2
  266. package/authoring/doctypes/reference/parse.mjs +2 -2
  267. package/authoring/doctypes/schema/parse.mjs +2 -2
  268. package/authoring/doctypes/template/parse.d.mts +0 -101
  269. package/authoring/doctypes/template/parse.mjs +131 -106
  270. package/authoring/doctypes/theme/parse.d.mts +0 -23
  271. package/authoring/doctypes/theme/parse.mjs +52 -36
  272. package/authoring/gap-report/parse.d.mts +1 -1
  273. package/authoring/integration/integration.doc.mjs +8 -0
  274. package/authoring/integration/schema.d.mts +14 -3
  275. package/authoring/integration/schema.mjs +20 -2
  276. package/authoring/integration/type.ts +14 -0
  277. package/clients/cli/build-id.generated.json +1 -1
  278. package/clients/cli/commands/build.mjs +27 -13
  279. package/clients/cli/commands/component.mjs +14 -3
  280. package/clients/cli/commands/discover.doc.mjs +2 -2
  281. package/clients/cli/commands/discover.mjs +20 -3
  282. package/clients/cli/commands/docs.doc.mjs +11 -9
  283. package/clients/cli/commands/docs.mjs +50 -21
  284. package/clients/cli/commands/experimental/icon.mjs +330 -227
  285. package/clients/cli/commands/experimental/render.mjs +16 -1
  286. package/clients/cli/commands/experimental/theme.mjs +42 -17
  287. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  288. package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
  289. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
  290. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
  291. package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
  292. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  293. package/clients/cli/commands/experimental-render.doc.mjs +3 -3
  294. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  295. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  296. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  297. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  298. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  299. package/clients/cli/commands/init.doc.mjs +36 -24
  300. package/clients/cli/commands/integration-check.doc.mjs +1 -1
  301. package/clients/cli/commands/mcp.doc.mjs +53 -0
  302. package/clients/cli/commands/mcp.mjs +51 -0
  303. package/clients/cli/commands/search.mjs +46 -9
  304. package/clients/cli/commands/template.mjs +3 -2
  305. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  306. package/clients/cli/commands/theme.mjs +12 -2
  307. package/clients/cli/commands/upgrade.doc.mjs +3 -2
  308. package/clients/cli/commands.generated.json +1 -1
  309. package/clients/cli/formatters/index.mjs +52 -6
  310. package/clients/cli/index.mjs +23 -17
  311. package/clients/cli/lib/base-gate.mjs +37 -5
  312. package/clients/cli/lib/define-command.mjs +82 -4
  313. package/clients/cli/lib/json-shim.mjs +61 -4
  314. package/clients/cli/lib/manifest.mjs +9 -1
  315. package/clients/cli/lib/mcp-server.mjs +286 -0
  316. package/clients/cli/lib/mcp-tools.mjs +405 -0
  317. package/clients/cli/lib/other-cli-words.mjs +99 -0
  318. package/clients/cli/lib/stray-option.mjs +27 -1
  319. package/clients/cli/lib/unknown-command.mjs +326 -11
  320. package/clients/cli/manifest.generated.json +1 -1
  321. package/clients/cli/run.mjs +1 -1
  322. package/foundation/agent-docs/agent-docs.d.mts +49 -1
  323. package/foundation/agent-docs/agent-docs.mjs +108 -7
  324. package/foundation/agent-docs/computer-agent-text.mjs +1 -1
  325. package/foundation/bases/core.d.mts +1 -1
  326. package/foundation/bases/core.mjs +3 -3
  327. package/foundation/bases/resolve.d.mts +4 -8
  328. package/foundation/bases/resolve.mjs +15 -21
  329. package/foundation/bases/state.d.mts +15 -9
  330. package/foundation/bases/state.mjs +33 -6
  331. package/foundation/config/project.d.mts +5 -4
  332. package/foundation/config/project.mjs +33 -17
  333. package/foundation/discovery/component-discovery.mjs +15 -28
  334. package/foundation/discovery/icon-imports.d.mts +66 -0
  335. package/foundation/discovery/icon-imports.mjs +225 -0
  336. package/foundation/discovery/icon-ranking.d.mts +12 -2
  337. package/foundation/discovery/icon-ranking.mjs +197 -10
  338. package/foundation/discovery/icon-set-checks.mjs +2 -1
  339. package/foundation/discovery/icon-set-discovery.d.mts +28 -0
  340. package/foundation/discovery/icon-set-discovery.mjs +42 -0
  341. package/foundation/discovery/icon-set-writer.d.mts +2 -11
  342. package/foundation/discovery/icon-set-writer.mjs +3 -29
  343. package/foundation/discovery/module-exports.d.mts +1 -1
  344. package/foundation/discovery/module-exports.mjs +136 -33
  345. package/foundation/discovery/name-roots.d.mts +5 -0
  346. package/foundation/discovery/name-roots.mjs +11 -0
  347. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  348. package/foundation/discovery/runner-allowlist.mjs +2 -0
  349. package/foundation/discovery/runner-commands.mjs +1 -0
  350. package/foundation/discovery/template-adapter.d.mts +1 -1
  351. package/foundation/discovery/template-destination.d.mts +14 -6
  352. package/foundation/discovery/template-destination.mjs +42 -8
  353. package/foundation/discovery/template-icons.d.mts +45 -2
  354. package/foundation/discovery/template-icons.mjs +26 -54
  355. package/foundation/discovery/template-needs.d.mts +28 -2
  356. package/foundation/discovery/template-needs.mjs +92 -11
  357. package/foundation/discovery/theme-discovery.d.mts +8 -0
  358. package/foundation/discovery/theme-discovery.mjs +23 -6
  359. package/foundation/discovery/theme-imports.mjs +2 -4
  360. package/foundation/doc-compiler/parse-readable.mjs +4 -3
  361. package/foundation/doc-compiler/stored-docs.d.mts +13 -0
  362. package/foundation/doc-compiler/stored-docs.mjs +74 -3
  363. package/foundation/env/cli-command.d.mts +68 -10
  364. package/foundation/env/cli-command.mjs +116 -22
  365. package/foundation/env/project-scope.d.mts +9 -0
  366. package/foundation/env/project-scope.mjs +28 -2
  367. package/foundation/fs/gather-cache.d.mts +23 -0
  368. package/foundation/fs/gather-cache.mjs +94 -2
  369. package/foundation/fs/module-loader.d.mts +3 -1
  370. package/foundation/fs/module-loader.mjs +85 -5
  371. package/foundation/fs/read-record.mjs +9 -5
  372. package/foundation/identity/package-names.d.mts +18 -0
  373. package/foundation/identity/package-names.mjs +19 -0
  374. package/foundation/identity/providers.mjs +3 -2
  375. package/foundation/integrations/icon-features.d.mts +63 -0
  376. package/foundation/integrations/icon-features.mjs +54 -0
  377. package/foundation/integrations/integrations.d.mts +13 -1
  378. package/foundation/integrations/integrations.mjs +47 -6
  379. package/foundation/integrations/pack-state.d.mts +21 -0
  380. package/foundation/integrations/pack-state.mjs +42 -19
  381. package/foundation/integrations/validate-contributions.d.mts +11 -3
  382. package/foundation/integrations/validate-contributions.mjs +51 -13
  383. package/foundation/release/cache.d.mts +13 -1
  384. package/foundation/release/cache.mjs +94 -14
  385. package/foundation/release/notices.d.mts +15 -0
  386. package/foundation/release/notices.mjs +111 -7
  387. package/foundation/release/project.d.mts +3 -4
  388. package/foundation/release/project.mjs +5 -6
  389. package/foundation/render/client-bundle.d.mts +126 -0
  390. package/foundation/render/client-bundle.mjs +565 -0
  391. package/foundation/render/cut-short.d.mts +7 -1
  392. package/foundation/render/cut-short.mjs +46 -6
  393. package/foundation/render/embedded-imports.d.mts +4 -3
  394. package/foundation/render/embedded-imports.mjs +13 -8
  395. package/foundation/render/esbuild-dependency.d.mts +14 -0
  396. package/foundation/render/esbuild-dependency.mjs +41 -0
  397. package/foundation/render/file-header.mjs +5 -4
  398. package/foundation/render/page-worker.mjs +562 -86
  399. package/foundation/render/picture-chrome.mjs +54 -29
  400. package/foundation/render/picture-playwright.mjs +78 -42
  401. package/foundation/render/picture-window.d.mts +33 -0
  402. package/foundation/render/picture-window.mjs +78 -0
  403. package/foundation/render/render-page.d.mts +55 -4
  404. package/foundation/render/render-page.mjs +199 -28
  405. package/foundation/render/restore-folder.d.mts +13 -0
  406. package/foundation/render/restore-folder.mjs +30 -0
  407. package/foundation/render/served-packages.d.mts +2 -1
  408. package/foundation/render/served-packages.mjs +5 -3
  409. package/foundation/render/ts-paths.d.mts +11 -0
  410. package/foundation/render/ts-paths.mjs +27 -2
  411. package/foundation/render/value-uses.d.mts +43 -0
  412. package/foundation/render/value-uses.mjs +110 -0
  413. package/foundation/response/error-codes.d.mts +2 -1
  414. package/foundation/response/error-codes.doc.mjs +7 -1
  415. package/foundation/response/error-codes.mjs +10 -2
  416. package/foundation/response/response-types.doc.mjs +12 -12
  417. package/foundation/runtime/package-root.d.mts +8 -0
  418. package/foundation/runtime/package-root.mjs +20 -0
  419. package/foundation/suggest/other-command.d.mts +11 -0
  420. package/foundation/suggest/other-command.mjs +1 -1
  421. package/foundation/text/icon-id.d.mts +20 -0
  422. package/foundation/text/icon-id.mjs +40 -0
  423. package/foundation/text/icon-set-next.d.mts +25 -0
  424. package/foundation/text/icon-set-next.mjs +29 -0
  425. package/foundation/xle/browser.d.mts +2 -2
  426. package/package.json +7 -6
@@ -27,879 +27,917 @@ import {z} from 'zod';
27
27
  /** @typedef {import('./command/type.js').CommandDoc} CommandDoc */
28
28
  /** @typedef {import('./enum/type.js').EnumDoc} EnumDoc */
29
29
 
30
- const nonEmptyString = z.string().min(1);
31
-
32
- /** Every authored doc-kind discriminant accepted by parseDoc. */
33
- export const AuthoredDocKindSchema = z.enum([
34
- 'component',
35
- 'function',
36
- 'generic',
37
- 'page',
38
- 'block',
39
- 'schema',
40
- 'command',
41
- 'enum',
42
- 'namespace',
43
- 'icon-definition',
44
- ]);
45
-
46
- /**
47
- * @typedef {import('../_shared/contract.js').Expect<
48
- * import('../_shared/contract.js').Equal<z.infer<typeof AuthoredDocKindSchema>, AuthoredDocKind>
49
- * >} _AuthoredDocKindDriftLock
50
- */
51
-
52
- /** Shared optional graph fields for every authored doc kind. */
53
- export const AuthoredDocGraphFields = {
54
- placement: z
55
- .object({
56
- parent: nonEmptyString,
57
- slot: nonEmptyString.optional(),
58
- order: z.number().int().safe().optional(),
59
- })
60
- .strict()
61
- .optional(),
62
- aliases: z.array(nonEmptyString).optional(),
63
- audience: z.enum(['public', 'internal']).optional(),
64
- stability: z.literal('experimental').optional(),
65
- };
66
-
67
- const _AuthoredDocGraphSchema = z.object(AuthoredDocGraphFields).strict();
68
-
69
- /**
70
- * @typedef {import('../_shared/contract.js').Expect<
71
- * import('../_shared/contract.js').MutuallyAssignable<
72
- * z.infer<typeof _AuthoredDocGraphSchema>,
73
- * AuthoredDocGraphFieldsType
74
- * >
75
- * >} _AuthoredDocGraphDriftLock
76
- */
77
-
78
- const ProseBlockSchema = z
79
- .object({type: z.literal('prose'), text: nonEmptyString})
80
- .strict();
81
- const HeadingBlockSchema = z
82
- .object({
83
- type: z.literal('heading'),
84
- level: z.union([z.literal(3), z.literal(4), z.literal(5), z.literal(6)]),
85
- text: nonEmptyString,
86
- })
87
- .strict();
88
- const CodeBlockSchema = z
89
- .object({
90
- type: z.literal('code'),
91
- lang: nonEmptyString,
92
- code: z.string(),
93
- label: nonEmptyString.optional(),
94
- })
95
- .strict();
96
- const TableBlockSchema = z
97
- .object({
98
- type: z.literal('table'),
99
- headers: z.array(z.string()).min(1),
100
- rows: z.array(z.array(z.string())),
101
- })
102
- .strict()
103
- .superRefine((table, context) => {
104
- table.rows.forEach((row, index) => {
105
- if (row.length !== table.headers.length) {
106
- context.addIssue({
107
- code: 'custom',
108
- path: ['rows', index],
109
- message: `expected ${table.headers.length} cells`,
110
- });
111
- }
112
- });
113
- });
114
- const ListBlockSchema = z
115
- .object({
116
- type: z.literal('list'),
117
- style: z.enum(['ordered', 'unordered', 'do', 'dont']),
118
- items: z.array(nonEmptyString).min(1),
119
- })
120
- .strict();
121
- const TokenReferenceBlockSchema = z
122
- .object({
123
- type: z.literal('token-ref'),
124
- topic: nonEmptyString,
125
- section: nonEmptyString,
126
- })
127
- .strict();
128
- const WorkflowBlockSchema = z
129
- .object({
130
- type: z.literal('workflow'),
131
- title: nonEmptyString.optional(),
132
- steps: z
133
- .array(
134
- z
135
- .object({
136
- title: nonEmptyString,
137
- description: nonEmptyString.optional(),
138
- references: z.array(nonEmptyString).min(1).optional(),
139
- })
140
- .strict(),
141
- )
142
- .min(1),
143
- })
144
- .strict();
145
- const CollectionBlockSchema = z
146
- .object({
147
- type: z.literal('collection'),
148
- title: nonEmptyString.optional(),
149
- source: z.object({slot: nonEmptyString}).strict(),
150
- presentation: z.enum(['list', 'cards', 'compact']).optional(),
151
- whenEmpty: z.enum(['show', 'omit']).optional(),
152
- })
153
- .strict();
154
- const ReferenceBlockSchema = z
155
- .object({
156
- type: z.literal('reference'),
157
- target: nonEmptyString,
158
- projection: z
30
+ function buildDocSchemas() {
31
+ const nonEmptyString = z.string().min(1);
32
+
33
+ /** Every authored doc-kind discriminant accepted by parseDoc. */
34
+ const AuthoredDocKindSchema = z.enum([
35
+ 'component',
36
+ 'function',
37
+ 'generic',
38
+ 'page',
39
+ 'block',
40
+ 'schema',
41
+ 'command',
42
+ 'enum',
43
+ 'namespace',
44
+ 'icon-definition',
45
+ ]);
46
+
47
+ /**
48
+ * @typedef {import('../_shared/contract.js').Expect<
49
+ * import('../_shared/contract.js').Equal<z.infer<typeof AuthoredDocKindSchema>, AuthoredDocKind>
50
+ * >} _AuthoredDocKindDriftLock
51
+ */
52
+
53
+ /** Shared optional graph fields for every authored doc kind. */
54
+ const AuthoredDocGraphFields = {
55
+ placement: z
159
56
  .object({
160
- fields: z.array(nonEmptyString).min(1).optional(),
161
- sections: z.array(nonEmptyString).min(1).optional(),
57
+ parent: nonEmptyString,
58
+ slot: nonEmptyString.optional(),
59
+ order: z.number().int().safe().optional(),
162
60
  })
163
61
  .strict()
164
62
  .optional(),
165
- presentation: z.enum(['summary', 'compact', 'full']).optional(),
166
- })
167
- .strict();
168
-
169
- /** Runtime schema for the stable content-block union published in 0.6.x. */
170
- export const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
171
- ProseBlockSchema,
172
- HeadingBlockSchema,
173
- CodeBlockSchema,
174
- TableBlockSchema,
175
- ListBlockSchema,
176
- TokenReferenceBlockSchema,
177
- ]);
178
-
179
- /** Runtime schema for graph-only blocks used by NamespaceDoc. */
180
- export const GraphContentBlockSchema = z.discriminatedUnion('type', [
181
- WorkflowBlockSchema,
182
- CollectionBlockSchema,
183
- ReferenceBlockSchema,
184
- ]);
185
-
186
- /**
187
- * A topic section's blocks: the stable union, plus a reference block, which a
188
- * read inlines as the doc it includes.
189
- */
190
- export const SectionContentBlockSchema = z.discriminatedUnion('type', [
191
- ProseBlockSchema,
192
- HeadingBlockSchema,
193
- CodeBlockSchema,
194
- TableBlockSchema,
195
- ListBlockSchema,
196
- TokenReferenceBlockSchema,
197
- ReferenceBlockSchema,
198
- ]);
199
-
200
- /** Namespace content accepts both stable reference blocks and graph-only blocks. */
201
- export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
202
- ProseBlockSchema,
203
- HeadingBlockSchema,
204
- CodeBlockSchema,
205
- TableBlockSchema,
206
- ListBlockSchema,
207
- TokenReferenceBlockSchema,
208
- WorkflowBlockSchema,
209
- CollectionBlockSchema,
210
- ReferenceBlockSchema,
211
- ]);
212
-
213
- /**
214
- * @typedef {import('../_shared/contract.js').Expect<
215
- * import('../_shared/contract.js').Equal<
216
- * z.infer<typeof ReferenceContentBlockSchema>,
217
- * ReferenceContentBlock
218
- * >
219
- * >} _ReferenceContentBlockDriftLock
220
- */
221
-
222
- /**
223
- * @typedef {import('../_shared/contract.js').Expect<
224
- * import('../_shared/contract.js').Equal<
225
- * z.infer<typeof GraphContentBlockSchema>,
226
- * GraphContentBlock
227
- * >
228
- * >} _GraphContentBlockDriftLock
229
- */
230
-
231
- /**
232
- * @typedef {import('../_shared/contract.js').Expect<
233
- * import('../_shared/contract.js').Equal<
234
- * z.infer<typeof SectionContentBlockSchema>,
235
- * ReferenceSection['content'][number]
236
- * >
237
- * >} _SectionContentBlockDriftLock
238
- */
239
-
240
- const ReferenceSectionSchema = z
241
- .object({
242
- id: nonEmptyString.optional(),
243
- title: nonEmptyString,
244
- category: z.string().optional(),
245
- content: z.array(SectionContentBlockSchema),
246
- // Where an extension adds this section to the topic it extends: before
247
- // or after the section with this key. Ignored on any other section.
248
- before: nonEmptyString.optional(),
249
- after: nonEmptyString.optional(),
250
- previewType: z
251
- .enum([
252
- 'swatch',
253
- 'shadow-box',
254
- 'radius-box',
255
- 'spacing-bar',
256
- 'size-bar',
257
- 'border-line',
258
- 'duration-bar',
259
- 'easing-curve',
260
- 'font-sample',
261
- ])
262
- .optional(),
263
- })
264
- .strict();
265
-
266
- const PropSchema = z
267
- .object({
268
- name: z.string().min(1, 'prop name is required'),
269
- type: z.string().min(1, 'prop type is required'),
270
- description: z.string(),
271
- default: z.string().optional(),
272
- required: z.boolean().optional(),
273
- })
274
- .passthrough();
275
-
276
- const ParamSchema = z
277
- .object({
278
- name: z.string().min(1, 'param name is required'),
279
- type: z.string().min(1, 'param type is required'),
280
- description: z.string(),
281
- default: z.string().optional(),
282
- required: z.boolean().optional(),
283
- })
284
- .passthrough();
285
-
286
- const ReturnSchema = z
287
- .object({
288
- name: z.string().min(1, 'return name is required'),
289
- type: z.string().min(1, 'return type is required'),
290
- description: z.string(),
291
- })
292
- .passthrough();
293
-
294
- /** Every example kind, in the order the docs list them. */
295
- const EXAMPLE_KINDS = /** @type {const} */ (['demo', 'setup']);
296
-
297
- /**
298
- * An example's `kind`. The message names both values and what each one does,
299
- * because an author who misspells it needs to pick again.
300
- */
301
- const ExampleKindSchema = z.enum(EXAMPLE_KINDS, {
302
- error: issue =>
303
- `unknown example kind ${JSON.stringify(issue.input)}; use 'demo' (may render as a live preview) or 'setup' (code only)`,
304
- });
305
-
306
- /**
307
- * One component example as it loads. Only `kind` is checked: the rest passes
308
- * through unchecked, as component examples always have.
309
- */
310
- const ComponentExampleSchema = z
311
- .object({kind: ExampleKindSchema.optional()})
312
- .passthrough();
313
-
314
- /**
315
- * The example fields of any doc, checked before the permissive legacy union so
316
- * a bad `kind` fails with its own message, not as a union mismatch.
317
- */
318
- export const DocExampleKindsSchema = z
319
- .object({
320
- examples: z.array(ComponentExampleSchema).optional(),
321
- components: z
322
- .array(
323
- z
324
- .object({examples: z.array(ComponentExampleSchema).optional()})
325
- .passthrough(),
326
- )
327
- .optional(),
328
- })
329
- .passthrough();
330
-
331
- const BaseDocFields = {
332
- ...AuthoredDocGraphFields,
333
- name: z.string().min(1, 'name is required'),
334
- displayName: z.string().optional(),
335
- description: z.string().optional(),
336
- usage: z.unknown().optional(),
337
- import: z.string().min(1).optional(),
338
- group: z.string().optional(),
339
- category: z.string().optional(),
340
- keywords: z.array(z.string()).optional(),
341
- parent: z.string().optional(),
342
- relatedDocs: z.array(z.string()).optional(),
343
- hidden: z.boolean().optional(),
344
- isHiddenFromOverview: z.boolean().optional(),
345
- };
346
-
347
- /**
348
- * A deprecated component's replacement (`ComponentBaseDoc.deprecated`). Strict:
349
- * the docsite and search read both fields, so a misspelled one fails to load.
350
- */
351
- const ComponentDeprecationSchema = z
352
- .object({
353
- replacement: nonEmptyString,
354
- description: nonEmptyString,
355
- })
356
- .strict();
357
-
358
- const ComponentBaseSchema = z
359
- .object({
360
- ...BaseDocFields,
361
- type: z.literal('component'),
362
- theming: z.unknown().optional(),
363
- playground: z.unknown().optional(),
364
- examples: z.array(ComponentExampleSchema).optional(),
365
- replaces: z.string().min(1).optional(),
366
- deprecated: ComponentDeprecationSchema.optional(),
367
- })
368
- .passthrough();
369
-
370
- /**
371
- * One entry in a group doc's `components`: a full ComponentEntry or a
372
- * name-only ComponentRef. Readers look every entry up by `name`, so that much
373
- * is checked here; the rest passes through, as on an unstamped doc.
374
- */
375
- const ComponentGroupEntrySchema = z
376
- .object({
377
- name: z.string().min(1, 'component name is required'),
378
- examples: z.array(ComponentExampleSchema).optional(),
379
- })
380
- .passthrough();
381
-
382
- /**
383
- * New-format stamped component doc (`type: 'component'`): one component's
384
- * `props`, or the `components` a group doc documents together. These are the
385
- * shapes the published ComponentDoc type allows, and the ones an unstamped doc
386
- * may already take.
387
- */
388
- export const ComponentDocKindSchema = ComponentBaseSchema.extend({
389
- props: z.array(PropSchema).optional(),
390
- components: z.array(ComponentGroupEntrySchema).optional(),
391
- }).superRefine((doc, context) => {
392
- if (doc.props == null && doc.components == null) {
393
- context.addIssue({
394
- code: 'custom',
395
- path: ['props'],
396
- message:
397
- 'expected the props array, or `components` for a doc that groups several components',
63
+ aliases: z.array(nonEmptyString).optional(),
64
+ audience: z.enum(['public', 'internal']).optional(),
65
+ stability: z.literal('experimental').optional(),
66
+ };
67
+
68
+ const _AuthoredDocGraphSchema = z.object(AuthoredDocGraphFields).strict();
69
+
70
+ /**
71
+ * @typedef {import('../_shared/contract.js').Expect<
72
+ * import('../_shared/contract.js').MutuallyAssignable<
73
+ * z.infer<typeof _AuthoredDocGraphSchema>,
74
+ * AuthoredDocGraphFieldsType
75
+ * >
76
+ * >} _AuthoredDocGraphDriftLock
77
+ */
78
+
79
+ const ProseBlockSchema = z
80
+ .object({type: z.literal('prose'), text: nonEmptyString})
81
+ .strict();
82
+ const HeadingBlockSchema = z
83
+ .object({
84
+ type: z.literal('heading'),
85
+ level: z.union([z.literal(3), z.literal(4), z.literal(5), z.literal(6)]),
86
+ text: nonEmptyString,
87
+ })
88
+ .strict();
89
+ const CodeBlockSchema = z
90
+ .object({
91
+ type: z.literal('code'),
92
+ lang: nonEmptyString,
93
+ code: z.string(),
94
+ label: nonEmptyString.optional(),
95
+ })
96
+ .strict();
97
+ const TableBlockSchema = z
98
+ .object({
99
+ type: z.literal('table'),
100
+ headers: z.array(z.string()).min(1),
101
+ rows: z.array(z.array(z.string())),
102
+ })
103
+ .strict()
104
+ .superRefine((table, context) => {
105
+ table.rows.forEach((row, index) => {
106
+ if (row.length !== table.headers.length) {
107
+ context.addIssue({
108
+ code: 'custom',
109
+ path: ['rows', index],
110
+ message: `expected ${table.headers.length} cells`,
111
+ });
112
+ }
113
+ });
398
114
  });
399
- }
400
- });
401
-
402
- /**
403
- * A stamped component doc as it loads. The loader accepts what the unstamped
404
- * format always accepted, so stamping an existing doc never breaks it:
405
- * `displayName` may be missing, `category` is any string, `usage`, `theming`
406
- * and `playground` pass through unchecked, an example is checked only for its
407
- * `kind`, and a doc has `props`, `components`, or both; each `components` entry
408
- * needs only a `name`. Every
409
- * other field matches the published type.
410
- *
411
- * @typedef {Omit<SingleComponentDoc,
412
- * 'type' | 'displayName' | 'category' | 'usage' | 'theming' | 'examples' | 'playground' | 'props'>
413
- * & {type: 'component', displayName?: string, category?: string, usage?: unknown,
414
- * theming?: unknown, examples?: Array<{kind?: ExampleKind}>, playground?: unknown,
415
- * props?: ComponentPropDoc[],
416
- * components?: Array<{name: string, examples?: Array<{kind?: ExampleKind}>}>}} LoadedComponentDoc
417
- */
418
- /**
419
- * @typedef {import('../_shared/contract.js').Expect<
420
- * import('../_shared/contract.js').MutuallyAssignable<
421
- * import('../_shared/contract.js').NamedFields<z.infer<typeof ComponentDocKindSchema>>,
422
- * import('../_shared/contract.js').NamedFields<LoadedComponentDoc>
423
- * >
424
- * >} _ComponentDocDriftLock
425
- */
115
+ const ListBlockSchema = z
116
+ .object({
117
+ type: z.literal('list'),
118
+ style: z.enum(['ordered', 'unordered', 'do', 'dont']),
119
+ items: z.array(nonEmptyString).min(1),
120
+ })
121
+ .strict();
122
+ const TokenReferenceBlockSchema = z
123
+ .object({
124
+ type: z.literal('token-ref'),
125
+ topic: nonEmptyString,
126
+ section: nonEmptyString,
127
+ })
128
+ .strict();
129
+ const WorkflowBlockSchema = z
130
+ .object({
131
+ type: z.literal('workflow'),
132
+ title: nonEmptyString.optional(),
133
+ steps: z
134
+ .array(
135
+ z
136
+ .object({
137
+ title: nonEmptyString,
138
+ description: nonEmptyString.optional(),
139
+ references: z.array(nonEmptyString).min(1).optional(),
140
+ })
141
+ .strict(),
142
+ )
143
+ .min(1),
144
+ })
145
+ .strict();
146
+ const CollectionBlockSchema = z
147
+ .object({
148
+ type: z.literal('collection'),
149
+ title: nonEmptyString.optional(),
150
+ source: z.object({slot: nonEmptyString}).strict(),
151
+ presentation: z.enum(['list', 'cards', 'compact']).optional(),
152
+ whenEmpty: z.enum(['show', 'omit']).optional(),
153
+ })
154
+ .strict();
155
+ const ReferenceBlockSchema = z
156
+ .object({
157
+ type: z.literal('reference'),
158
+ target: nonEmptyString,
159
+ projection: z
160
+ .object({
161
+ fields: z.array(nonEmptyString).min(1).optional(),
162
+ sections: z.array(nonEmptyString).min(1).optional(),
163
+ })
164
+ .strict()
165
+ .optional(),
166
+ presentation: z.enum(['summary', 'compact', 'full']).optional(),
167
+ })
168
+ .strict();
169
+
170
+ /** Runtime schema for the stable content-block union published in 0.6.x. */
171
+ const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
172
+ ProseBlockSchema,
173
+ HeadingBlockSchema,
174
+ CodeBlockSchema,
175
+ TableBlockSchema,
176
+ ListBlockSchema,
177
+ TokenReferenceBlockSchema,
178
+ ]);
179
+
180
+ /** Runtime schema for graph-only blocks used by NamespaceDoc. */
181
+ const GraphContentBlockSchema = z.discriminatedUnion('type', [
182
+ WorkflowBlockSchema,
183
+ CollectionBlockSchema,
184
+ ReferenceBlockSchema,
185
+ ]);
186
+
187
+ /**
188
+ * A topic section's blocks: the stable union, plus a reference block, which a
189
+ * read inlines as the doc it includes.
190
+ */
191
+ const SectionContentBlockSchema = z.discriminatedUnion('type', [
192
+ ProseBlockSchema,
193
+ HeadingBlockSchema,
194
+ CodeBlockSchema,
195
+ TableBlockSchema,
196
+ ListBlockSchema,
197
+ TokenReferenceBlockSchema,
198
+ ReferenceBlockSchema,
199
+ ]);
200
+
201
+ /** Namespace content accepts both stable reference blocks and graph-only blocks. */
202
+ const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
203
+ ProseBlockSchema,
204
+ HeadingBlockSchema,
205
+ CodeBlockSchema,
206
+ TableBlockSchema,
207
+ ListBlockSchema,
208
+ TokenReferenceBlockSchema,
209
+ WorkflowBlockSchema,
210
+ CollectionBlockSchema,
211
+ ReferenceBlockSchema,
212
+ ]);
213
+
214
+ /**
215
+ * @typedef {import('../_shared/contract.js').Expect<
216
+ * import('../_shared/contract.js').Equal<
217
+ * z.infer<typeof ReferenceContentBlockSchema>,
218
+ * ReferenceContentBlock
219
+ * >
220
+ * >} _ReferenceContentBlockDriftLock
221
+ */
222
+
223
+ /**
224
+ * @typedef {import('../_shared/contract.js').Expect<
225
+ * import('../_shared/contract.js').Equal<
226
+ * z.infer<typeof GraphContentBlockSchema>,
227
+ * GraphContentBlock
228
+ * >
229
+ * >} _GraphContentBlockDriftLock
230
+ */
231
+
232
+ /**
233
+ * @typedef {import('../_shared/contract.js').Expect<
234
+ * import('../_shared/contract.js').Equal<
235
+ * z.infer<typeof SectionContentBlockSchema>,
236
+ * ReferenceSection['content'][number]
237
+ * >
238
+ * >} _SectionContentBlockDriftLock
239
+ */
240
+
241
+ const ReferenceSectionSchema = z
242
+ .object({
243
+ id: nonEmptyString.optional(),
244
+ title: nonEmptyString,
245
+ category: z.string().optional(),
246
+ content: z.array(SectionContentBlockSchema),
247
+ // Where an extension adds this section to the topic it extends: before
248
+ // or after the section with this key. Ignored on any other section.
249
+ before: nonEmptyString.optional(),
250
+ after: nonEmptyString.optional(),
251
+ previewType: z
252
+ .enum([
253
+ 'swatch',
254
+ 'shadow-box',
255
+ 'radius-box',
256
+ 'spacing-bar',
257
+ 'size-bar',
258
+ 'border-line',
259
+ 'duration-bar',
260
+ 'easing-curve',
261
+ 'font-sample',
262
+ ])
263
+ .optional(),
264
+ })
265
+ .strict();
426
266
 
427
- /** Return entry for generalized function docs. */
428
- const FunctionReturnSchema = z
429
- .object({
430
- name: z.string().min(1).optional(),
431
- type: z.string().min(1, 'return type is required'),
432
- description: z.string(),
433
- })
434
- .passthrough();
267
+ const PropSchema = z
268
+ .object({
269
+ name: z.string().min(1, 'prop name is required'),
270
+ type: z.string().min(1, 'prop type is required'),
271
+ description: z.string(),
272
+ default: z.string().optional(),
273
+ required: z.boolean().optional(),
274
+ })
275
+ .passthrough();
435
276
 
436
- /** New-format stamped function doc (`type: 'function'`). */
437
- export const FunctionDocKindSchema = z
438
- .object({
439
- ...BaseDocFields,
440
- type: z.literal('function'),
441
- params: z.array(ParamSchema),
442
- returns: z.array(FunctionReturnSchema),
443
- examples: z
444
- .array(
445
- z
446
- .object({
447
- label: z.string().optional(),
448
- code: z.string(),
449
- result: z.string().optional(),
450
- kind: ExampleKindSchema.optional(),
451
- })
452
- .passthrough(),
453
- )
454
- .optional(),
455
- })
456
- .passthrough();
277
+ const ParamSchema = z
278
+ .object({
279
+ name: z.string().min(1, 'param name is required'),
280
+ type: z.string().min(1, 'param type is required'),
281
+ description: z.string(),
282
+ default: z.string().optional(),
283
+ required: z.boolean().optional(),
284
+ })
285
+ .passthrough();
457
286
 
458
- /**
459
- * A stamped function doc as it loads: as with components, `displayName` may be
460
- * missing and `usage` passes through unchecked.
461
- *
462
- * @typedef {Omit<FunctionDoc, 'type' | 'displayName' | 'usage'>
463
- * & {type: 'function', displayName?: string, usage?: unknown}} LoadedFunctionDoc
464
- */
465
- /**
466
- * @typedef {import('../_shared/contract.js').Expect<
467
- * import('../_shared/contract.js').MutuallyAssignable<
468
- * import('../_shared/contract.js').NamedFields<z.infer<typeof FunctionDocKindSchema>>,
469
- * import('../_shared/contract.js').NamedFields<LoadedFunctionDoc>
470
- * >
471
- * >} _FunctionDocDriftLock
472
- */
287
+ const ReturnSchema = z
288
+ .object({
289
+ name: z.string().min(1, 'return name is required'),
290
+ type: z.string().min(1, 'return type is required'),
291
+ description: z.string(),
292
+ })
293
+ .passthrough();
294
+
295
+ /** Every example kind, in the order the docs list them. */
296
+ const EXAMPLE_KINDS = /** @type {const} */ (['demo', 'setup']);
297
+
298
+ /**
299
+ * An example's `kind`. The message names both values and what each one does,
300
+ * because an author who misspells it needs to pick again.
301
+ */
302
+ const ExampleKindSchema = z.enum(EXAMPLE_KINDS, {
303
+ error: issue =>
304
+ `unknown example kind ${JSON.stringify(issue.input)}; use 'demo' (may render as a live preview) or 'setup' (code only)`,
305
+ });
473
306
 
474
- /**
475
- * Every HookDoc is a FunctionDoc, so the one function schema covers both.
476
- *
477
- * @typedef {import('../_shared/contract.js').Expect<[HookDoc] extends [FunctionDoc] ? true : false>} _HookDocIsFunctionDocLock
478
- */
307
+ /**
308
+ * One component example as it loads. Only `kind` is checked: the rest passes
309
+ * through unchecked, as component examples always have.
310
+ */
311
+ const ComponentExampleSchema = z
312
+ .object({kind: ExampleKindSchema.optional()})
313
+ .passthrough();
314
+
315
+ /**
316
+ * The example fields of any doc, checked before the permissive legacy union so
317
+ * a bad `kind` fails with its own message, not as a union mismatch.
318
+ */
319
+ const DocExampleKindsSchema = z
320
+ .object({
321
+ examples: z.array(ComponentExampleSchema).optional(),
322
+ components: z
323
+ .array(
324
+ z
325
+ .object({examples: z.array(ComponentExampleSchema).optional()})
326
+ .passthrough(),
327
+ )
328
+ .optional(),
329
+ })
330
+ .passthrough();
479
331
 
480
- /**
481
- * Stamped generic reference/topic doc (`type: 'generic'`). `title` and
482
- * `sections` stay optional at this parser boundary for docs produced by the
483
- * shipped v0.3.0 factory-removal codemod. When present, all rich fields and
484
- * semantic blocks are validated.
485
- */
486
- export const GenericDocKindSchema = z
487
- .object({
488
- ...BaseDocFields,
489
- type: z.literal('generic'),
490
- title: nonEmptyString.optional(),
491
- // Search terms the title and sections do not use; `astryx search` matches
492
- // them as keywords of the whole topic (ReferenceDoc `keywords`).
332
+ const BaseDocFields = {
333
+ ...AuthoredDocGraphFields,
334
+ name: z.string().min(1, 'name is required'),
335
+ displayName: z.string().optional(),
336
+ description: z.string().optional(),
337
+ usage: z.unknown().optional(),
338
+ import: z.string().min(1).optional(),
339
+ group: z.string().optional(),
340
+ category: z.string().optional(),
493
341
  keywords: z.array(z.string()).optional(),
494
- sections: z.array(ReferenceSectionSchema).min(1).optional(),
495
- replaces: nonEmptyString.optional(),
496
- extends: nonEmptyString.optional(),
497
- tokenCategory: z.string().optional(),
498
- })
499
- .passthrough()
500
- .superRefine((doc, context) => {
501
- if (doc.replaces != null && doc.extends != null) {
342
+ parent: z.string().optional(),
343
+ relatedDocs: z.array(z.string()).optional(),
344
+ hidden: z.boolean().optional(),
345
+ isHiddenFromOverview: z.boolean().optional(),
346
+ };
347
+
348
+ /**
349
+ * A deprecated component's replacement (`ComponentBaseDoc.deprecated`). Strict:
350
+ * the docsite and search read both fields, so a misspelled one fails to load.
351
+ */
352
+ const ComponentDeprecationSchema = z
353
+ .object({
354
+ replacement: nonEmptyString,
355
+ description: nonEmptyString,
356
+ })
357
+ .strict();
358
+
359
+ const ComponentBaseSchema = z
360
+ .object({
361
+ ...BaseDocFields,
362
+ type: z.literal('component'),
363
+ theming: z.unknown().optional(),
364
+ playground: z.unknown().optional(),
365
+ examples: z.array(ComponentExampleSchema).optional(),
366
+ replaces: z.string().min(1).optional(),
367
+ deprecated: ComponentDeprecationSchema.optional(),
368
+ })
369
+ .passthrough();
370
+
371
+ /**
372
+ * One entry in a group doc's `components`: a full ComponentEntry or a
373
+ * name-only ComponentRef. Readers look every entry up by `name`, so that much
374
+ * is checked here; the rest passes through, as on an unstamped doc.
375
+ */
376
+ const ComponentGroupEntrySchema = z
377
+ .object({
378
+ name: z.string().min(1, 'component name is required'),
379
+ examples: z.array(ComponentExampleSchema).optional(),
380
+ })
381
+ .passthrough();
382
+
383
+ /**
384
+ * New-format stamped component doc (`type: 'component'`): one component's
385
+ * `props`, or the `components` a group doc documents together. These are the
386
+ * shapes the published ComponentDoc type allows, and the ones an unstamped doc
387
+ * may already take.
388
+ */
389
+ const ComponentDocKindSchema = ComponentBaseSchema.extend({
390
+ props: z.array(PropSchema).optional(),
391
+ components: z.array(ComponentGroupEntrySchema).optional(),
392
+ }).superRefine((doc, context) => {
393
+ if (doc.props == null && doc.components == null) {
502
394
  context.addIssue({
503
395
  code: 'custom',
504
- path: ['extends'],
505
- message: 'declares both `replaces` and `extends`; choose one',
396
+ path: ['props'],
397
+ message:
398
+ 'expected the props array, or `components` for a doc that groups several components',
506
399
  });
507
400
  }
508
- const sectionIds = new Set();
509
- doc.sections?.forEach((section, index) => {
510
- if (section.id == null) return;
511
- if (sectionIds.has(section.id)) {
401
+ });
402
+
403
+ /**
404
+ * A stamped component doc as it loads. The loader accepts what the unstamped
405
+ * format always accepted, so stamping an existing doc never breaks it:
406
+ * `displayName` may be missing, `category` is any string, `usage`, `theming`
407
+ * and `playground` pass through unchecked, an example is checked only for its
408
+ * `kind`, and a doc has `props`, `components`, or both; each `components` entry
409
+ * needs only a `name`. Every
410
+ * other field matches the published type.
411
+ *
412
+ * @typedef {Omit<SingleComponentDoc,
413
+ * 'type' | 'displayName' | 'category' | 'usage' | 'theming' | 'examples' | 'playground' | 'props'>
414
+ * & {type: 'component', displayName?: string, category?: string, usage?: unknown,
415
+ * theming?: unknown, examples?: Array<{kind?: ExampleKind}>, playground?: unknown,
416
+ * props?: ComponentPropDoc[],
417
+ * components?: Array<{name: string, examples?: Array<{kind?: ExampleKind}>}>}} LoadedComponentDoc
418
+ */
419
+ /**
420
+ * @typedef {import('../_shared/contract.js').Expect<
421
+ * import('../_shared/contract.js').MutuallyAssignable<
422
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof ComponentDocKindSchema>>,
423
+ * import('../_shared/contract.js').NamedFields<LoadedComponentDoc>
424
+ * >
425
+ * >} _ComponentDocDriftLock
426
+ */
427
+
428
+ /** Return entry for generalized function docs. */
429
+ const FunctionReturnSchema = z
430
+ .object({
431
+ name: z.string().min(1).optional(),
432
+ type: z.string().min(1, 'return type is required'),
433
+ description: z.string(),
434
+ })
435
+ .passthrough();
436
+
437
+ /** New-format stamped function doc (`type: 'function'`). */
438
+ const FunctionDocKindSchema = z
439
+ .object({
440
+ ...BaseDocFields,
441
+ type: z.literal('function'),
442
+ params: z.array(ParamSchema),
443
+ returns: z.array(FunctionReturnSchema),
444
+ examples: z
445
+ .array(
446
+ z
447
+ .object({
448
+ label: z.string().optional(),
449
+ code: z.string(),
450
+ result: z.string().optional(),
451
+ kind: ExampleKindSchema.optional(),
452
+ })
453
+ .passthrough(),
454
+ )
455
+ .optional(),
456
+ })
457
+ .passthrough();
458
+
459
+ /**
460
+ * A stamped function doc as it loads: as with components, `displayName` may be
461
+ * missing and `usage` passes through unchecked.
462
+ *
463
+ * @typedef {Omit<FunctionDoc, 'type' | 'displayName' | 'usage'>
464
+ * & {type: 'function', displayName?: string, usage?: unknown}} LoadedFunctionDoc
465
+ */
466
+ /**
467
+ * @typedef {import('../_shared/contract.js').Expect<
468
+ * import('../_shared/contract.js').MutuallyAssignable<
469
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof FunctionDocKindSchema>>,
470
+ * import('../_shared/contract.js').NamedFields<LoadedFunctionDoc>
471
+ * >
472
+ * >} _FunctionDocDriftLock
473
+ */
474
+
475
+ /**
476
+ * Every HookDoc is a FunctionDoc, so the one function schema covers both.
477
+ *
478
+ * @typedef {import('../_shared/contract.js').Expect<[HookDoc] extends [FunctionDoc] ? true : false>} _HookDocIsFunctionDocLock
479
+ */
480
+
481
+ /**
482
+ * Stamped generic reference/topic doc (`type: 'generic'`). `title` and
483
+ * `sections` stay optional at this parser boundary for docs produced by the
484
+ * shipped v0.3.0 factory-removal codemod. When present, all rich fields and
485
+ * semantic blocks are validated.
486
+ */
487
+ const GenericDocKindSchema = z
488
+ .object({
489
+ ...BaseDocFields,
490
+ type: z.literal('generic'),
491
+ title: nonEmptyString.optional(),
492
+ // Search terms the title and sections do not use; `astryx search` matches
493
+ // them as keywords of the whole topic (ReferenceDoc `keywords`).
494
+ keywords: z.array(z.string()).optional(),
495
+ sections: z.array(ReferenceSectionSchema).min(1).optional(),
496
+ replaces: nonEmptyString.optional(),
497
+ extends: nonEmptyString.optional(),
498
+ tokenCategory: z.string().optional(),
499
+ })
500
+ .passthrough()
501
+ .superRefine((doc, context) => {
502
+ if (doc.replaces != null && doc.extends != null) {
512
503
  context.addIssue({
513
504
  code: 'custom',
514
- path: ['sections', index, 'id'],
515
- message: `duplicate section id "${section.id}"`,
505
+ path: ['extends'],
506
+ message: 'declares both `replaces` and `extends`; choose one',
516
507
  });
517
508
  }
518
- sectionIds.add(section.id);
509
+ const sectionIds = new Set();
510
+ doc.sections?.forEach((section, index) => {
511
+ if (section.id == null) return;
512
+ if (sectionIds.has(section.id)) {
513
+ context.addIssue({
514
+ code: 'custom',
515
+ path: ['sections', index, 'id'],
516
+ message: `duplicate section id "${section.id}"`,
517
+ });
518
+ }
519
+ sectionIds.add(section.id);
520
+ });
519
521
  });
520
- });
521
-
522
- /**
523
- * A stamped generic doc as the load check accepts it. `title`, `description`
524
- * and `sections` may be missing, as in docs the v0.3.0 factory-removal codemod
525
- * produced; `parseReference` then fills them (title from `displayName` or
526
- * `name`, an empty description, no sections), so its result is a full
527
- * ReferenceDoc. Only a doc with a description and sections is a usable topic
528
- * (see `problemsInTopic`).
529
- *
530
- * @typedef {Omit<ReferenceDoc, 'type' | 'title' | 'description' | 'sections'>
531
- * & {type: 'generic'}
532
- * & Partial<Pick<ReferenceDoc, 'title' | 'description' | 'sections'>>} LoadedReferenceDoc
533
- */
534
- /**
535
- * @typedef {import('../_shared/contract.js').Expect<
536
- * import('../_shared/contract.js').MutuallyAssignable<
537
- * import('../_shared/contract.js').NamedFields<z.infer<typeof GenericDocKindSchema>>,
538
- * import('../_shared/contract.js').NamedFields<LoadedReferenceDoc>
539
- * >
540
- * >} _ReferenceDocDriftLock
541
- */
542
-
543
- /** Recursive field descriptor for a SchemaDoc. */
544
- const SchemaFieldSchema =
545
- /** @type {import('zod').ZodType<import('./schema/type.js').SchemaFieldDoc>} */ (
546
- z.lazy(() =>
547
- z
548
- .object({
549
- name: z.string().min(1, 'field name is required'),
550
- type: z
551
- .string({error: 'field type is required'})
552
- .min(1, 'field type is required'),
553
- description: z.string(),
554
- required: z.boolean().optional(),
555
- default: z.string().optional(),
556
- example: z.string().optional(),
557
- deprecated: z.string().optional(),
558
- stability: z.literal('experimental').optional(),
559
- fields: z.array(SchemaFieldSchema).optional(),
560
- })
561
- .passthrough(),
562
- )
563
- );
564
-
565
- /** New stamped schema doc (`type: 'schema'`). */
566
- export const SchemaDocKindSchema = z
567
- .object({
568
- ...AuthoredDocGraphFields,
569
- type: z.literal('schema'),
570
- name: z.string().min(1, 'name is required'),
571
- displayName: z.string().min(1, 'displayName is required'),
572
- description: z.string(),
573
- namespace: z.string().optional(),
574
- appliesTo: z.string().optional(),
575
- fields: z.array(SchemaFieldSchema),
576
- examples: z
577
- .array(
578
- z
579
- .object({label: z.string().optional(), code: z.string()})
580
- .passthrough(),
581
- )
582
- .optional(),
583
- notes: z.array(ReferenceContentBlockSchema).optional(),
584
- })
585
- .passthrough();
586
-
587
- /**
588
- * @typedef {import('../_shared/contract.js').Expect<
589
- * import('../_shared/contract.js').MutuallyAssignable<
590
- * import('../_shared/contract.js').NamedFields<z.infer<typeof SchemaDocKindSchema>>,
591
- * import('../_shared/contract.js').NamedFields<SchemaDoc & {type: 'schema'}>
592
- * >
593
- * >} _SchemaDocDriftLock
594
- */
595
522
 
596
- /**
597
- * A platform step a base serves, named `<capability>.<step>`. The schema
598
- * checks the shape; the closed list lives with the CLI's requirement check,
599
- * and a test holds every command declaration to it.
600
- * @type {z.ZodType<import('../integration/type.js').BaseStep>}
601
- */
602
- const BaseStepSchema = z.custom(
603
- value => typeof value === 'string' && /^[a-z]+\.[a-zA-Z]+$/u.test(value),
604
- {message: 'a step is named `<capability>.<step>`, such as `themes.compile`'},
605
- );
606
-
607
- /** New stamped command doc (`type: 'command'`). */
608
- export const CommandDocKindSchema = z
609
- .object({
610
- ...AuthoredDocGraphFields,
611
- type: z.literal('command'),
612
- name: z.string().min(1, 'name is required'),
613
- displayName: z.string().min(1, 'displayName is required'),
614
- summary: z.string(),
615
- description: z.string().optional(),
616
- namespace: z.string().optional(),
617
- fn: z.string().optional(),
618
- args: z
619
- .array(
523
+ /**
524
+ * A stamped generic doc as the load check accepts it. `title`, `description`
525
+ * and `sections` may be missing, as in docs the v0.3.0 factory-removal codemod
526
+ * produced; `parseReference` then fills them (title from `displayName` or
527
+ * `name`, an empty description, no sections), so its result is a full
528
+ * ReferenceDoc. Only a doc with a description and sections is a usable topic
529
+ * (see `problemsInTopic`).
530
+ *
531
+ * @typedef {Omit<ReferenceDoc, 'type' | 'title' | 'description' | 'sections'>
532
+ * & {type: 'generic'}
533
+ * & Partial<Pick<ReferenceDoc, 'title' | 'description' | 'sections'>>} LoadedReferenceDoc
534
+ */
535
+ /**
536
+ * @typedef {import('../_shared/contract.js').Expect<
537
+ * import('../_shared/contract.js').MutuallyAssignable<
538
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof GenericDocKindSchema>>,
539
+ * import('../_shared/contract.js').NamedFields<LoadedReferenceDoc>
540
+ * >
541
+ * >} _ReferenceDocDriftLock
542
+ */
543
+
544
+ /** Recursive field descriptor for a SchemaDoc. */
545
+ const SchemaFieldSchema =
546
+ /** @type {import('zod').ZodType<import('./schema/type.js').SchemaFieldDoc>} */ (
547
+ z.lazy(() =>
620
548
  z
621
549
  .object({
622
- name: z.string().min(1),
623
- param: z.string().optional(),
624
- description: z.string().optional(),
550
+ name: z.string().min(1, 'field name is required'),
551
+ type: z
552
+ .string({error: 'field type is required'})
553
+ .min(1, 'field type is required'),
554
+ description: z.string(),
625
555
  required: z.boolean().optional(),
626
- variadic: z.boolean().optional(),
627
- requires: z.record(z.string(), z.array(BaseStepSchema)).optional(),
628
- names: z
629
- .enum(['component', 'hook', 'topic', 'template', 'theme'])
630
- .optional(),
631
- })
632
- .passthrough(),
633
- )
634
- .optional(),
635
- options: z
636
- .array(
637
- z
638
- .object({
639
- flag: z.string().min(1),
640
- param: z.string().optional(),
641
- description: z.string().optional(),
642
- choices: z.array(z.string()).optional(),
643
- default: z
644
- .union([z.string(), z.boolean(), z.array(z.string())])
645
- .optional(),
646
- cliOnly: z.boolean().optional(),
647
- requires: z.array(BaseStepSchema).optional(),
648
- names: z
649
- .enum(['component', 'hook', 'topic', 'template', 'theme'])
650
- .optional(),
556
+ default: z.string().optional(),
557
+ example: z.string().optional(),
558
+ deprecated: z.string().optional(),
559
+ stability: z.literal('experimental').optional(),
560
+ fields: z.array(SchemaFieldSchema).optional(),
651
561
  })
652
562
  .passthrough(),
653
563
  )
654
- .optional(),
655
- subcommands: z.array(z.string()).optional(),
656
- examples: z
657
- .array(
564
+ );
565
+
566
+ /** New stamped schema doc (`type: 'schema'`). */
567
+ const SchemaDocKindSchema = z
568
+ .object({
569
+ ...AuthoredDocGraphFields,
570
+ type: z.literal('schema'),
571
+ name: z.string().min(1, 'name is required'),
572
+ displayName: z.string().min(1, 'displayName is required'),
573
+ description: z.string(),
574
+ namespace: z.string().optional(),
575
+ appliesTo: z.string().optional(),
576
+ fields: z.array(SchemaFieldSchema),
577
+ examples: z
578
+ .array(
579
+ z
580
+ .object({label: z.string().optional(), code: z.string()})
581
+ .passthrough(),
582
+ )
583
+ .optional(),
584
+ notes: z.array(ReferenceContentBlockSchema).optional(),
585
+ })
586
+ .passthrough();
587
+
588
+ /**
589
+ * @typedef {import('../_shared/contract.js').Expect<
590
+ * import('../_shared/contract.js').MutuallyAssignable<
591
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof SchemaDocKindSchema>>,
592
+ * import('../_shared/contract.js').NamedFields<SchemaDoc & {type: 'schema'}>
593
+ * >
594
+ * >} _SchemaDocDriftLock
595
+ */
596
+
597
+ /**
598
+ * A platform step a base serves, named `<capability>.<step>`. The schema
599
+ * checks the shape; the closed list lives with the CLI's requirement check,
600
+ * and a test holds every command declaration to it.
601
+ * @type {z.ZodType<import('../integration/type.js').BaseStep>}
602
+ */
603
+ const BaseStepSchema = z.custom(
604
+ value => typeof value === 'string' && /^[a-z]+\.[a-zA-Z]+$/u.test(value),
605
+ {
606
+ message:
607
+ 'a step is named `<capability>.<step>`, such as `themes.compile`',
608
+ },
609
+ );
610
+
611
+ /** New stamped command doc (`type: 'command'`). */
612
+ const CommandDocKindSchema = z
613
+ .object({
614
+ ...AuthoredDocGraphFields,
615
+ type: z.literal('command'),
616
+ name: z.string().min(1, 'name is required'),
617
+ displayName: z.string().min(1, 'displayName is required'),
618
+ summary: z.string(),
619
+ description: z.string().optional(),
620
+ namespace: z.string().optional(),
621
+ fn: z.string().optional(),
622
+ args: z
623
+ .array(
624
+ z
625
+ .object({
626
+ name: z.string().min(1),
627
+ param: z.string().optional(),
628
+ description: z.string().optional(),
629
+ required: z.boolean().optional(),
630
+ variadic: z.boolean().optional(),
631
+ requires: z
632
+ .record(z.string(), z.array(BaseStepSchema))
633
+ .optional(),
634
+ names: z
635
+ .enum(['component', 'hook', 'topic', 'template', 'theme'])
636
+ .optional(),
637
+ })
638
+ .passthrough(),
639
+ )
640
+ .optional(),
641
+ options: z
642
+ .array(
643
+ z
644
+ .object({
645
+ flag: z.string().min(1),
646
+ param: z.string().optional(),
647
+ description: z.string().optional(),
648
+ choices: z.array(z.string()).optional(),
649
+ default: z
650
+ .union([z.string(), z.boolean(), z.array(z.string())])
651
+ .optional(),
652
+ cliOnly: z.boolean().optional(),
653
+ requires: z.array(BaseStepSchema).optional(),
654
+ names: z
655
+ .enum(['component', 'hook', 'topic', 'template', 'theme'])
656
+ .optional(),
657
+ })
658
+ .passthrough(),
659
+ )
660
+ .optional(),
661
+ subcommands: z.array(z.string()).optional(),
662
+ examples: z
663
+ .array(
664
+ z
665
+ .object({
666
+ label: z.string().optional(),
667
+ cli: z.string(),
668
+ output: z.string().optional(),
669
+ })
670
+ .passthrough(),
671
+ )
672
+ .optional(),
673
+ exitCodes: z
674
+ .array(z.object({code: z.number(), when: z.string()}).passthrough())
675
+ .optional(),
676
+ outsideProject: z.enum(['same', 'refuse', 'own']).optional(),
677
+ replaces: z.array(z.string()).optional(),
678
+ requires: z.array(BaseStepSchema).optional(),
679
+ pointers: z
680
+ .array(
681
+ z
682
+ .object({
683
+ commands: z.array(z.string().min(1)).min(1),
684
+ text: z.string().min(1),
685
+ })
686
+ .strict(),
687
+ )
688
+ .optional(),
689
+ related: z.array(z.string()).optional(),
690
+ notes: z.array(ReferenceContentBlockSchema).optional(),
691
+ })
692
+ .passthrough();
693
+
694
+ /**
695
+ * @typedef {import('../_shared/contract.js').Expect<
696
+ * import('../_shared/contract.js').MutuallyAssignable<
697
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof CommandDocKindSchema>>,
698
+ * import('../_shared/contract.js').NamedFields<CommandDoc & {type: 'command'}>
699
+ * >
700
+ * >} _CommandDocDriftLock
701
+ */
702
+
703
+ /** New stamped enum doc (`type: 'enum'`). */
704
+ const EnumDocKindSchema = z
705
+ .object({
706
+ ...AuthoredDocGraphFields,
707
+ type: z.literal('enum'),
708
+ name: z.string().min(1, 'name is required'),
709
+ displayName: z.string().min(1, 'displayName is required'),
710
+ description: z.string(),
711
+ namespace: z.string().optional(),
712
+ members: z.array(
658
713
  z
659
714
  .object({
660
- label: z.string().optional(),
661
- cli: z.string(),
662
- output: z.string().optional(),
715
+ value: z.string().min(1, 'member value is required'),
716
+ description: z.string(),
717
+ deprecated: z.string().optional(),
718
+ stability: z.literal('experimental').optional(),
663
719
  })
664
720
  .passthrough(),
665
- )
666
- .optional(),
667
- exitCodes: z
668
- .array(z.object({code: z.number(), when: z.string()}).passthrough())
669
- .optional(),
670
- outsideProject: z.enum(['same', 'refuse', 'own']).optional(),
671
- replaces: z.array(z.string()).optional(),
672
- requires: z.array(BaseStepSchema).optional(),
673
- pointers: z
674
- .array(
675
- z
676
- .object({
677
- commands: z.array(z.string().min(1)).min(1),
678
- text: z.string().min(1),
679
- })
680
- .strict(),
681
- )
682
- .optional(),
683
- related: z.array(z.string()).optional(),
684
- notes: z.array(ReferenceContentBlockSchema).optional(),
685
- })
686
- .passthrough();
687
-
688
- /**
689
- * @typedef {import('../_shared/contract.js').Expect<
690
- * import('../_shared/contract.js').MutuallyAssignable<
691
- * import('../_shared/contract.js').NamedFields<z.infer<typeof CommandDocKindSchema>>,
692
- * import('../_shared/contract.js').NamedFields<CommandDoc & {type: 'command'}>
693
- * >
694
- * >} _CommandDocDriftLock
695
- */
696
-
697
- /** New stamped enum doc (`type: 'enum'`). */
698
- export const EnumDocKindSchema = z
699
- .object({
700
- ...AuthoredDocGraphFields,
701
- type: z.literal('enum'),
702
- name: z.string().min(1, 'name is required'),
703
- displayName: z.string().min(1, 'displayName is required'),
704
- description: z.string(),
705
- namespace: z.string().optional(),
706
- members: z.array(
707
- z
721
+ ),
722
+ })
723
+ .passthrough();
724
+
725
+ /**
726
+ * @typedef {import('../_shared/contract.js').Expect<
727
+ * import('../_shared/contract.js').MutuallyAssignable<
728
+ * import('../_shared/contract.js').NamedFields<z.infer<typeof EnumDocKindSchema>>,
729
+ * import('../_shared/contract.js').NamedFields<EnumDoc & {type: 'enum'}>
730
+ * >
731
+ * >} _EnumDocDriftLock
732
+ */
733
+
734
+ const NamespaceSlotSchema = z
735
+ .object({
736
+ title: nonEmptyString,
737
+ accepts: z
708
738
  .object({
709
- value: z.string().min(1, 'member value is required'),
710
- description: z.string(),
711
- deprecated: z.string().optional(),
712
- stability: z.literal('experimental').optional(),
739
+ kinds: z.array(AuthoredDocKindSchema).min(1),
740
+ providers: z.enum(['same', 'configured']).optional(),
713
741
  })
714
- .passthrough(),
715
- ),
716
- })
717
- .passthrough();
718
-
719
- /**
720
- * @typedef {import('../_shared/contract.js').Expect<
721
- * import('../_shared/contract.js').MutuallyAssignable<
722
- * import('../_shared/contract.js').NamedFields<z.infer<typeof EnumDocKindSchema>>,
723
- * import('../_shared/contract.js').NamedFields<EnumDoc & {type: 'enum'}>
724
- * >
725
- * >} _EnumDocDriftLock
726
- */
742
+ .strict(),
743
+ })
744
+ .strict();
727
745
 
728
- const NamespaceSlotSchema = z
729
- .object({
730
- title: nonEmptyString,
731
- accepts: z
732
- .object({
733
- kinds: z.array(AuthoredDocKindSchema).min(1),
734
- providers: z.enum(['same', 'configured']).optional(),
735
- })
736
- .strict(),
737
- })
738
- .strict();
746
+ /** The one new authored doctype: a hierarchy and layout owner. */
747
+ const NamespaceDocKindSchema = z
748
+ .object({
749
+ ...AuthoredDocGraphFields,
750
+ type: z.literal('namespace'),
751
+ name: nonEmptyString,
752
+ title: nonEmptyString,
753
+ summary: nonEmptyString,
754
+ keywords: z.array(nonEmptyString).optional(),
755
+ describes: z.literal('cli').optional(),
756
+ slots: z
757
+ .record(nonEmptyString, NamespaceSlotSchema)
758
+ .refine(slots => Object.keys(slots).length > 0, {
759
+ message: 'at least one slot is required',
760
+ }),
761
+ adopts: z
762
+ .array(
763
+ z
764
+ .object({
765
+ source: z
766
+ .object({
767
+ group: nonEmptyString,
768
+ kinds: z.array(AuthoredDocKindSchema).min(1).optional(),
769
+ packages: z.literal('all').optional(),
770
+ })
771
+ .strict(),
772
+ into: nonEmptyString,
773
+ groupBy: z.literal('kind').optional(),
774
+ })
775
+ .strict(),
776
+ )
777
+ .optional(),
778
+ blocks: z.array(NamespaceContentBlockSchema).optional(),
779
+ })
780
+ .strict()
781
+ .superRefine((doc, context) => {
782
+ const slots = new Set(Object.keys(doc.slots));
783
+ doc.adopts?.forEach((rule, index) => {
784
+ const slot = doc.slots[rule.into];
785
+ if (slot == null) {
786
+ context.addIssue({
787
+ code: 'custom',
788
+ path: ['adopts', index, 'into'],
789
+ message: `must name a declared slot; received "${rule.into}"`,
790
+ });
791
+ return;
792
+ }
793
+ /** @type {AuthoredDocKind[]} */
794
+ const adoptedKinds =
795
+ rule.groupBy === 'kind' ? ['namespace'] : (rule.source.kinds ?? []);
796
+ adoptedKinds.forEach(kind => {
797
+ if (!slot.accepts.kinds.includes(kind)) {
798
+ context.addIssue({
799
+ code: 'custom',
800
+ path: ['adopts', index, 'into'],
801
+ message: `slot "${rule.into}" does not accept adopted kind "${kind}"`,
802
+ });
803
+ }
804
+ });
805
+ });
806
+ doc.blocks?.forEach((block, index) => {
807
+ if (block.type === 'collection' && !slots.has(block.source.slot)) {
808
+ context.addIssue({
809
+ code: 'custom',
810
+ path: ['blocks', index, 'source', 'slot'],
811
+ message: `must name a declared slot; received "${block.source.slot}"`,
812
+ });
813
+ }
814
+ });
815
+ });
739
816
 
740
- /** The one new authored doctype: a hierarchy and layout owner. */
741
- export const NamespaceDocKindSchema = z
742
- .object({
817
+ /**
818
+ * @typedef {import('../_shared/contract.js').Expect<
819
+ * import('../_shared/contract.js').Equal<
820
+ * z.infer<typeof NamespaceDocKindSchema>,
821
+ * NamespaceDoc
822
+ * >
823
+ * >} _NamespaceDocDriftLock
824
+ */
825
+
826
+ // Legacy loose format stays permissive for backward compatibility.
827
+ const LegacyBaseDocSchema = z.object({
743
828
  ...AuthoredDocGraphFields,
744
- type: z.literal('namespace'),
745
- name: nonEmptyString,
829
+ name: z.string().min(1, 'name is required'),
830
+ displayName: z.string().optional(),
831
+ description: z.string().optional(),
832
+ group: z.string().optional(),
833
+ category: z.string().optional(),
834
+ keywords: z.array(z.string()).optional(),
835
+ isHiddenFromOverview: z.boolean().optional(),
836
+ hidden: z.boolean().optional(),
837
+ hiddenComponents: z.array(z.string()).optional(),
838
+ usage: z.unknown().optional(),
839
+ playground: z.unknown().optional(),
840
+ theming: z.unknown().optional(),
841
+ examples: z.array(z.unknown()).optional(),
842
+ showcase: z.unknown().optional(),
843
+ parent: z.string().optional(),
844
+ relatedDocs: z.array(z.string()).optional(),
845
+ relatedComponents: z.array(z.string()).optional(),
846
+ relatedHooks: z.array(z.string()).optional(),
847
+ });
848
+
849
+ const LegacyReferenceDocSchema = LegacyBaseDocSchema.extend({
746
850
  title: nonEmptyString,
747
- summary: nonEmptyString,
748
- keywords: z.array(nonEmptyString).optional(),
749
- describes: z.literal('cli').optional(),
750
- slots: z
751
- .record(nonEmptyString, NamespaceSlotSchema)
752
- .refine(slots => Object.keys(slots).length > 0, {
753
- message: 'at least one slot is required',
754
- }),
755
- adopts: z
756
- .array(
757
- z
758
- .object({
759
- source: z
760
- .object({
761
- group: nonEmptyString,
762
- kinds: z.array(AuthoredDocKindSchema).min(1).optional(),
763
- packages: z.literal('all').optional(),
764
- })
765
- .strict(),
766
- into: nonEmptyString,
767
- groupBy: z.literal('kind').optional(),
768
- })
769
- .strict(),
770
- )
771
- .optional(),
772
- blocks: z.array(NamespaceContentBlockSchema).optional(),
851
+ description: z.string(),
852
+ // As on the stamped schema: search terms for the whole topic.
853
+ keywords: z.array(z.string()).optional(),
854
+ sections: z.array(ReferenceSectionSchema).min(1),
855
+ replaces: nonEmptyString.optional(),
856
+ extends: nonEmptyString.optional(),
857
+ tokenCategory: z.string().optional(),
773
858
  })
774
- .strict()
775
- .superRefine((doc, context) => {
776
- const slots = new Set(Object.keys(doc.slots));
777
- doc.adopts?.forEach((rule, index) => {
778
- const slot = doc.slots[rule.into];
779
- if (slot == null) {
859
+ .passthrough()
860
+ .superRefine((doc, context) => {
861
+ if (doc.replaces != null && doc.extends != null) {
780
862
  context.addIssue({
781
863
  code: 'custom',
782
- path: ['adopts', index, 'into'],
783
- message: `must name a declared slot; received "${rule.into}"`,
864
+ path: ['extends'],
865
+ message: 'declares both `replaces` and `extends`; choose one',
784
866
  });
785
- return;
786
867
  }
787
- /** @type {AuthoredDocKind[]} */
788
- const adoptedKinds =
789
- rule.groupBy === 'kind' ? ['namespace'] : (rule.source.kinds ?? []);
790
- adoptedKinds.forEach(kind => {
791
- if (!slot.accepts.kinds.includes(kind)) {
868
+ const sectionIds = new Set();
869
+ doc.sections.forEach((section, index) => {
870
+ if (section.id == null) return;
871
+ if (sectionIds.has(section.id)) {
792
872
  context.addIssue({
793
873
  code: 'custom',
794
- path: ['adopts', index, 'into'],
795
- message: `slot "${rule.into}" does not accept adopted kind "${kind}"`,
874
+ path: ['sections', index, 'id'],
875
+ message: `duplicate section id "${section.id}"`,
796
876
  });
797
877
  }
878
+ sectionIds.add(section.id);
798
879
  });
799
880
  });
800
- doc.blocks?.forEach((block, index) => {
801
- if (block.type === 'collection' && !slots.has(block.source.slot)) {
802
- context.addIssue({
803
- code: 'custom',
804
- path: ['blocks', index, 'source', 'slot'],
805
- message: `must name a declared slot; received "${block.source.slot}"`,
806
- });
807
- }
808
- });
809
- });
810
881
 
811
- /**
812
- * @typedef {import('../_shared/contract.js').Expect<
813
- * import('../_shared/contract.js').Equal<
814
- * z.infer<typeof NamespaceDocKindSchema>,
815
- * NamespaceDoc
816
- * >
817
- * >} _NamespaceDocDriftLock
818
- */
882
+ const LegacySingleComponentDocSchema = LegacyBaseDocSchema.extend({
883
+ props: z.array(PropSchema),
884
+ deprecated: ComponentDeprecationSchema.optional(),
885
+ }).passthrough();
819
886
 
820
- // Legacy loose format stays permissive for backward compatibility.
821
- const LegacyBaseDocSchema = z.object({
822
- ...AuthoredDocGraphFields,
823
- name: z.string().min(1, 'name is required'),
824
- displayName: z.string().optional(),
825
- description: z.string().optional(),
826
- group: z.string().optional(),
827
- category: z.string().optional(),
828
- keywords: z.array(z.string()).optional(),
829
- isHiddenFromOverview: z.boolean().optional(),
830
- hidden: z.boolean().optional(),
831
- hiddenComponents: z.array(z.string()).optional(),
832
- usage: z.unknown().optional(),
833
- playground: z.unknown().optional(),
834
- theming: z.unknown().optional(),
835
- examples: z.array(z.unknown()).optional(),
836
- showcase: z.unknown().optional(),
837
- parent: z.string().optional(),
838
- relatedDocs: z.array(z.string()).optional(),
839
- relatedComponents: z.array(z.string()).optional(),
840
- relatedHooks: z.array(z.string()).optional(),
841
- });
842
-
843
- const LegacyReferenceDocSchema = LegacyBaseDocSchema.extend({
844
- title: nonEmptyString,
845
- description: z.string(),
846
- // As on the stamped schema: search terms for the whole topic.
847
- keywords: z.array(z.string()).optional(),
848
- sections: z.array(ReferenceSectionSchema).min(1),
849
- replaces: nonEmptyString.optional(),
850
- extends: nonEmptyString.optional(),
851
- tokenCategory: z.string().optional(),
852
- })
853
- .passthrough()
854
- .superRefine((doc, context) => {
855
- if (doc.replaces != null && doc.extends != null) {
856
- context.addIssue({
857
- code: 'custom',
858
- path: ['extends'],
859
- message: 'declares both `replaces` and `extends`; choose one',
860
- });
861
- }
862
- const sectionIds = new Set();
863
- doc.sections.forEach((section, index) => {
864
- if (section.id == null) return;
865
- if (sectionIds.has(section.id)) {
866
- context.addIssue({
867
- code: 'custom',
868
- path: ['sections', index, 'id'],
869
- message: `duplicate section id "${section.id}"`,
870
- });
871
- }
872
- sectionIds.add(section.id);
873
- });
874
- });
887
+ const LegacyMultiComponentDocSchema = LegacyBaseDocSchema.extend({
888
+ components: z.array(z.unknown()),
889
+ deprecated: ComponentDeprecationSchema.optional(),
890
+ }).passthrough();
875
891
 
876
- const LegacySingleComponentDocSchema = LegacyBaseDocSchema.extend({
877
- props: z.array(PropSchema),
878
- deprecated: ComponentDeprecationSchema.optional(),
879
- }).passthrough();
880
-
881
- const LegacyMultiComponentDocSchema = LegacyBaseDocSchema.extend({
882
- components: z.array(z.unknown()),
883
- deprecated: ComponentDeprecationSchema.optional(),
884
- }).passthrough();
885
-
886
- const LegacyHookDocSchema = LegacyBaseDocSchema.extend({
887
- params: z.array(ParamSchema),
888
- returns: z.array(ReturnSchema),
889
- }).passthrough();
890
-
891
- const LegacySubComponentDocSchema = LegacyBaseDocSchema.extend({
892
- subComponentOf: z.string().min(1, 'subComponentOf is required'),
893
- description: z.string(),
894
- props: z.array(PropSchema),
895
- deprecated: ComponentDeprecationSchema.optional(),
896
- }).passthrough();
897
-
898
- /** The permissive legacy union (sub-component, hook, multi, single, then reference). */
899
- export const LegacyDocSchema = z.union([
900
- LegacySubComponentDocSchema,
901
- LegacyHookDocSchema,
902
- LegacyMultiComponentDocSchema,
903
- LegacySingleComponentDocSchema,
904
- LegacyReferenceDocSchema,
905
- ]);
892
+ const LegacyHookDocSchema = LegacyBaseDocSchema.extend({
893
+ params: z.array(ParamSchema),
894
+ returns: z.array(ReturnSchema),
895
+ }).passthrough();
896
+
897
+ const LegacySubComponentDocSchema = LegacyBaseDocSchema.extend({
898
+ subComponentOf: z.string().min(1, 'subComponentOf is required'),
899
+ description: z.string(),
900
+ props: z.array(PropSchema),
901
+ deprecated: ComponentDeprecationSchema.optional(),
902
+ }).passthrough();
903
+
904
+ /** The permissive legacy union (sub-component, hook, multi, single, then reference). */
905
+ const LegacyDocSchema = z.union([
906
+ LegacySubComponentDocSchema,
907
+ LegacyHookDocSchema,
908
+ LegacyMultiComponentDocSchema,
909
+ LegacySingleComponentDocSchema,
910
+ LegacyReferenceDocSchema,
911
+ ]);
912
+
913
+ return {
914
+ AuthoredDocKindSchema,
915
+ AuthoredDocGraphFields,
916
+ ReferenceContentBlockSchema,
917
+ GraphContentBlockSchema,
918
+ SectionContentBlockSchema,
919
+ NamespaceContentBlockSchema,
920
+ DocExampleKindsSchema,
921
+ ComponentDocKindSchema,
922
+ FunctionDocKindSchema,
923
+ GenericDocKindSchema,
924
+ SchemaDocKindSchema,
925
+ CommandDocKindSchema,
926
+ EnumDocKindSchema,
927
+ NamespaceDocKindSchema,
928
+ LegacyDocSchema,
929
+ };
930
+ }
931
+
932
+ /** @type {ReturnType<typeof buildDocSchemas> | undefined} */
933
+ let builtDocSchemas;
934
+
935
+ /**
936
+ * The sealed schemas. They are built when a doc is first parsed, not when
937
+ * this module loads: a read whose docs all have a stored or kept parse
938
+ * parses nothing, so it builds none of them.
939
+ * @returns {ReturnType<typeof buildDocSchemas>}
940
+ */
941
+ export function docSchemas() {
942
+ return (builtDocSchemas ??= buildDocSchemas());
943
+ }