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

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 (409) hide show
  1. package/README.md +7 -2
  2. package/api/build/_adapter.d.mts +7 -6
  3. package/api/build/_adapter.mjs +18 -11
  4. package/api/build/build.type.mjs +1 -1
  5. package/api/build/kit/kind.d.mts +6 -0
  6. package/api/build/kit/kind.mjs +1 -1
  7. package/api/build/kit/rank.d.mts +7 -1
  8. package/api/build/kit/rank.mjs +15 -5
  9. package/api/build/kit/signals.mjs +58 -57
  10. package/api/build/kit/start.d.mts +2 -1
  11. package/api/build/kit/start.mjs +62 -9
  12. package/api/build/kit/words.d.mts +6 -2
  13. package/api/build/kit/words.mjs +7 -3
  14. package/api/component/__fixtures__/resolutions/modules.txt +2 -2
  15. package/api/component/_adapter.d.mts +30 -24
  16. package/api/component/_adapter.mjs +72 -31
  17. package/api/component/component.mjs +4 -4
  18. package/api/component/detail/detail.d.mts +2 -2
  19. package/api/component/detail/detail.mjs +1 -1
  20. package/api/component/list/list.d.mts +2 -2
  21. package/api/component/list/list.mjs +4 -4
  22. package/api/discover/_adapter.mjs +15 -15
  23. package/api/docs/_adapter.d.mts +13 -5
  24. package/api/docs/_adapter.mjs +37 -10
  25. package/api/doctor/_adapter.d.mts +32 -0
  26. package/api/doctor/_adapter.mjs +56 -1
  27. package/api/doctor/doctor.mjs +28 -5
  28. package/api/doctor/theme-checks.mjs +165 -83
  29. package/api/error.d.mts +4 -3
  30. package/api/error.mjs +3 -2
  31. package/api/hook/_adapter.d.mts +5 -4
  32. package/api/hook/_adapter.mjs +6 -5
  33. package/api/icon/_options.d.mts +17 -0
  34. package/api/icon/_options.mjs +54 -0
  35. package/api/icon/exportIconIndex.doc.d.mts +10 -0
  36. package/api/icon/exportIconIndex.doc.mjs +59 -0
  37. package/api/icon/icon.mjs +11 -34
  38. package/api/icon/icon.type.d.mts +49 -0
  39. package/api/icon/icon.type.mjs +24 -0
  40. package/api/icon/rankIconIndex.doc.d.mts +10 -0
  41. package/api/icon/rankIconIndex.doc.mjs +79 -0
  42. package/api/icon/search/icon-index.d.mts +41 -0
  43. package/api/icon/search/icon-index.mjs +139 -0
  44. package/api/icon/search/search.d.mts +18 -0
  45. package/api/icon/search/search.mjs +13 -0
  46. package/api/index.d.mts +1 -0
  47. package/api/index.mjs +1 -0
  48. package/api/search/_adapter.d.mts +8 -5
  49. package/api/search/_adapter.mjs +14 -10
  50. package/api/search/_gather-components.d.mts +4 -4
  51. package/api/search/_gather-components.mjs +4 -3
  52. package/api/search/_gather-hooks.d.mts +2 -2
  53. package/api/search/_gather-hooks.mjs +1 -1
  54. package/api/search/_lexical.mjs +12 -2
  55. package/api/search/_priority.d.mts +10 -2
  56. package/api/search/_priority.mjs +37 -7
  57. package/api/search/_score.d.mts +12 -3
  58. package/api/search/_score.mjs +6 -3
  59. package/api/search/_words.mjs +12 -3
  60. package/api/search/search.d.mts +7 -1
  61. package/api/search/search.mjs +37 -4
  62. package/api/swizzle/_adapter.d.mts +7 -5
  63. package/api/swizzle/_adapter.mjs +7 -3
  64. package/api/swizzle/copy/copy.mjs +5 -4
  65. package/api/theme/build/build.d.mts +5 -0
  66. package/api/theme/build/build.mjs +400 -21
  67. package/api/theme/build/family.mjs +18 -7
  68. package/api/theme/build/font-warning.mjs +5 -4
  69. package/api/theme/build/input-fields.d.mts +21 -6
  70. package/api/theme/build/input-fields.mjs +104 -13
  71. package/api/theme/build/typography-values.d.mts +22 -0
  72. package/api/theme/build/typography-values.mjs +172 -22
  73. package/api/theme/build/written-values.d.mts +7 -0
  74. package/api/theme/build/written-values.mjs +57 -8
  75. package/api/theme/generateTonalPalette.doc.mjs +1 -1
  76. package/api/theme/palette/generate/generator.d.mts +14 -2
  77. package/api/theme/palette/generate/generator.mjs +94 -8
  78. package/api/theme/theme.type.d.mts +21 -4
  79. package/api/theme/theme.type.mjs +14 -5
  80. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  81. package/api/theme/themeTemplate.doc.mjs +18 -3
  82. package/api/theme-edit/_adapter.d.mts +1 -1
  83. package/api/theme-edit/_adapter.mjs +1 -1
  84. package/api/theme-edit/_catalog.d.mts +10 -4
  85. package/api/theme-edit/_catalog.mjs +81 -22
  86. package/api/theme-edit/_check.mjs +402 -88
  87. package/api/theme-edit/_color.d.mts +11 -2
  88. package/api/theme-edit/_color.mjs +23 -7
  89. package/api/theme-edit/_compiler.mjs +11 -3
  90. package/api/theme-edit/_context.d.mts +87 -6
  91. package/api/theme-edit/_context.mjs +224 -17
  92. package/api/theme-edit/_css.mjs +4 -0
  93. package/api/theme-edit/_edit.mjs +331 -58
  94. package/api/theme-edit/_how-question.d.mts +11 -0
  95. package/api/theme-edit/_how-question.mjs +2514 -234
  96. package/api/theme-edit/_how.mjs +79 -14
  97. package/api/theme-edit/_missed.mjs +294 -32
  98. package/api/theme-edit/_normal.d.mts +3 -1
  99. package/api/theme-edit/_normal.mjs +4 -1
  100. package/api/theme-edit/_palette.mjs +36 -5
  101. package/api/theme-edit/_part-words.mjs +20 -2
  102. package/api/theme-edit/_parts.d.mts +12 -1
  103. package/api/theme-edit/_parts.mjs +116 -11
  104. package/api/theme-edit/_preview-app.mjs +40 -2
  105. package/api/theme-edit/_preview.d.mts +45 -5
  106. package/api/theme-edit/_preview.mjs +173 -21
  107. package/api/theme-edit/_settings.d.mts +20 -0
  108. package/api/theme-edit/_settings.mjs +1033 -94
  109. package/api/theme-edit/_tables.mjs +2 -2
  110. package/api/theme-edit/theme-edit.type.d.mts +6 -5
  111. package/api/theme-edit/theme-edit.type.mjs +8 -8
  112. package/api/upgrade/_adapter.mjs +13 -2
  113. package/assets/component-list.generated.json +1 -1
  114. package/assets/docs/tree/authoring.doc.mjs +1 -0
  115. package/assets/docs/tree/cli.doc.mjs +1 -0
  116. package/assets/docs/tree/computer-agent-guide.doc.mjs +1 -1
  117. package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
  118. package/assets/docs/tree/global.doc.mjs +1 -0
  119. package/assets/docs/tree/single-component.doc.mjs +40 -2
  120. package/assets/docs/tree/updates.doc.mjs +1 -1
  121. package/assets/docs/tree/who-answers.doc.mjs +2 -2
  122. package/assets/docs-routes.generated.json +1 -1
  123. package/assets/docs.generated.json +2 -2
  124. package/assets/search-catalog.generated.json +2 -2
  125. package/assets/self-audit.generated.json +1 -1
  126. package/assets/templates/blocks/components/Blockquote/BlockquoteShowcase.tsx +1 -1
  127. package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +4 -4
  128. package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx +1 -0
  129. package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsSupportingVariant.tsx +2 -2
  130. package/assets/templates/blocks/components/Card/CardElevations.tsx +1 -1
  131. package/assets/templates/blocks/components/Card/CardWithInnerLayout.tsx +19 -3
  132. package/assets/templates/blocks/components/Card/ClickableCardWithNestedButton.tsx +11 -1
  133. package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +1 -1
  134. package/assets/templates/blocks/components/Card/SelectableCardMulti.tsx +1 -1
  135. package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +1 -1
  136. package/assets/templates/blocks/components/Center/CenterInsideACard.tsx +1 -1
  137. package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx +8 -0
  138. package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.tsx +8 -2
  139. package/assets/templates/blocks/components/ChatLayout/ChatLayoutPanelChat.tsx +1 -0
  140. package/assets/templates/blocks/components/ChatLayout/ChatLayoutShowcase.tsx +1 -1
  141. package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleCustomContent.tsx +9 -1
  142. package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleMetadata.tsx +12 -2
  143. package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.tsx +28 -7
  144. package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.tsx +35 -7
  145. package/assets/templates/blocks/components/Collapsible/CollapsibleShowcase.tsx +1 -1
  146. package/assets/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.tsx +20 -4
  147. package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +15 -3
  148. package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +29 -6
  149. package/assets/templates/blocks/components/ContextMenu/ContextMenuBasic.tsx +2 -2
  150. package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.tsx +1 -1
  151. package/assets/templates/blocks/components/ContextMenu/ContextMenuShowcase.tsx +2 -2
  152. package/assets/templates/blocks/components/Divider/DividerFullBleed.tsx +1 -1
  153. package/assets/templates/blocks/components/Divider/DividerShowcase.tsx +1 -1
  154. package/assets/templates/blocks/components/Divider/DividerVariants.tsx +1 -1
  155. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +23 -4
  156. package/assets/templates/blocks/components/EmptyState/EmptyStateActions.tsx +18 -2
  157. package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.tsx +20 -2
  158. package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.tsx +16 -2
  159. package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.tsx +11 -1
  160. package/assets/templates/blocks/components/Heading/HeadingTruncation.tsx +12 -2
  161. package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +1 -1
  162. package/assets/templates/blocks/components/LayoutContent/LayoutContentBasic.tsx +1 -1
  163. package/assets/templates/blocks/components/LayoutContent/LayoutContentShowcase.tsx +1 -1
  164. package/assets/templates/blocks/components/LayoutFooter/LayoutFooterActions.tsx +17 -3
  165. package/assets/templates/blocks/components/LayoutFooter/LayoutFooterShowcase.tsx +17 -3
  166. package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderShowcase.tsx +15 -3
  167. package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.tsx +9 -2
  168. package/assets/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.tsx +1 -1
  169. package/assets/templates/blocks/components/LayoutPanel/LayoutPanelShowcase.tsx +1 -1
  170. package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.tsx +1 -1
  171. package/assets/templates/blocks/components/MultiSelector/MultiSelectorGhostToolbar.tsx +14 -2
  172. package/assets/templates/blocks/components/Outline/OutlineDensity.tsx +2 -0
  173. package/assets/templates/blocks/components/OverflowList/OverflowListShowcase.tsx +6 -1
  174. package/assets/templates/blocks/components/Pagination/PaginationVariants.tsx +4 -0
  175. package/assets/templates/blocks/components/Popover/PopoverHookUsage.tsx +17 -2
  176. package/assets/templates/blocks/components/SegmentedControl/SegmentedControlFillLayout.tsx +1 -1
  177. package/assets/templates/blocks/components/Selector/SelectorGhostToolbar.tsx +14 -2
  178. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +8 -1
  179. package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +2 -2
  180. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -0
  181. package/assets/templates/blocks/components/Switch/SwitchWithStatus.tsx +1 -1
  182. package/assets/templates/blocks/components/TabList/TabListTabsFillLayout.tsx +1 -1
  183. package/assets/templates/blocks/components/TabList/TabListTabsWithActions.tsx +12 -1
  184. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +11 -1
  185. package/assets/templates/blocks/components/Table/TableInCard.tsx +2 -2
  186. package/assets/templates/blocks/components/Text/TextTruncation.tsx +1 -1
  187. package/assets/templates/blocks/components/Text/TextWordBreak.tsx +12 -2
  188. package/assets/templates/blocks/components/Text/TextWrap.tsx +19 -4
  189. package/assets/templates/blocks/components/TextArea/TextAreaCharacterCount.tsx +1 -1
  190. package/assets/templates/blocks/components/TextArea/TextAreaShowcase.tsx +1 -1
  191. package/assets/templates/blocks/components/TextArea/TextAreaStates.tsx +1 -1
  192. package/assets/templates/blocks/components/TextArea/TextAreaValidation.tsx +1 -1
  193. package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.tsx +1 -1
  194. package/assets/templates/blocks/components/TextInput/TextInputStatusVariant.tsx +2 -2
  195. package/assets/templates/blocks/components/Timestamp/TimestampAutoFormat.tsx +15 -1
  196. package/assets/templates/blocks/components/Timestamp/TimestampRelativeFormat.tsx +15 -1
  197. package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +8 -0
  198. package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +12 -1
  199. package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +18 -3
  200. package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.tsx +6 -0
  201. package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.tsx +7 -1
  202. package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.tsx +2 -2
  203. package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +9 -0
  204. package/assets/templates/components.generated.json +1 -1
  205. package/assets/templates/pages/ai-chat/page.tsx +102 -6
  206. package/assets/templates/pages/canvas-editor/page.tsx +73 -2
  207. package/assets/templates/pages/centered-hero/page.tsx +10 -4
  208. package/assets/templates/pages/course-detail/page.tsx +46 -2
  209. package/assets/templates/pages/dashboard/page.tsx +45 -16
  210. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +31 -20
  211. package/assets/templates/pages/dashboard-comparison/page.tsx +9 -0
  212. package/assets/templates/pages/dashboard-composition/page.tsx +22 -9
  213. package/assets/templates/pages/dashboard-progress/page.tsx +27 -15
  214. package/assets/templates/pages/dashboard-scorecard/page.tsx +9 -0
  215. package/assets/templates/pages/detail-page/page.tsx +105 -77
  216. package/assets/templates/pages/documentation/page.tsx +15 -2
  217. package/assets/templates/pages/documentation-design/page.tsx +7 -34
  218. package/assets/templates/pages/documentation-technical/page.tsx +76 -12
  219. package/assets/templates/pages/editor/page.tsx +26 -21
  220. package/assets/templates/pages/file-explorer/page.tsx +35 -1
  221. package/assets/templates/pages/form-two-column/page.tsx +2 -3
  222. package/assets/templates/pages/form-wizard/page.tsx +31 -3
  223. package/assets/templates/pages/form-wizard-vertical/page.tsx +32 -3
  224. package/assets/templates/pages/gallery-hero/page.tsx +2 -1
  225. package/assets/templates/pages/ide/page.tsx +15 -1
  226. package/assets/templates/pages/incident-console/page.tsx +2 -1
  227. package/assets/templates/pages/incident-console/template.doc.mjs +1 -1
  228. package/assets/templates/pages/kanban-board/page.tsx +39 -2
  229. package/assets/templates/pages/payment-form/page.tsx +77 -39
  230. package/assets/templates/pages/product-gallery/page.tsx +16 -14
  231. package/assets/templates/pages/settings/page.tsx +35 -3
  232. package/assets/templates/pages/settings-dialog/page.tsx +34 -5
  233. package/assets/templates/pages/settings-sidebar/page.tsx +23 -3
  234. package/assets/templates/pages/shell-nav/page.tsx +28 -12
  235. package/assets/templates/pages/shell-side-nav/page.tsx +16 -1
  236. package/assets/templates/pages/shell-top-nav/page.tsx +27 -1
  237. package/assets/templates/pages/side-gallery/page.tsx +1 -1
  238. package/assets/templates/pages/table/page.tsx +2 -1
  239. package/assets/templates/pages/table/template.doc.mjs +1 -1
  240. package/assets/templates/pages/table-collapsible/page.tsx +1 -1
  241. package/assets/templates/pages/table-comparison/page.tsx +1 -1
  242. package/assets/templates/pages/table-filter/page.tsx +9 -2
  243. package/assets/templates/pages/table-grouped/page.tsx +16 -6
  244. package/assets/templates/pages/table-inbox/page.tsx +60 -1
  245. package/assets/templates/pages/table-page/page.tsx +10 -2
  246. package/assets/templates/pages/table-tree/page.tsx +95 -13
  247. package/assets/templates/pages/theme-showcase/page.tsx +107 -11
  248. package/assets/templates/pages/work-item-detail/page.tsx +88 -74
  249. package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -1
  250. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
  251. package/assets/templates/themes/gothic/gothicTheme.ts +5 -0
  252. package/assets/templates/themes/neutral/neutralTheme.ts +1 -1
  253. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
  254. package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
  255. package/authoring/debug/parse.d.mts +1 -1
  256. package/authoring/doctypes/_schema.d.mts +22 -8
  257. package/authoring/doctypes/_schema.mjs +31 -0
  258. package/authoring/doctypes/command/command.doc.mjs +24 -0
  259. package/authoring/doctypes/command/type.ts +31 -0
  260. package/authoring/doctypes/component/component.doc.mjs +1 -1
  261. package/authoring/doctypes/component/type.ts +8 -5
  262. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -0
  263. package/authoring/doctypes/namespace/type.ts +4 -0
  264. package/authoring/doctypes/template/type.ts +0 -7
  265. package/authoring/index.d.ts +6 -1
  266. package/authoring/integration/integration.doc.mjs +7 -0
  267. package/authoring/integration/schema.d.mts +6 -0
  268. package/authoring/integration/schema.mjs +3 -0
  269. package/authoring/integration/type.ts +34 -0
  270. package/clients/cli/build-id.generated.json +1 -1
  271. package/clients/cli/commands/component.doc.mjs +1 -0
  272. package/clients/cli/commands/component.mjs +5 -1
  273. package/clients/cli/commands/docs.doc.mjs +1 -1
  274. package/clients/cli/commands/experimental/index.mjs +4 -1
  275. package/clients/cli/commands/experimental/theme.mjs +139 -64
  276. package/clients/cli/commands/experimental-render.doc.mjs +2 -0
  277. package/clients/cli/commands/experimental-theme-add.doc.mjs +2 -0
  278. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -0
  279. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -0
  280. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -1
  281. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -2
  282. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -1
  283. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +3 -2
  284. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -0
  285. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -0
  286. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -0
  287. package/clients/cli/commands/experimental-theme-remove.doc.mjs +2 -0
  288. package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -0
  289. package/clients/cli/commands/experimental-theme-template.doc.mjs +1 -0
  290. package/clients/cli/commands/experimental-theme-use.doc.mjs +2 -0
  291. package/clients/cli/commands/gap-report.doc.mjs +1 -0
  292. package/clients/cli/commands/hook.doc.mjs +1 -1
  293. package/clients/cli/commands/init.doc.mjs +1 -1
  294. package/clients/cli/commands/integration-add.doc.mjs +1 -0
  295. package/clients/cli/commands/manifest.mjs +10 -3
  296. package/clients/cli/commands/swizzle.doc.mjs +8 -1
  297. package/clients/cli/commands/swizzle.mjs +13 -6
  298. package/clients/cli/commands/template.doc.mjs +3 -0
  299. package/clients/cli/commands/theme-add.doc.mjs +2 -1
  300. package/clients/cli/commands/theme-build.doc.mjs +2 -1
  301. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  302. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
  303. package/clients/cli/commands/theme-remove.doc.mjs +2 -1
  304. package/clients/cli/commands/theme-targets.doc.mjs +1 -0
  305. package/clients/cli/commands/theme-template.doc.mjs +1 -0
  306. package/clients/cli/commands/theme-use.doc.mjs +2 -1
  307. package/clients/cli/commands/theme.doc.mjs +7 -2
  308. package/clients/cli/commands/theme.mjs +21 -5
  309. package/clients/cli/index.mjs +167 -59
  310. package/clients/cli/lib/base-gate.mjs +522 -0
  311. package/clients/cli/lib/command-path.mjs +26 -0
  312. package/clients/cli/lib/define-command.mjs +161 -12
  313. package/clients/cli/lib/json-shim.mjs +34 -31
  314. package/clients/cli/lib/manifest.d.ts +14 -0
  315. package/clients/cli/lib/manifest.mjs +78 -22
  316. package/clients/cli/lib/root-args.mjs +79 -0
  317. package/clients/cli/lib/stray-option.mjs +21 -8
  318. package/clients/cli/lib/unknown-command.mjs +27 -6
  319. package/clients/cli/manifest.generated.json +1 -1
  320. package/clients/cli/run.mjs +13 -1
  321. package/foundation/agent-docs/computer-agent-text.mjs +1 -1
  322. package/foundation/bases/core-docs.d.mts +10 -0
  323. package/foundation/bases/core-docs.mjs +42 -0
  324. package/foundation/bases/core.d.mts +11 -0
  325. package/foundation/bases/core.mjs +32 -0
  326. package/foundation/bases/requirements.d.mts +128 -0
  327. package/foundation/bases/requirements.mjs +193 -0
  328. package/foundation/bases/resolve.d.mts +134 -0
  329. package/foundation/bases/resolve.mjs +295 -0
  330. package/foundation/bases/state.d.mts +24 -0
  331. package/foundation/bases/state.mjs +46 -0
  332. package/foundation/bases/steps.d.mts +49 -0
  333. package/foundation/bases/steps.mjs +88 -0
  334. package/foundation/config/project.d.mts +14 -0
  335. package/foundation/config/project.mjs +68 -1
  336. package/foundation/discovery/cli-self-docs.mjs +9 -1
  337. package/foundation/discovery/command-pointers.d.mts +28 -0
  338. package/foundation/discovery/command-pointers.mjs +31 -0
  339. package/foundation/discovery/component-discovery.d.mts +9 -8
  340. package/foundation/discovery/component-discovery.mjs +9 -4
  341. package/foundation/discovery/docs-discovery.d.mts +13 -5
  342. package/foundation/discovery/docs-discovery.mjs +25 -6
  343. package/foundation/discovery/hook-discovery.d.mts +6 -6
  344. package/foundation/discovery/hook-discovery.mjs +6 -4
  345. package/foundation/discovery/template-adapter.mjs +5 -0
  346. package/foundation/discovery/template-ids.d.mts +1 -1
  347. package/foundation/discovery/template-ids.mjs +5 -1
  348. package/foundation/discovery/theme-discovery.mjs +3 -0
  349. package/foundation/discovery/theme-imports.mjs +19 -1
  350. package/foundation/doc-compiler/tree.d.mts +4 -2
  351. package/foundation/doc-compiler/tree.mjs +46 -1
  352. package/foundation/env/package-manager.d.mts +7 -0
  353. package/foundation/env/package-manager.mjs +21 -0
  354. package/foundation/fonts/font-stylesheet.d.mts +8 -0
  355. package/foundation/fonts/font-stylesheet.mjs +26 -2
  356. package/foundation/fs/gather-cache.mjs +44 -13
  357. package/foundation/fs/own-modules.d.mts +29 -0
  358. package/foundation/fs/own-modules.mjs +57 -0
  359. package/foundation/fs/paths.d.mts +30 -2
  360. package/foundation/fs/paths.mjs +49 -2
  361. package/foundation/integrations/integrations.d.mts +4 -0
  362. package/foundation/integrations/integrations.mjs +6 -1
  363. package/foundation/release/choose.d.mts +7 -0
  364. package/foundation/release/choose.mjs +16 -2
  365. package/foundation/release/notices.d.mts +26 -0
  366. package/foundation/release/notices.mjs +48 -19
  367. package/foundation/release/project.d.mts +3 -2
  368. package/foundation/release/project.mjs +4 -5
  369. package/foundation/release/run-context.d.mts +7 -2
  370. package/foundation/release/run-context.mjs +6 -2
  371. package/foundation/render/css-cut.mjs +86 -6
  372. package/foundation/render/cut-short.d.mts +35 -0
  373. package/foundation/render/cut-short.mjs +124 -0
  374. package/foundation/render/font-probe.d.mts +27 -0
  375. package/foundation/render/font-probe.mjs +77 -0
  376. package/foundation/render/layers.d.mts +1 -9
  377. package/foundation/render/layers.mjs +2 -111
  378. package/foundation/render/page-worker.mjs +83 -6
  379. package/foundation/render/picture-chrome.mjs +24 -2
  380. package/foundation/render/picture-playwright.mjs +22 -2
  381. package/foundation/render/picture-window.d.mts +20 -4
  382. package/foundation/render/picture-window.mjs +137 -4
  383. package/foundation/response/base.d.ts +25 -0
  384. package/foundation/response/error-codes.d.mts +4 -1
  385. package/foundation/response/error-codes.d.ts +4 -1
  386. package/foundation/response/error-codes.doc.mjs +17 -0
  387. package/foundation/response/error-codes.mjs +21 -0
  388. package/foundation/response/json.d.mts +3 -1
  389. package/foundation/response/json.mjs +7 -2
  390. package/foundation/response/response-types.doc.mjs +2 -2
  391. package/foundation/suggest/name-index.d.mts +2 -1
  392. package/foundation/suggest/name-index.mjs +1 -1
  393. package/foundation/suggest/other-command.d.mts +4 -1
  394. package/foundation/suggest/other-command.mjs +23 -6
  395. package/foundation/text/string-utils.d.mts +7 -2
  396. package/foundation/text/string-utils.mjs +24 -10
  397. package/package.json +6 -6
  398. package/assets/templates/pages/access-denied/page.tsx +0 -101
  399. package/assets/templates/pages/access-denied/template.doc.mjs +0 -24
  400. package/assets/templates/pages/error-page/page.tsx +0 -130
  401. package/assets/templates/pages/error-page/template.doc.mjs +0 -22
  402. package/assets/templates/pages/not-found/page.tsx +0 -124
  403. package/assets/templates/pages/not-found/template.doc.mjs +0 -30
  404. package/assets/templates/pages/review-workspace/page.tsx +0 -551
  405. package/assets/templates/pages/review-workspace/template.doc.mjs +0 -31
  406. package/assets/templates/pages/run-console/page.tsx +0 -945
  407. package/assets/templates/pages/run-console/template.doc.mjs +0 -27
  408. package/assets/templates/pages/welcome-portal/page.tsx +0 -538
  409. package/assets/templates/pages/welcome-portal/template.doc.mjs +0 -38
