@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0404a74

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 (529) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +17 -0
  3. package/api/build/_adapter.mjs +53 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/blocks/blocks.weights.json +1 -1
  7. package/api/build/build.doc.mjs +4 -3
  8. package/api/build/build.type.d.mts +2 -2
  9. package/api/build/build.type.mjs +3 -3
  10. package/api/build/kit/kind.d.mts +2 -1
  11. package/api/build/kit/kind.mjs +199 -10
  12. package/api/build/kit/kit.mjs +6 -4
  13. package/api/build/kit/rank.d.mts +6 -4
  14. package/api/build/kit/rank.mjs +132 -28
  15. package/api/build/kit/signals.d.mts +7 -1
  16. package/api/build/kit/signals.mjs +21 -10
  17. package/api/build/kit/start.d.mts +5 -4
  18. package/api/build/kit/start.mjs +14 -9
  19. package/api/build/kit/weights.d.mts +39 -3
  20. package/api/build/kit/weights.json +1 -1
  21. package/api/build/kit/weights.mjs +351 -46
  22. package/api/build/kit/word-model.d.mts +23 -0
  23. package/api/build/kit/word-model.mjs +46 -0
  24. package/api/build/kit/words.d.mts +86 -0
  25. package/api/build/kit/words.mjs +241 -1
  26. package/api/build/tree.mjs +1 -1
  27. package/api/component/__fixtures__/resolutions/modules.txt +5 -6
  28. package/api/component/_adapter.d.mts +26 -2
  29. package/api/component/_adapter.mjs +135 -8
  30. package/api/component/component.mjs +14 -1
  31. package/api/component/list/list.d.mts +1 -1
  32. package/api/component/list/list.mjs +48 -6
  33. package/api/discover/_adapter.d.mts +11 -1
  34. package/api/discover/_adapter.mjs +95 -1
  35. package/api/discover/detail/item/item.mjs +5 -0
  36. package/api/discover/discover.mjs +12 -3
  37. package/api/discover/discover.type.d.mts +16 -3
  38. package/api/discover/discover.type.mjs +13 -3
  39. package/api/discover/search/search.mjs +3 -2
  40. package/api/docs/_adapter.d.mts +57 -2
  41. package/api/docs/_adapter.mjs +266 -33
  42. package/api/docs/_entry-names-lazily.d.mts +22 -0
  43. package/api/docs/_entry-names-lazily.mjs +25 -0
  44. package/api/docs/_entry-names.d.mts +23 -0
  45. package/api/docs/_entry-names.mjs +105 -0
  46. package/api/docs/docs.d.mts +3 -0
  47. package/api/docs/docs.doc.mjs +7 -1
  48. package/api/docs/docs.mjs +12 -0
  49. package/api/docs/docs.type.d.mts +5 -0
  50. package/api/docs/docs.type.mjs +2 -0
  51. package/api/docs/node/node.mjs +1 -1
  52. package/api/doctor/_adapter.d.mts +54 -5
  53. package/api/doctor/_adapter.mjs +162 -11
  54. package/api/doctor/built-checks.mjs +40 -14
  55. package/api/doctor/doctor.d.mts +15 -3
  56. package/api/doctor/doctor.doc.mjs +1 -1
  57. package/api/doctor/doctor.mjs +31 -7
  58. package/api/doctor/theme-checks.d.mts +35 -3
  59. package/api/doctor/theme-checks.mjs +377 -29
  60. package/api/hook/_adapter.d.mts +10 -4
  61. package/api/hook/_adapter.mjs +41 -5
  62. package/api/hook/detail/detail.mjs +5 -2
  63. package/api/hook/detail/params/params.mjs +10 -3
  64. package/api/icon/_records.mjs +2 -1
  65. package/api/index.d.mts +2 -0
  66. package/api/index.mjs +2 -0
  67. package/api/integration/_adapter.d.mts +44 -0
  68. package/api/integration/_adapter.mjs +77 -1
  69. package/api/integration/add-helpers.mjs +10 -0
  70. package/api/integration/authoring-checks.mjs +11 -8
  71. package/api/integration/example-scope.d.mts +14 -0
  72. package/api/integration/example-scope.mjs +44 -0
  73. package/api/integration/example-scope.type.d.mts +29 -0
  74. package/api/integration/example-scope.type.mjs +25 -0
  75. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  76. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  77. package/api/integration/pack-check.mjs +16 -1
  78. package/api/integration/validate-integration.d.mts +18 -6
  79. package/api/integration/validate-integration.mjs +129 -15
  80. package/api/integration/validate-integration.type.d.mts +22 -0
  81. package/api/integration/validate-integration.type.mjs +2 -1
  82. package/api/integration/validateIntegration.doc.mjs +1 -1
  83. package/api/render/_adapter.mjs +591 -195
  84. package/api/render/render.doc.mjs +11 -3
  85. package/api/render/render.type.d.mts +53 -1
  86. package/api/render/render.type.mjs +32 -2
  87. package/api/search/ORDERING.md +2 -2
  88. package/api/search/_adapter.d.mts +9 -0
  89. package/api/search/_adapter.mjs +85 -0
  90. package/api/search/_candidate-score.d.mts +9 -4
  91. package/api/search/_candidate-score.mjs +133 -46
  92. package/api/search/_fit-order.mjs +3 -3
  93. package/api/search/_gather-components.d.mts +3 -2
  94. package/api/search/_gather-components.mjs +12 -3
  95. package/api/search/_lexical.d.mts +14 -0
  96. package/api/search/_lexical.mjs +93 -11
  97. package/api/search/_result.d.mts +11 -9
  98. package/api/search/_result.mjs +4 -4
  99. package/api/search/_score.d.mts +6 -1
  100. package/api/search/_score.mjs +15 -3
  101. package/api/search/search-index.mjs +7 -1
  102. package/api/search/search.d.mts +1 -1
  103. package/api/template/_adapter.d.mts +16 -0
  104. package/api/template/_adapter.mjs +39 -2
  105. package/api/template/cdn/cdn.mjs +37 -8
  106. package/api/template/copy/copy.d.mts +6 -3
  107. package/api/template/copy/copy.mjs +40 -8
  108. package/api/template/template.doc.mjs +3 -3
  109. package/api/template/template.mjs +63 -11
  110. package/api/template/template.type.d.mts +1 -0
  111. package/api/template/template.type.mjs +1 -0
  112. package/api/theme/_adapter.d.mts +12 -1
  113. package/api/theme/_adapter.mjs +132 -13
  114. package/api/theme/_app-provider.d.mts +31 -0
  115. package/api/theme/_app-provider.mjs +135 -0
  116. package/api/theme/add/add.mjs +3 -1
  117. package/api/theme/build/build.d.mts +142 -1
  118. package/api/theme/build/build.mjs +692 -284
  119. package/api/theme/build/core-interception.d.mts +10 -0
  120. package/api/theme/build/core-interception.mjs +10 -0
  121. package/api/theme/build/font-warning.d.mts +80 -5
  122. package/api/theme/build/font-warning.mjs +323 -55
  123. package/api/theme/build/icon-imports.mjs +51 -9
  124. package/api/theme/build/null-values.d.mts +28 -0
  125. package/api/theme/build/null-values.mjs +191 -0
  126. package/api/theme/list/list.mjs +17 -1
  127. package/api/theme/remove/remove.d.mts +2 -1
  128. package/api/theme/remove/remove.mjs +7 -3
  129. package/api/theme/theme.type.d.mts +78 -1
  130. package/api/theme/theme.type.mjs +38 -2
  131. package/api/theme/themeAdd.doc.mjs +1 -1
  132. package/api/theme/themeListAvailable.doc.mjs +1 -1
  133. package/api/theme/themeRemove.doc.mjs +8 -5
  134. package/api/theme-edit/_adapter.d.mts +116 -4
  135. package/api/theme-edit/_adapter.mjs +1058 -93
  136. package/api/theme-edit/_catalog.d.mts +46 -2
  137. package/api/theme-edit/_catalog.mjs +115 -14
  138. package/api/theme-edit/_check.d.mts +133 -24
  139. package/api/theme-edit/_check.mjs +3392 -531
  140. package/api/theme-edit/_color.d.mts +26 -0
  141. package/api/theme-edit/_color.mjs +92 -2
  142. package/api/theme-edit/_compiler.d.mts +5 -1
  143. package/api/theme-edit/_compiler.mjs +141 -17
  144. package/api/theme-edit/_context.d.mts +74 -6
  145. package/api/theme-edit/_context.mjs +468 -76
  146. package/api/theme-edit/_css.d.mts +21 -0
  147. package/api/theme-edit/_css.mjs +87 -14
  148. package/api/theme-edit/_edit.d.mts +74 -7
  149. package/api/theme-edit/_edit.mjs +4426 -319
  150. package/api/theme-edit/_how-commands.d.mts +76 -1
  151. package/api/theme-edit/_how-commands.mjs +793 -9
  152. package/api/theme-edit/_how-question.d.mts +97 -6
  153. package/api/theme-edit/_how-question.mjs +9184 -747
  154. package/api/theme-edit/_how.d.mts +5 -2
  155. package/api/theme-edit/_how.mjs +255 -46
  156. package/api/theme-edit/_importers.d.mts +38 -0
  157. package/api/theme-edit/_importers.mjs +188 -0
  158. package/api/theme-edit/_marks.d.mts +31 -5
  159. package/api/theme-edit/_marks.mjs +57 -5
  160. package/api/theme-edit/_name-rule.d.mts +11 -0
  161. package/api/theme-edit/_name-rule.mjs +12 -0
  162. package/api/theme-edit/_normal.d.mts +322 -0
  163. package/api/theme-edit/_normal.mjs +1630 -0
  164. package/api/theme-edit/_palette.d.mts +49 -0
  165. package/api/theme-edit/_palette.mjs +180 -38
  166. package/api/theme-edit/_part-words.d.mts +39 -0
  167. package/api/theme-edit/_part-words.mjs +152 -0
  168. package/api/theme-edit/_parts.d.mts +55 -3
  169. package/api/theme-edit/_parts.mjs +421 -36
  170. package/api/theme-edit/_preview-app.d.mts +7 -13
  171. package/api/theme-edit/_preview-app.mjs +1108 -599
  172. package/api/theme-edit/_preview.d.mts +156 -19
  173. package/api/theme-edit/_preview.mjs +809 -180
  174. package/api/theme-edit/_project.d.mts +61 -1
  175. package/api/theme-edit/_project.mjs +177 -6
  176. package/api/theme-edit/_settings.d.mts +619 -48
  177. package/api/theme-edit/_settings.mjs +4910 -617
  178. package/api/theme-edit/_tables.d.mts +41 -0
  179. package/api/theme-edit/_tables.mjs +261 -41
  180. package/api/theme-edit/_vet.d.mts +31 -0
  181. package/api/theme-edit/_vet.mjs +114 -8
  182. package/api/theme-edit/theme-edit.type.d.mts +34 -2
  183. package/api/theme-edit/theme-edit.type.mjs +18 -3
  184. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  185. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  186. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  187. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  188. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  189. package/api/upgrade/run/run.mjs +4 -3
  190. package/api/upgrade/upgrade.mjs +16 -1
  191. package/assets/codemods/integration-discovery.mjs +2 -1
  192. package/assets/codemods/integration-runner.mjs +1 -1
  193. package/assets/codemods/jscodeshift.d.ts +1 -1
  194. package/assets/codemods/run-codemod.mjs +151 -18
  195. package/assets/codemods/runner.mjs +1 -4
  196. package/assets/codemods/transforms/next/index.mjs +11 -1
  197. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  198. package/assets/component-list.generated.json +1 -0
  199. package/assets/docs/author-a-theme.doc.mjs +2 -0
  200. package/assets/docs/theme.doc.dense.mjs +76 -7
  201. package/assets/docs/theme.doc.mjs +66 -2
  202. package/assets/docs/theme.doc.zh.mjs +51 -1
  203. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  204. package/assets/docs/tree/checks.doc.mjs +2 -2
  205. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  206. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  207. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  208. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  209. package/assets/docs/tree/render-pages.doc.mjs +46 -5
  210. package/assets/docs/tree/share-a-page.doc.mjs +157 -0
  211. package/assets/docs/tree/single-component.doc.mjs +4 -0
  212. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  213. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  214. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  215. package/assets/docs/use-a-theme.doc.mjs +2 -2
  216. package/assets/docs-routes.generated.json +1 -0
  217. package/assets/docs.generated.json +2 -2
  218. package/assets/search-catalog.generated.json +2 -0
  219. package/assets/self-audit.generated.json +1 -1
  220. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  221. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  222. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
  223. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
  224. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  225. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  226. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  227. package/assets/templates/components.generated.json +1 -1
  228. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  229. package/assets/templates/pages/ai-chat-landing/page.tsx +31 -4
  230. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
  231. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  232. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  233. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  234. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  235. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  236. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  237. package/assets/templates/pages/dashboard-alert-rail/page.tsx +1 -1
  238. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  239. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +1 -1
  240. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  241. package/assets/templates/pages/dashboard-comparison/page.tsx +2 -2
  242. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  243. package/assets/templates/pages/dashboard-progress/page.tsx +1 -1
  244. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  245. package/assets/templates/pages/detail-page/page.tsx +60 -7
  246. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  247. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  248. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  249. package/assets/templates/pages/documentation-technical/page.tsx +13 -13
  250. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  251. package/assets/templates/pages/editor/page.tsx +14 -2
  252. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  253. package/assets/templates/pages/file-explorer/page.tsx +9 -0
  254. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  255. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  256. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  257. package/assets/templates/pages/form-wizard-vertical/page.tsx +23 -3
  258. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  259. package/assets/templates/pages/ide/page.tsx +33 -2
  260. package/assets/templates/pages/kanban-board/page.tsx +12 -2
  261. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  262. package/assets/templates/pages/library/template.doc.mjs +4 -1
  263. package/assets/templates/pages/login/template.doc.mjs +2 -1
  264. package/assets/templates/pages/login-card/page.tsx +16 -0
  265. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  266. package/assets/templates/pages/login-split/page.tsx +19 -6
  267. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  268. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  269. package/assets/templates/pages/messaging-shell/template.doc.mjs +6 -0
  270. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  271. package/assets/templates/pages/payment-form/page.tsx +30 -4
  272. package/assets/templates/pages/product-detail/page.tsx +26 -2
  273. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  274. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  275. package/assets/templates/pages/settings-dialog/page.tsx +162 -12
  276. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  277. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  278. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  279. package/assets/templates/pages/shell-side-nav/page.tsx +11 -3
  280. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  281. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  282. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  283. package/assets/templates/pages/table-filter/page.tsx +9 -0
  284. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  285. package/assets/templates/pages/table-grouped/page.tsx +161 -133
  286. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  287. package/assets/templates/pages/table-page/page.tsx +14 -1
  288. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  289. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  290. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  291. package/assets/templates/pages/work-item-detail/page.tsx +47 -7
  292. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  293. package/assets/theme.template.ts +9 -2
  294. package/authoring/debug/parse.d.mts +3 -3
  295. package/authoring/doctypes/_schema.d.mts +9 -9
  296. package/authoring/doctypes/command/command.doc.mjs +1 -1
  297. package/authoring/doctypes/component/categories.d.mts +37 -0
  298. package/authoring/doctypes/component/categories.mjs +54 -0
  299. package/authoring/doctypes/template/template.doc.mjs +1 -1
  300. package/authoring/doctypes/template/type.ts +9 -0
  301. package/authoring/example/example.doc.d.mts +12 -0
  302. package/authoring/example/example.doc.mjs +69 -0
  303. package/authoring/example/preview.d.mts +92 -0
  304. package/authoring/example/preview.mjs +994 -0
  305. package/authoring/example/type.ts +102 -0
  306. package/authoring/index.d.mts +1 -0
  307. package/authoring/index.d.ts +12 -0
  308. package/authoring/index.mjs +3 -1
  309. package/authoring/integration/integration.doc.mjs +8 -0
  310. package/authoring/integration/schema.d.mts +24 -1
  311. package/authoring/integration/schema.mjs +126 -4
  312. package/authoring/integration/type.ts +14 -0
  313. package/clients/cli/bin/astryx.mjs +6 -9
  314. package/clients/cli/build-id.generated.json +1 -1
  315. package/clients/cli/commands/component.doc.mjs +1 -1
  316. package/clients/cli/commands/component.mjs +22 -3
  317. package/clients/cli/commands/discover.mjs +70 -3
  318. package/clients/cli/commands/docs.doc.mjs +7 -1
  319. package/clients/cli/commands/docs.mjs +44 -6
  320. package/clients/cli/commands/doctor.mjs +84 -16
  321. package/clients/cli/commands/experimental/render.mjs +42 -1
  322. package/clients/cli/commands/experimental/theme.mjs +1032 -134
  323. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  324. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  325. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  326. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  327. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  328. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  329. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  330. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  331. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
  332. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  333. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  334. package/clients/cli/commands/experimental-theme-remove.doc.mjs +4 -4
  335. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  336. package/clients/cli/commands/search.doc.mjs +2 -1
  337. package/clients/cli/commands/search.mjs +6 -1
  338. package/clients/cli/commands/template.doc.mjs +1 -1
  339. package/clients/cli/commands/template.mjs +15 -2
  340. package/clients/cli/commands/theme-add.doc.mjs +1 -1
  341. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  342. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  343. package/clients/cli/commands/theme-remove.doc.mjs +13 -5
  344. package/clients/cli/commands/theme.doc.mjs +1 -1
  345. package/clients/cli/commands/theme.mjs +849 -441
  346. package/clients/cli/commands/upgrade.mjs +46 -8
  347. package/clients/cli/index.mjs +9 -19
  348. package/clients/cli/lib/cli-error.mjs +2 -1
  349. package/clients/cli/lib/component-format.mjs +205 -98
  350. package/clients/cli/lib/hook-format.mjs +9 -19
  351. package/clients/cli/lib/json-shim.mjs +265 -29
  352. package/clients/cli/lib/manifest.mjs +3 -2
  353. package/clients/cli/lib/stray-option.mjs +478 -0
  354. package/clients/cli/lib/unknown-command.mjs +353 -0
  355. package/clients/cli/manifest.generated.json +1 -1
  356. package/foundation/agent-docs/agent-docs.mjs +1 -1
  357. package/foundation/config/project.d.mts +8 -0
  358. package/foundation/config/project.mjs +26 -29
  359. package/foundation/config/theme-state.d.mts +31 -2
  360. package/foundation/config/theme-state.mjs +140 -8
  361. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  362. package/foundation/discovery/cli-self-doc-names.d.mts +13 -0
  363. package/foundation/discovery/cli-self-doc-names.mjs +51 -0
  364. package/foundation/discovery/cli-self-docs.d.mts +0 -2
  365. package/foundation/discovery/cli-self-docs.mjs +2 -15
  366. package/foundation/discovery/component-discovery.d.mts +11 -0
  367. package/foundation/discovery/component-discovery.mjs +59 -10
  368. package/foundation/discovery/component-replacement.mjs +130 -1
  369. package/foundation/discovery/copied-passages.mjs +2 -1
  370. package/foundation/discovery/core-component-docs.d.mts +29 -0
  371. package/foundation/discovery/core-component-docs.mjs +83 -0
  372. package/foundation/discovery/core-theme-facts.d.mts +70 -0
  373. package/foundation/discovery/core-theme-facts.mjs +384 -0
  374. package/foundation/discovery/doc-types.mjs +4 -3
  375. package/foundation/discovery/docs-discovery.d.mts +66 -9
  376. package/foundation/discovery/docs-discovery.mjs +126 -60
  377. package/foundation/discovery/entry-name-files.d.mts +106 -0
  378. package/foundation/discovery/entry-name-files.mjs +354 -0
  379. package/foundation/discovery/hook-discovery.d.mts +18 -2
  380. package/foundation/discovery/hook-discovery.mjs +93 -42
  381. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  382. package/foundation/discovery/icon-set-checks.mjs +2 -1
  383. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  384. package/foundation/discovery/integration-component-views.d.mts +15 -0
  385. package/foundation/discovery/integration-component-views.mjs +91 -0
  386. package/foundation/discovery/integration-doc-files.mjs +2 -1
  387. package/foundation/discovery/module-exports.d.mts +26 -1
  388. package/foundation/discovery/module-exports.mjs +114 -40
  389. package/foundation/discovery/name-roots.d.mts +38 -0
  390. package/foundation/discovery/name-roots.mjs +108 -0
  391. package/foundation/discovery/next-routes.d.mts +48 -0
  392. package/foundation/discovery/next-routes.mjs +181 -0
  393. package/foundation/discovery/package-exports.d.mts +10 -0
  394. package/foundation/discovery/package-exports.mjs +56 -3
  395. package/foundation/discovery/prop-drift.mjs +9 -9
  396. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  397. package/foundation/discovery/runner-allowlist.mjs +2 -0
  398. package/foundation/discovery/stored-component-list.d.mts +43 -0
  399. package/foundation/discovery/stored-component-list.mjs +90 -0
  400. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  401. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  402. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  403. package/foundation/discovery/stored-self-audit.mjs +40 -18
  404. package/foundation/discovery/template-adapter.d.mts +49 -29
  405. package/foundation/discovery/template-adapter.mjs +89 -99
  406. package/foundation/discovery/template-destination.d.mts +28 -0
  407. package/foundation/discovery/template-destination.mjs +104 -0
  408. package/foundation/discovery/template-icons.mjs +2 -1
  409. package/foundation/discovery/template-ids.d.mts +69 -0
  410. package/foundation/discovery/template-ids.mjs +199 -0
  411. package/foundation/discovery/theme-discovery.d.mts +12 -0
  412. package/foundation/discovery/theme-discovery.mjs +34 -4
  413. package/foundation/discovery/theme-imports.d.mts +24 -0
  414. package/foundation/discovery/theme-imports.mjs +61 -4
  415. package/foundation/discovery/theming-targets.d.mts +13 -5
  416. package/foundation/discovery/theming-targets.mjs +41 -47
  417. package/foundation/doc-compiler/generated-levels.d.mts +43 -0
  418. package/foundation/doc-compiler/generated-levels.mjs +72 -0
  419. package/foundation/doc-compiler/import.mjs +7 -1
  420. package/foundation/doc-compiler/inputs.mjs +3 -2
  421. package/foundation/doc-compiler/literal-doc.d.mts +12 -0
  422. package/foundation/doc-compiler/literal-doc.mjs +322 -0
  423. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  424. package/foundation/doc-compiler/stored-docs.d.mts +29 -0
  425. package/foundation/doc-compiler/stored-docs.mjs +63 -1
  426. package/foundation/doc-compiler/tree.d.mts +4 -84
  427. package/foundation/doc-compiler/tree.mjs +4 -62
  428. package/foundation/env/semver.mjs +3 -1
  429. package/foundation/fonts/font-stylesheet.d.mts +46 -0
  430. package/foundation/fonts/font-stylesheet.mjs +173 -0
  431. package/foundation/fs/cache-eviction.d.mts +21 -0
  432. package/foundation/fs/cache-eviction.mjs +73 -0
  433. package/foundation/fs/exact-codec.d.mts +12 -2
  434. package/foundation/fs/exact-codec.mjs +23 -6
  435. package/foundation/fs/file-protection.mjs +16 -5
  436. package/foundation/fs/gather-cache.d.mts +94 -4
  437. package/foundation/fs/gather-cache.mjs +671 -106
  438. package/foundation/fs/glob.d.mts +16 -0
  439. package/foundation/fs/glob.mjs +105 -0
  440. package/foundation/fs/jiti-cache.d.mts +19 -1
  441. package/foundation/fs/jiti-cache.mjs +130 -6
  442. package/foundation/fs/kept-tree.d.mts +80 -0
  443. package/foundation/fs/kept-tree.mjs +240 -0
  444. package/foundation/fs/listing-cache.d.mts +7 -0
  445. package/foundation/fs/listing-cache.mjs +10 -0
  446. package/foundation/fs/module-loader.d.mts +24 -2
  447. package/foundation/fs/module-loader.mjs +94 -21
  448. package/foundation/fs/path-safety.d.mts +11 -2
  449. package/foundation/fs/path-safety.mjs +108 -18
  450. package/foundation/fs/paths.d.mts +18 -0
  451. package/foundation/fs/paths.mjs +15 -2
  452. package/foundation/fs/read-record.d.mts +56 -7
  453. package/foundation/fs/read-record.mjs +280 -56
  454. package/foundation/fs/regular-file.d.mts +29 -0
  455. package/foundation/fs/regular-file.mjs +77 -0
  456. package/foundation/fs/stop-cleanup.d.mts +12 -0
  457. package/foundation/fs/stop-cleanup.mjs +66 -0
  458. package/foundation/identity/provider-identity.d.mts +6 -0
  459. package/foundation/identity/provider-identity.mjs +10 -1
  460. package/foundation/integrations/contribution-inventory.mjs +4 -3
  461. package/foundation/integrations/example-code.d.mts +63 -0
  462. package/foundation/integrations/example-code.mjs +416 -0
  463. package/foundation/integrations/integrations.d.mts +23 -1
  464. package/foundation/integrations/integrations.mjs +18 -1
  465. package/foundation/integrations/pack-state.d.mts +75 -0
  466. package/foundation/integrations/pack-state.mjs +314 -0
  467. package/foundation/integrations/public-imports.d.mts +9 -0
  468. package/foundation/integrations/public-imports.mjs +3 -2
  469. package/foundation/integrations/shipped-imports.d.mts +122 -0
  470. package/foundation/integrations/shipped-imports.mjs +497 -0
  471. package/foundation/integrations/validate-contributions.d.mts +0 -17
  472. package/foundation/integrations/validate-contributions.mjs +59 -333
  473. package/foundation/render/assets.mjs +52 -7
  474. package/foundation/render/charts.d.mts +78 -27
  475. package/foundation/render/charts.mjs +266 -90
  476. package/foundation/render/embedded-files.d.mts +6 -0
  477. package/foundation/render/embedded-files.mjs +25 -5
  478. package/foundation/render/embedded-imports.d.mts +70 -7
  479. package/foundation/render/embedded-imports.mjs +132 -41
  480. package/foundation/render/file-header.d.mts +66 -0
  481. package/foundation/render/file-header.mjs +118 -0
  482. package/foundation/render/host-answer.d.mts +18 -0
  483. package/foundation/render/host-answer.mjs +46 -0
  484. package/foundation/render/host-exit.d.mts +1 -0
  485. package/foundation/render/host-exit.mjs +6 -1
  486. package/foundation/render/html-reader.d.mts +55 -2
  487. package/foundation/render/html-reader.mjs +145 -26
  488. package/foundation/render/layers.d.mts +30 -0
  489. package/foundation/render/layers.mjs +158 -0
  490. package/foundation/render/markup-edits.d.mts +57 -0
  491. package/foundation/render/markup-edits.mjs +182 -0
  492. package/foundation/render/offline.d.mts +32 -0
  493. package/foundation/render/offline.mjs +56 -0
  494. package/foundation/render/page-host.mjs +29 -12
  495. package/foundation/render/page-worker.mjs +354 -21
  496. package/foundation/render/picture-chrome.d.mts +4 -0
  497. package/foundation/render/picture-chrome.mjs +192 -0
  498. package/foundation/render/picture-playwright.d.mts +4 -0
  499. package/foundation/render/picture-playwright.mjs +46 -0
  500. package/foundation/render/rebuild.mjs +2 -1
  501. package/foundation/render/render-page.d.mts +79 -5
  502. package/foundation/render/render-page.mjs +735 -109
  503. package/foundation/render/source-block.d.mts +85 -6
  504. package/foundation/render/source-block.mjs +211 -20
  505. package/foundation/render/ts-paths.d.mts +69 -6
  506. package/foundation/render/ts-paths.mjs +326 -40
  507. package/foundation/response/error-codes.d.mts +3 -1
  508. package/foundation/response/error-codes.d.ts +1 -0
  509. package/foundation/response/error-codes.doc.mjs +12 -1
  510. package/foundation/response/error-codes.mjs +11 -1
  511. package/foundation/response/response-types.doc.mjs +6 -6
  512. package/foundation/suggest/name-index.d.mts +148 -0
  513. package/foundation/suggest/name-index.mjs +317 -0
  514. package/foundation/suggest/other-command.d.mts +140 -0
  515. package/foundation/suggest/other-command.mjs +756 -0
  516. package/foundation/text/compare-text.d.mts +14 -0
  517. package/foundation/text/compare-text.mjs +68 -0
  518. package/foundation/text/css-escape.d.mts +18 -0
  519. package/foundation/text/css-escape.mjs +35 -0
  520. package/foundation/text/entry-names.d.mts +14 -0
  521. package/foundation/text/entry-names.mjs +14 -0
  522. package/foundation/text/string-utils.d.mts +46 -6
  523. package/foundation/text/string-utils.mjs +118 -20
  524. package/foundation/text/suggest-order.d.mts +47 -4
  525. package/foundation/text/suggest-order.mjs +174 -5
  526. package/foundation/xle/browser.d.mts +2 -2
  527. package/foundation/xle/expand.mjs +2 -1
  528. package/host/index.mjs +8 -6
  529. package/package.json +7 -6
