@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03

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 (369) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +51 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +4 -3
  7. package/api/build/build.type.d.mts +2 -2
  8. package/api/build/build.type.mjs +3 -3
  9. package/api/build/kit/kind.d.mts +2 -1
  10. package/api/build/kit/kind.mjs +199 -10
  11. package/api/build/kit/kit.mjs +6 -4
  12. package/api/build/kit/rank.d.mts +4 -2
  13. package/api/build/kit/rank.mjs +125 -24
  14. package/api/build/kit/start.d.mts +5 -4
  15. package/api/build/kit/start.mjs +12 -8
  16. package/api/build/kit/weights.d.mts +39 -3
  17. package/api/build/kit/weights.json +1 -1
  18. package/api/build/kit/weights.mjs +340 -43
  19. package/api/build/kit/word-model.d.mts +23 -0
  20. package/api/build/kit/word-model.mjs +46 -0
  21. package/api/build/kit/words.d.mts +48 -0
  22. package/api/build/kit/words.mjs +90 -1
  23. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  24. package/api/component/list/list.d.mts +1 -1
  25. package/api/component/list/list.mjs +48 -6
  26. package/api/discover/_adapter.d.mts +1 -1
  27. package/api/discover/search/search.mjs +3 -2
  28. package/api/docs/_adapter.d.mts +26 -2
  29. package/api/docs/_adapter.mjs +219 -6
  30. package/api/docs/docs.d.mts +3 -0
  31. package/api/docs/docs.doc.mjs +7 -1
  32. package/api/docs/docs.mjs +12 -0
  33. package/api/docs/docs.type.d.mts +5 -0
  34. package/api/docs/docs.type.mjs +2 -0
  35. package/api/docs/node/node.mjs +1 -1
  36. package/api/doctor/_adapter.d.mts +27 -5
  37. package/api/doctor/_adapter.mjs +83 -10
  38. package/api/doctor/built-checks.mjs +40 -14
  39. package/api/doctor/doctor.d.mts +4 -3
  40. package/api/doctor/doctor.mjs +14 -7
  41. package/api/doctor/theme-checks.mjs +121 -17
  42. package/api/icon/_records.mjs +2 -1
  43. package/api/index.d.mts +2 -0
  44. package/api/index.mjs +2 -0
  45. package/api/integration/_adapter.d.mts +44 -0
  46. package/api/integration/_adapter.mjs +77 -1
  47. package/api/integration/authoring-checks.mjs +6 -6
  48. package/api/integration/example-scope.d.mts +14 -0
  49. package/api/integration/example-scope.mjs +44 -0
  50. package/api/integration/example-scope.type.d.mts +29 -0
  51. package/api/integration/example-scope.type.mjs +25 -0
  52. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  53. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  54. package/api/integration/validate-integration.mjs +19 -1
  55. package/api/integration/validate-integration.type.d.mts +9 -0
  56. package/api/integration/validate-integration.type.mjs +1 -1
  57. package/api/integration/validateIntegration.doc.mjs +1 -1
  58. package/api/render/_adapter.mjs +591 -195
  59. package/api/render/render.doc.mjs +11 -3
  60. package/api/render/render.type.d.mts +52 -0
  61. package/api/render/render.type.mjs +31 -1
  62. package/api/search/ORDERING.md +1 -1
  63. package/api/search/_adapter.d.mts +9 -0
  64. package/api/search/_adapter.mjs +85 -0
  65. package/api/search/_candidate-score.mjs +51 -32
  66. package/api/search/_fit-order.mjs +3 -3
  67. package/api/search/_gather-components.d.mts +3 -2
  68. package/api/search/_gather-components.mjs +12 -3
  69. package/api/search/_lexical.d.mts +5 -0
  70. package/api/search/_lexical.mjs +8 -2
  71. package/api/search/_result.d.mts +11 -9
  72. package/api/search/_result.mjs +4 -4
  73. package/api/search/_score.d.mts +6 -1
  74. package/api/search/_score.mjs +15 -3
  75. package/api/search/search-index.mjs +7 -1
  76. package/api/search/search.d.mts +1 -1
  77. package/api/theme/_adapter.mjs +12 -1
  78. package/api/theme/build/build.d.mts +122 -1
  79. package/api/theme/build/build.mjs +412 -84
  80. package/api/theme/build/core-interception.d.mts +10 -0
  81. package/api/theme/build/core-interception.mjs +10 -0
  82. package/api/theme/build/font-warning.d.mts +23 -3
  83. package/api/theme/build/font-warning.mjs +54 -5
  84. package/api/theme/build/icon-imports.mjs +25 -2
  85. package/api/theme/theme.type.d.mts +10 -0
  86. package/api/theme/theme.type.mjs +7 -1
  87. package/api/theme-edit/_adapter.d.mts +103 -3
  88. package/api/theme-edit/_adapter.mjs +961 -82
  89. package/api/theme-edit/_catalog.mjs +19 -4
  90. package/api/theme-edit/_check.d.mts +63 -24
  91. package/api/theme-edit/_check.mjs +2467 -362
  92. package/api/theme-edit/_color.d.mts +10 -0
  93. package/api/theme-edit/_color.mjs +49 -1
  94. package/api/theme-edit/_compiler.mjs +89 -6
  95. package/api/theme-edit/_context.d.mts +3 -3
  96. package/api/theme-edit/_context.mjs +165 -54
  97. package/api/theme-edit/_css.d.mts +14 -0
  98. package/api/theme-edit/_css.mjs +46 -1
  99. package/api/theme-edit/_edit.d.mts +31 -4
  100. package/api/theme-edit/_edit.mjs +2433 -204
  101. package/api/theme-edit/_how-commands.d.mts +72 -1
  102. package/api/theme-edit/_how-commands.mjs +759 -9
  103. package/api/theme-edit/_how-question.d.mts +82 -5
  104. package/api/theme-edit/_how-question.mjs +6473 -553
  105. package/api/theme-edit/_how.d.mts +2 -1
  106. package/api/theme-edit/_how.mjs +237 -41
  107. package/api/theme-edit/_marks.d.mts +31 -5
  108. package/api/theme-edit/_marks.mjs +57 -5
  109. package/api/theme-edit/_name-rule.d.mts +11 -0
  110. package/api/theme-edit/_name-rule.mjs +12 -0
  111. package/api/theme-edit/_normal.d.mts +292 -0
  112. package/api/theme-edit/_normal.mjs +1454 -0
  113. package/api/theme-edit/_palette.mjs +10 -4
  114. package/api/theme-edit/_part-words.d.mts +31 -0
  115. package/api/theme-edit/_part-words.mjs +126 -0
  116. package/api/theme-edit/_parts.d.mts +18 -1
  117. package/api/theme-edit/_parts.mjs +246 -23
  118. package/api/theme-edit/_preview-app.d.mts +7 -1
  119. package/api/theme-edit/_preview-app.mjs +776 -187
  120. package/api/theme-edit/_preview.d.mts +100 -14
  121. package/api/theme-edit/_preview.mjs +582 -139
  122. package/api/theme-edit/_project.d.mts +4 -0
  123. package/api/theme-edit/_project.mjs +3 -1
  124. package/api/theme-edit/_settings.d.mts +417 -42
  125. package/api/theme-edit/_settings.mjs +3262 -424
  126. package/api/theme-edit/_tables.d.mts +15 -0
  127. package/api/theme-edit/_tables.mjs +63 -1
  128. package/api/theme-edit/_vet.d.mts +20 -0
  129. package/api/theme-edit/_vet.mjs +47 -2
  130. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  131. package/api/theme-edit/theme-edit.type.mjs +4 -1
  132. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  133. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  134. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  135. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  136. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  137. package/api/upgrade/run/run.mjs +4 -3
  138. package/assets/codemods/integration-discovery.mjs +2 -1
  139. package/assets/codemods/run-codemod.mjs +87 -7
  140. package/assets/codemods/transforms/next/index.mjs +11 -1
  141. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  142. package/assets/component-list.generated.json +1 -0
  143. package/assets/docs/author-a-theme.doc.mjs +1 -0
  144. package/assets/docs/theme.doc.dense.mjs +2 -2
  145. package/assets/docs/theme.doc.mjs +1 -1
  146. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  147. package/assets/docs/tree/checks.doc.mjs +1 -1
  148. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  149. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  150. package/assets/docs/tree/single-component.doc.mjs +4 -0
  151. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  152. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  153. package/assets/docs/use-a-theme.doc.mjs +1 -1
  154. package/assets/docs.generated.json +2 -2
  155. package/assets/search-catalog.generated.json +2 -0
  156. package/assets/self-audit.generated.json +1 -1
  157. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  158. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  159. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  160. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  161. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  162. package/assets/templates/components.generated.json +1 -1
  163. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  164. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
  165. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  166. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  167. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  168. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  169. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  170. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  171. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  172. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  173. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  174. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  175. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  176. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  177. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  178. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  179. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  180. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  181. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  182. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  183. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  184. package/assets/templates/pages/ide/page.tsx +24 -2
  185. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  186. package/assets/templates/pages/library/template.doc.mjs +4 -1
  187. package/assets/templates/pages/login/template.doc.mjs +2 -1
  188. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  189. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  190. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  191. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  192. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  193. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  194. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  195. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  196. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  197. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  198. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  199. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  200. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  201. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  202. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  203. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  204. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  205. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  206. package/assets/theme.template.ts +6 -0
  207. package/authoring/debug/parse.d.mts +3 -3
  208. package/authoring/doctypes/_schema.d.mts +3 -3
  209. package/authoring/doctypes/command/command.doc.mjs +1 -1
  210. package/authoring/doctypes/component/categories.d.mts +37 -0
  211. package/authoring/doctypes/component/categories.mjs +54 -0
  212. package/authoring/doctypes/template/template.doc.mjs +1 -1
  213. package/authoring/doctypes/template/type.ts +9 -0
  214. package/authoring/example/example.doc.d.mts +12 -0
  215. package/authoring/example/example.doc.mjs +69 -0
  216. package/authoring/example/preview.d.mts +92 -0
  217. package/authoring/example/preview.mjs +994 -0
  218. package/authoring/example/type.ts +102 -0
  219. package/authoring/index.d.mts +1 -0
  220. package/authoring/index.d.ts +12 -0
  221. package/authoring/index.mjs +3 -1
  222. package/clients/cli/bin/astryx.mjs +6 -9
  223. package/clients/cli/build-id.generated.json +1 -1
  224. package/clients/cli/commands/component.doc.mjs +1 -1
  225. package/clients/cli/commands/component.mjs +22 -3
  226. package/clients/cli/commands/docs.doc.mjs +7 -1
  227. package/clients/cli/commands/docs.mjs +3 -1
  228. package/clients/cli/commands/doctor.mjs +32 -14
  229. package/clients/cli/commands/experimental/render.mjs +42 -1
  230. package/clients/cli/commands/experimental/theme.mjs +358 -63
  231. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  233. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  234. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  235. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  236. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  237. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  238. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  239. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  240. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  241. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  242. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  243. package/clients/cli/commands/search.doc.mjs +2 -1
  244. package/clients/cli/commands/search.mjs +6 -1
  245. package/clients/cli/commands/template.mjs +4 -2
  246. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  247. package/clients/cli/commands/theme.doc.mjs +1 -1
  248. package/clients/cli/commands/theme.mjs +317 -47
  249. package/clients/cli/commands/upgrade.mjs +42 -7
  250. package/clients/cli/index.mjs +1 -1
  251. package/clients/cli/lib/cli-error.mjs +2 -1
  252. package/clients/cli/lib/component-format.mjs +205 -98
  253. package/clients/cli/lib/hook-format.mjs +9 -19
  254. package/clients/cli/lib/json-shim.mjs +92 -21
  255. package/clients/cli/lib/manifest.mjs +3 -2
  256. package/clients/cli/manifest.generated.json +1 -1
  257. package/foundation/agent-docs/agent-docs.mjs +1 -1
  258. package/foundation/config/theme-state.d.mts +13 -1
  259. package/foundation/config/theme-state.mjs +47 -7
  260. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  261. package/foundation/discovery/component-discovery.d.mts +11 -0
  262. package/foundation/discovery/component-discovery.mjs +56 -8
  263. package/foundation/discovery/component-replacement.mjs +130 -1
  264. package/foundation/discovery/copied-passages.mjs +2 -1
  265. package/foundation/discovery/doc-types.mjs +4 -3
  266. package/foundation/discovery/entry-name-files.d.mts +43 -0
  267. package/foundation/discovery/entry-name-files.mjs +264 -0
  268. package/foundation/discovery/hook-discovery.d.mts +8 -2
  269. package/foundation/discovery/hook-discovery.mjs +22 -8
  270. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  271. package/foundation/discovery/icon-set-checks.mjs +2 -1
  272. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  273. package/foundation/discovery/integration-doc-files.mjs +2 -1
  274. package/foundation/discovery/package-exports.d.mts +10 -0
  275. package/foundation/discovery/package-exports.mjs +56 -3
  276. package/foundation/discovery/prop-drift.mjs +9 -9
  277. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  278. package/foundation/discovery/runner-allowlist.mjs +2 -0
  279. package/foundation/discovery/stored-component-list.d.mts +43 -0
  280. package/foundation/discovery/stored-component-list.mjs +90 -0
  281. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  282. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  283. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  284. package/foundation/discovery/stored-self-audit.mjs +38 -18
  285. package/foundation/discovery/template-adapter.d.mts +53 -1
  286. package/foundation/discovery/template-adapter.mjs +176 -12
  287. package/foundation/discovery/template-icons.mjs +2 -1
  288. package/foundation/discovery/theme-discovery.mjs +31 -4
  289. package/foundation/discovery/theme-imports.d.mts +14 -0
  290. package/foundation/discovery/theme-imports.mjs +43 -1
  291. package/foundation/discovery/theming-targets.mjs +3 -2
  292. package/foundation/doc-compiler/import.mjs +7 -1
  293. package/foundation/doc-compiler/inputs.mjs +3 -2
  294. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  295. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  296. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  297. package/foundation/env/semver.mjs +3 -1
  298. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  299. package/foundation/fonts/font-stylesheet.mjs +115 -0
  300. package/foundation/fs/cache-eviction.d.mts +21 -0
  301. package/foundation/fs/cache-eviction.mjs +73 -0
  302. package/foundation/fs/exact-codec.d.mts +12 -2
  303. package/foundation/fs/exact-codec.mjs +23 -6
  304. package/foundation/fs/file-protection.mjs +4 -3
  305. package/foundation/fs/gather-cache.d.mts +62 -4
  306. package/foundation/fs/gather-cache.mjs +512 -91
  307. package/foundation/fs/jiti-cache.d.mts +19 -1
  308. package/foundation/fs/jiti-cache.mjs +130 -6
  309. package/foundation/fs/kept-tree.d.mts +60 -0
  310. package/foundation/fs/kept-tree.mjs +154 -0
  311. package/foundation/fs/listing-cache.d.mts +7 -0
  312. package/foundation/fs/listing-cache.mjs +10 -0
  313. package/foundation/fs/module-loader.d.mts +24 -2
  314. package/foundation/fs/module-loader.mjs +94 -21
  315. package/foundation/fs/paths.d.mts +18 -0
  316. package/foundation/fs/paths.mjs +15 -2
  317. package/foundation/fs/read-record.d.mts +9 -0
  318. package/foundation/fs/read-record.mjs +19 -11
  319. package/foundation/fs/stop-cleanup.d.mts +12 -0
  320. package/foundation/fs/stop-cleanup.mjs +66 -0
  321. package/foundation/identity/provider-identity.d.mts +6 -0
  322. package/foundation/identity/provider-identity.mjs +10 -1
  323. package/foundation/integrations/contribution-inventory.mjs +4 -3
  324. package/foundation/integrations/example-code.d.mts +63 -0
  325. package/foundation/integrations/example-code.mjs +416 -0
  326. package/foundation/integrations/public-imports.d.mts +9 -0
  327. package/foundation/integrations/public-imports.mjs +3 -2
  328. package/foundation/integrations/validate-contributions.mjs +17 -45
  329. package/foundation/render/embedded-files.d.mts +6 -0
  330. package/foundation/render/embedded-files.mjs +25 -5
  331. package/foundation/render/embedded-imports.d.mts +39 -7
  332. package/foundation/render/embedded-imports.mjs +66 -27
  333. package/foundation/render/file-header.d.mts +66 -0
  334. package/foundation/render/file-header.mjs +118 -0
  335. package/foundation/render/host-answer.d.mts +18 -0
  336. package/foundation/render/host-answer.mjs +46 -0
  337. package/foundation/render/host-exit.d.mts +1 -0
  338. package/foundation/render/host-exit.mjs +6 -1
  339. package/foundation/render/html-reader.d.mts +55 -2
  340. package/foundation/render/html-reader.mjs +145 -26
  341. package/foundation/render/markup-edits.d.mts +57 -0
  342. package/foundation/render/markup-edits.mjs +182 -0
  343. package/foundation/render/page-host.mjs +29 -12
  344. package/foundation/render/page-worker.mjs +121 -13
  345. package/foundation/render/picture-chrome.d.mts +4 -0
  346. package/foundation/render/picture-chrome.mjs +185 -0
  347. package/foundation/render/picture-playwright.d.mts +4 -0
  348. package/foundation/render/picture-playwright.mjs +34 -0
  349. package/foundation/render/rebuild.mjs +2 -1
  350. package/foundation/render/render-page.d.mts +35 -3
  351. package/foundation/render/render-page.mjs +641 -96
  352. package/foundation/render/source-block.d.mts +85 -6
  353. package/foundation/render/source-block.mjs +211 -20
  354. package/foundation/render/ts-paths.d.mts +69 -6
  355. package/foundation/render/ts-paths.mjs +326 -40
  356. package/foundation/response/error-codes.d.mts +3 -1
  357. package/foundation/response/error-codes.d.ts +1 -0
  358. package/foundation/response/error-codes.doc.mjs +12 -1
  359. package/foundation/response/error-codes.mjs +11 -1
  360. package/foundation/response/response-types.doc.mjs +2 -2
  361. package/foundation/text/compare-text.d.mts +14 -0
  362. package/foundation/text/compare-text.mjs +68 -0
  363. package/foundation/text/string-utils.d.mts +3 -2
  364. package/foundation/text/string-utils.mjs +18 -4
  365. package/foundation/text/suggest-order.d.mts +9 -0
  366. package/foundation/text/suggest-order.mjs +15 -1
  367. package/foundation/xle/expand.mjs +2 -1
  368. package/host/index.mjs +8 -6
  369. package/package.json +7 -6
