@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
@@ -22,7 +22,7 @@
22
22
  * theme editor writes (_catalog.mjs)
23
23
  */
24
24
 
25
- import {PICTURE_WINDOW} from './picture-window.mjs';
25
+ import {desktopMatches} from './picture-window.mjs';
26
26
  import {promisify} from 'node:util';
27
27
  import {chartDocument} from './charts.mjs';
28
28
 
@@ -143,116 +143,7 @@ export async function layerDocument() {
143
143
  }
144
144
  }
145
145
 
146
- /** The pointer of the window a picture is taken in. */
147
- const DESKTOP_POINTER = Object.freeze({
148
- pointer: 'fine',
149
- 'any-pointer': 'fine',
150
- hover: 'hover',
151
- 'any-hover': 'hover',
152
- });
153
-
154
- /** CSS pixels in an em or a rem, at the browser's default font size. */
155
- const EM_PX = 16;
156
-
157
- /**
158
- * A length in a media query, in CSS pixels; NaN for one it cannot read.
159
- * @param {string} text
160
- * @returns {number}
161
- */
162
- function mediaLength(text) {
163
- const m = /^\s*(-?[\d.]+)\s*(px|r?em)?\s*$/i.exec(text);
164
- if (!m) return NaN;
165
- return Number(m[1]) * (m[2] && /em/i.test(m[2]) ? EM_PX : 1);
166
- }
167
-
168
- /**
169
- * Whether one feature of a media query holds in the picture's window: its
170
- * width and height (with min- and max-, or a range), its orientation, and a
171
- * mouse for the pointer. Any other feature holds, as in the chart document
172
- * (no motion).
173
- * @param {string} feature what the parentheses hold
174
- * @returns {boolean}
175
- */
176
- function featureHolds(feature) {
177
- const {width, height} = PICTURE_WINDOW;
178
- /** @type {Record<string, number>} */
179
- const size = {width, height};
180
- const plain = /^\s*([a-z-]+)\s*(?::\s*(.*?))?\s*$/i.exec(feature);
181
- if (plain) {
182
- const [, name, value] = plain;
183
- const pointer = /** @type {Record<string, string>} */ (DESKTOP_POINTER)[
184
- name
185
- ];
186
- if (pointer != null) return value == null || value.trim() === pointer;
187
- if (name === 'orientation')
188
- return (
189
- value == null ||
190
- value.trim() === (width >= height ? 'landscape' : 'portrait')
191
- );
192
- const dim = /^(min-|max-)?(width|height)$/.exec(name);
193
- if (!dim) return true;
194
- if (value == null) return true;
195
- const at = mediaLength(value);
196
- if (Number.isNaN(at)) return true;
197
- const own = size[dim[2]];
198
- return dim[1] === 'min-'
199
- ? own >= at
200
- : dim[1] === 'max-'
201
- ? own <= at
202
- : own === at;
203
- }
204
- // A range: `width < 640px`, `640px <= width`, `400px < width <= 700px`.
205
- const parts = feature.split(/(<=|>=|<|>|=)/).map(x => x.trim());
206
- const at = parts.findIndex(x => x === 'width' || x === 'height');
207
- if (at < 0) return true;
208
- const own = size[parts[at]];
209
- /** @param {number} a @param {string} op @param {number} b */
210
- const holds = (a, op, b) =>
211
- op === '<'
212
- ? a < b
213
- : op === '<='
214
- ? a <= b
215
- : op === '>'
216
- ? a > b
217
- : op === '>='
218
- ? a >= b
219
- : a === b;
220
- let ok = true;
221
- if (at >= 2) {
222
- const v = mediaLength(parts[at - 2]);
223
- if (!Number.isNaN(v)) ok &&= holds(v, parts[at - 1], own);
224
- }
225
- if (at + 2 < parts.length) {
226
- const v = mediaLength(parts[at + 2]);
227
- if (!Number.isNaN(v)) ok &&= holds(own, parts[at + 1], v);
228
- }
229
- return ok;
230
- }
231
-
232
- /**
233
- * Whether a media query matches in the window a picture is taken in
234
- * (PICTURE_WINDOW, a desktop's, with a mouse): each comma-separated query
235
- * matches when its media type is the screen's and every feature holds
236
- * (featureHolds); `not` turns it round.
237
- * @param {string} query
238
- * @returns {boolean}
239
- */
240
- export function desktopMatches(query) {
241
- return String(query)
242
- .split(',')
243
- .some(part => {
244
- const type = /^\s*(?:not\s+|only\s+)?([a-z]+)\s*(?:and\b|$)/i.exec(
245
- part,
246
- )?.[1];
247
- const screen = type == null || !/^(print|speech)$/i.test(type);
248
- const all =
249
- screen &&
250
- [...part.matchAll(/\(([^()]*)\)/g)].every(([, feature]) =>
251
- featureHolds(feature),
252
- );
253
- return /^\s*not\s/.test(part) ? !all : all;
254
- });
255
- }
146
+ export {desktopMatches} from './picture-window.mjs';
256
147
 