@@ -53,6 +53,18 @@ export function paletteFiles(slug: string): {
53
53
  * @param {string} value
54
54
  */
55
55
  export function seedOf(value: string): string | null;
56
+ /**
57
+ * Whether a color dial's seed comes out different at two vibrancies: the
58
+ * ramp the generator grows from it, light and dark, compared shade by
59
+ * shade. A seed with no saturation to change (a pure gray) gives the same
60
+ * ramp at every vibrancy. A gray-ish seed is grown as the editor grows it
61
+ * (a neutral), so a warm or cool gray counts by what it shows.
62
+ * @param {string} dial
63
+ * @param {string | null} seed
64
+ * @param {number} from
65
+ * @param {number} to
66
+ */
67
+ export function vibrancyMoves(dial: string, seed: string | null, from: number, to: number): boolean;
56
68
  /**
57
69
  * The modes a theme has: one for a one-mode theme, else light and dark.
58
70
  * @param {{mode?: string}} data
@@ -111,6 +123,14 @@ export function syncPalette(cwd: string, slug: string, data: {
111
123
  * @returns {Record<string, string>}
112
124
  */
113
125
  export function readWrittenRecord(cwd: string, slug: string): Record<string, string>;
126
+ /**
127
+ * The record of what the editor wrote, read from a theme folder as it is
128
+ * (a copy of one included); empty when there is none or it is damaged.
129
+ * @param {string} dir
130
+ * @param {string} slug
131
+ * @returns {Record<string, string>}
132
+ */
133
+ export function readRecordIn(dir: string, slug: string): Record<string, string>;
114
134
  /**
115
135
  * Write the record whole, or remove it when it names nothing. A record that
116
136
  * cannot be written leaves nothing removed later: the safe way round.
@@ -195,6 +215,33 @@ export function paletteDialOf(token: string): string | null;
195
215
  * @returns {string[]}
196
216
  */
197
217
  export function mappingRows(dial: string): string[];
218
+ /**
219
+ * A contrast check's identity: its token, its mode and what it is measured
220
+ * on, whatever ratio or shade it reaches. The same check before and after a
221
+ * change has the same key, as a text or border problem's key does.
222
+ * @param {ContrastCheck} c
223
+ */
224
+ export function paletteCheckKey(c: ContrastCheck): string;
225
+ /**
226
+ * The contrast checks a dial's colors fail, as their notes say them, each
227
+ * with its identity ({@link paletteCheckKey}), to tell the checks a change
228
+ * made fail from the ones that failed before it.
229
+ * @param {PaletteMapping | null} pal
230
+ * @param {string} dial
231
+ * @param {Mode[]} [modes] the modes the theme has
232
+ * @returns {Array<{key: string, text: string}>}
233
+ */
234
+ export function paletteFailures(pal: PaletteMapping | null, dial: string, modes?: Mode[]): Array<{
235
+ key: string;
236
+ text: string;
237
+ }>;
238
+ /**
239
+ * The identities of every contrast check a palette fails, whatever its
240
+ * dial: what a change compares its own failures with.
241
+ * @param {PaletteMapping | null} pal
242
+ * @returns {Set<string>}
243
+ */
244
+ export function paletteFailedKeys(pal: PaletteMapping | null): Set<string>;
198
245
  /**
199
246
  * What one color dial did, for the result notes: what its main token uses
200
247
  * in each mode, every token contrast moved, and last the generated files.
@@ -207,6 +254,7 @@ export function mappingRows(dial: string): string[];
207
254
  * @returns {string[]}
208
255
  */
209
256
  export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: string, modes?: Mode[]): string[];
