@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
@@ -1,6 +1,13 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The colors written inside a value (a shadow's layers, a gradient's
6
+ * stops): each hex color and each color function, in order.
7
+ * @param {string} value
8
+ * @returns {string[]}
9
+ */
10
+ export function colorsIn(value: string): string[];
4
11
  /**
5
12
  * The opacity of a CSS color, 0 to 1: the alpha of an 8- or 4-digit hex,
6
13
  * `rgba()`/`hsla()`, or a `/ alpha` part; 0 for `transparent`; 1 otherwise.
@@ -72,6 +79,9 @@ export function isSafeValue(v: string): boolean;
72
79
  export { splitTop };
73
80
  /** The CSS named colors, for suggestions. */
74
81
  export const COLOR_NAMES: string[];
82
+ export function namedColorHex(name: string): string | null;
83
+ /** One color written inside a value: a hex color or a color function. */
84
+ export const COLOR_IN_VALUE: RegExp;
75
85
  export function hex(rgb: number[]): string;
76
86
  export function isColorValue(v: unknown): boolean;
77
87
  export function isSize(v: unknown, name?: string): boolean;
@@ -179,6 +179,14 @@ const NAMED = wordTable(
179
179
  /** The CSS named colors, for suggestions. */
180
180
  export const COLOR_NAMES = Object.keys(NAMED);
181
181
 
182
+ /**
183
+ * The hex a CSS color name is, or null.
184
+ * @param {string} name
185
+ * @returns {string | null}
186
+ */
187
+ export const namedColorHex = name =>
188
+ Object.hasOwn(NAMED, name) ? NAMED[name] : null;
189
+
182
190
  /** Color keywords that are valid colors but have no fixed value. */
183
191
  const KEYWORDS = ['transparent', 'currentcolor', ...CSS_WIDE];
184
192
 
@@ -441,6 +449,20 @@ const polar = (c, h) => [
441
449
  c * Math.sin((h * Math.PI) / 180),
442
450
  ];
443
451
 
452
+ /**
453
+ * The colors written inside a value (a shadow's layers, a gradient's
454
+ * stops): each hex color and each color function, in order.
455
+ * @param {string} value
456
+ * @returns {string[]}
457
+ */
458
+ export function colorsIn(value) {
459
+ return [...String(value ?? '').matchAll(COLOR_IN_VALUE)].map(m => m[0]);
460
+ }
461
+
462
+ /** One color written inside a value: a hex color or a color function. */
463
+ export const COLOR_IN_VALUE =
464
+ /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\((?:[^()]|\([^()]*\))*\)/gi;
465
+
444
466
  /**
445
467
  * The opacity of a CSS color, 0 to 1: the alpha of an 8- or 4-digit hex,
446
468
  * `rgba()`/`hsla()`, or a `/ alpha` part; 0 for `transparent`; 1 otherwise.
@@ -514,7 +536,33 @@ export function mixSide(side) {
514
536
  if (w == null) return null;
515
537
  const plain = /^calc\(\s*(.*?)\s*\)$/i.exec(w)?.[1] ?? w;
516
538
  const n = cssNumber(plain);
517
- return n?.unit === '%' ? n.value : null;
539
+ if (n) return n.unit === '%' ? n.value : null;
540
+ // Math of two terms that gives a percentage: percentages added or
541
+ // taken away (`25% + 25%`), a percentage scaled by a number
542
+ // (`50% * 1`, `100% / 2`).
543
+ const m = /^(\S+)\s*([*/+-])\s*(\S+)$/.exec(plain);
544
+ if (!m) return null;
545
+ const [a, b] = [cssNumber(m[1]), cssNumber(m[3])];
546
+ if (!a || !b) return null;
547
+ const pct = (/** @type {{unit: string}} */ x) => x.unit === '%';
548
+ const plainNum = (/** @type {{unit: string}} */ x) => x.unit === '';
549
+ const r =
550
+ m[2] === '+' || m[2] === '-'
551
+ ? pct(a) && pct(b)
552
+ ? m[2] === '+'
553
+ ? a.value + b.value
554
+ : a.value - b.value
555
+ : null
556
+ : m[2] === '*'
557
+ ? pct(a) && plainNum(b)
558
+ ? a.value * b.value
559
+ : plainNum(a) && pct(b)
560
+ ? a.value * b.value
561
+ : null
562
+ : pct(a) && plainNum(b) && b.value !== 0
563
+ ? a.value / b.value
564
+ : null;
565
+ return r != null && Number.isFinite(r) ? r : null;
518
566
  };