257
148
  /**
258
149
  * The markup of each overlay the drawn page shows open, then of each popup
@@ -36,7 +36,7 @@ import * as fs from 'node:fs';
36
36
  import * as path from 'node:path';
37
37
  import Module, {createRequire, register} from 'node:module';
38
38
  import {pathToFileURL} from 'node:url';
39
- import {format} from 'node:util';
39
+ import {format, stripVTControlCharacters} from 'node:util';
40
40
  import {parentPort, workerData} from 'node:worker_threads';
41
41
  import {transformSync} from '@babel/core';
42
42
  import {LOAD_EXTENSIONS, existingFile, matchPath, pathsFor, resolvePath} from './ts-paths.mjs';
@@ -1123,12 +1123,75 @@ function fail(code, message, detail) {
1123
1123
  parentPort?.postMessage({ok: false, error: {code, message, detail}, logs});
1124
1124
  }
1125
1125
 
1126
+ /**
1127
+ * A compile error's text without colour codes (Babel colours its code frame
1128
+ * where a terminal or CI asks for colour), and the absolute path Babel puts
1129
+ * before the message, when it names one.
1130
+ * @param {any} err
1131
+ * @returns {{text: string, named?: string}}
1132
+ */
1133
+ function compileText(err) {
1134
+ const text = stripVTControlCharacters(String(err?.message ?? err));
1135
+ const lead = /^(.*?): /.exec(text)?.[1];
1136
+ return lead && path.isAbsolute(lead) ? {text: text.slice(lead.length + 2), named: lead} : {text};
1137
+ }
1138
+
1139
+ /**
1140
+ * Where a compile error points: the file, as a path from the project, and the
1141
+ * line its location or code frame marks (`> 3 | gap,`), with the token the
1142
+ * carets under that line mark.
1143
+ * @param {any} err
1144
+ * @returns {{file?: string, line?: number, column?: number, token?: string, source?: string}}
1145
+ */
1146
+ function compileSite(err) {
1147
+ const {text, named} = compileText(err);
1148
+ const fromRoot = named ? path.relative(root, named) : '';
1149
+ const file = named
1150
+ ? (fromRoot.startsWith('..') || path.isAbsolute(fromRoot) ? path.basename(named) : fromRoot).split(path.sep).join('/')
1151
+ : undefined;
1152
+ const frame = /^>\s*(\d+)\s*\|(.*)\n\s*\|(\s*)(\^+)/m.exec(text);
1153
+ const line = err?.loc?.line ?? (frame ? Number(frame[1]) : undefined);
1154
+ const column = err?.loc ? err.loc.column + 1 : frame ? frame[3].length : undefined;
1155
+ // An aliased import (`gap as space`) is read by its local name.
1156
+ const token = frame
1157
+ ? frame[2].slice(frame[3].length, frame[3].length + frame[4].length).split(/\s+as\s+/).pop()
1158
+ : undefined;
1159
+ return {
1160
+ ...(file ? {file} : {}),
1161
+ ...(line ? {line} : {}),
1162
+ ...(column ? {column} : {}),
1163
+ ...(token ? {token} : {}),
1164
+ ...(named ? {source: named} : {}),
1165
+ };
1166
+ }
1167
+
1168
+ /**
1169
+ * The module an import declaration names, read from the line of one of its
1170
+ * names onward (an import can span lines).
1171
+ * @param {string} file
1172
+ * @param {number} line
1173
+ * @returns {string | undefined}
1174
+ */
1175
+ function importedFrom(file, line) {
1176
+ let lines;
1177
+ try {
1178
+ lines = fs.readFileSync(file, 'utf8').split('\n').slice(line - 1, line + 40);
1179
+ } catch {
1180
+ return undefined;
1181
+ }
1182
+ for (const text of lines) {
1183
+ const from = /\bfrom\s*(['"])([^'"]+)\1/.exec(text);
1184
+ if (from) return from[2];
1185
+ }
1186
+ return undefined;
1187
+ }
1188
+
1126
1189
  /** @param {unknown} e */
1127
1190
  function classify(e) {
1128
1191
  const err = /** @type {any} */ (e);
1129
- if (err?.renderCode) return fail(err.renderCode, String(err.message).replace(/^\/[^:\n]*: /, ''));
1192
+ if (err?.renderCode) return fail(err.renderCode, compileText(err).text);
1130
1193
  // Babel prefixes errors raised while compiling with the file's path.
1131
- const message = String(err?.message ?? err).replace(/^\/[^:\n]*: /, '');
1194
+ const message = compileText(err).text;
1132
1195
  if (/suspended while responding to synchronous input|A component suspended/.test(message)) {
1133
1196
  return fail(
1134
1197
  'ERR_RENDER_FAILED',
@@ -1154,9 +1217,23 @@ function classify(e) {
1154
1217
  return fail('ERR_FILE_NOT_FOUND', `The page imports ${missing[1]}, which does not exist`, {module: missing[1]});
1155
1218
  }
1156
1219
  if (err?.code === 'BABEL_PARSE_ERROR' || err?.reasonCode || /SyntaxError|Unexpected token/.test(`${err?.name} ${message}`)) {
1157
- const loc = err?.loc ? `:${err.loc.line}:${err.loc.column + 1}` : '';
1158
- return fail('ERR_RENDER_COMPILE', `The page does not compile${loc ? ` (line ${err.loc.line})` : ''}: ${message.split('\n')[0]}`, {
1159
- ...(err?.loc ? {line: err.loc.line, column: err.loc.column + 1} : {}),
1220
+ const site = compileSite(err);
1221
+ const where = [site.file, site.line ? `line ${site.line}` : ''].filter(Boolean).join(', ');
1222
+ let reason = message.split('\n')[0];
1223
+ // StyleX reads at build time each value a style uses; an imported value
1224
+ // only from a file it can read, which it says without naming the import.
1225
+ if (reason.startsWith('Could not resolve the path to the imported file')) {
1226
+ const spec = site.source && site.line ? importedFrom(site.source, site.line) : undefined;
1227
+ const value = site.token ? `\`${site.token}\`` : 'an imported value';
1228
+ reason =
1229
+ spec && /\.stylex(?:\.[cm]?[jt]sx?)?$/.test(spec)
1230
+ ? `StyleX could not find ${spec}, which ${value} comes from, at build time. Check that the file exists, or that its package is installed where the page is.`
1231
+ : `StyleX could not read ${value}${spec ? ` from ${spec}` : ''} at build time. A value a style uses must be written in the style, or come from a .stylex.ts or .stylex.js file that defines it with stylex.defineVars or stylex.defineConsts.`;
1232
+ }
1233
+ return fail('ERR_RENDER_COMPILE', `The page does not compile${where ? ` (${where})` : ''}: ${reason}`, {
1234
+ ...(site.file ? {file: site.file} : {}),
1235
+ ...(site.line ? {line: site.line} : {}),
1236
+ ...(site.column ? {column: site.column} : {}),
1160
1237
  });
1161
1238
  }
1162
1239
  const browser = /\b(window|document|localStorage|sessionStorage|navigator|location|matchMedia|requestAnimationFrame|IntersectionObserver|ResizeObserver|HTMLElement|customElements) is not defined/.exec(message);
@@ -6,8 +6,10 @@
6
6
  * editor's browser runner.
7
7
  * @input argv: the browser, the page (.html), the picture (.png), the color
8
8
  * mode
9
- * @output the whole page, every pixel of its height, at the path given; on
10
- * failure, the browser's reason on stderr and exit code 1
9
+ * @output the whole page, every pixel of its height, at the path given, and
10
+ * on stdout the fonts it drew its text in (font-probe.mjs) and the text
11
+ * it draws cut short (cut-short.mjs); on failure, the browser's reason
12
+ * on stderr and exit code 1
11
13
  * @position run by `screenshot` in api/theme-edit/_preview.mjs through
12
14
  * `runBrowser`, which gives it a temp folder of its own (the browser's
13
15
  * profile goes there), its time bound and its stop
@@ -18,8 +20,10 @@ import * as fs from 'node:fs';
18
20
  import * as os from 'node:os';
19
21
  import * as path from 'node:path';
20
22
  import {pathToFileURL} from 'node:url';
23
+ import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
21
24
  import {NETWORK_URL_PATTERNS, QUIET_BROWSER_ARGS} from './offline.mjs';
22
25
  import {PICTURE_WINDOW} from './picture-window.mjs';
26
+ import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
23
27
 
24
28
  const [chrome, html, png, mode] = process.argv.slice(2);
25
29
 
@@ -197,6 +201,24 @@ try {
197
201
  sessionId,
198
202
  );
199
203
  fs.writeFileSync(png, Buffer.from(data, 'base64'));
204
+ // The fonts the picture drew its text in, for the editor's note.
205
+ const fonts = await probeFonts((method, params) =>
206
+ send(method, params, sessionId),
207
+ ).catch(() => null);
208
+ if (fonts)
209
+ process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
210
+ // The text the picture draws cut short, measured on the page as the
211
+ // picture shows it. A measurement that does not run says nothing, and
212
+ // the picture stands.
213
+ const measured = await send(
214
+ 'Runtime.evaluate',
215
+ {expression: `(${cutShortText})()`, returnByValue: true},
216
+ sessionId,
217
+ ).catch(() => null);
218
+ if (Array.isArray(measured?.result?.value) && !measured.exceptionDetails)
219
+ process.stdout.write(
220
+ `${CUT_SHORT_PREFIX}${JSON.stringify(measured.result.value)}\n`,
221
+ );
200
222
  await send('Browser.close').catch(() => {});
201
223
  } catch (e) {
202
224
  process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
@@ -5,15 +5,19 @@
5
5
  * own process by the editor's browser runner.
6
6
  * @input argv: the Playwright entry file, the page (.html), the picture
7
7
  * (.png), the color mode, and a browser to use instead of Playwright's own
8
- * @output the picture at the path given; on failure, Playwright's error on
9
- * stderr and exit code 1
8
+ * @output the picture at the path given, and on stdout the fonts it drew
9
+ * its text in (font-probe.mjs) and the text it draws cut short
10
+ * (cut-short.mjs); on failure, Playwright's error on stderr and exit
11
+ * code 1
10
12
  * @position run by `screenshot` in api/theme-edit/_preview.mjs through
11
13
  * `runBrowser`, which gives it a temp folder of its own, its time bound and its stop
12
14
  */
13
15
 
14
16
  import {pathToFileURL} from 'node:url';
17
+ import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
15
18
  import {LOCAL_URL, QUIET_BROWSER_ARGS} from './offline.mjs';
16
19
  import {PICTURE_WINDOW} from './picture-window.mjs';
20
+ import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
17
21
 
18
22
  const [entry, html, png, mode, executablePath] = process.argv.slice(2);
19
23
  try {
@@ -41,6 +45,22 @@ try {
41
45
  // page loads: the picture is taken with each animation that ends run
42
46
  // to its end, so it shows the overlay as it looks open.
43
47
  await page.screenshot({path: png, fullPage: true, animations: 'disabled'});
48
+ // The fonts the picture drew its text in, for the editor's note.
49
+ const fonts = await (async () => {
50
+ const cdp = await page.context().newCDPSession(page);
51
+ return probeFonts((method, params) => cdp.send(method, params));
52
+ })().catch(() => null);
53
+ if (fonts)
54
+ process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
55
+ // The text the picture draws cut short, measured on the page as the
56
+ // picture shows it. A page that runs no script measures nothing, and
57
+ // the picture stands: nothing is said.
58
+ try {
59
+ const cut = await page.evaluate(cutShortText);
60
+ process.stdout.write(`${CUT_SHORT_PREFIX}${JSON.stringify(cut)}\n`);
61
+ } catch {
62
+ // Not measured.
63
+ }
44
64
  } finally {
45
65
  await browser.close();
46
66
  }
@@ -1,14 +1,30 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * Whether a media query matches in the window a picture is taken in
6
+ * (PICTURE_WINDOW, a desktop's, with a mouse): each comma-separated query
7
+ * matches when its media type is the screen's and every feature holds
8
+ * (featureHolds); `not` turns it round. A feature the window does not judge
9
+ * holds, as in the chart document (no motion); with `sure`, a query that
10
+ * holds one never matches, so only what the window answers counts.
11
+ * @param {string} query
12
+ * @param {{sure?: boolean}} [options]
13
+ * @returns {boolean}
14
+ */
15
+ export function desktopMatches(query: string, { sure }?: {
16
+ sure?: boolean;
17
+ }): boolean;
4
18
  /**
5
19
  * @file The window the editor's pictures are taken in.
6
20
  * @input None.
7
- * @output `PICTURE_WINDOW`: its width and height in CSS pixels.
21
+ * @output `PICTURE_WINDOW`: its width and height in CSS pixels;
22
+ * `desktopMatches(query)`: whether a media query matches there.
8
23
  * @position Read by the picture scripts (picture-chrome.mjs,
9
- * picture-playwright.mjs), which open the browser at this size, and by the
10
- * layer drawing (layers.mjs), which answers media queries for it, so a
11
- * part drawn open lays out as the picture shows it.
24
+ * picture-playwright.mjs), which open the browser at this size, by the
25
+ * layer drawing (layers.mjs), which answers media queries for it, and by
26
+ * the stylesheet cut (css-cut.mjs), so a part drawn open or in a state
27
+ * lays out as the picture shows it.
12
28
  */
13
29
  export const PICTURE_WINDOW: Readonly<{
14
30
  width: 1280;
@@ -3,11 +3,144 @@
3
3
  /**
4
4
  * @file The window the editor's pictures are taken in.
5
5
  * @input None.
6
- * @output `PICTURE_WINDOW`: its width and height in CSS pixels.
6
+ * @output `PICTURE_WINDOW`: its width and height in CSS pixels;
7
+ * `desktopMatches(query)`: whether a media query matches there.
7
8
  * @position Read by the picture scripts (picture-chrome.mjs,
8
- * picture-playwright.mjs), which open the browser at this size, and by the
9
- * layer drawing (layers.mjs), which answers media queries for it, so a
10
- * part drawn open lays out as the picture shows it.
9
+ * picture-playwright.mjs), which open the browser at this size, by the
10
+ * layer drawing (layers.mjs), which answers media queries for it, and by
11
+ * the stylesheet cut (css-cut.mjs), so a part drawn open or in a state
12
+ * lays out as the picture shows it.
11
13
  */
12
14
 
13
15
  export const PICTURE_WINDOW = Object.freeze({width: 1280, height: 900});
16
+
17
+ /** The pointer of the window a picture is taken in. */
18
+ const DESKTOP_POINTER = Object.freeze({
19
+ pointer: 'fine',
20
+ 'any-pointer': 'fine',
21
+ hover: 'hover',
22
+ 'any-hover': 'hover',
23
+ });
24
+
25
+ /** CSS pixels in an em or a rem, at the browser's default font size. */
26
+ const EM_PX = 16;
27
+
28
+ /**
29
+ * A length in a media query, in CSS pixels; NaN for one it cannot read.
30
+ * @param {string} text
31
+ * @returns {number}
32
+ */
33
+ function mediaLength(text) {
34
+ const m = /^\s*(-?[\d.]+)\s*(px|r?em)?\s*$/i.exec(text);
35
+ if (!m) return NaN;
36
+ return Number(m[1]) * (m[2] && /em/i.test(m[2]) ? EM_PX : 1);
37
+ }
38
+
39
+ /**
40
+ * How the picture's window answers the features a display mode sets: no
41
+ * forced colors (a high-contrast mode), no contrast preference, colors not
42
+ * inverted, a color screen. Each is the feature's off value, so a bare
43
+ * `(name)` never holds in the window.
44
+ */
45
+ const DESKTOP_DISPLAY = Object.freeze({
46
+ 'forced-colors': 'none',
47
+ 'prefers-contrast': 'no-preference',
48
+ 'inverted-colors': 'none',
49
+ monochrome: '0',
50
+ });
51
+
52
+ /**
53
+ * Whether one feature of a media query holds in the picture's window: its
54
+ * width and height (with min- and max-, or a range), its orientation, a
55
+ * mouse for the pointer, and its display (DESKTOP_DISPLAY). Null for a
56
+ * feature the window does not judge (motion, the color scheme).
57
+ * @param {string} feature what the parentheses hold
58
+ * @returns {boolean | null}
59
+ */
60
+ function featureHolds(feature) {
61
+ const {width, height} = PICTURE_WINDOW;
62
+ /** @type {Record<string, number>} */
63
+ const size = {width, height};
64
+ const plain = /^\s*([a-z-]+)\s*(?::\s*(.*?))?\s*$/i.exec(feature);
65
+ if (plain) {
66
+ const [, name, value] = plain;
67
+ const pointer = /** @type {Record<string, string>} */ (DESKTOP_POINTER)[
68
+ name
69
+ ];
70
+ if (pointer != null) return value == null || value.trim() === pointer;
71
+ const display = /** @type {Record<string, string>} */ (DESKTOP_DISPLAY)[
72
+ name
73
+ ];
74
+ if (display != null) return value != null && value.trim() === display;
75
+ if (name === 'orientation')
76
+ return (
77
+ value == null ||
78
+ value.trim() === (width >= height ? 'landscape' : 'portrait')
79
+ );
80
+ const dim = /^(min-|max-)?(width|height)$/.exec(name);
81
+ if (!dim) return null;
82
+ if (value == null) return true;
83
+ const at = mediaLength(value);
84
+ if (Number.isNaN(at)) return null;
85
+ const own = size[dim[2]];
86
+ return dim[1] === 'min-'
87
+ ? own >= at
88
+ : dim[1] === 'max-'
89
+ ? own <= at
90
+ : own === at;
91
+ }
92
+ // A range: `width < 640px`, `640px <= width`, `400px < width <= 700px`.
93
+ const parts = feature.split(/(<=|>=|<|>|=)/).map(x => x.trim());
94
+ const at = parts.findIndex(x => x === 'width' || x === 'height');
95
+ if (at < 0) return null;
96
+ const own = size[parts[at]];
97
+ /** @param {number} a @param {string} op @param {number} b */
98
+ const holds = (a, op, b) =>
99
+ op === '<'
100
+ ? a < b
101
+ : op === '<='
102
+ ? a <= b
103
+ : op === '>'
104
+ ? a > b
105
+ : op === '>='
106
+ ? a >= b
107
+ : a === b;
108
+ let ok = true;
109
+ if (at >= 2) {
110
+ const v = mediaLength(parts[at - 2]);
111
+ if (!Number.isNaN(v)) ok &&= holds(v, parts[at - 1], own);
112
+ }
113
+ if (at + 2 < parts.length) {
114
+ const v = mediaLength(parts[at + 2]);
115
+ if (!Number.isNaN(v)) ok &&= holds(own, parts[at + 1], v);
116
+ }
117
+ return ok;
118
+ }
119
+
120
+ /**
121
+ * Whether a media query matches in the window a picture is taken in
122
+ * (PICTURE_WINDOW, a desktop's, with a mouse): each comma-separated query
123
+ * matches when its media type is the screen's and every feature holds
124
+ * (featureHolds); `not` turns it round. A feature the window does not judge
125
+ * holds, as in the chart document (no motion); with `sure`, a query that
126
+ * holds one never matches, so only what the window answers counts.
127
+ * @param {string} query
128
+ * @param {{sure?: boolean}} [options]
129
+ * @returns {boolean}
130
+ */
131
+ export function desktopMatches(query, {sure = false} = {}) {
132
+ return String(query)
133
+ .split(',')
134
+ .some(part => {
135
+ const type = /^\s*(?:not\s+|only\s+)?([a-z]+)\s*(?:and\b|$)/i.exec(
136
+ part,
137
+ )?.[1];
138
+ const screen = type == null || !/^(print|speech)$/i.test(type);
139
+ const answers = [...part.matchAll(/\(([^()]*)\)/g)].map(([, feature]) =>
140
+ featureHolds(feature),
141
+ );
142
+ if (sure && answers.includes(null)) return false;
143
+ const all = screen && answers.every(a => a !== false);
144
+ return /^\s*not\s/.test(part) ? !all : all;
145
+ });
146
+ }
@@ -41,6 +41,29 @@ export interface CLIError {
41
41
  * error: branch on `code`.
42
42
  */
43
43
  receipt?: Record<string, unknown>;
44
+ /**
45
+ * What a refused run needs, present only on `ERR_BASE_CAPABILITY`: the
46
+ * command, the option or argument value that declared the step, the steps
47
+ * it requires and the ones the run's base does not serve, why, and the base.
48
+ */
49
+ requirement?: BaseRequirement;
50
+ }
51
+
52
+ /** The `requirement` member of an `ERR_BASE_CAPABILITY` error. */
53
+ export interface BaseRequirement {
54
+ /** The command as a user types it after `astryx`, e.g. `theme build`. */
55
+ command: string;
56
+ /** The option's long flag, when an option declared the step. */
57
+ option: string | null;
58
+ /** The argument and value, when an argument value declared the step. */
59
+ argument: {name: string; value: string} | null;
60
+ requires: string[];
61
+ missing: string[];
62
+ /** `not-declared`: no declared adapter exports the step. `failed-to-load`:
63
+ * the declared adapter module does not load; `module` names it. */
64
+ reason: 'not-declared' | 'failed-to-load';
65
+ module?: string;
66
+ base: {name: string; version: string | null};
44
67
  }
45
68
 
46
69
  /** Returned by the fallback hook for commands without --json support. */
@@ -84,6 +107,8 @@ export interface AnsweredBy {
84
107
  /** The Core the run pairs with, or `null` when there is none. */
85
108
  core: string | null;
86
109
  copy: 'project' | 'starting' | 'matched' | 'carried' | 'fallback';
110
+ /** The run's base, present only when it is not Core; `core` is then `null`. */
111
+ base?: {name: string; version: string | null};
87
112
  }
88
113
 
89
114
  export interface CLIResponse {
@@ -103,6 +103,9 @@ export function allErrorCodes(): string[];
103
103
  * | 'ERR_SIGNAL_TERMINATED'
104
104
  * | 'ERR_VERSIONS_UNAVAILABLE'
105
105
  * | 'ERR_PROJECT_REQUIRED'
106
+ * | 'ERR_BASE_CAPABILITY'
107
+ * | 'ERR_BASE_NOT_FOUND'
108
+ * | 'ERR_BASE_AMBIGUOUS'
106
109
  * | 'ERR_RENDER_COMPILE'
107
110
  * | 'ERR_RENDER_NO_DEFAULT_EXPORT'
108
111
  * | 'ERR_RENDER_MISSING_DEPENDENCY'
@@ -136,4 +139,4 @@ export const ERROR_CODES: Readonly<Record<ErrorCode, ErrorCode>>;
136
139
  /**
137
140
  * Stable error-code string union. Append-only.
138
141
  */
139
- export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_READ_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_THEME_STALE" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_RENDER_NEWER_FORMAT" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_NOT_CHECKED" | "ERR_THEME_BUSY" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
142
+ export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_READ_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_THEME_STALE" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_BASE_CAPABILITY" | "ERR_BASE_NOT_FOUND" | "ERR_BASE_AMBIGUOUS" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_RENDER_NEWER_FORMAT" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_NOT_CHECKED" | "ERR_THEME_BUSY" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
@@ -54,7 +54,10 @@ export type ErrorCode =
54
54
  | 'ERR_DEP_MISSING'
55
55
  | 'ERR_GH_CLI'
56
56
  | 'ERR_LAYOUT_PARSE'
57
- | 'ERR_LAYOUT_INVALID';
57
+ | 'ERR_LAYOUT_INVALID'
58
+ | 'ERR_BASE_CAPABILITY'
59
+ | 'ERR_BASE_NOT_FOUND'
60
+ | 'ERR_BASE_AMBIGUOUS';
58
61
 
59
62
  /** The frozen runtime map of all error codes (keys === values). */
60
63
  export declare const ERROR_CODES: Readonly<Record<ErrorCode, ErrorCode>>;
@@ -301,6 +301,23 @@ export const doc = {
301
301
  'The command needs a project (an app with Astryx installed, or an integration package) and was run outside one. Nothing was written.',
302
302
  },
303
303
 
304
+ // Bases
305
+ {
306
+ value: 'ERR_BASE_CAPABILITY',
307
+ description:
308
+ "The command, or an option or argument value given to it, needs a step the run's base does not serve. Nothing was written. The envelope's `requirement` names the command, the steps, and the base.",
309
+ },
310
+ {
311
+ value: 'ERR_BASE_NOT_FOUND',
312
+ description:
313
+ '`--base` names a package that is not installed where the run can read it, or that is not Core and does not declare `base`. Nothing was done.',
314
+ },
315
+ {
316
+ value: 'ERR_BASE_AMBIGUOUS',
317
+ description:
318
+ 'The project installs two or more bases and no Core, and the run named none with `--base`. Nothing was done.',
319
+ },
320
+
304
321
  // Render (experimental: may change or be removed in a patch release)
305
322
  {
306
323
  value: 'ERR_RENDER_COMPILE',
@@ -92,6 +92,9 @@
92
92
  * | 'ERR_SIGNAL_TERMINATED'
93
93
  * | 'ERR_VERSIONS_UNAVAILABLE'
94
94
  * | 'ERR_PROJECT_REQUIRED'
95
+ * | 'ERR_BASE_CAPABILITY'
96
+ * | 'ERR_BASE_NOT_FOUND'
97
+ * | 'ERR_BASE_AMBIGUOUS'
95
98
  * | 'ERR_RENDER_COMPILE'
96
99
  * | 'ERR_RENDER_NO_DEFAULT_EXPORT'
97
100
  * | 'ERR_RENDER_MISSING_DEPENDENCY'
@@ -283,6 +286,24 @@ export const ERROR_CODES = Object.freeze({
283
286
  */
284
287
  ERR_PROJECT_REQUIRED: 'ERR_PROJECT_REQUIRED',
285
288
 
289
+ // ── Bases ────────────────────────────────────────────────────────
290
+ /**
291
+ * The command, or an option or argument value given to it, needs a step
292
+ * the run's base does not serve. Nothing was written. The envelope's
293
+ * `requirement` names the command, the steps, and the base.
294
+ */
295
+ ERR_BASE_CAPABILITY: 'ERR_BASE_CAPABILITY',
296
+ /**
297
+ * `--base` names a package that is not installed where the run can read
298
+ * it, or that is not Core and does not declare `base`. Nothing was done.
299
+ */
300
+ ERR_BASE_NOT_FOUND: 'ERR_BASE_NOT_FOUND',
301
+ /**
302
+ * The project installs two or more bases and no Core, and the run named
303
+ * none with `--base`. Nothing was done.
304
+ */
305
+ ERR_BASE_AMBIGUOUS: 'ERR_BASE_AMBIGUOUS',
306
+
286
307
  // ── Render (experimental) ────────────────────────────────────────
287
308
  /**
288
309
  * The page given to `astryx experimental render` does not compile (a syntax