257
+ export { readRegularFile };
210
258
  export function isEditorTemp(name: string): boolean;
211
259
  /** @typedef {'light' | 'dark'} Mode */
212
260
  /** @typedef {import('./_settings.mjs').Setting} Setting */
@@ -377,3 +425,4 @@ export type PaletteMapping = {
377
425
  */
378
426
  lift: Record<string, Partial<Record<Mode, StopRef>>> | null;
379
427
  };
428
+ import { readRegularFile } from '../../foundation/fs/regular-file.mjs';
@@ -17,6 +17,7 @@
17
17
 
18
18
  import * as fs from 'node:fs';
19
19
  import * as path from 'node:path';
20
+ import {readRegularFile} from '../../foundation/fs/regular-file.mjs';
20
21
  import {isAlive} from '../../foundation/release/cache.mjs';
21
22
  import {stillHolds} from '../../foundation/release/folder-lock.mjs';
22
23
  import {AstryxError} from '../error.mjs';
@@ -64,6 +65,8 @@ import {P, wordTable} from './_tables.mjs';
64
65
  import {quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
65
66
  import {sha256} from '../../foundation/render/source-block.mjs';
66
67
 
68
+ export {readRegularFile};
69
+
67
70
  /**
68
71
  * Write a file whole: a temp file beside it, renamed into place, so a link
69
72
  * there is replaced, never written through, and a stopped write leaves the
@@ -156,7 +159,11 @@ function sweepTemps(dir) {
156
159
  }
157
160
  continue;
158
161
  }
159
- const m = /^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n);
162
+ // A picture taken under its own name (`.<picture>.part-<pid>.png`) by a
163
+ // run stopped while the browser ran.
164
+ const m =
165
+ /^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n) ??
166
+ /^\.[\w-]+\.part-(\d+)\.png$/.exec(n);
160
167
  if (!m) continue;
161
168
  const p = path.join(dir, n);
162
169
  try {
@@ -203,12 +210,14 @@ export function removeEmptyFolder(dir, opts = {}) {
203
210
 
204
211
  /**
205
212
  * Whether a file name is one of the editor's own temp files: a whole-file
206
- * write's `.<name>.astryx-<pid>-<random>.tmp`, or a build's
207
- * `.<name>.tmp-<id>`. A command stopped part way can leave one behind.
213
+ * write's `.<name>.astryx-<pid>-<random>.tmp`, a build's `.<name>.tmp-<id>`,
214
+ * or a picture's `.<picture>.part-<pid>.png`. A command stopped part way can
215
+ * leave one behind.
208
216
  * @param {string} name
209
217
  */
210
218
  export const isEditorTemp = name =>
211
- /^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name);
219
+ /^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name) ||
220
+ /^\.[\w-]+\.part-\d+\.png$/.test(name);
212
221
 