519
567
  if (words.length < 2) return {color: side.trim(), pct: null};
520
568
  const last = share(words.at(-1));
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import {DIRECT, GROUPS, HOW} from './_tables.mjs';
13
+ import {splitTop} from './_css.mjs';
13
14
  import {quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
14
15
 
15
16
  /** Only these token types may differ between light and dark. */
@@ -115,8 +116,12 @@ export function makeCompiler(project, parts) {
115
116
  const kept = (attrPart.includes('=') ? attrPart.split(',') : []).filter(
116
117
  kv => {
117
118
  const [k] = kv.split('=');
119
+ // (The place another component puts the part in, from the part
120
+ // data's context conditions, stays: it is never the part at rest.)
118
121
  return (
119
122
  k === 'selected' ||
123
+ k === 'current' ||
124
+ k === 'pressed' ||
120
125
  (['variant', 'status', 'tone', 'color'].includes(k) &&
121
126
  (attrs[k]?.length ?? 0) > 1)
122
127
  );
@@ -384,7 +389,16 @@ export function makeCompiler(project, parts) {
384
389
  function variantValues(target) {
385
390
  const comp = TARGET.get(target)?.component;
386
391
  const info = comp ? project.components[comp] : undefined;
392
+ // The component named like the part (Heading for heading) owns its
393
+ // values before any other component whose docs name the same class.
394
+ const pascal = target.replace(/(^|-)([a-z0-9])/g, (_, __, ch) =>
395
+ ch.toUpperCase(),
396
+ );
397
+ const own = project.components?.[pascal]?.targets?.find(
398
+ (/** @type {any} */ x) => x.className === `astryx-${target}`,
399
+ );
387
400
  const t =
401
+ own ??
388
402
  info?.targets.find(x => x.className === `astryx-${target}`) ??
389
403
  info?.targets[0];
390
404
  const fromDocs = t?.values ?? {};
@@ -393,9 +407,55 @@ export function makeCompiler(project, parts) {
393
407
  const out = {};
394
408
  for (const p of TARGET.get(target)?.props ?? [])
395
409
  out[p] = fromDocs[p]?.length ? fromDocs[p] : (seen[p] ?? []);
410
+ // A state Core marks with more than one value (a checkbox's checked and
411
+ // indeterminate looks) is a condition --when names by value.
412
+ for (const st of TARGET.get(target)?.states ?? [])
413
+ if ((seen[st] ?? []).some(v => v !== st)) out[st] = seen[st];
396
414
  return out;
397
415
  }
398
416
 
417
+ /**
418
+ * The color stops of a background made of gradients, or null when any
419
+ * layer is an image or any stop has no color the editor can name.
420
+ * @param {string} v
421
+ * @returns {string[] | null}
422
+ */
423
+ function gradientStops(v) {
424
+ /** The parts between commas outside parentheses. @param {string} x */
425
+ const top = x =>
426
+ splitTop(x, ',')
427
+ .map(part => part.trim())
428
+ .filter(Boolean);
429
+ /** @type {string[]} */
430
+ const stops = [];
431
+ for (const layer of top(v)) {
432
+ const m =
433
+ /^(?:repeating-)?(?:linear|radial|conic)-gradient\((.*)\)$/s.exec(
434
+ layer,
435
+ );
436
+ if (!m) {
437
+ // A layer that is one color (the shorthand's last) is a stop too.
438
+ if (/url\(|gradient\(/.test(layer)) return null;
439
+ stops.push(layer);
440
+ continue;
441
+ }
442
+ for (const arg of top(m[1])) {
443
+ // The direction, shape or position comes first, with no color.
444
+ if (
445
+ /^(to\b|at\b|from\b|-?[\d.]+(deg|turn|rad|grad)\b|circle\b|ellipse\b|closest|farthest)/.test(
446
+ arg,
447
+ )
448
+ )
449
+ continue;
450
+ // A stop is its color and up to two positions after it.
451
+ const color = arg.replace(/(\s+-?[\d.]+(%|px|rem|em)?)+$/, '').trim();
452
+ if (!color || /^-?[\d.]+(%|px|rem|em)?$/.test(color)) continue;
453
+ stops.push(color);
454
+ }
455
+ }
456
+ return stops.length ? stops : null;
457
+ }
458
+
399
459
  /**
400
460
  * Text that this theme made unreadable: every real text-on-background pair,
401
461
  * in each mode, below 4.5:1 now but not as low in the base theme. Also
@@ -446,9 +506,30 @@ export function makeCompiler(project, parts) {
446
506
  continue;
447
507
  for (const m of modes) {
448
508
  const fg = value(p, 'fg', m);
449
- const bg = value(p, 'bg', m);
450
- if (/gradient|url\(/.test(String(bg))) continue;
451
- const pair = drawn(fg, bg, m);
509
+ const whole = value(p, 'bg', m);
510
+ // A gradient is measured at each of its color stops, the worst one
511
+ // counting; an image, or a stop with no fixed color, is not checked.
512
+ const stops = /gradient|url\(/.test(String(whole))
513
+ ? gradientStops(String(whole))
514
+ : [whole];
515
+ if (!stops) {
516
+ if (whole !== baseValue(p, 'bg', m)) unchecked.add(String(whole));
517
+ continue;
518
+ }
519
+ const measured = stops.map(stop => ({stop, pair: drawn(fg, stop, m)}));
520
+ if (stops.length > 1 && measured.some(x => !x.pair)) {
521
+ if (whole !== baseValue(p, 'bg', m)) unchecked.add(String(whole));
522
+ continue;
523
+ }
524
+ const worst = measured.reduce((a, b) =>
525
+ a.pair &&
526
+ b.pair &&
527
+ ratio(b.pair[0], b.pair[1]) < ratio(a.pair[0], a.pair[1])
528
+ ? b
529
+ : a,
530
+ );
531
+ const bg = worst.stop;
532
+ const pair = worst.pair;
452
533
  if (!pair) {
453
534
  for (const [v, side] of /** @type {const} */ ([
454
535
  [fg, 'fg'],
@@ -483,9 +564,11 @@ export function makeCompiler(project, parts) {
483
564
  : (p.fg.tokens[0] ?? String(fg)),
484
565
  bgPart: p.bg.target,
485
566
  bg:
486
- bg !== baseValue(p, 'bg', m)
487
- ? String(bg)
488
- : (p.bg.tokens[0] ?? String(bg)),
567
+ stops.length > 1
568
+ ? `${bg}, a stop of its gradient`
569
+ : bg !== baseValue(p, 'bg', m)
570
+ ? String(bg)
571
+ : (p.bg.tokens[0] ?? String(bg)),
489
572
  });
490
573
  }
491
574
  }
@@ -101,9 +101,9 @@ export function pictures(project: import("./_project.mjs").ThemeProject, shots:
101
101
  problem: string | null;
102
102
  }>;
103
103
  /**
104
- * Font notes for the settings: the import line for an open font, the
105
- * install line when its package is missing, and a warning for a family no
106
- * package loads, naming the closest open font.
104
+ * Font notes for the families the theme builds: the import line for an
105
+ * open font, the install line when its package is missing, and a warning
106
+ * for a family no package loads, naming the closest open font.
107
107
  * @param {import('./_settings.mjs').Ctx} ctx
108
108
  * @param {import('./_settings.mjs').ThemeData} data
109
109
  * @returns {string[]}
@@ -40,18 +40,30 @@ import {partData} from './_parts.mjs';
40
40
  import {writeWhole} from './_palette.mjs';
41
41
  import {
42
42
  fontOf,
43
+ builtFontFamilies,
43
44
  fontPackages,
45
+ fontsourcePackageOf,
44
46
  modesOf,
45
47
  nearest,
46
48
  refuse,
47
- adoptOlderPicture,
48
49
  editorWrote,
49
50
  recordWritten,
50
51
  themeFiles,
51
52
  refuseThemesNotFolder,
53
+ shown,
52
54
  } from './_settings.mjs';
53
- import {SHOWCASE_GROUPS, renderPreview, screenshot} from './_preview.mjs';
55
+ import {
56
+ SHOWCASE_GROUPS,
57
+ copyFontsCss,
58
+ newPictureRun,
59
+ renderPreview,
60
+ screenshot,
61
+ } from './_preview.mjs';
54
62
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
63
+ import {
64
+ fontKey,
65
+ importedFontFamilies,
66
+ } from '../../foundation/fonts/font-stylesheet.mjs';
55
67
 
56
68
  const E = ERROR_CODES;
57
69
 
@@ -384,8 +396,10 @@ const notChecked = cause =>
384
396
  export async function pictures(project, shots, modes) {
385
397
  /** @type {string[]} */
386
398
  const files = [];
387
- /** @type {string[]} */
388
- const cut = [];
399
+ /** What a later browser's success says of an earlier one. @type {string[]} */
400
+ const notes = [];
401
+ /** One run for every picture: a browser that failed is not tried again. */
402
+ const run = newPictureRun();
389
403
  /** @param {string} png @param {'light' | 'dark'} m */
390
404
  const outOf = (png, m) =>
391
405
  modes.length > 1 && m === 'dark' ? png.replace(/\.png$/, '-dark.png') : png;
@@ -398,21 +412,17 @@ export async function pictures(project, shots, modes) {
398
412
  : null;
399
413
  };
400
414
  // A picture is written only over a picture the editor took, unchanged
401
- // since: a file of the user's by that name blocks every picture, and is
402
- // named.
403
- /** Pictures an older editor took, now recorded. @type {string[]} */
404
- const adopted = [];
415
+ // since: a file of the user's by that name (a screenshot of the same
416
+ // size included) blocks every picture, and is named.
405
417
  const blocked = shots
406
418
  .flatMap(({png}) => modes.map(m => outOf(png, m)))
407
419
  .filter(out => {
408
420
  const slug = themeOf(out);
409
- if (!slug || !fs.existsSync(out) || editorWrote(project.cwd, slug, out))
410
- return false;
411
- if (adoptOlderPicture(project.cwd, slug, out)) {
412
- adopted.push(path.relative(project.cwd, out));
413
- return false;
414
- }
415
- return true;
421
+ return (
422
+ Boolean(slug) &&
423
+ fs.existsSync(out) &&
424
+ !editorWrote(project.cwd, /** @type {string} */ (slug), out)
425
+ );
416
426
  });
417
427
  if (blocked.length)
418
428
  return {
@@ -422,8 +432,58 @@ export async function pictures(project, shots, modes) {
422
432
  for (const {html, png} of shots) {
423
433
  for (const m of modes) {
424
434
  const out = outOf(png, m);
425
- const r = await screenshot(project, html, out, m);
426
- if (!r.ok) return {files, problem: r.reason};
435
+ // Taken under a name of its own and moved into place once whole: a
436
+ // run stopped while the browser runs leaves no picture at the real
437
+ // name (one the next run would read as a file of yours). A part left
438
+ // by a run stopped before is cleared.
439
+ const part = path.join(
440
+ path.dirname(out),
441
+ `.${path.basename(out, '.png')}.part-${process.pid}.png`,
442
+ );
443
+ for (const n of fs.existsSync(path.dirname(out))
444
+ ? fs.readdirSync(path.dirname(out))
445
+ : [])
446
+ if (n.startsWith(`.${path.basename(out, '.png')}.part-`)) {
447
+ // Only a file is a part: a folder by that name is left alone.
448
+ const p = path.join(path.dirname(out), n);
449
+ try {
450
+ if (fs.lstatSync(p).isFile()) fs.rmSync(p, {force: true});
451
+ } catch {
452
+ // Gone already.
453
+ }
454
+ }
455
+ // A folder (or anything else) where this run's part goes: no
456
+ // picture, the path named, never a crash after a saved change.
457
+ if (fs.existsSync(part) && !fs.lstatSync(part).isFile())
458
+ return {
459
+ files,
460
+ problem: `${path.relative(project.cwd, part)} is a folder, where --png writes a picture before moving it into place, so no picture was taken; move it out of ${path.relative(project.cwd, path.dirname(out))}/`,
461
+ };
462
+ // A folder it cannot write gets no picture: named before the browser
463
+ // starts, never read as a browser that failed.
464
+ try {
465
+ fs.accessSync(path.dirname(out), fs.constants.W_OK);
466
+ } catch (e) {
467
+ return {
468
+ files,
469
+ problem: `${path.relative(project.cwd, path.dirname(out))}/ cannot be written (${/** @type {any} */ (e)?.code ?? 'no access'}), so no picture was taken; fix its permissions, then run the command again`,
470
+ };
471
+ }
472
+ const r = await screenshot(project, html, part, m, run);
473
+ if (!r.ok) {
474
+ fs.rmSync(part, {force: true});
475
+ return {files, problem: r.reason};
476
+ }
477
+ try {
478
+ fs.renameSync(part, out);
479
+ } catch (e) {
480
+ fs.rmSync(part, {force: true});
481
+ return {
482
+ files,
483
+ problem: `the picture could not be moved into ${path.relative(project.cwd, out)} (${/** @type {any} */ (e)?.code ?? e})`,
484
+ };
485
+ }
486
+ r.file = path.relative(project.cwd, out).split(path.sep).join('/');
427
487
  files.push(r.file);
428
488
  // A picture in a theme folder is recorded as the editor's, so a later
429
489
  // change removes it and never a picture of the user's.
@@ -440,31 +500,20 @@ export async function pictures(project, shots, modes) {
440
500
  }
441
501
  recordWritten(project.cwd, slug, [out]);
442
502
  }
443
- if (r.cut) cut.push(r.file);
503
+ if (r.note && !notes.includes(r.note)) notes.push(r.note);
444
504
  }
445
505
  }
446
- const adoptedNote = adopted.length
447
- ? `${adopted.join(', ')} ${adopted.length === 1 ? 'was' : 'were'} taken by an earlier version of the editor and ${adopted.length === 1 ? 'is' : 'are'} now recorded as its own`
448
- : null;
449
506
  return {
450
507
  files,
451
- // A picture of the window shows the top of a longer page only.
452
- problem:
453
- [
454
- adoptedNote,
455
- cut.length
456
- ? `${cut.join(', ')} show${cut.length === 1 ? 's' : ''} the top 2400 pixels of the page only (Chrome takes the window, not the whole page); open the .html beside ${cut.length === 1 ? 'it' : 'them'} to see all of it, or install Playwright (${installLine(project.cwd, ['playwright'])}) for whole-page pictures`
457
- : null,
458
- ]
459
- .filter(Boolean)
460
- .join('; ') || null,
508
+ // Pictures were taken; a note says why an earlier browser did not.
509
+ problem: notes.join('; ') || null,
461
510
  };
462
511
  }
463
512
 
464
513
  /**
465
- * Font notes for the settings: the import line for an open font, the
466
- * install line when its package is missing, and a warning for a family no
467
- * package loads, naming the closest open font.
514
+ * Font notes for the families the theme builds: the import line for an
515
+ * open font, the install line when its package is missing, and a warning
516
+ * for a family no package loads, naming the closest open font.
468
517
  * @param {import('./_settings.mjs').Ctx} ctx
469
518
  * @param {import('./_settings.mjs').ThemeData} data
470
519
  * @returns {string[]}
@@ -499,9 +548,16 @@ export function fontNotes(ctx, data) {
499
548
  first.replace(/["']/g, '').trim().toLowerCase() === f,
500
549
  );
501
550
  };
551
+ // A font setting whose family the build no longer uses (the theme's own
552
+ // source sets every place it went) gets no note: nothing shows it.
553
+ const built = builtFontFamilies(ctx, data.name);
502
554
  for (const s of data.settings) {
503
555
  if (
504
556
  s.thing !== 'font' ||
557
+ (built &&
558
+ !built.has(
559
+ fontOf(s.value).family.replace(/["']/g, '').trim().toLowerCase(),
560
+ )) ||
505
561
  SYSTEM_FONTS.includes(s.value) ||
506
562
  isDesktopFamily(fontOf(s.value).family.replace(/["']/g, '')) ||
507
563
  OPEN_FONTS[s.value] ||
@@ -529,7 +585,34 @@ export function fontNotes(ctx, data) {
529
585
  continue;
530
586
  }
531
587
  notes.push(
532
- `"${fontOf(s.value).family.replace(/^["']|["']$/g, '')}" is not a system font and no package loads it: the app must load it, or it falls back.${near ? ` The closest open font is ${near}: ${P} set ${data.name} font ${near}${s.on ? ` --on ${s.on}` : ''}` : ''}`,
588
+ `"${named}" is not a system font and no package loads it: the app must load it, or it falls back. If Fontsource publishes it, ${installLine(ctx.project.cwd, [fontsourcePackageOf(named)])} installs its package, which the previews and the app copy then load.${near ? ` The closest open font is ${near}: ${P} set ${data.name} font ${near}${s.on ? ` --on ${s.on}` : ''}` : ''}`,
589
+ );
590
+ }
591
+ // Every other family the build writes that nothing loads (a part's own
592
+ // font, a font token, a family the theme's own source sets) is named
593
+ // once, with the package that would load it: the same built families
594
+ // the app copy and the previews load fonts for.
595
+ /** @type {Set<string>} */
596
+ const loaded = new Set();
597
+ for (const spec of copyFontsCss(ctx, data.name, data))
598
+ for (const f of importedFontFamilies(spec, ctx.project.cwd)) loaded.add(f);
599
+ const dialFamilies = new Set(
600
+ data.settings
601
+ .filter(s => s.thing === 'font')
602
+ .map(s => fontKey(fontOf(s.value).family)),
603
+ );
604
+ for (const family of built?.values() ?? []) {
605
+ const key = fontKey(family);
606
+ if (
607
+ loaded.has(key) ||
608
+ dialFamilies.has(key) ||
609
+ packages.some(x => fontKey(x.family) === key) ||
610
+ isDesktopFamily(family) ||
611
+ oneSystemOf(family)
612
+ )
613
+ continue;
614
+ notes.push(
615
+ `"${family}" is not a system font and no package loads it: the app must load it, or it falls back. If Fontsource publishes it, ${installLine(ctx.project.cwd, [fontsourcePackageOf(family)])} installs its package, which the previews and the app copy then load.`,
533
616
  );
534
617
  }
535
618
  return notes;
@@ -570,30 +653,52 @@ export function styledChanges(before, after, base) {
570
653
  : p.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
571
654
  for (const prop of new Set([...Object.keys(x), ...Object.keys(y)])) {
572
655
  if (JSON.stringify(x[prop]) === JSON.stringify(y[prop])) continue;
573
- // Writing what the base theme already shows there changes nothing.
574
656
  const shown = base?.components?.[target]?.[key]?.[prop];
575
- if (
576
- x[prop] === undefined &&
577
- shown !== undefined &&
578
- plain(shown) === plain(y[prop])
579
- )
580
- continue;
657
+ /**
658
+ * Whether a write only repeats what the base theme already shows
659
+ * there, which changes nothing.
660
+ * @param {any} was @param {any} now @param {any} baseValue
661
+ */
662
+ const repeatsBase = (was, now, baseValue) =>
663
+ was === undefined &&
664
+ baseValue !== undefined &&
665
+ typeof baseValue !== 'object' &&
666
+ plain(baseValue) === plain(now);
581
667
  const where = `${target}${key === 'base' ? '' : ` ${key}`}`;
582
- // A state block (`:hover`) lists each property it changes.
668
+ // A block (a state, `:hover`, a mode block, a state inside a mode
669
+ // block) lists each property it changes, under its path.
670
+ /**
671
+ * @param {string} path @param {any} xs @param {any} ys @param {any} shownIn
672
+ */
673
+ const blockLines = (path, xs, ys, shownIn) => {
674
+ for (const p of new Set([
675
+ ...Object.keys(xs ?? {}),
676
+ ...Object.keys(ys ?? {}),
677
+ ])) {
678
+ const was = xs?.[p];
679
+ const now = ys?.[p];
680
+ if (JSON.stringify(was) === JSON.stringify(now)) continue;
681
+ if (
682
+ (now && typeof now === 'object') ||
683
+ (was && typeof was === 'object')
684
+ ) {
685
+ blockLines(`${path} ${p}`, was ?? {}, now ?? {}, shownIn?.[p]);
686
+ continue;
687
+ }
688
+ if (repeatsBase(was, now, shownIn?.[p])) continue;
689
+ out.push(
690
+ `${where} ${path}: ${cssName(p)} ${now === undefined ? '(removed)' : String(now)}`,
691
+ );
692
+ }
693
+ };
583
694
  if (
584
- prop.startsWith(':') &&
585
- ((y[prop] && typeof y[prop] === 'object') ||
586
- (x[prop] && typeof x[prop] === 'object'))
695
+ (y[prop] && typeof y[prop] === 'object') ||
696
+ (x[prop] && typeof x[prop] === 'object')
587
697
  ) {
588
- const xs = x[prop] ?? {};
589
- const ys = y[prop] ?? {};
590
- for (const p of new Set([...Object.keys(xs), ...Object.keys(ys)]))
591
- if (JSON.stringify(xs[p]) !== JSON.stringify(ys[p]))
592
- out.push(
593
- `${where} ${prop}: ${cssName(p)} ${ys[p] === undefined ? '(removed)' : String(ys[p])}`,
594
- );
698
+ blockLines(prop, x[prop] ?? {}, y[prop] ?? {}, shown);
595
699
  continue;
596
700
  }
701
+ if (repeatsBase(x[prop], y[prop], shown)) continue;
597
702
  out.push(
598
703
  `${where}: ${cssName(prop)} ${y[prop] === undefined ? '(removed)' : typeof y[prop] === 'string' ? y[prop] : JSON.stringify(y[prop])}`,
599
704
  );
@@ -650,6 +755,7 @@ export async function previewAfter(ctx, slug, data, png) {
650
755
  /** @type {string | null} */
651
756
  let preview = null;
652
757
  let cause = ctx.unchecked ?? null;
758
+ const f0 = themeFiles(ctx.project.cwd, slug);
653
759
  try {
654
760
  preview = await renderPreview(ctx, slug, data);
655
761
  } catch (e) {
@@ -659,7 +765,12 @@ export async function previewAfter(ctx, slug, data, png) {
659
765
  ? renderCause(ctx.project, /** @type {Error} */ (e).message)
660
766
  : ['ENOSPC', 'EACCES', 'EPERM', 'EROFS', 'EIO'].includes(code)
661
767
  ? `preview.html could not be written (${code === 'ENOSPC' ? 'the disk is full' : code}), so it still shows the theme as it was`
662
- : `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
768
+ : // A folder (or another thing) where preview.html goes: the page
769
+ // was rendered, and could not be written there.
770
+ code === ERROR_CODES.ERR_WRITE_FAILED ||
771
+ (fs.existsSync(f0.preview) && !fs.statSync(f0.preview).isFile())
772
+ ? `preview.html could not be written (${shown(ctx.project.cwd, f0.preview)} is ${fs.existsSync(f0.preview) && fs.statSync(f0.preview).isDirectory() ? 'a folder' : 'in the way'}; move it, then run ${P} show ${slug}), so it still shows the theme as it was`
773
+ : `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
663
774
  }
664
775
  const f = themeFiles(ctx.project.cwd, slug);
665
776
  // The sheet of every component is made by show only: after a change it
@@ -107,6 +107,20 @@ export function cssNumber(value: string): {
107
107
  * @returns {string[]}
108
108
  */
109
109
  export function splitTop(v: string, sep: "," | " " | "/"): string[];
110
+ /**
111
+ * Several values of one kind (`-4px -8px`, `1.5 2`, `var(--a) var(--b)`):
112
+ * the items, split as CSS splits them, and their kind (a number's unit, ''
113
+ * for a bare number, `var` for a var()), when every item is of the first
114
+ * one's kind; null otherwise (`all 200`). The one reading of "several
115
+ * values of one kind" that a repair offers the first of and the repair
116
+ * gate allows.
117
+ * @param {string} v
118
+ * @returns {{items: string[], kind: string} | null}
119
+ */
120
+ export function sameKindValues(v: string): {
121
+ items: string[];
122
+ kind: string;
123
+ } | null;
110
124
  /**
111
125
  * The parts of a CSS `font` value, by the longhand each sets, as written:
112
126
  * `italic small-caps 700 1rem/1 Arial` gives font-style, font-variant-caps,
@@ -235,6 +235,17 @@ export function matchType(type, value) {
235
235
  */
236
236
  function matchWith(value, match) {
237
237
  const {lexer, parse} = csstree();
238
+ // A color function holding a variable (color-mix(…, var(--x))) is a
239
+ // color whatever the variable holds: it is matched as one, so a value
240
+ // with many of them is read like the same value with plain colors.
241
+ for (let i = 0; i < 4; i++) {
242
+ const next = value.replace(
243
+ /\b(?:color-mix|light-dark|rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)/gi,
244
+ m => (/\bvar\(/i.test(m) ? 'red' : m),
245
+ );
246
+ if (next === value) break;
247
+ value = next;
248
+ }
238
249
  const vars =
239
250
  value.match(/(?:var|env)\([^()]*(?:\([^()]*\)[^()]*)*\)/gi) ?? [];
240
251
  /** @param {string} v */
@@ -263,7 +274,16 @@ function matchWith(value, match) {
263
274
  return null;
264
275
  }
265
276
  }
266
- if (vars.length > 3) return null;
277
+ // Many variables: each stands for the same kind of value at once.
278
+ if (vars.length > 3) {
279
+ for (const stand of VAR_STANDS_FOR) {
280
+ let v = value;
281
+ for (const x of vars) v = v.replace(x, stand);
282
+ const ast = tryOne(v);
283
+ if (ast) return ast;
284
+ }
285
+ return null;
286
+ }
267
287
  /** @param {string} v @param {number} i @returns {any | null} */
268
288
  const fill = (v, i) => {
269
289
  if (i === vars.length) return tryOne(v);
@@ -788,6 +808,31 @@ export function splitTop(v, sep) {
788
808
  return out.filter(x => sep === ',' || x.trim());
789
809
  }
790
810
 
811
+ /**
812
+ * Several values of one kind (`-4px -8px`, `1.5 2`, `var(--a) var(--b)`):
813
+ * the items, split as CSS splits them, and their kind (a number's unit, ''
814
+ * for a bare number, `var` for a var()), when every item is of the first
815
+ * one's kind; null otherwise (`all 200`). The one reading of "several
816
+ * values of one kind" that a repair offers the first of and the repair
817
+ * gate allows.
818
+ * @param {string} v
819
+ * @returns {{items: string[], kind: string} | null}
820
+ */
821
+ export function sameKindValues(v) {
822
+ const items = splitTop(String(v).trim(), ' ');
823
+ /** @param {string} x */
824
+ const kind = x =>
825
+ /^var\(/i.test(x)
826
+ ? 'var'
827
+ : (/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?([a-z%]*)$/i
828
+ .exec(x)?.[1]
829
+ ?.toLowerCase() ?? null);
830
+ const first = kind(items[0] ?? '');
831
+ if (items.length < 2 || first === null || items.some(x => kind(x) !== first))
832
+ return null;
833
+ return {items, kind: first};
834
+ }
835
+
791
836
  /** The longhand each type of the `font` grammar sets, where css-tree names a type, not a property. */
792
837
  const FONT_TYPE_LONGHAND = wordTable(
793
838
  /** @type {Record<string, string>} */ ({