@@ -156,7 +156,11 @@ function sweepTemps(dir) {
156
156
  }
157
157
  continue;
158
158
  }
159
- const m = /^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n);
159
+ // A picture taken under its own name (`.<picture>.part-<pid>.png`) by a
160
+ // run stopped while the browser ran.
161
+ const m =
162
+ /^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n) ??
163
+ /^\.[\w-]+\.part-(\d+)\.png$/.exec(n);
160
164
  if (!m) continue;
161
165
  const p = path.join(dir, n);
162
166
  try {
@@ -203,12 +207,14 @@ export function removeEmptyFolder(dir, opts = {}) {
203
207
 
204
208
  /**
205
209
  * 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.
210
+ * write's `.<name>.astryx-<pid>-<random>.tmp`, a build's `.<name>.tmp-<id>`,
211
+ * or a picture's `.<picture>.part-<pid>.png`. A command stopped part way can
212
+ * leave one behind.
208
213
  * @param {string} name
209
214
  */
210
215
  export const isEditorTemp = name =>
211
- /^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name);
216
+ /^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name) ||
217
+ /^\.[\w-]+\.part-\d+\.png$/.test(name);
212
218
 
213
219
  /**
214
220
  * A temp file beside `file` for a whole write, named so only the editor
@@ -0,0 +1,31 @@
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
+ * @file The plain words for parts that Core's catalog cannot give (groups,
13
+ * variants, font roles, phrases of several words, and words two components
14
+ * share), and the part or group one plain word names.
15
+ * @position api/theme-edit — a leaf with no imports, read by _how-question.mjs
16
+ * and _check.mjs
17
+ */
18
+ /**
19
+ * Phrases for parts that Core's catalog cannot give: groups, variants,
20
+ * font roles, phrases of several words, and words two components share.
21
+ * They are read before the catalog's names and doc keywords
22
+ * (partLexicon), longest phrase first.
23
+ * @type {Array<[RegExp, {on: string, when?: string, role?: string, level?: string, missing?: string}]>}
24
+ */
25
+ export const OVERRIDES: Array<[RegExp, {
26
+ on: string;
27
+ when?: string;
28
+ role?: string;
29
+ level?: string;
30
+ missing?: string;
31
+ }]>;
@@ -0,0 +1,126 @@
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
+ [/\b(checkbox(es)?|check ?marks?)\b/, {on: 'checks'}],
90
+ // "switch off", "switch the buttons to" are the verb, not the part.
91
+ [
92
+ /\b(toggles?|switch(?:e?s)?(?! (off|on|to|the|out|it|them|over|back|from)\b))\b/,
93
+ {on: 'switch'},
94
+ ],
95
+ [/\b((table )?cells?)\b/, {on: 'table-cell'}],
96
+ [/\b(table rows?|rows?|tables?)\b/, {on: 'table-row'}],
97
+ [/\b(badges?|chips?|tags?)\b/, {on: 'badge'}],
98
+ [/\bh([1-6])\b/, {on: 'heading'}],
99
+ [/\b(headings?|titles?)\b/, {on: 'heading'}],
100
+ [/\b(modals?|popups?)\b/, {on: 'dialog'}],
101
+ [/\bcode\b/, {on: 'code', role: 'code'}],
102
+ // Small, secondary and supporting text, captions and fine print: the
103
+ // supporting text style, not the base size.
104
+ [
105
+ /\b((?:small|secondary|supporting|helper|hint|caption|muted) (?:text|copy)|fine print|captions?)\b/,
106
+ {on: 'body', role: 'supporting'},
107
+ ],
108
+ [/\bbody( text)?\b/, {on: 'body', role: 'body'}],
109
+ ];
110
+
111
+ /**
112
+ * The part or group a plain word names, as how reads it (`checkboxes` is
113
+ * the checks group, `panels` the containers), or null.
114
+ * @param {string} word
115
+ * @returns {string | null}
116
+ */
117
+ export function partForWord(word) {
118
+ const w = String(word ?? '')
119
+ .trim()
120
+ .toLowerCase();
121
+ if (!w) return null;
122
+ for (const [re, hit] of OVERRIDES)
123
+ if (/** @type {RegExp} */ (re).test(w))
124
+ return /** @type {{on: string}} */ (hit).on;
125
+ return null;
126
+ }
@@ -31,7 +31,8 @@ export function isItemOf(project: import("./_project.mjs").ThemeProject, name: s
31
31
  * A component's catalog entries, all from its doc: its demo props
32
32
  * ({@link demoProps}), then once per value of each visual prop with a
33
33
  * closed set of values (`variant`, `status`, `color`, and a number union
34
- * such as a heading's level), and its checked and disabled states. An
34
+ * such as a heading's level), its checked and disabled states, and each look
35
+ * flag (`isStriped`) turned on. An
35
36
  * overlay the playground shows in place renders open; on a page people
36
37
  * see, once, as some of its variants size the window, not the card.
37
38
  * @param {import('./_project.mjs').ThemeProject} project
@@ -142,6 +143,10 @@ export type PartRecord = {
142
143
  tokens: Record<string, string[]>;
143
144
  values: string[];
144
145
  }>;
146
+ /**
147
+ * - property -> the value under each condition, private variables resolved
148
+ */
149
+ at?: Record<string, Record<string, string>> | undefined;
145
150
  /**
146
151
  * - tokens read by unnamed elements inside the part -> properties
147
152
  */
@@ -154,6 +159,18 @@ export type PartRecord = {
154
159
  * - parts rendered inside it
155
160
  */
156
161
  contains: string[];
162
+ /**
163
+ * - the elements it is rendered as (`tr` for a table row)
164
+ */
165
+ tags?: string[] | undefined;
166
+ /**
167
+ * - the radius tokens of the corners Core draws by place on the parts directly inside it (a button group's end buttons)
168
+ */
169
+ innerCorners?: string[] | undefined;
170
+ /**
171
+ * - state ('' for always) -> property -> the token Core paints it with as an inline style, which no theme rule can replace
172
+ */
173
+ inline?: Record<string, Record<string, string>> | undefined;
157
174
  };
158
175
  export type PaintSide = {
159
176
  target: string | null;
@@ -29,16 +29,33 @@ import {
29
29
  RenderError,
30
30
  } from '../../foundation/render/render-page.mjs';
31
31
  import {SAMPLE_PAGE, elementNames, pageSource} from './_catalog.mjs';
32
+ import {removeOnStop} from '../../foundation/fs/stop-cleanup.mjs';
32
33
 
33
34
  /** Bump when the shape of the cached part data changes. */
34
- const PART_DATA_VERSION = 4;
35
+ const PART_DATA_VERSION = 11;
36
+
37
+ /**
38
+ * Flags that change what a component does or whether it shows, not how it
39
+ * looks: the catalog never turns them on (disabled has its own entry).
40
+ */
41
+ const LIFECYCLE_FLAGS = new Set([
42
+ 'isDisabled',
43
+ 'isOpen',
44
+ 'isDefaultOpen',
45
+ 'hasAutoFocus',
46
+ 'isHidden',
47
+ ]);
35
48
 
36
49
  /**
37
50
  * @typedef {object} PartRecord
38
51
  * @property {Record<string, {tokens: Record<string, string[]>, values: string[]}>} own - property -> tokens (with conditions) and raw values
52
+ * @property {Record<string, Record<string, string>>} [at] - property -> the value under each condition, private variables resolved
39
53
  * @property {Record<string, string[]>} inside - tokens read by unnamed elements inside the part -> properties
40
54
  * @property {Record<string, string[]>} attrs - data attributes seen on the part
41
55
  * @property {string[]} contains - parts rendered inside it
56
+ * @property {string[]} [tags] - the elements it is rendered as (`tr` for a table row)
57
+ * @property {string[]} [innerCorners] - the radius tokens of the corners Core draws by place on the parts directly inside it (a button group's end buttons)
58
+ * @property {Record<string, Record<string, string>>} [inline] - state ('' for always) -> property -> the token Core paints it with as an inline style, which no theme rule can replace
42
59
  */
43
60
 
44
61
  /**
@@ -177,7 +194,8 @@ export function isItemOf(project, name) {
177
194
  * A component's catalog entries, all from its doc: its demo props
178
195
  * ({@link demoProps}), then once per value of each visual prop with a
179
196
  * closed set of values (`variant`, `status`, `color`, and a number union
180
- * such as a heading's level), and its checked and disabled states. An
197
+ * such as a heading's level), its checked and disabled states, and each look
198
+ * flag (`isStriped`) turned on. An
181
199
  * overlay the playground shows in place renders open; on a page people
182
200
  * see, once, as some of its variants size the window, not the card.
183
201
  * @param {import('./_project.mjs').ThemeProject} project
@@ -223,6 +241,12 @@ export function catalogVariants(project, name, cap, opts = {}) {
223
241
  // The states the doc names that a prop sets: checked (a boolean value)
224
242
  // and disabled. The label says the state shown.
225
243
  const states = new Set(info.targets.flatMap(t => t.states ?? []));
244
+ // A value the doc lists beside true and false (a checkbox's
245
+ // 'indeterminate'): rendered too, so the look Core gives it is read.
246
+ if (states.has('checked'))
247
+ for (const word of literals(info.props?.value?.type ?? ''))
248
+ if (word !== 'true' && word !== 'false')
249
+ variants.push({label: word, props: {...base, value: word}});
226
250
  if (states.has('checked') && info.props?.value?.type.startsWith('boolean')) {
227
251
  const on = base.value !== true;
228
252
  variants.push({
@@ -243,6 +267,17 @@ export function catalogVariants(project, name, cap, opts = {}) {
243
267
  if (n !== base[p])
244
268
  variants.push({label: `${p} ${n}`, props: {...base, [p]: n}});
245
269
  }
270
+ // Each look flag the doc names (`isStriped`, `hasHover`), turned on, so
271
+ // the styles Core gives only under it are read too: a table row's hover
272
+ // and stripes come from its table's flags.
273
+ for (const [p, doc] of Object.entries(info.props ?? {}))
274
+ if (
275
+ /^(is|has)[A-Z]/.test(p) &&
276
+ !LIFECYCLE_FLAGS.has(p) &&
277
+ String(/** @type {any} */ (doc)?.type ?? '').trim() === 'boolean' &&
278
+ base[p] !== true
279
+ )
280
+ variants.push({label: p, props: {...base, [p]: true}});
246
281
  return variants.slice(0, cap);
247
282
  }