213
222
  /**
214
223
  * A temp file beside `file` for a whole write, named so only the editor
@@ -323,8 +332,9 @@ const NON_TEXT = 3;
323
332
  /**
324
333
  * The official neutral theme's color mapping, read from the theme the CLI
325
334
  * ships rather than copied: each token's stops, `[light, dark]`, written
326
- * there as `<family>.<mode>[N]` or `withAlpha(<family>.<mode>[N], 'aa')`,
327
- * and the parts whose secondary text it lifts (`[part, block]`).
335
+ * there as `<family>.<mode>[N]` or `withAlpha(<family>.<mode>[N], 'aa')`
336
+ * (one stop for both modes when it writes one), and the parts whose
337
+ * secondary text it lifts (`[part, block]`).
328
338
  * @returns {{stops: Record<string, Array<{stop: number, alpha?: string}>>, lifted: Array<[string, string]>}}
329
339
  */
330
340
  function readOfficialNeutral() {
@@ -364,6 +374,9 @@ function readOfficialNeutral() {
364
374
  if (keys.at(-1) === 'tokens' && node.value.type === 'ArrayExpression') {
365
375
  const pair = node.value.elements.map(stopOf);
366
376
  if (pair.length === 2 && pair.every(Boolean)) stops[key] = pair;
377
+ } else if (keys.at(-1) === 'tokens') {
378
+ const one = stopOf(node.value);
379
+ if (one) stops[key] = [one, one];
367
380
  }
368
381
  if (keys.at(-3) === 'components' && key === '--color-text-secondary')
369
382
  lifted.push([keys.at(-2) ?? '', keys.at(-1) ?? '']);
@@ -387,27 +400,41 @@ const officialStops = token =>
387
400
  /**
388
401
  * The tokens the neutral color sets at the official theme's stops. The page
389
402
  * background, `--color-background-body`, stays the base theme's, so a
390
- * tinted gray never tints the page. A layout without one of these stops
391
- * uses the nearest one it has.
403
+ * tinted gray never tints the page. The inverted surface (tooltips,
404
+ * toasts), which the official theme leaves to Core, is the card surface of
405
+ * the other mode, as Core makes it from a neutral scale, inside the ramp
406
+ * (Core's tones 10 and 99: never the white or black end every ramp shares)
407
+ * so it carries the neutral color (NEUTRAL_INSIDE); the text on it is the
408
+ * theme's on-dark and on-light. A layout without one of these stops uses
409
+ * the nearest one it has.
392
410
  */
393
411
  const NEUTRAL_STOPS = wordTable(
394
- Object.fromEntries(
395
- [
396
- '--color-background-surface',
397
- '--color-background-card',
398
- '--color-background-popover',
399
- '--color-background-muted',
400
- '--color-text-primary',
401
- '--color-text-secondary',
402
- '--color-text-disabled',
403
- '--color-icon-primary',
404
- '--color-icon-secondary',
405
- '--color-icon-disabled',
406
- '--color-border-emphasized',
407
- '--color-skeleton',
408
- ].map(t => [t, officialStops(t)]),
409
- ),
412
+ /** @type {Record<string, [number, number]>} */ ({
413
+ ...Object.fromEntries(
414
+ [
415
+ '--color-background-surface',
416
+ '--color-background-card',
417
+ '--color-background-popover',
418
+ '--color-background-muted',
419
+ '--color-text-primary',
420
+ '--color-text-secondary',
421
+ '--color-text-disabled',
422
+ '--color-icon-primary',
423
+ '--color-icon-secondary',
424
+ '--color-icon-disabled',
425
+ '--color-border-emphasized',
426
+ '--color-skeleton',
427
+ '--color-on-dark',
428
+ '--color-on-light',
429
+ ].map(t => [t, officialStops(t)]),
430
+ ),
431
+ '--color-background-inverted': /** @type {[number, number]} */ (
432
+ [...officialStops('--color-background-card')].reverse()
433
+ ),
434
+ }),
410
435
  );
436
+ /** Neutral tokens whose shade stays inside the ramp, off its white and black ends. */
437
+ const NEUTRAL_INSIDE = new Set(['--color-background-inverted']);
411
438
  /** Neutral tints: a stop with an opacity, `[[stop, alpha], [stop, alpha]]`. */
412
439
  const NEUTRAL_TINTS = wordTable(
413
440
  Object.fromEntries(
@@ -536,6 +563,33 @@ const isGray = seed => hexToOklch(seed).C < GRAY_CHROMA;
536
563
  /** Whether a seed (or no seed) has no color to saturate. @param {string | null} seed */
537
564
  export const isGraySeed = seed => !seed || isGray(seed);
538
565
 
566
+ /**
567
+ * Whether a color dial's seed comes out different at two vibrancies: the
568
+ * ramp the generator grows from it, light and dark, compared shade by
569
+ * shade. A seed with no saturation to change (a pure gray) gives the same
570
+ * ramp at every vibrancy. A gray-ish seed is grown as the editor grows it
571
+ * (a neutral), so a warm or cool gray counts by what it shows.
572
+ * @param {string} dial
573
+ * @param {string | null} seed
574
+ * @param {number} from
575
+ * @param {number} to
576
+ */
577
+ export function vibrancyMoves(dial, seed, from, to) {
578
+ if (!seed || from === to) return false;
579
+ const kind = dial === 'neutral' || isGray(seed) ? 'neutral' : 'chromatic';
580
+ const ramp = (/** @type {number} */ vibrancy) =>
581
+ JSON.stringify(
582
+ /** @type {any} */ (
583
+ generate({
584
+ vibrancy,
585
+ ...(kind === 'neutral' ? {neutralProfile: 'custom'} : {}),
586
+ families: [{id: 'seed', seed, kind}],
587
+ }).palette.seed
588
+ ),
589
+ );
590
+ return ramp(from) !== ramp(to);
591
+ }
592
+
539
593
  /** @param {unknown} a @param {unknown} b */
540
594
  function sameColor(a, b) {
541
595
  try {
@@ -782,6 +836,12 @@ function tools(
782
836
  const {stops} = candidate;
783
837
  /** @param {number} n */
784
838
  const at = n => nearestStop(stops, n);
839
+ /** The stop nearest `n` off the white and black ends. @param {number} n */
840
+ const atInside = n =>
841
+ nearestStop(
842
+ stops.filter(s => s > 0 && s < 100),
843
+ n,
844
+ );
785
845
  /** @param {string} id @param {Mode} m @param {number} stop @param {string} [alpha] @returns {StopRef} */
786
846
  const ref = (id, m, stop, alpha) => {
787
847
  const color = /** @type {any} */ (candidate.palette[id])[m][stop];
@@ -960,6 +1020,7 @@ function tools(
960
1020
  return {
961
1021
  stops,
962
1022
  at,
1023
+ atInside,
963
1024
  ref,
964
1025
  exactOf,
965
1026
  settingOf,
@@ -1460,9 +1521,20 @@ function syncPaletteFiles(cwd, slug, data, base) {
1460
1521
  * @returns {Record<string, string>}
1461
1522
  */
1462
1523
  export function readWrittenRecord(cwd, slug) {
1524
+ return readRecordIn(path.join(cwd, 'themes', slug), slug);
1525
+ }
1526
+
1527
+ /**
1528
+ * The record of what the editor wrote, read from a theme folder as it is
1529
+ * (a copy of one included); empty when there is none or it is damaged.
1530
+ * @param {string} dir
1531
+ * @param {string} slug
1532
+ * @returns {Record<string, string>}
1533
+ */
1534
+ export function readRecordIn(dir, slug) {
1463
1535
  try {
1464
1536
  const json = JSON.parse(
1465
- fs.readFileSync(writtenRecordFile(cwd, slug), 'utf8'),
1537
+ readRegularFile(path.join(dir, `${slug}.pictures.json`), 'utf8'),
1466
1538
  );
1467
1539
  return json && typeof json === 'object' && !Array.isArray(json) ? json : {};
1468
1540
  } catch {
@@ -1902,7 +1974,18 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
1902
1974
  const {config} = plan;
1903
1975
  const candidate = generate(config, paletteFiles(slug).config);
1904
1976
  const t = tools(candidate, data, base, ownSourceTokenValues(cwd, slug));
1905
- const {stops, at, ref, exactOf, rawOf, settingOf, side, solid, surfaces} = t;
1977
+ const {
1978
+ stops,
1979
+ at,
1980
+ atInside,
1981
+ ref,
1982
+ exactOf,
1983
+ rawOf,
1984
+ settingOf,
1985
+ side,
1986
+ solid,
1987
+ surfaces,
1988
+ } = t;
1906
1989
  // Both halves, for a one-mode theme too (see planPalette).
1907
1990
  const modes = modesForStrategy('light-and-dark');
1908
1991
  /** @type {PaletteMapping['tokens']} */
@@ -1984,10 +2067,11 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
1984
2067
  token === '--color-icon-secondary'
1985
2068
  )
1986
2069
  continue;
2070
+ const shade = NEUTRAL_INSIDE.has(token) ? atInside : at;
1987
2071
  put(
1988
2072
  token,
1989
2073
  'neutral',
1990
- each(m => ref('neutral', m, at(pair[side(m)]))),
2074
+ each(m => ref('neutral', m, shade(pair[side(m)]))),
1991
2075
  );
1992
2076
  }
1993
2077
  for (const [token, pair] of Object.entries(NEUTRAL_TINTS))
@@ -2506,7 +2590,7 @@ export function mappingRows(dial) {
2506
2590
  'your exact color sits at its own shade, light and dark, and the shades around it follow it (white and black are already the ends of every ramp)',
2507
2591
  ...Object.entries(NEUTRAL_STOPS).map(
2508
2592
  ([t, [l, d]]) =>
2509
- `${t}: light shade ${l}, dark shade ${d}${t.endsWith('-secondary') ? ` (moves to a shade that reads at ${t.includes('icon') ? NON_TEXT : TEXT}:1 on the surfaces)` : ''}`,
2593
+ `${t}: light shade ${l}, dark shade ${d}${t.endsWith('-secondary') ? ` (moves to a shade that reads at ${t.includes('icon') ? NON_TEXT : TEXT}:1 on the surfaces)` : NEUTRAL_INSIDE.has(t) ? ' (the card surface of the other mode, for tooltips and toasts, at the nearest shade inside the ramp so it carries your color)' : ''}`,
2510
2594
  ),
2511
2595
  ...Object.entries(NEUTRAL_TINTS).map(
2512
2596
  ([t, [[l, la], [d, da]]]) =>
@@ -2550,6 +2634,72 @@ export function mappingRows(dial) {
2550
2634
  return rows;
2551
2635
  }
2552
2636
 
2637
+ /**
2638
+ * The contrast checks of the colors a dial makes, in the theme's modes.
2639
+ * @param {PaletteMapping} pal
2640
+ * @param {string} dial
2641
+ * @param {Mode[]} modes
2642
+ */
2643
+ function dialChecks(pal, dial, modes) {
2644
+ return pal.contrast.filter(
2645
+ c =>
2646
+ (pal.tokens[c.token]?.family === dial || c.dials?.includes(dial)) &&
2647
+ // A theme with one mode never shows the other one's shades.
2648
+ modes.includes(c.mode),
2649
+ );
2650
+ }
2651
+
2652
+ /**
2653
+ * What one contrast check says: its own note, or for a failed one the
2654
+ * ratio it reached.
2655
+ * @param {PaletteMapping['contrast'][number]} c
2656
+ * @param {string} dial
2657
+ */
2658
+ function checkNote(c, dial) {
2659
+ return (
2660
+ c.note ||
2661
+ `${c.token} reads at only ${c.ratio}:1 in ${c.mode} on ${c.against} (needs ${c.needs}:1) even at shade ${shade(c.stop)}, the most contrasting one: pick a lighter or darker ${dial}, or set ${c.token} exactly`
2662
+ );
2663
+ }
2664
+
2665
+ /**
2666
+ * A contrast check's identity: its token, its mode and what it is measured
2667
+ * on, whatever ratio or shade it reaches. The same check before and after a
2668
+ * change has the same key, as a text or border problem's key does.
2669
+ * @param {ContrastCheck} c
2670
+ */
2671
+ export function paletteCheckKey(c) {
2672
+ return `palette|${c.token}|${c.mode}|${c.against}`;
2673
+ }
2674
+
2675
+ /**
2676
+ * The contrast checks a dial's colors fail, as their notes say them, each
2677
+ * with its identity ({@link paletteCheckKey}), to tell the checks a change
2678
+ * made fail from the ones that failed before it.
2679
+ * @param {PaletteMapping | null} pal
2680
+ * @param {string} dial
2681
+ * @param {Mode[]} [modes] the modes the theme has
2682
+ * @returns {Array<{key: string, text: string}>}
2683
+ */
2684
+ export function paletteFailures(pal, dial, modes = ['light', 'dark']) {
2685
+ if (!pal) return [];
2686
+ return dialChecks(pal, dial, modes)
2687
+ .filter(c => !c.pass)
2688
+ .map(c => ({key: paletteCheckKey(c), text: checkNote(c, dial)}));
2689
+ }
2690
+
2691
+ /**
2692
+ * The identities of every contrast check a palette fails, whatever its
2693
+ * dial: what a change compares its own failures with.
2694
+ * @param {PaletteMapping | null} pal
2695
+ * @returns {Set<string>}
2696
+ */
2697
+ export function paletteFailedKeys(pal) {
2698
+ return new Set(
2699
+ (pal?.contrast ?? []).filter(c => !c.pass).map(paletteCheckKey),
2700
+ );
2701
+ }
2702
+
2553
2703
  /**
2554
2704
  * What one color dial did, for the result notes: what its main token uses
2555
2705
  * in each mode, every token contrast moved, and last the generated files.
@@ -2598,16 +2748,8 @@ export function paletteNotes(pal, dial, slug, modes = ['light', 'dark']) {
2598
2748
  notes.push(
2599
2749
  `your ${dial} ${given.value} is outside the colors every screen shows (sRGB), so the nearest one, ${given.seed}, is used`,
2600
2750
  );
2601
- for (const c of pal.contrast) {
2602
- if (pal.tokens[c.token]?.family !== dial && !c.dials?.includes(dial))
2603
- continue;
2604
- // A theme with one mode never shows the other one's shades.
2605
- if (!modes.includes(c.mode)) continue;
2606
- if (c.note) notes.push(c.note);
2607
- else if (!c.pass)
2608
- notes.push(
2609
- `${c.token} reads at only ${c.ratio}:1 in ${c.mode} on ${c.against} (needs ${c.needs}:1) even at shade ${shade(c.stop)}, the most contrasting one: pick a lighter or darker ${dial}, or set ${c.token} exactly`,
2610
- );
2751
+ for (const c of dialChecks(pal, dial, modes)) {
2752
+ if (c.note || !c.pass) notes.push(checkNote(c, dial));
2611
2753
  else if (c.stop !== c.preferred)
2612
2754
  notes.push(
2613
2755
  `${c.token} uses shade ${shade(c.stop)} in ${c.mode}, not ${shade(c.preferred)}, so it reads at ${c.ratio}:1 on ${c.against}`,
@@ -0,0 +1,39 @@
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 part or group a plain word names, as how reads it (`checkboxes` is
6
+ * the checks group, `panels` the containers), or null.
7
+ * @param {string} word
8
+ * @returns {string | null}
9
+ */
10
+ export function partForWord(word: string): string | null;
11
+ /**
12
+ * The single words the table reads as a part or group, each with what it
13
+ * names (`sidebar` side-nav, `checkbox` checks, `toggle` switch): the words
14
+ * a part's typo is read against beside the part names. Taken from the
15
+ * table's own words, a plural's singular (`toggles?`) included.
16
+ * @returns {Map<string, string>}
17
+ */
18
+ export function partWords(): Map<string, string>;
19
+ /**
20
+ * @file The plain words for parts that Core's catalog cannot give (groups,
21
+ * variants, font roles, phrases of several words, and words two components
22
+ * share), and the part or group one plain word names.
23
+ * @position api/theme-edit — a leaf with no imports, read by _how-question.mjs
24
+ * and _check.mjs
25
+ */
26
+ /**
27
+ * Phrases for parts that Core's catalog cannot give: groups, variants,
28
+ * font roles, phrases of several words, and words two components share.
29
+ * They are read before the catalog's names and doc keywords
30
+ * (partLexicon), longest phrase first.
31
+ * @type {Array<[RegExp, {on: string, when?: string, role?: string, level?: string, missing?: string}]>}
32
+ */
33
+ export const OVERRIDES: Array<[RegExp, {
34
+ on: string;
35
+ when?: string;
36
+ role?: string;
37
+ level?: string;
38
+ missing?: string;
39
+ }]>;
@@ -0,0 +1,152 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The plain words for parts that Core's catalog cannot give (groups,
5
+ * variants, font roles, phrases of several words, and words two components
6
+ * share), and the part or group one plain word names.
7
+ * @position api/theme-edit — a leaf with no imports, read by _how-question.mjs
8
+ * and _check.mjs
9
+ */
10
+
11
+ /**
12
+ * Phrases for parts that Core's catalog cannot give: groups, variants,
13
+ * font roles, phrases of several words, and words two components share.
14
+ * They are read before the catalog's names and doc keywords
15
+ * (partLexicon), longest phrase first.
16
+ * @type {Array<[RegExp, {on: string, when?: string, role?: string, level?: string, missing?: string}]>}
17
+ */
18
+ export const OVERRIDES = [
19
+ [/\bdividers?\b/, {on: 'divider'}],
20
+ [
21
+ /\baccordions? (headers?|triggers?|titles?|headings?)\b/,
22
+ {on: 'collapsible-trigger'},
23
+ ],
24
+ [/\baccordions?\b/, {on: 'collapsible'}],
25
+ [/\bcombo ?box(es)?\b/, {on: 'complex-selector'}],
26
+ [/\bnotifications?\b/, {on: 'toast'}],
27
+ [/\b(focus (ring|outline)s?)\b/, {on: 'focus-ring'}],
28
+ [/\b((modal |dialog )?(overlay|scrim|backdrop))\b/, {on: 'overlay'}],
29
+ [/\bicons?\b/, {on: 'icons'}],
30
+ [
31
+ /\b(table header|column headers?|table headings?)\b/,
32
+ {on: 'table-header-cell'},
33
+ ],
34
+ [
35
+ /\b(tabs? (underline|indicator)s?|underline (of|on|under) (the )?tabs?)\b/,
36
+ {on: 'tab-indicator'},
37
+ ],
38
+ [/\b(status dots?)\b/, {on: 'status-dot'}],
39
+ [/\b(progress( bar)?( fill)?|loading bar)\b/, {on: 'progress-bar-fill'}],
40
+ [
41
+ /\b((side ?nav|sidebar)( nav(igation)?)? (links?|items?))\b/,
42
+ {on: 'side-nav-item'},
43
+ ],
44
+ [
45
+ /\b((dropdown |context )?menu (items?|options?|entries)|dropdown items?)\b/,
46
+ {on: 'dropdown-menu-item'},
47
+ ],
48
+ [/\b(nav(igation)? (links?|items?))\b/, {on: 'top-nav-item'}],
49
+ // A context menu is its own part in Core (its items are the dropdown
50
+ // menu's items, which it reuses).
51
+ [/\b(context ?menus?|right[- ]click menus?)\b/, {on: 'context-menu'}],
52
+ [/\b((dropdown )?menus?)\b/, {on: 'dropdown-menu'}],
53
+ // A part's own header or footer ("dialog header", "card footer") is that
54
+ // part's, never the app's top bar or footer.
55
+ [
56
+ /(?<!\b(?:dialog|modal|card|drawer|sheet|popover|panel|section|table|menu)s? )\bfooters?\b/,
57
+ {on: 'layout-footer'},
58
+ ],
59
+ [/\b(side ?nav|sidebar|side ?panel)\b/, {on: 'side-nav'}],
60
+ [
61
+ /\b(app (name|title)|logo|site title|product name)\b/,
62
+ {on: 'top-nav-heading'},
63
+ ],
64
+ [
65
+ /(?<!\b(?:dialog|modal|card|drawer|sheet|popover|panel|section|table|menu)s? )\b(header|top ?bar|title ?bar|nav ?bar|app ?bar|masthead)\b/,
66
+ {on: 'app-shell-header'},
67
+ ],
68
+ [/\b(page|app background|whole background|body background)\b/, {on: 'page'}],
69
+ [/\b(radio( buttons?)?|radios)\b/, {on: 'radio-indicator'}],
70
+ [/\b(primary|main) buttons?\b/, {on: 'button', when: 'variant:primary'}],
71
+ [/\bsecondary buttons?\b/, {on: 'button', when: 'variant:secondary'}],
72
+ [/\bghost buttons?\b/, {on: 'button', when: 'variant:ghost'}],
73
+ [
74
+ /\b(danger|destructive|delete) (buttons?|ones?|variant)\b/,
75
+ {on: 'button', when: 'variant:destructive'},
76
+ ],
77
+ [/\b(panels?|windows?|boxes|tiles?|containers?)\b/, {on: 'containers'}],
78
+ [/\b(banners?|alerts?|notices?|announcements?)\b/, {on: 'banner'}],
79
+ [/\b(text ?areas?|multi-?line (inputs?|fields?))\b/, {on: 'text-area'}],
80
+ [
81
+ /\b(select (dropdowns?|menus?|box(es)?|inputs?)|selects|dropdowns?|pickers?|select(?! (the|a|an|all|any|one|which|what|it|them)\b))\b/,
82
+ {on: 'selector'},
83
+ ],
84
+ [/\b(skeletons?( loaders?)?|loading placeholders?)\b/, {on: 'skeleton'}],
85
+ [
86
+ /\b(inputs?|text ?box(es)?|text ?fields?|form fields?|fields?)\b/,
87
+ {on: 'inputs'},
88
+ ],
89
+ // A checkbox is the box itself; the checks group (checkbox and radio)
90
+ // goes by its own name.
91
+ [/\b(checkbox(es)?|check ?marks?)\b/, {on: 'checkbox-indicator'}],
92
+ // "switch off", "switch the buttons to" are the verb, not the part.
93
+ [
94
+ /\b(toggles?|switch(?:e?s)?(?! (off|on|to|the|out|it|them|over|back|from)\b))\b/,
95
+ {on: 'switch'},
96
+ ],
97
+ [/\b((table )?cells?)\b/, {on: 'table-cell'}],
98
+ [/\b(table rows?|rows?|tables?)\b/, {on: 'table-row'}],
99
+ [/\b(badges?|chips?|tags?)\b/, {on: 'badge'}],
100
+ [/\bh([1-6])\b/, {on: 'heading'}],
101
+ [/\b(headings?|titles?)\b/, {on: 'heading'}],
102
+ [/\b(modals?|popups?)\b/, {on: 'dialog'}],
103
+ [/\bcode\b/, {on: 'code', role: 'code'}],
104
+ // Small, secondary and supporting text, captions and fine print: the
105
+ // supporting text style, not the base size.
106
+ [
107
+ /\b((?:small|secondary|supporting|helper|hint|caption|muted) (?:text|copy)|fine print|captions?)\b/,
108
+ {on: 'body', role: 'supporting'},
109
+ ],
110
+ [/\bbody( text)?\b/, {on: 'body', role: 'body'}],
111
+ ];
112
+
113
+ /**
114
+ * The part or group a plain word names, as how reads it (`checkboxes` is
115
+ * the checks group, `panels` the containers), or null.
116
+ * @param {string} word
117
+ * @returns {string | null}
118
+ */
119
+ export function partForWord(word) {
120
+ const w = String(word ?? '')
121
+ .trim()
122
+ .toLowerCase();
123
+ if (!w) return null;
124
+ for (const [re, hit] of OVERRIDES)
125
+ if (/** @type {RegExp} */ (re).test(w))
126
+ return /** @type {{on: string}} */ (hit).on;
127
+ return null;
128
+ }
129
+
130
+ /** @type {Map<string, string> | null} */
131
+ let words = null;
132
+
133
+ /**
134
+ * The single words the table reads as a part or group, each with what it
135
+ * names (`sidebar` side-nav, `checkbox` checks, `toggle` switch): the words
136
+ * a part's typo is read against beside the part names. Taken from the
137
+ * table's own words, a plural's singular (`toggles?`) included.
138
+ * @returns {Map<string, string>}
139
+ */
140
+ export function partWords() {
141
+ if (words) return words;
142
+ words = new Map();
143
+ for (const [re] of OVERRIDES)
144
+ for (const m of re.source.matchAll(/[a-z]{3,}(\?)?/g)) {
145
+ const w = m[0].replace(/\?$/, '');
146
+ for (const each of m[1] ? [w, w.slice(0, -1)] : [w]) {
147
+ const on = partForWord(each);
148
+ if (on && !words.has(each)) words.set(each, on);
149
+ }
150
+ }
151
+ return words;
152
+ }