@@ -17,7 +17,24 @@ export function refuseOtherOptions(kind: keyof typeof ALLOWED, options: Record<s
17
17
  * @param {ReadonlyArray<readonly [string, string]>} pairs
18
18
  */
19
19
  export function refuseIgnoredPairs(given: Record<string, boolean>, pairs: ReadonlyArray<readonly [string, string]>): void;
20
+ /**
21
+ * Refuse an icon query that is not a string.
22
+ * @param {unknown} query
23
+ */
24
+ export function checkIconQueryType(query: unknown): void;
25
+ /**
26
+ * Refuse an empty icon search.
27
+ * @param {string} term the trimmed query
28
+ */
29
+ export function requireIconTerm(term: string): void;
30
+ /**
31
+ * Refuse a limit that is not a positive integer.
32
+ * @param {unknown} limit
33
+ */
34
+ export function checkIconLimit(limit: unknown): void;
20
35
  export function passed(value: unknown): boolean;
36
+ /** `<set>/<id>` or `<package>/<set>/<id>`: no spaces, and an id after a slash. */
37
+ export const REFERENCE_RE: RegExp;
21
38
  /** The options each call takes. */
22
39
  declare const ALLOWED: {
23
40
  'icon-set': Set<string>;
@@ -75,3 +75,57 @@ export function refuseIgnoredPairs(given, pairs) {
75
75
  /** @param {unknown} value whether an option was passed at all */
76
76
  export const passed = value =>
77
77
  value !== undefined && value !== null && value !== false && value !== '';
78
+
79
+ /** `<set>/<id>` or `<package>/<set>/<id>`: no spaces, and an id after a slash. */
80
+ export const REFERENCE_RE = /^[^\s/][^\s]*\/[a-z0-9]+(?:-[a-z0-9]+)*$/u;
81
+
82
+ /**
83
+ * Refuse an icon query that is not a string.
84
+ * @param {unknown} query
85
+ */
86
+ export function checkIconQueryType(query) {
87
+ if (query != null && typeof query !== 'string') {
88
+ throw new AstryxError(
89
+ `Invalid icon query: ${String(query)}`,
90
+ [],
91
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
92
+ );
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Refuse an empty icon search.
98
+ * @param {string} term the trimmed query
99
+ */
100
+ export function requireIconTerm(term) {
101
+ if (!term) {
102
+ throw new AstryxError(
103
+ 'An icon query is required',
104
+ [
105
+ {
106
+ name: 'astryx experimental icon delete',
107
+ reason: 'find icons by meaning',
108
+ },
109
+ {
110
+ name: 'astryx experimental icon --list',
111
+ reason: 'list the installed sets',
112
+ },
113
+ ],
114
+ ERROR_CODES.ERR_MISSING_ARGUMENT,
115
+ );
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Refuse a limit that is not a positive integer.
121
+ * @param {unknown} limit
122
+ */
123
+ export function checkIconLimit(limit) {
124
+ if (limit != null && (!Number.isInteger(limit) || Number(limit) <= 0)) {
125
+ throw new AstryxError(
126
+ `Invalid limit "${limit}". Must be a positive integer.`,
127
+ undefined,
128
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
129
+ );
130
+ }
131
+ }
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `exportIconIndex()`. Colocated with the API function it
6
+ * documents; the shape source of truth stays in `icon.type.mjs`.
7
+ * @position packages/cli/api/icon — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `exportIconIndex()`. Colocated with the API function it
5
+ * documents; the shape source of truth stays in `icon.type.mjs`.
6
+ * @position packages/cli/api/icon — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'exportIconIndex',
14
+ namespace: 'cli/api',
15
+ stability: 'experimental',
16
+ displayName: 'exportIconIndex()',
17
+ summary:
18
+ 'The icon sets icon() searches in a folder, as plain JSON to store and rank later with rankIconIndex().',
19
+ description:
20
+ "Reads the icon sets `icon()` would search in `cwd` and returns them as `{version, sets, withdrawn}`. Reading them loads each installed package's integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankIconIndex}. With `package`, the index keeps only the sets that package ships, for a catalog that stores one index per package. Paths into the folder are left out, so an index reads the same wherever it was made. The sets are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
21
+ importPath: '@astryxdesign/cli/api',
22
+ signature:
23
+ 'exportIconIndex(options?: {cwd?: string, package?: string}): Promise<IconIndex>',
24
+ keywords: ['icon index', 'stored icon index', 'icon search'],
25
+ params: [
26
+ {
27
+ name: 'options.cwd',
28
+ type: 'string',
29
+ description: 'The folder to read, as `icon()` reads it.',
30
+ default: 'process.cwd()',
31
+ },
32
+ {
33
+ name: 'options.package',
34
+ type: 'string',
35
+ description:
36
+ 'Keep only the sets this npm package ships. Without it the index holds every installed set.',
37
+ },
38
+ ],
39
+ returns: [
40
+ {
41
+ type: 'IconIndex',
42
+ description:
43
+ '`version`, the CLI version that made it; `sets`, the valid sets in tie order as plain JSON; and `withdrawn`, the sets read but withdrawn, and why.',
44
+ },
45
+ ],
46
+ throws: [
47
+ {
48
+ code: 'ERR_INVALID_ARGUMENT',
49
+ when: '`package` is given and is not a non-empty string',
50
+ },
51
+ ],
52
+ examples: [
53
+ {
54
+ label: 'Index one installed icon-set package',
55
+ code: "const index = await exportIconIndex({cwd: '/tmp/harness', package: '@acme/icons'});",
56
+ },
57
+ ],
58
+ related: ['icon', 'rankIconIndex'],
59
+ };
package/api/icon/icon.mjs CHANGED
@@ -25,14 +25,18 @@ import {iconDetail} from './detail/detail.mjs';
25
25
  import {iconList} from './list/list.mjs';
26
26
  import {iconSetIcons} from './search/search.mjs';
27
27
  import {iconDefinitions} from './definitions/definitions.mjs';
28
- import {passed, refuseIgnoredPairs} from './_options.mjs';
28
+ import {
29
+ REFERENCE_RE,
30
+ checkIconLimit,
31
+ checkIconQueryType,
32
+ passed,
33
+ refuseIgnoredPairs,
34
+ requireIconTerm,
35
+ } from './_options.mjs';
29
36
 
30
37
  /** The default `limit` for `icon.search`. */
31
38
  export const DEFAULT_ICON_LIMIT = 10;
32
39
 
33
- /** `<set>/<id>` or `<package>/<set>/<id>`: no spaces, and an id after a slash. */
34
- const REFERENCE_RE = /^[^\s/][^\s]*\/[a-z0-9]+(?:-[a-z0-9]+)*$/u;
35
-
36
40
  /**
37
41
  * Find icons by meaning, read one icon, or list the installed icon sets.
38
42
  *
@@ -81,13 +85,7 @@ export async function icon(query, options = {}) {
81
85
  ],
82
86
  );
83
87
  const limit = givenLimit ?? DEFAULT_ICON_LIMIT;
84
- if (query != null && typeof query !== 'string') {
85
- throw new AstryxError(
86
- `Invalid icon query: ${String(query)}`,
87
- [],
88
- ERROR_CODES.ERR_INVALID_ARGUMENT,
89
- );
90
- }
88
+ checkIconQueryType(query);
91
89
  const term = (query ?? '').trim();
92
90
  if (list) return iconList({cwd});
93
91
  if (definitions) return iconDefinitions({cwd, set});
@@ -106,29 +104,8 @@ export async function icon(query, options = {}) {
106
104
  }
107
105
  return iconSetIcons({cwd, set});
108
106
  }
109
- if (!term) {
110
- throw new AstryxError(
111
- 'An icon query is required',
112
- [
113
- {
114
- name: 'astryx experimental icon delete',
115
- reason: 'find icons by meaning',
116
- },
117
- {
118
- name: 'astryx experimental icon --list',
119
- reason: 'list the installed sets',
120
- },
121
- ],
122
- ERROR_CODES.ERR_MISSING_ARGUMENT,
123
- );
124
- }
125
- if (limit != null && (!Number.isInteger(limit) || limit <= 0)) {
126
- throw new AstryxError(
127
- `Invalid limit "${limit}". Must be a positive integer.`,
128
- undefined,
129
- ERROR_CODES.ERR_INVALID_ARGUMENT,
130
- );
131
- }
107
+ requireIconTerm(term);
108
+ checkIconLimit(limit);
132
109
  if (REFERENCE_RE.test(term)) return iconDetail(term, {cwd});
133
110
  return iconSearch(term, {cwd, set, limit});
134
111
  }
@@ -660,3 +660,52 @@ export type IconNewDefinitionResponse = {
660
660
  data: IconNewData;
661
661
  };
662
662
  export type IconNewResponse = IconNewSetResponse | IconNewDefinitionResponse;
663
+ /**
664
+ * One icon set as an icon index stores it: the part of a set the ranking
665
+ * reads, as plain JSON.
666
+ */
667
+ export type IconIndexSet = {
668
+ /**
669
+ * - The set's name.
670
+ */
671
+ name: string;
672
+ /**
673
+ * - The integration package that ships the set.
674
+ */
675
+ package: string;
676
+ /**
677
+ * - The set's data file.
678
+ */
679
+ data: import("../../authoring/doctypes/icon-set/type").IconSetData;
680
+ /**
681
+ * - The set's own icon definitions.
682
+ */
683
+ definitions: Array<{
684
+ doc: Record<string, unknown>;
685
+ }>;
686
+ };
687
+ /**
688
+ * The icon sets `icon` searches in a folder, as `exportIconIndex()` returns
689
+ * them: plain JSON to store and rank later with `rankIconIndex()`.
690
+ */
691
+ export type IconIndex = {
692
+ /**
693
+ * - The CLI version that made it. `rankIconIndex()`
694
+ * ranks only indexes made by its own version.
695
+ */
696
+ version: string;
697
+ /**
698
+ * - The valid sets, in tie order. Their fields
699
+ * are the ranker's input, not a contract: they may change in any release,
700
+ * which is why `version` must match.
701
+ */
702
+ sets: IconIndexSet[];
703
+ /**
704
+ * - The sets read but withdrawn, and why, so a `set` that names one gives the same error as `icon()`.
705
+ */
706
+ withdrawn: Array<{
707
+ name: string;
708
+ package: string;
709
+ reason: string;
710
+ }>;
711
+ };
@@ -390,4 +390,28 @@
390
390
  * @typedef {IconNewSetResponse | IconNewDefinitionResponse} IconNewResponse
391
391
  */
392
392
 
393
+ /**
394
+ * One icon set as an icon index stores it: the part of a set the ranking
395
+ * reads, as plain JSON.
396
+ * @experimental May change or be removed in a patch release.
397
+ * @typedef {object} IconIndexSet
398
+ * @property {string} name - The set's name.
399
+ * @property {string} package - The integration package that ships the set.
400
+ * @property {import('../../authoring/doctypes/icon-set/type').IconSetData} data - The set's data file.
401
+ * @property {Array<{doc: Record<string, unknown>}>} definitions - The set's own icon definitions.
402
+ */
403
+
404
+ /**
405
+ * The icon sets `icon` searches in a folder, as `exportIconIndex()` returns
406
+ * them: plain JSON to store and rank later with `rankIconIndex()`.
407
+ * @experimental May change or be removed in a patch release.
408
+ * @typedef {object} IconIndex
409
+ * @property {string} version - The CLI version that made it. `rankIconIndex()`
410
+ * ranks only indexes made by its own version.
411
+ * @property {IconIndexSet[]} sets - The valid sets, in tie order. Their fields
412
+ * are the ranker's input, not a contract: they may change in any release,
413
+ * which is why `version` must match.
414
+ * @property {Array<{name: string, package: string, reason: string}>} withdrawn - The sets read but withdrawn, and why, so a `set` that names one gives the same error as `icon()`.
415
+ */
416
+
393
417
  export {};
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `rankIconIndex()`. Colocated with the API function it
6
+ * documents; the shape source of truth stays in `icon.type.mjs`.
7
+ * @position packages/cli/api/icon — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,79 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `rankIconIndex()`. Colocated with the API function it
5
+ * documents; the shape source of truth stays in `icon.type.mjs`.
6
+ * @position packages/cli/api/icon — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'rankIconIndex',
14
+ namespace: 'cli/api',
15
+ stability: 'experimental',
16
+ displayName: 'rankIconIndex()',
17
+ summary:
18
+ "Ranks stored icon indexes with icon()'s own ranking: an index made in one folder answers as icon() does there.",
19
+ description:
20
+ "Ranks the sets of every index together, with the same ranking as {@link function:icon}. An index made with `exportIconIndex()` in one folder answers a word search exactly as `icon(query)` does in that folder: the same matches, order, scores, and `matchCount`. A `<set>/<id>` query, which `icon()` reads as one icon, is refused. Indexes made in separate folders are ranked as one list, in the order they are given: equal scores keep that order, as `icon()` keeps a project's set order. An index holds no project choice, so no set leads unless its index comes first. `set` keeps one set, by name or `<package>/<set>`, with the errors `icon()` gives. Every index must come from this CLI's version, because the sets' shape is the ranker's input. Experimental: it may change or be removed in a patch release.",
21
+ importPath: '@astryxdesign/cli/api',
22
+ signature:
23
+ 'rankIconIndex(query: string, indexes: IconIndex | IconIndex[], options?: {set?: string, limit?: number}): Promise<IconSearchResponse>',
24
+ keywords: ['icon index', 'stored icon index', 'icon search'],
25
+ params: [
26
+ {
27
+ name: 'query',
28
+ type: 'string',
29
+ description: 'Words to search for.',
30
+ required: true,
31
+ },
32
+ {
33
+ name: 'indexes',
34
+ type: 'IconIndex | IconIndex[]',
35
+ description: 'Indexes made by `exportIconIndex()` with this CLI version.',
36
+ required: true,
37
+ },
38
+ {
39
+ name: 'options.set',
40
+ type: 'string',
41
+ description: 'Search one set, by name or `<package>/<set>`.',
42
+ },
43
+ {
44
+ name: 'options.limit',
45
+ type: 'number',
46
+ description:
47
+ 'Max matches, a positive integer. `matchCount` counts every match.',
48
+ default: '10',
49
+ },
50
+ ],
51
+ returns: [
52
+ {
53
+ type: 'icon.search',
54
+ description:
55
+ 'The same response as `icon(query)`: the query, `matchCount`, and the ranked matches bounded by `limit`.',
56
+ },
57
+ ],
58
+ throws: [
59
+ {
60
+ code: 'ERR_MISSING_ARGUMENT',
61
+ when: 'the query is empty',
62
+ },
63
+ {
64
+ code: 'ERR_INVALID_ARGUMENT',
65
+ when: 'the query is not a string or names one icon (`<set>/<id>`), `limit` is not a positive integer, an index is not `{version, sets}`, or an index was made by another CLI version',
66
+ },
67
+ {
68
+ code: 'ERR_NOT_FOUND',
69
+ when: '`set` names no valid set in the indexes',
70
+ },
71
+ ],
72
+ examples: [
73
+ {
74
+ label: 'Rank one stored index',
75
+ code: "const r = await rankIconIndex('delete', index);",
76
+ },
77
+ ],
78
+ related: ['icon', 'exportIconIndex'],
79
+ };
@@ -0,0 +1,41 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The icon sets `icon` searches in a folder, as plain JSON: store it, and
6
+ * rank it later with {@link rankIconIndex}.
7
+ *
8
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
9
+ * release.
10
+ * @experimental
11
+ * @param {object} [options]
12
+ * @param {string} [options.cwd] - The folder to read, as `icon` reads it.
13
+ * @param {string} [options.package] - Keep only the sets this npm package ships.
14
+ * @returns {Promise<import('../icon.type.mjs').IconIndex>}
15
+ */
16
+ export function exportIconIndex(options?: {
17
+ cwd?: string | undefined;
18
+ package?: string | undefined;
19
+ }): Promise<import("../icon.type.mjs").IconIndex>;
20
+ /**
21
+ * Ranks stored icon indexes with `icon`'s own ranking. An index made in one
22
+ * folder answers a word search as `icon(query)` does there; a `<set>/<id>`
23
+ * query, which `icon()` reads as one icon, is refused. The sets of every index are
24
+ * ranked together as one list, in the order the indexes are given; equal
25
+ * scores keep that order. Every index must come from this CLI's version,
26
+ * since the ranking reads the sets' shape.
27
+ *
28
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
29
+ * release.
30
+ * @experimental
31
+ * @param {string} query - Words to search for.
32
+ * @param {import('../icon.type.mjs').IconIndex | import('../icon.type.mjs').IconIndex[]} indexes
33
+ * @param {object} [options]
34
+ * @param {string} [options.set] - Search one set, by name or `<package>/<set>`.
35
+ * @param {number} [options.limit] - Max matches (default 10).
36
+ * @returns {Promise<import('../icon.type.mjs').IconSearchResponse>}
37
+ */
38
+ export function rankIconIndex(query: string, indexes: import("../icon.type.mjs").IconIndex | import("../icon.type.mjs").IconIndex[], options?: {
39
+ set?: string | undefined;
40
+ limit?: number | undefined;
41
+ }): Promise<import("../icon.type.mjs").IconSearchResponse>;
@@ -0,0 +1,139 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A stored icon index: the icon sets `icon` searches in a folder, as
5
+ * plain JSON, and the ranking of stored sets with `icon`'s own ranking.
6
+ *
7
+ * Reading a folder's icon sets loads each integration's manifest, which runs
8
+ * the package's code. A catalog that lists packages it must not load stores
9
+ * each package's index once, where loading is safe, and ranks the stored
10
+ * indexes per query.
11
+ * @position api/icon/search; search.mjs holds the ranking both share.
12
+ */
13
+
14
+ import {cliVersion} from '../../../foundation/release/run-context.mjs';
15
+ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
16
+ import {AstryxError} from '../../error.mjs';
17
+ import {loadIconSets} from '../_adapter.mjs';
18
+ import {
19
+ REFERENCE_RE,
20
+ checkIconLimit,
21
+ checkIconQueryType,
22
+ requireIconTerm,
23
+ } from '../_options.mjs';
24
+ import {DEFAULT_ICON_LIMIT} from '../icon.mjs';
25
+ import {rankIconSets} from './search.mjs';
26
+
27
+ /**
28
+ * The part of a set the ranking reads, as plain JSON. Paths into the folder
29
+ * the set was read from are left out, so an index reads the same wherever it
30
+ * was made.
31
+ * @param {Awaited<ReturnType<typeof loadIconSets>>['sets'][number]} set
32
+ * @returns {import('../icon.type.mjs').IconIndexSet}
33
+ */
34
+ function portableSet(set) {
35
+ return JSON.parse(
36
+ JSON.stringify({
37
+ name: set.name,
38
+ package: set.package,
39
+ data: set.data,
40
+ definitions: (set.definitions ?? []).map(each => ({doc: each.doc})),
41
+ }),
42
+ );
43
+ }
44
+
45
+ /**
46
+ * The icon sets `icon` searches in a folder, as plain JSON: store it, and
47
+ * rank it later with {@link rankIconIndex}.
48
+ *
49
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
50
+ * release.
51
+ * @experimental
52
+ * @param {object} [options]
53
+ * @param {string} [options.cwd] - The folder to read, as `icon` reads it.
54
+ * @param {string} [options.package] - Keep only the sets this npm package ships.
55
+ * @returns {Promise<import('../icon.type.mjs').IconIndex>}
56
+ */
57
+ export async function exportIconIndex(options = {}) {
58
+ const {cwd = process.cwd(), package: owner} = options;
59
+ if (owner != null && (typeof owner !== 'string' || owner.trim() === '')) {
60
+ throw new AstryxError(
61
+ `Invalid package "${owner}". Pass an npm package name.`,
62
+ undefined,
63
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
64
+ );
65
+ }
66
+ const {sets, withdrawn} = await loadIconSets(cwd);
67
+ /** @param {{package: string}} each */
68
+ const kept = each => owner == null || each.package === owner;
69
+ return {
70
+ version: cliVersion(),
71
+ sets: sets.filter(kept).map(portableSet),
72
+ withdrawn: withdrawn
73
+ .filter(kept)
74
+ .map(({name, package: pkg, reason}) => ({name, package: pkg, reason})),
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Ranks stored icon indexes with `icon`'s own ranking. An index made in one
80
+ * folder answers a word search as `icon(query)` does there; a `<set>/<id>`
81
+ * query, which `icon()` reads as one icon, is refused. The sets of every index are
82
+ * ranked together as one list, in the order the indexes are given; equal
83
+ * scores keep that order. Every index must come from this CLI's version,
84
+ * since the ranking reads the sets' shape.
85
+ *
86
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
87
+ * release.
88
+ * @experimental
89
+ * @param {string} query - Words to search for.
90
+ * @param {import('../icon.type.mjs').IconIndex | import('../icon.type.mjs').IconIndex[]} indexes
91
+ * @param {object} [options]
92
+ * @param {string} [options.set] - Search one set, by name or `<package>/<set>`.
93
+ * @param {number} [options.limit] - Max matches (default 10).
94
+ * @returns {Promise<import('../icon.type.mjs').IconSearchResponse>}
95
+ */
96
+ export async function rankIconIndex(query, indexes, options = {}) {
97
+ const {set} = options;
98
+ const limit = options.limit ?? DEFAULT_ICON_LIMIT;
99
+ checkIconQueryType(query);
100
+ const term = (query ?? '').trim();
101
+ requireIconTerm(term);
102
+ checkIconLimit(limit);
103
+ if (REFERENCE_RE.test(term)) {
104
+ throw new AstryxError(
105
+ `"${term}" names one icon; rankIconIndex() ranks words. Read one icon with icon().`,
106
+ [],
107
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
108
+ );
109
+ }
110
+ const list = Array.isArray(indexes) ? indexes : [indexes];
111
+ const version = cliVersion();
112
+ /** @type {import('../icon.type.mjs').IconIndexSet[]} */
113
+ const sets = [];
114
+ /** @type {Array<{name: string, package: string, reason: string}>} */
115
+ const withdrawn = [];
116
+ for (const index of list) {
117
+ if (index == null || !Array.isArray(index.sets)) {
118
+ throw new AstryxError(
119
+ 'An icon index is {version, sets, withdrawn}, as exportIconIndex() returns it.',
120
+ undefined,
121
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
122
+ );
123
+ }
124
+ if (index.version !== version) {
125
+ throw new AstryxError(
126
+ `This icon index was made by CLI ${index.version}; this is CLI ${version}. Make it again with this version's exportIconIndex().`,
127
+ undefined,
128
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
129
+ );
130
+ }
131
+ sets.push(...index.sets);
132
+ withdrawn.push(...(index.withdrawn ?? []));
133
+ }
134
+ // A stored set holds exactly the fields the ranking reads.
135
+ const ranked = /** @type {Parameters<typeof rankIconSets>[0]} */ (
136
+ /** @type {unknown} */ (sets)
137
+ );
138
+ return rankIconSets(ranked, withdrawn, term, {set, limit});
139
+ }
@@ -22,3 +22,21 @@ export function iconSearch(query: string, { cwd, set, limit }: {
22
22
  set?: string;
23
23
  limit: number;
24
24
  }): Promise<import("../icon.type.mjs").IconSearchResponse>;
25
+ /**
26
+ * Rank the icons of `sets` against a query: the one ranking behind both
27
+ * `icon()` and `rankIconIndex()`.
28
+ * @param {Parameters<typeof rankIcons>[0]} sets in tie order
29
+ * @param {Array<{name: string, package: string, reason: string}>} withdrawn
30
+ * @param {string} query
31
+ * @param {{set?: string, limit: number}} options
32
+ * @returns {import('../icon.type.mjs').IconSearchResponse}
33
+ */
34
+ export function rankIconSets(sets: Parameters<typeof rankIcons>[0], withdrawn: Array<{
35
+ name: string;
36
+ package: string;
37
+ reason: string;
38
+ }>, query: string, { set, limit }: {
39
+ set?: string;
40
+ limit: number;
41
+ }): import("../icon.type.mjs").IconSearchResponse;
42
+ import { rankIcons } from '../_records.mjs';
@@ -58,6 +58,19 @@ export async function iconSetIcons({cwd, set}) {
58
58
  */
59
59
  export async function iconSearch(query, {cwd, set, limit}) {
60
60
  const {sets, withdrawn} = await loadIconSets(cwd);
61
+ return rankIconSets(sets, withdrawn, query, {set, limit});
62
+ }
63
+
64
+ /**
65
+ * Rank the icons of `sets` against a query: the one ranking behind both
66
+ * `icon()` and `rankIconIndex()`.
67
+ * @param {Parameters<typeof rankIcons>[0]} sets in tie order
68
+ * @param {Array<{name: string, package: string, reason: string}>} withdrawn
69
+ * @param {string} query
70
+ * @param {{set?: string, limit: number}} options
71
+ * @returns {import('../icon.type.mjs').IconSearchResponse}
72
+ */
73
+ export function rankIconSets(sets, withdrawn, query, {set, limit}) {
61
74
  let searched = sets;
62
75
  if (set != null) {
63
76
  searched = setsNamed(sets, set);
package/api/index.d.mts CHANGED
@@ -50,6 +50,7 @@ export * from "./integration/example-scope.type.mjs";
50
50
  export type Logger = import("./logger.mjs").Logger;
51
51
  export { themeBuild, themeAdd, themeRemove, themeUse, themeEject, themeTemplate, themeList, themeListAvailable, themeListCopySources, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
52
52
  export { exportSearchIndex, rankSearchIndex } from "./search/search-index.mjs";
53
+ export { exportIconIndex, rankIconIndex } from "./icon/search/icon-index.mjs";
53
54
  export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
54
55
  export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
55
56
  export { integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts } from "./integration/authoring-checks.mjs";
package/api/index.mjs CHANGED
@@ -49,6 +49,7 @@ export {
49
49
  export {hook} from './hook/hook.mjs';
50
50
  export {search} from './search/search.mjs';
51
51
  export {exportSearchIndex, rankSearchIndex} from './search/search-index.mjs';
52
+ export {exportIconIndex, rankIconIndex} from './icon/search/icon-index.mjs';
52
53
  export {build} from './build/build.mjs';
53
54
  export {swizzle} from './swizzle/swizzle.mjs';
54
55
  export {gapReport} from './gap-report/gap-report.mjs';
@@ -5,11 +5,13 @@
5
5
  /**
6
6
  * The Core a typed search reads: the project's, else the release's own,
7
7
  * installed into the per-user cache first when needed (a network install and
8
- * an npm subprocess; spec AST-081 FR3). Throws as requireCoreDir does.
8
+ * an npm subprocess; spec AST-081 FR3). Throws as requireCoreDir does. Null
9
+ * in a run whose base is not Core: such a search finds no Core component or
10
+ * hook, and still gathers its integrations' components.
9
11
  * @param {string} cwd
10
- * @returns {string}
12
+ * @returns {string | null}
11
13
  */
12
- export function requireSearchCoreDir(cwd: string): string;
14
+ export function searchCoreContentDir(cwd: string): string | null;
13
15
  /**
14
16
  * Gathers every candidate the query's domains hold. The gather runs in one
15
17
  * listing-cache operation, so its discovery helpers list each folder once, as
@@ -39,11 +41,12 @@ export function gatherCandidates(options: {
39
41
  * without Core gathers the docs and themes alone and records why in
40
42
  * `coreSkipped`; it never fails silently.
41
43
  * @param {string | undefined} type
42
- * @param {(cwd: string) => string} lookup finds the Core folder, or throws
44
+ * @param {(cwd: string) => string | null} lookup finds the Core folder (null
45
+ * when the run reads no Core), or throws
43
46
  * @param {string} cwd
44
47
  * @returns {{coreDir: string | null, coreSkipped: string | null, coreSkippedCode: string | null, wants: (domain: string) => boolean}}
45
48
  */
46
- export function resolveSearchCore(type: string | undefined, lookup: (cwd: string) => string, cwd: string): {
49
+ export function resolveSearchCore(type: string | undefined, lookup: (cwd: string) => string | null, cwd: string): {
47
50
  coreDir: string | null;
48
51
  coreSkipped: string | null;
49
52
  coreSkippedCode: string | null;