248
283
 
@@ -367,14 +402,9 @@ export async function renderGenerated(project, file, source, extra = []) {
367
402
  );
368
403
  })();
369
404
  fs.mkdirSync(dir, {recursive: true});
370
- // Stopped by a signal, the render folder still goes.
371
- const cleanup = () => fs.rmSync(dir, {recursive: true, force: true});
372
- const onSignal = (/** @type {NodeJS.Signals} */ sig) => {
373
- cleanup();
374
- process.kill(process.pid, sig);
375
- };
376
- process.once('SIGINT', onSignal);
377
- process.once('SIGTERM', onSignal);
405
+ // Stopped by a signal (the terminal closing too), the render folder
406
+ // still goes.
407
+ const untrack = removeOnStop(dir);
378
408
  const entry = path.join(dir, file);
379
409
  // Demo images point at the docs site's own folder (`/template-assets/…`),
380
410
  // which a page opened from disk cannot reach: the inline placeholder
@@ -430,8 +460,7 @@ export async function renderGenerated(project, file, source, extra = []) {
430
460
  fs.rmSync(f, {force: true});
431
461
  // Another render may still use it: a folder with a file in it stays.
432
462
  removeEmptyFolder(madeThemes ? themes : dir, {deep: true});
433
- process.removeListener('SIGINT', onSignal);
434
- process.removeListener('SIGTERM', onSignal);
463
+ untrack();
435
464
  }
436
465
  }
437
466
 
@@ -473,6 +502,141 @@ export async function partData(project) {
473
502
  return data;
474
503
  }
475
504
 
505
+ /** The tokens Core's indicator focus ring is drawn from, per property. */
506
+ const RING_TOKENS = {
507
+ 'outline-width': '--focus-outline-width',
508
+ 'outline-style': '--focus-outline-style',
509
+ 'outline-color': '--focus-outline-color',
510
+ };
511
+
512
+ /**
513
+ * Add the focus ring a control draws on its indicator at focus time (Core's
514
+ * `useIndicatorFocusRing`, used by a control whose input is visually
515
+ * hidden): an inline style the server render never shows, read from the
516
+ * focus outline tokens. The tokens are read by the indicator always (it
517
+ * never takes focus itself, so no state reaches the ring), and the outline
518
+ * properties are painted inline, which no theme rule can replace. The
519
+ * indicator is the control's own `-indicator` target, or for a part of
520
+ * another component (a radio list's item), that component's.
521
+ * @param {import('./_project.mjs').ThemeProject} project
522
+ * @param {Record<string, PartRecord>} map
523
+ */
524
+ function addIndicatorRings(project, map) {
525
+ for (const [name, info] of Object.entries(project.components)) {
526
+ const at = info.importPath?.split('/').pop();
527
+ let source;
528
+ try {
529
+ source = at
530
+ ? fs.readFileSync(
531
+ path.join(project.coreDir, 'dist', at, `${name}.js`),
532
+ 'utf8',
533
+ )
534
+ : '';
535
+ } catch {
536
+ continue;
537
+ }
538
+ if (!source.includes('useIndicatorFocusRing')) continue;
539
+ /** @param {import('./_project.mjs').ComponentInfo | undefined} c */
540
+ const indicators = c =>
541
+ (c?.targets ?? [])
542
+ .map(t => t.className.replace(/^astryx-/, ''))
543
+ .filter(k => k.endsWith('-indicator'));
544
+ const own = indicators(info);
545
+ const keys = own.length
546
+ ? own
547
+ : indicators(
548
+ info.subComponentOf
549
+ ? project.components[info.subComponentOf]
550
+ : undefined,
551
+ );
552
+ for (const key of keys) {
553
+ const rec = (map[key] ??= {
554
+ own: {},
555
+ inside: {},
556
+ attrs: {},
557
+ contains: [],
558
+ });
559
+ for (const [prop, token] of Object.entries(RING_TOKENS)) {
560
+ rec.inside[token] = [...new Set([...(rec.inside[token] ?? []), prop])];
561
+ (rec.inline ??= {})[''] = {...rec.inline?.[''], [prop]: token};
562
+ }
563
+ }
564
+ }
565
+ }
566
+
567
+ /**
568
+ * Add the paint Core writes as an inline style when it sets a theme state
569
+ * at run time (a table row's selection wash, set by the selection plugin
570
+ * beside the row's `selected` state): something the server render never
571
+ * shows. A built module under a component's folder that writes a state's
572
+ * attribute (`themeDataAttributes({selected: 'selected'})`) and an inline
573
+ * property from a color token (`el.style.backgroundColor = …` with
574
+ * `colorVars['--color-accent-muted']`) paints that state with it, on each
575
+ * of the component's targets that lists the state.
576
+ * @param {import('./_project.mjs').ThemeProject} project
577
+ * @param {Record<string, PartRecord>} map
578
+ */
579
+ function addInlineStatePaint(project, map) {
580
+ const dist = path.join(project.coreDir, 'dist');
581
+ /** @param {string} dir @returns {string[]} */
582
+ const modules = dir => {
583
+ let entries;
584
+ try {
585
+ entries = fs.readdirSync(dir, {withFileTypes: true});
586
+ } catch {
587
+ return [];
588
+ }
589
+ return entries.flatMap(e =>
590
+ e.isDirectory()
591
+ ? modules(path.join(dir, e.name))
592
+ : e.name.endsWith('.js')
593
+ ? [path.join(dir, e.name)]
594
+ : [],
595
+ );
596
+ };
597
+ for (const [name, info] of Object.entries(project.components)) {
598
+ const folder = info.importPath?.split('/').pop();
599
+ if (!folder || folder !== name) continue;
600
+ const withStates = info.targets.filter(t => t.states.length);
601
+ if (!withStates.length) continue;
602
+ for (const file of modules(path.join(dist, folder))) {
603
+ const source = fs.readFileSync(file, 'utf8');
604
+ const states = [
605
+ ...source.matchAll(
606
+ /themeDataAttributes\(\{\s*([\w-]+):\s*'\1'\s*\}\)/g,
607
+ ),
608
+ ].map(m => m[1]);
609
+ if (!states.length) continue;
610
+ const props = [
611
+ ...source.matchAll(/\.style\.([a-z][A-Za-z]*)\s*=(?!=)/g),
612
+ ].map(m => m[1].replace(/[A-Z]/g, c => `-${c.toLowerCase()}`));
613
+ const colorTokens = [
614
+ ...source.matchAll(/colorVars\[['"](--color-[\w-]+)['"]\]/g),
615
+ ].map(m => m[1]);
616
+ if (!props.length || colorTokens.length !== 1) continue;
617
+ for (const t of withStates) {
618
+ const key = t.className.replace(/^astryx-/, '');
619
+ const rec = map[key];
620
+ if (!rec) continue;
621
+ for (const state of states.filter(st => t.states.includes(st)))
622
+ for (const prop of props) {
623
+ (rec.inline ??= {})[state] = {
624
+ ...rec.inline?.[state],
625
+ [prop]: colorTokens[0],
626
+ };
627
+ const own = (rec.own[prop] ??= {tokens: {}, values: []});
628
+ own.tokens[colorTokens[0]] = [
629
+ ...new Set([
630
+ ...(own.tokens[colorTokens[0]] ?? []),
631
+ `${state}=${state}`,
632
+ ]),
633
+ ];
634
+ }
635
+ }
636
+ }
637
+ }
638
+ }
639
+
476
640
  /**
477
641
  * Build the part data: render the catalog, then walk its markup.
478
642
  * @param {import('./_project.mjs').ThemeProject} project
@@ -497,6 +661,8 @@ async function buildPartData(project) {
497
661
  }
498
662
  const tokens = new Set(Object.keys(project.core.tokenDefaults ?? {}));
499
663
  const result = walkMarkup(markup, declarations(css), tokens);
664
+ addInlineStatePaint(project, result.map);
665
+ addIndicatorRings(project, result.map);
500
666
  return {
501
667
  version: PART_DATA_VERSION,
502
668
  coreKey: project.coreKey,
@@ -666,6 +832,24 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
666
832
  return out;
667
833
  }
668
834
 
835
+ /**
836
+ * A value with the private variables set on the element or its ancestors
837
+ * put in (a variable with no fallback only), so it reads public tokens and
838
+ * literal values alone where it can.
839
+ * @param {string} v
840
+ * @param {Record<string, string>} env
841
+ * @param {Set<string>} tokens
842
+ * @param {number} [depth]
843
+ * @returns {string}
844
+ */
845
+ function resolvePrivate(v, env, tokens, depth = 0) {
846
+ if (depth > 8) return v;
847
+ const out = v.replace(/var\((--[a-zA-Z0-9_-]+)\)/g, (m, name) =>
848
+ !tokens.has(name) && env[name] != null ? env[name] : m,
849
+ );
850
+ return out === v ? v : resolvePrivate(out, env, tokens, depth + 1);
851
+ }
852
+
669
853
  /**
670
854
  * Walk server-rendered markup: for each element, its classes' declarations
671
855
  * become what its part reads; text records the color pair it sits on.
@@ -675,7 +859,7 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
675
859
  * @returns {{map: Record<string, PartRecord>, pairs: TextPair[]}}
676
860
  */
677
861
  export function walkMarkup(html, decls, tokens) {
678
- /** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>}>} */
862
+ /** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, at: Record<string, Record<string, string>>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>, tags: Set<string>, innerCorners: Set<string>}>} */
679
863
  const map = {};
680
864
  /** @type {Array<{env: Record<string, string>, target: string | null, fg: PaintSide | null, bg: PaintSide | null}>} */
681
865
  const stack = [{env: {}, target: null, fg: null, bg: null}];
@@ -709,10 +893,21 @@ export function walkMarkup(html, decls, tokens) {
709
893
  const dataAttrs = Object.fromEntries(
710
894
  [
711
895
  ...attrs.matchAll(
712
- /data-(variant|status|size|selected|state|elevation|tone|color|level|weight)="([^"]*)"/g,
896
+ /data-(variant|status|size|selected|state|elevation|tone|color|level|weight|checked)="([^"]*)"/g,
713
897
  ),
714
898
  ].map(x => [x[1], x[2]]),
715
899
  );
900
+ // The place another component puts a part in (the current page's
901
+ // button in a pagination, a pressed toggle) is a condition of what that
902
+ // component styles it with there, never the part's look at rest. A part
903
+ // that marks the place with a theme state of its own (a selected tab)
904
+ // is conditioned by that state already.
905
+ const ownState = ['selected', 'checked', 'state'].some(k => k in dataAttrs);
906
+ const context = ownState
907
+ ? []
908
+ : [...attrs.matchAll(/\baria-(current|pressed)="([^"]*)"/g)]
909
+ .filter(x => x[2] !== 'false')
910
+ .map(x => `${x[1]}=${x[2]}`);
716
911
  const parent = stack[stack.length - 1];
717
912
  const env = {...parent.env};
718
913
  const own = cls.flatMap(c => decls.get(c) ?? []);
@@ -723,25 +918,39 @@ export function walkMarkup(html, decls, tokens) {
723
918
  );
724
919
  const target = named[0]?.slice(7) ?? parent.target;
725
920
  const ownsTarget = named.length > 0;
726
- if (target) {
727
- const T = (map[target] ??= {
921
+ // An element can carry several targets (a shell's side nav region is a
922
+ // layout panel too): its declarations are each one's own.
923
+ for (const t of ownsTarget ? named.map(c => c.slice(7)) : [target]) {
924
+ if (!t) continue;
925
+ const T = (map[t] ??= {
728
926
  own: {},
927
+ at: {},
729
928
  inside: {},
730
929
  attrs: {},
731
930
  contains: new Set(),
931
+ tags: new Set(),
932
+ innerCorners: new Set(),
732
933
  });
733
934
  if (ownsTarget)
734
935
  for (const [k, v] of Object.entries(dataAttrs))
735
936
  (T.attrs[k] ??= new Set()).add(v);
736
- const cond0 = Object.entries(dataAttrs)
737
- .map(([k, v]) => `${k}=${v}`)
738
- .join(',');
937
+ const cond0 = [
938
+ ...Object.entries(dataAttrs).map(([k, v]) => `${k}=${v}`),
939
+ ...context,
940
+ ].join(',');
739
941
  for (const d of own) {
740
942
  if (d.prop.startsWith('--')) continue;
943
+ // (An inherited background paints nothing of its own: it reads no
944
+ // token, and what shows is its parent's.)
741
945
  const toks = expand(d.value, env, tokens);
742
946
  const cond = [cond0, d.cond].filter(Boolean).join(' ');
743
947
  if (ownsTarget) {
744
948
  const P = (T.own[d.prop] ??= {tokens: {}, values: new Set()});
949
+ (T.at[d.prop] ??= {})[cond || 'always'] ??= resolvePrivate(
950
+ d.value,
951
+ env,
952
+ tokens,
953
+ );
745
954
  P.values.add(
746
955
  d.value.length > 80 ? `${d.value.slice(0, 80)}...` : d.value,
747
956
  );
@@ -763,14 +972,25 @@ export function walkMarkup(html, decls, tokens) {
763
972
  }
764
973
  if (d.prop === 'background-color') {
765
974
  const t = [...expand(d.value, env, tokens)];
766
- if (t.length || !/transparent/.test(d.value))
975
+ if (t.length || !/transparent|^\s*inherit\s*$/i.test(d.value))
767
976
  bg = {target, tokens: t, raw: t.length ? null : d.value};
768
977
  }
769
978
  }
770
- if (ownsTarget && target)
979
+ for (const t of ownsTarget ? named.map(c => c.slice(7)) : [])
771
980
  for (const anc of stack)
772
- if (anc.target && anc.target !== target)
773
- map[anc.target].contains.add(target);
981
+ if (anc.target && anc.target !== t) map[anc.target].contains.add(t);
982
+ if (ownsTarget) {
983
+ for (const t of named) map[t.slice(7)].tags.add(tag.toLowerCase());
984
+ // Corners Core draws on a part by its place among its siblings (a
985
+ // button group's first and last buttons): the radius token they read
986
+ // is the enclosing part's corners.
987
+ if (parent.target && !named.includes(`astryx-${parent.target}`))
988
+ for (const d of own)
989
+ if (/^border-(start|end)-(start|end)-radius$/.test(d.prop))
990
+ for (const tok of expand(d.value, env, tokens))
991
+ if (/^--radius-/.test(tok))
992
+ map[parent.target].innerCorners.add(tok);
993
+ }
774
994
  if (!selfClose && !VOID.has(tag.toLowerCase()))
775
995
  stack.push({env, target, fg, bg});
776
996
  }
@@ -792,6 +1012,7 @@ export function walkMarkup(html, decls, tokens) {
792
1012
  },
793
1013
  ]),
794
1014
  ),
1015
+ at: v.at,
795
1016
  inside: Object.fromEntries(
796
1017
  Object.entries(v.inside).map(([k, s]) => [k, [...s]]),
797
1018
  ),
@@ -799,6 +1020,8 @@ export function walkMarkup(html, decls, tokens) {
799
1020
  Object.entries(v.attrs).map(([k, s]) => [k, [...s]]),
800
1021
  ),
801
1022
  contains: [...v.contains],
1023
+ tags: [...v.tags],
1024
+ innerCorners: [...v.innerCorners],
802
1025
  };
803
1026
  }
804
1027
  return {map: out, pairs: [...pairs.values()]};
@@ -68,12 +68,18 @@ export function refreshPreviewRoute(cwd: string, slug: string): Promise<{
68
68
  * @param {'colors' | 'components' | 'overview'} focus
69
69
  * @param {{code: string, cause: string} | null} [notChecked] why the change
70
70
  * could not be rendered
71
+ * @param {{pictureProblem?: string | null, stale?: string[]}} [extra] this
72
+ * result's picture problem (what kept --png from taking pictures) and its
73
+ * previewStale entries (an in-app preview changed by hand)
71
74
  * @returns {string}
72
75
  */
73
76
  export function seeLine(cwd: string, slug: string, focus: "colors" | "components" | "overview", notChecked?: {
74
77
  code: string;
75
78
  cause: string;
76
- } | null): string;
79
+ } | null, extra?: {
80
+ pictureProblem?: string | null;
81
+ stale?: string[];
82
+ }): string;
77
83
  /**
78
84
  * Add pages to the in-app theme preview, and write the preview route the
79
85
  * first time. With a description, the build ranking picks the template