@astryxdesign/cli 0.7.17 → 0.7.18-canary.g32556bb

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 (261) hide show
  1. package/README.md +1 -1
  2. package/api/discover/_adapter.d.mts +7 -5
  3. package/api/discover/_adapter.mjs +12 -11
  4. package/api/docs/_adapter.d.mts +19 -2
  5. package/api/docs/_adapter.mjs +66 -5
  6. package/api/doctor/_adapter.d.mts +11 -62
  7. package/api/doctor/_adapter.mjs +242 -472
  8. package/api/doctor/doctor.d.mts +1 -1
  9. package/api/doctor/doctor.mjs +3 -3
  10. package/api/doctor/theme-checks.mjs +37 -45
  11. package/api/error.d.mts +21 -0
  12. package/api/error.mjs +89 -0
  13. package/api/hook/list/list.d.mts +1 -1
  14. package/api/icon/_adapter.d.mts +8 -0
  15. package/api/icon/_adapter.mjs +17 -0
  16. package/api/icon/_authoring.mjs +6 -6
  17. package/api/icon/_default-look.mjs +16 -16
  18. package/api/icon/add/add.mjs +3 -3
  19. package/api/icon/exportIconIndex.doc.mjs +2 -2
  20. package/api/icon/icon.doc.mjs +2 -2
  21. package/api/icon/icon.type.d.mts +4 -0
  22. package/api/icon/icon.type.mjs +2 -1
  23. package/api/icon/search/icon-index.mjs +16 -3
  24. package/api/icon/search/search.d.mts +15 -5
  25. package/api/icon/search/search.mjs +74 -16
  26. package/api/icon/use/use.mjs +4 -4
  27. package/api/render/_adapter.mjs +233 -40
  28. package/api/render/render.type.d.mts +1 -1
  29. package/api/render/render.type.mjs +1 -1
  30. package/api/search/ORDERING.md +2 -2
  31. package/api/search/_adapter.mjs +4 -0
  32. package/api/search/_candidate-score.mjs +32 -8
  33. package/api/search/_cards.json +1 -1
  34. package/api/search/_compound.d.mts +0 -1
  35. package/api/search/_compound.mjs +93 -2
  36. package/api/search/_icons.d.mts +4 -2
  37. package/api/search/_icons.mjs +4 -2
  38. package/api/search/_lexical.mjs +177 -17
  39. package/api/search/_order.d.mts +3 -1
  40. package/api/search/_order.mjs +16 -5
  41. package/api/search/_result.d.mts +9 -0
  42. package/api/search/_result.mjs +10 -0
  43. package/api/search/_score.mjs +21 -3
  44. package/api/swizzle/_moduleGraph.d.mts +8 -0
  45. package/api/swizzle/_moduleGraph.mjs +61 -3
  46. package/api/template/copy/copy.mjs +5 -3
  47. package/api/template/template.type.d.mts +3 -3
  48. package/api/template/template.type.mjs +3 -3
  49. package/api/theme/_adapter.mjs +48 -12
  50. package/api/theme/build/build.d.mts +4 -0
  51. package/api/theme/build/build.mjs +69 -18
  52. package/api/theme/build/style-keys.mjs +4 -5
  53. package/api/theme/build/theme-object.mjs +5 -0
  54. package/api/theme/palette/generate/color.d.mts +47 -0
  55. package/api/theme/palette/generate/color.mjs +58 -1
  56. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  57. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  58. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  59. package/api/theme/palette/generate/editor-look.mjs +550 -0
  60. package/api/theme/palette/generate/mapping.d.mts +94 -9
  61. package/api/theme/palette/generate/mapping.mjs +94 -22
  62. package/api/theme-edit/_adapter.mjs +13 -2
  63. package/api/theme-edit/_catalog.d.mts +13 -13
  64. package/api/theme-edit/_catalog.mjs +66 -28
  65. package/api/theme-edit/_check.d.mts +82 -6
  66. package/api/theme-edit/_check.mjs +1270 -238
  67. package/api/theme-edit/_color.d.mts +74 -0
  68. package/api/theme-edit/_color.mjs +168 -3
  69. package/api/theme-edit/_compiler.d.mts +3 -5
  70. package/api/theme-edit/_compiler.mjs +122 -23
  71. package/api/theme-edit/_context.d.mts +55 -12
  72. package/api/theme-edit/_context.mjs +114 -60
  73. package/api/theme-edit/_css.d.mts +11 -0
  74. package/api/theme-edit/_css.mjs +40 -0
  75. package/api/theme-edit/_edit.d.mts +15 -2
  76. package/api/theme-edit/_edit.mjs +1469 -133
  77. package/api/theme-edit/_how-commands.d.mts +116 -0
  78. package/api/theme-edit/_how-commands.mjs +227 -115
  79. package/api/theme-edit/_how-question.d.mts +74 -29
  80. package/api/theme-edit/_how-question.mjs +8514 -1256
  81. package/api/theme-edit/_how-sides.d.mts +22 -0
  82. package/api/theme-edit/_how-sides.mjs +173 -0
  83. package/api/theme-edit/_how-steps.d.mts +42 -0
  84. package/api/theme-edit/_how-steps.mjs +208 -0
  85. package/api/theme-edit/_how-values.d.mts +29 -0
  86. package/api/theme-edit/_how-values.mjs +111 -0
  87. package/api/theme-edit/_how-words.d.mts +15 -0
  88. package/api/theme-edit/_how-words.mjs +239 -0
  89. package/api/theme-edit/_how.d.mts +1 -1
  90. package/api/theme-edit/_how.mjs +422 -37
  91. package/api/theme-edit/_missed.d.mts +2 -1
  92. package/api/theme-edit/_missed.mjs +125 -13
  93. package/api/theme-edit/_normal.d.mts +5 -3
  94. package/api/theme-edit/_normal.mjs +54 -14
  95. package/api/theme-edit/_palette.d.mts +204 -4
  96. package/api/theme-edit/_palette.mjs +901 -25
  97. package/api/theme-edit/_part-pieces.d.mts +54 -0
  98. package/api/theme-edit/_part-pieces.mjs +179 -0
  99. package/api/theme-edit/_part-words.mjs +33 -5
  100. package/api/theme-edit/_parts.d.mts +133 -0
  101. package/api/theme-edit/_parts.mjs +599 -10
  102. package/api/theme-edit/_picture-traits.d.mts +259 -0
  103. package/api/theme-edit/_picture-traits.mjs +1030 -0
  104. package/api/theme-edit/_preview.d.mts +95 -4
  105. package/api/theme-edit/_preview.mjs +284 -31
  106. package/api/theme-edit/_project.d.mts +14 -4
  107. package/api/theme-edit/_project.mjs +95 -26
  108. package/api/theme-edit/_resolved.d.mts +46 -0
  109. package/api/theme-edit/_resolved.mjs +800 -0
  110. package/api/theme-edit/_set-line.d.mts +29 -0
  111. package/api/theme-edit/_set-line.mjs +100 -0
  112. package/api/theme-edit/_settings.d.mts +625 -28
  113. package/api/theme-edit/_settings.mjs +4867 -888
  114. package/api/theme-edit/_tables.d.mts +25 -1
  115. package/api/theme-edit/_tables.mjs +115 -11
  116. package/api/theme-edit/_text-looks.d.mts +78 -0
  117. package/api/theme-edit/_text-looks.mjs +376 -0
  118. package/api/theme-edit/_vet.d.mts +3 -26
  119. package/api/theme-edit/_vet.mjs +5 -89
  120. package/api/theme-edit/how/how.d.mts +1 -1
  121. package/api/theme-edit/how/how.mjs +1 -1
  122. package/api/theme-edit/show/show.d.mts +4 -3
  123. package/api/theme-edit/show/show.mjs +3 -2
  124. package/api/theme-edit/theme-edit.type.d.mts +117 -1
  125. package/api/theme-edit/theme-edit.type.mjs +46 -3
  126. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  128. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  129. package/api/theme-edit/themeEditShow.doc.mjs +22 -3
  130. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  131. package/assets/component-list.generated.json +1 -1
  132. package/assets/docs/author-a-theme.doc.mjs +7 -4
  133. package/assets/docs/icons.doc.mjs +7 -6
  134. package/assets/docs/theme.doc.dense.mjs +10 -0
  135. package/assets/docs/theme.doc.mjs +10 -0
  136. package/assets/docs/theme.doc.zh.mjs +10 -0
  137. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  138. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  139. package/assets/docs/use-a-theme.doc.mjs +89 -17
  140. package/assets/docs-routes.generated.json +1 -1
  141. package/assets/docs.generated.json +2 -2
  142. package/assets/icons/definitions/article.doc.mjs +9 -0
  143. package/assets/icons/template-icons.json +5 -0
  144. package/assets/search-catalog.generated.json +2 -2
  145. package/assets/self-audit.generated.json +1 -1
  146. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  147. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  148. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  149. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  150. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  151. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  152. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  153. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  154. package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +9 -1
  155. package/assets/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonShowcase.doc.mjs +9 -2
  156. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.doc.mjs +3 -2
  157. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -1
  158. package/assets/templates/blocks/components/SideNavItem/SideNavItemShowcase.doc.mjs +3 -2
  159. package/assets/templates/blocks/components/SideNavSection/SideNavSectionShowcase.doc.mjs +2 -1
  160. package/assets/templates/components.generated.json +1 -1
  161. package/assets/templates/pages/ide/page.tsx +5 -10
  162. package/assets/templates/pages/payment-form/page.tsx +16 -60
  163. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  164. package/authoring/config/parse.mjs +1 -1
  165. package/authoring/debug/parse.d.mts +1 -1
  166. package/authoring/doctypes/_schema.d.mts +13 -13
  167. package/authoring/doctypes/icon-definition/parse.mjs +2 -2
  168. package/authoring/doctypes/icon-set/parse.mjs +1 -1
  169. package/authoring/doctypes/template/parse.mjs +1 -4
  170. package/authoring/gap-report/parse.d.mts +1 -1
  171. package/clients/cli/build-id.generated.json +1 -1
  172. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  173. package/clients/cli/commands/experimental/icon.mjs +7 -7
  174. package/clients/cli/commands/experimental/theme.mjs +175 -13
  175. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  176. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  177. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  178. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  179. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  180. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  181. package/clients/cli/commands/hook.mjs +7 -0
  182. package/clients/cli/commands/template.mjs +1 -1
  183. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  184. package/clients/cli/index.mjs +6 -2
  185. package/clients/cli/lib/hook-format.mjs +41 -1
  186. package/clients/cli/lib/json-shim.mjs +34 -14
  187. package/clients/cli/lib/other-cli-words.mjs +7 -0
  188. package/clients/cli/lib/unknown-command.mjs +345 -46
  189. package/clients/cli/manifest.generated.json +1 -1
  190. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  191. package/foundation/agent-docs/agent-docs.mjs +51 -8
  192. package/foundation/config/project.d.mts +11 -1
  193. package/foundation/config/project.mjs +11 -2
  194. package/foundation/discovery/component-replacement.d.mts +5 -8
  195. package/foundation/discovery/component-replacement.mjs +12 -14
  196. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  197. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  198. package/foundation/discovery/core-elements.d.mts +6 -0
  199. package/foundation/discovery/core-elements.mjs +10 -2
  200. package/foundation/discovery/core-prop-types.d.mts +5 -0
  201. package/foundation/discovery/core-prop-types.mjs +10 -3
  202. package/foundation/discovery/core-props.d.mts +8 -0
  203. package/foundation/discovery/core-props.mjs +29 -13
  204. package/foundation/discovery/icon-ranking.d.mts +5 -2
  205. package/foundation/discovery/icon-ranking.mjs +101 -18
  206. package/foundation/discovery/icon-set-checks.mjs +1 -1
  207. package/foundation/discovery/icon-set-writer.mjs +1 -1
  208. package/foundation/discovery/official-list.d.mts +17 -0
  209. package/foundation/discovery/official-list.mjs +77 -0
  210. package/foundation/discovery/template-icon-notes.mjs +3 -3
  211. package/foundation/discovery/template-icons.mjs +2 -2
  212. package/foundation/discovery/template-placeholders.mjs +1 -1
  213. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  214. package/foundation/discovery/unknown-core-props.mjs +601 -0
  215. package/foundation/discovery/written-prop-values.d.mts +35 -0
  216. package/foundation/discovery/written-prop-values.mjs +258 -0
  217. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  218. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  219. package/foundation/fs/package-name.d.mts +10 -0
  220. package/foundation/fs/package-name.mjs +37 -0
  221. package/foundation/fs/project-source-files.d.mts +27 -0
  222. package/foundation/fs/project-source-files.mjs +115 -0
  223. package/foundation/fs/project-sources.d.mts +25 -0
  224. package/foundation/fs/project-sources.mjs +83 -0
  225. package/foundation/fs/read-record.d.mts +18 -0
  226. package/foundation/fs/read-record.mjs +36 -2
  227. package/foundation/integrations/integration-warnings.d.mts +39 -7
  228. package/foundation/integrations/integration-warnings.mjs +141 -19
  229. package/foundation/integrations/missing-dependency.d.mts +11 -0
  230. package/foundation/integrations/missing-dependency.mjs +20 -5
  231. package/foundation/release/folder-lock.d.mts +5 -2
  232. package/foundation/release/folder-lock.mjs +9 -3
  233. package/foundation/release/notices.mjs +2 -8
  234. package/foundation/render/cut-short.d.mts +8 -2
  235. package/foundation/render/cut-short.mjs +50 -5
  236. package/foundation/render/drawn-contrast.d.mts +40 -0
  237. package/foundation/render/drawn-contrast.mjs +355 -0
  238. package/foundation/render/file-header.mjs +4 -0
  239. package/foundation/render/layers.d.mts +2 -1
  240. package/foundation/render/layers.mjs +22 -1
  241. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  242. package/foundation/render/package-resolve-hooks.mjs +124 -32
  243. package/foundation/render/page-worker.mjs +95 -23
  244. package/foundation/render/part-boxes.d.mts +27 -0
  245. package/foundation/render/part-boxes.mjs +45 -0
  246. package/foundation/render/picture-chrome.mjs +36 -4
  247. package/foundation/render/picture-playwright.mjs +26 -2
  248. package/foundation/render/picture-window.d.mts +29 -2
  249. package/foundation/render/picture-window.mjs +99 -1
  250. package/foundation/render/render-page.d.mts +39 -6
  251. package/foundation/render/render-page.mjs +26 -10
  252. package/foundation/render/ts-paths.mjs +2 -1
  253. package/foundation/response/error-codes.doc.mjs +1 -1
  254. package/foundation/response/error-codes.mjs +1 -1
  255. package/foundation/response/response-types.doc.mjs +9 -5
  256. package/foundation/suggest/other-command.mjs +25 -1
  257. package/foundation/text/icon-set-next.d.mts +1 -1
  258. package/foundation/text/icon-set-next.mjs +2 -2
  259. package/foundation/text/written-string.d.mts +4 -1
  260. package/foundation/text/written-string.mjs +4 -1
  261. package/package.json +8 -7
@@ -1,6 +1,58 @@
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
+ * One change a command makes.
6
+ * @typedef {object} Step
7
+ * @property {'set' | 'undo'} verb
8
+ * @property {string} thing
9
+ * @property {string} [value]
10
+ * @property {string} [on]
11
+ * @property {string} [when]
12
+ * @property {string} [state]
13
+ * @property {string} [mode]
14
+ * @property {boolean} [only] the one member of a group, not the group
15
+ * @property {boolean} [keeps] writes a look back as it shows it now (a
16
+ * status Core draws its own way): an except of that look never leaves
17
+ * it out, as it is what keeps the look
18
+ */
19
+ /**
20
+ * The theme the commands of one answer are for, and the checks they pass.
21
+ * @typedef {object} HowTheme
22
+ * @property {string} slug
23
+ * @property {boolean} exists - false when the app has no theme: the commands name {@link EXAMPLE_THEME} and the answer starts with `new`.
24
+ * @property {string | null} previewDamage - why the in-app preview's record is damaged and how to fix it, or null.
25
+ * @property {string[]} themes - Every theme the editor made in the app.
26
+ * @property {string | null} note - Which theme the commands are for when the app has several, or that it has none.
27
+ * @property {'named' | 'only' | 'last-changed' | 'none'} chosenBy - How the theme was picked.
28
+ * @property {number} undoSteps - How many changes `undo` can step back.
29
+ * @property {boolean} bodyFontReachesHeadings - Whether `font X --on body` also changes the heading font in this release.
30
+ * @property {import('./_settings.mjs').ThemeData} data
31
+ * @property {{light: Record<string, string>, dark: Record<string, string>, onDark?: Record<string, string>}} base - `onDark`: the tokens the base's dark media rule replaces
32
+ * @property {{light: Record<string, string>, dark: Record<string, string>}} [own] - The theme's own values: the base's with its settings applied.
33
+ * @property {(steps: Step[]) => {ok: true} | {ok: false, why: string, run?: string[]}} check
34
+ * @property {(steps: Step[], part: string, prop: string) => {light: string, dark: string} | null} valueAfter what a part shows for a property at rest after the steps, in each mode, or null when it reads none
35
+ * @property {(steps: Step[], intent: MeasureIntent) => string | null} measure the measured check: why the built result does not do what the question asks, or null
36
+ */
37
+ /**
38
+ * The theme's own token values in each mode: the base theme's, with the
39
+ * theme's settings applied (a whole-theme corners setting, an exact
40
+ * token), as `compile` builds them.
41
+ * A type scale the theme writes (the text-size and type dials write one)
42
+ * is expanded the way Core expands it, so a heading size reads as the
43
+ * scale draws it, not as the base theme's.
44
+ * @param {any} compiled
45
+ * @param {{light: Record<string, string>, dark: Record<string, string>}} base
46
+ * @param {any} [core] the project's Core module, which expands the scale
47
+ * @returns {{light: Record<string, string>, dark: Record<string, string>}}
48
+ */
49
+ export function ownTokens(compiled: any, base: {
50
+ light: Record<string, string>;
51
+ dark: Record<string, string>;
52
+ }, core?: any): {
53
+ light: Record<string, string>;
54
+ dark: Record<string, string>;
55
+ };
4
56
  /**
5
57
  * The theme an answer's commands are for: the one named, the only one, or
6
58
  * the one changed last; with none, a theme the answer first makes.
@@ -10,6 +62,66 @@
10
62
  * @returns {Promise<HowTheme>}
11
63
  */
12
64
  export function howTheme(ctx: import("./_settings.mjs").Ctx, cwd: string, name: string | undefined): Promise<HowTheme>;
65
+ /**
66
+ * Every value of a compiled part, by `when|state|prop`.
67
+ * @param {any} comp the part's compiled styles
68
+ * @returns {Map<string, string>}
69
+ */
70
+ export function partValues(comp: any): Map<string, string>;
71
+ /**
72
+ * A value with every var() written out from a mode's tokens, and
73
+ * light-dark() taken for that mode.
74
+ * @param {string} v
75
+ * @param {Record<string, string>} map
76
+ * @param {'light' | 'dark'} mode
77
+ */
78
+ export function resolveIn(v: string, map: Record<string, string>, mode: "light" | "dark"): string;
79
+ /**
80
+ * One part's rules: each source's declarations on top of the one before,
81
+ * condition by condition (a rule that sets one property keeps the earlier
82
+ * rule's others).
83
+ * @param {...Record<string, any>} sources the part's rules, earliest first
84
+ * @returns {Record<string, Record<string, any>>}
85
+ */
86
+ export function mergeRules(...sources: Record<string, any>[]): Record<string, Record<string, any>>;
87
+ /**
88
+ * The tokens inside a part in one mode: the theme's, with each token the
89
+ * part's own rule sets (a part-scoped dial's `--spacing-4`) over them, and a
90
+ * variant's rule over the part's in that variant.
91
+ * @param {Record<string, Record<string, any>>} rules the part's rules
92
+ * @param {Record<string, string>} tokens the theme's tokens in that mode
93
+ * @param {string} when the rule's condition (`base` at rest)
94
+ * @returns {Record<string, string>}
95
+ */
96
+ export function scopedTokens(rules: Record<string, Record<string, any>>, tokens: Record<string, string>, when: string): Record<string, string>;
97
+ /**
98
+ * The values a part shows, by `when|state|prop` and mode: its own
99
+ * compiled rules (the base theme's, with the theme's on top), then each
100
+ * token it reads for a property, with every var() written out from the
101
+ * part's tokens in that mode. `raw` is the declaration as written.
102
+ * @param {any} C the part data (what each part reads, from Core)
103
+ * @param {Record<string, any>} baseComponents the base theme's own part styles
104
+ * @param {any} compiled the theme's own compiled styles
105
+ * @param {{light: Record<string, string>, dark: Record<string, string>}} toks
106
+ * @param {string} part
107
+ * @returns {Map<string, {light: string, dark: string, raw: string}>}
108
+ */
109
+ export function partShows(C: any, baseComponents: Record<string, any>, compiled: any, toks: {
110
+ light: Record<string, string>;
111
+ dark: Record<string, string>;
112
+ }, part: string): Map<string, {
113
+ light: string;
114
+ dark: string;
115
+ raw: string;
116
+ }>;
117
+ /**
118
+ * Apply one step to theme data in memory, as `set` and `undo` do.
119
+ * @param {import('./_settings.mjs').Ctx} ctx
120
+ * @param {string} slug
121
+ * @param {import('./_settings.mjs').ThemeData} d
122
+ * @param {Step} st
123
+ */
124
+ export function apply(ctx: import("./_settings.mjs").Ctx, slug: string, d: import("./_settings.mjs").ThemeData, st: Step): void;
13
125
  /**
14
126
  * A step as the command a person runs.
15
127
  * @param {Step} st
@@ -94,9 +206,13 @@ export type HowTheme = {
94
206
  */
95
207
  bodyFontReachesHeadings: boolean;
96
208
  data: import("./_settings.mjs").ThemeData;
209
+ /**
210
+ * - `onDark`: the tokens the base's dark media rule replaces
211
+ */
97
212
  base: {
98
213
  light: Record<string, string>;
99
214
  dark: Record<string, string>;
215
+ onDark?: Record<string, string>;
100
216
  };
101
217
  /**
102
218
  * - The theme's own values: the base's with its settings applied.
@@ -10,7 +10,14 @@
10
10
 
11
11
  import {AstryxError} from '../error.mjs';
12
12
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
13
- import {checkSetting, indicatorLines, pillDrawnRadios} from './_check.mjs';
13
+ import {
14
+ BORDER_COLOR_PROP,
15
+ borderFor,
16
+ broughtBorderAt,
17
+ checkSetting,
18
+ indicatorLines,
19
+ pillDrawnRadios,
20
+ } from './_check.mjs';
14
21
  import {baseResolved} from './_project.mjs';
15
22
  import {readThemeListState} from '../theme/_adapter.mjs';
16
23
  import {
@@ -20,8 +27,9 @@ import {
20
27
  loadTheme,
21
28
  readHistory,
22
29
  themeFiles,
30
+ groupsOf,
23
31
  } from './_settings.mjs';
24
- import {FAMILIES, GROUPS, LIKE, P} from './_tables.mjs';
32
+ import {GROUPS, LIKE, P} from './_tables.mjs';
25
33
  import {hexToOklch} from '../theme/palette/generate/color.mjs';
26
34
  import {
27
35
  COLOR_IN_VALUE,
@@ -63,7 +71,7 @@ export const EXAMPLE_THEME = 'my-theme';
63
71
  * @property {number} undoSteps - How many changes `undo` can step back.
64
72
  * @property {boolean} bodyFontReachesHeadings - Whether `font X --on body` also changes the heading font in this release.
65
73
  * @property {import('./_settings.mjs').ThemeData} data
66
- * @property {{light: Record<string, string>, dark: Record<string, string>}} base
74
+ * @property {{light: Record<string, string>, dark: Record<string, string>, onDark?: Record<string, string>}} base - `onDark`: the tokens the base's dark media rule replaces
67
75
  * @property {{light: Record<string, string>, dark: Record<string, string>}} [own] - The theme's own values: the base's with its settings applied.
68
76
  * @property {(steps: Step[]) => {ok: true} | {ok: false, why: string, run?: string[]}} check
69
77
  * @property {(steps: Step[], part: string, prop: string) => {light: string, dark: string} | null} valueAfter what a part shows for a property at rest after the steps, in each mode, or null when it reads none
@@ -74,12 +82,37 @@ export const EXAMPLE_THEME = 'my-theme';
74
82
  * The theme's own token values in each mode: the base theme's, with the
75
83
  * theme's settings applied (a whole-theme corners setting, an exact
76
84
  * token), as `compile` builds them.
85
+ * A type scale the theme writes (the text-size and type dials write one)
86
+ * is expanded the way Core expands it, so a heading size reads as the
87
+ * scale draws it, not as the base theme's.
77
88
  * @param {any} compiled
78
89
  * @param {{light: Record<string, string>, dark: Record<string, string>}} base
90
+ * @param {any} [core] the project's Core module, which expands the scale
79
91
  * @returns {{light: Record<string, string>, dark: Record<string, string>}}
80
92
  */
81
- function ownTokens(compiled, base) {
93
+ export function ownTokens(compiled, base, core) {
82
94
  const out = {light: {...base.light}, dark: {...base.dark}};
95
+ const scale = compiled?.typography?.scale;
96
+ if (
97
+ scale &&
98
+ typeof scale.base === 'number' &&
99
+ typeof scale.ratio === 'number' &&
100
+ typeof core?.expandTypeScale === 'function'
101
+ ) {
102
+ try {
103
+ const expanded = core.expandTypeScale({
104
+ base: scale.base,
105
+ ratio: scale.ratio,
106
+ });
107
+ for (const [k, v] of Object.entries(expanded ?? {}))
108
+ if (typeof v === 'string' && /^--font-size-|^--text-.*-size$/.test(k)) {
109
+ out.light[k] = v;
110
+ out.dark[k] = v;
111
+ }
112
+ } catch {
113
+ // (A Core that cannot expand the scale leaves the base sizes.)
114
+ }
115
+ }
83
116
  for (const [k, v] of Object.entries(compiled?.tokens ?? {})) {
84
117
  const pair = Array.isArray(v)
85
118
  ? v
@@ -209,7 +242,7 @@ export async function howTheme(ctx, cwd, name) {
209
242
  : 'last-changed',
210
243
  data: theme,
211
244
  base,
212
- own: ownTokens(compileTheme(ctx, theme, base), base),
245
+ own: ownTokens(compileTheme(ctx, theme, base), base, ctx.project?.core),
213
246
  undoSteps: exists
214
247
  ? readHistory(themeFiles(cwd, slug).history).steps.length
215
248
  : 0,
@@ -260,7 +293,7 @@ export async function howTheme(ctx, cwd, name) {
260
293
  return null;
261
294
  }
262
295
  const now = compileTheme(ctx, d, base);
263
- const toks = ownTokens(now, base);
296
+ const toks = ownTokens(now, base, ctx.project?.core);
264
297
  const camel = prop.replace(/-([a-z])/g, (_m, x) => x.toUpperCase());
265
298
  /** @type {Record<string, any>} */
266
299
  const rules = {
@@ -365,7 +398,7 @@ const kebab = k => k.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
365
398
  * @param {any} comp the part's compiled styles
366
399
  * @returns {Map<string, string>}
367
400
  */
368
- function partValues(comp) {
401
+ export function partValues(comp) {
369
402
  /** @type {Map<string, string>} */
370
403
  const out = new Map();
371
404
  for (const [when, rules] of Object.entries(comp ?? {}))
@@ -390,7 +423,7 @@ function partValues(comp) {
390
423
  * @param {Record<string, string>} map
391
424
  * @param {'light' | 'dark'} mode
392
425
  */
393
- function resolveIn(v, map, mode) {
426
+ export function resolveIn(v, map, mode) {
394
427
  let out = String(v ?? '');
395
428
  for (let i = 0; i < 8; i++) {
396
429
  const next = out
@@ -565,9 +598,10 @@ function ruleValue(compiled, part, render, prop) {
565
598
  * @param {Step[]} steps
566
599
  * @param {MeasureIntent} intent
567
600
  * @param {'light' | 'dark' | null} visible
601
+ * @param {Record<string, string[]>} groups the family groups `--on` takes, read from the census
568
602
  * @returns {string | null}
569
603
  */
570
- function lineWay(C, was, now, tw, tn, steps, intent, visible) {
604
+ function lineWay(C, was, now, tw, tn, steps, intent, visible, groups) {
571
605
  const fainter = Boolean(intent.fainter) || intent.zero;
572
606
  // (A dial set to a named look, "the buttons dial, outline", draws that
573
607
  // look's lines: a line it adds is the look asked.)
@@ -587,7 +621,7 @@ function lineWay(C, was, now, tw, tn, steps, intent, visible) {
587
621
  steps
588
622
  .map(st => st.on)
589
623
  .filter(Boolean)
590
- .flatMap(x => FAMILIES[String(x)] ?? [String(x)]),
624
+ .flatMap(x => groups[String(x)] ?? [String(x)]),
591
625
  );
592
626
  if (changedTokens.size)
593
627
  for (const [part, info] of Object.entries(C.MAP ?? {}))
@@ -777,6 +811,133 @@ const CHROMA_STEP = 0.005;
777
811
  /** @param {number[]} c */
778
812
  const luminance = c => c[0] * 0.299 + c[1] * 0.587 + c[2] * 0.114;
779
813
 
814
+ /**
815
+ * One part's rules: each source's declarations on top of the one before,
816
+ * condition by condition (a rule that sets one property keeps the earlier
817
+ * rule's others).
818
+ * @param {...Record<string, any>} sources the part's rules, earliest first
819
+ * @returns {Record<string, Record<string, any>>}
820
+ */
821
+ export function mergeRules(...sources) {
822
+ /** @type {Record<string, Record<string, any>>} */
823
+ const rules = {};
824
+ for (const src of sources)
825
+ for (const [when, rule] of Object.entries(src ?? {}))
826
+ rules[when] =
827
+ rule && typeof rule === 'object' && !Array.isArray(rule)
828
+ ? {...(rules[when] ?? {}), ...rule}
829
+ : rule;
830
+ return rules;
831
+ }
832
+
833
+ /**
834
+ * The tokens inside a part in one mode: the theme's, with each token the
835
+ * part's own rule sets (a part-scoped dial's `--spacing-4`) over them, and a
836
+ * variant's rule over the part's in that variant.
837
+ * @param {Record<string, Record<string, any>>} rules the part's rules
838
+ * @param {Record<string, string>} tokens the theme's tokens in that mode
839
+ * @param {string} when the rule's condition (`base` at rest)
840
+ * @returns {Record<string, string>}
841
+ */
842
+ export function scopedTokens(rules, tokens, when) {
843
+ /** @type {Record<string, string>} */
844
+ const t = {...tokens};
845
+ for (const w of when === 'base' ? ['base'] : ['base', when])
846
+ for (const [k, v] of Object.entries(rules[w] ?? {}))
847
+ if (k.startsWith('--') && typeof v === 'string') t[k] = v;
848
+ return t;
849
+ }
850
+
851
+ /**
852
+ * The values a part shows, by `when|state|prop` and mode: its own
853
+ * compiled rules (the base theme's, with the theme's on top), then each
854
+ * token it reads for a property, with every var() written out from the
855
+ * part's tokens in that mode. `raw` is the declaration as written.
856
+ * @param {any} C the part data (what each part reads, from Core)
857
+ * @param {Record<string, any>} baseComponents the base theme's own part styles
858
+ * @param {any} compiled the theme's own compiled styles
859
+ * @param {{light: Record<string, string>, dark: Record<string, string>}} toks
860
+ * @param {string} part
861
+ * @returns {Map<string, {light: string, dark: string, raw: string}>}
862
+ */
863
+ export function partShows(C, baseComponents, compiled, toks, part) {
864
+ const rules = mergeRules(
865
+ baseComponents?.[part] ?? {},
866
+ compiled.components?.[part] ?? {},
867
+ );
868
+ const own = partValues(rules);
869
+ const scoped = (
870
+ /** @type {'light' | 'dark'} */ m,
871
+ /** @type {string} */ when,
872
+ ) => scopedTokens(rules, toks[m], when);
873
+ /** @type {Map<string, string>} */
874
+ const raw = new Map(own);
875
+ // The part at rest in its main variant is its `base` too (a set with no
876
+ // --when writes base).
877
+ const mainWhen = (/** @type {string[]} */ ws) =>
878
+ ws.some(
879
+ w =>
880
+ w === '' ||
881
+ /^variant=(default|primary|accent|neutral)$|^size=md$/.test(w),
882
+ );
883
+ // What Core writes for a property in a rule (a card's padding is its
884
+ // container padding less the border width): the whole declaration, so
885
+ // a value is never read from one token of several.
886
+ const declOf = (
887
+ /** @type {string} */ prop,
888
+ /** @type {string} */ w,
889
+ /** @type {string} */ token,
890
+ ) => {
891
+ const at = C.MAP[part]?.at?.[prop] ?? {};
892
+ const attrs = w ? w.split(' ') : [];
893
+ const key = Object.keys(at).find(k =>
894
+ attrs.every(x => k.split(',').includes(x)),
895
+ );
896
+ // (Only a declaration of several theme tokens: one token alone is
897
+ // read as that token.)
898
+ const decl = key ? String(at[key]) : '';
899
+ const tokens = new Set(
900
+ [...decl.matchAll(/var\(\s*(--[a-z][a-z0-9-]*)/g)]
901
+ .map(m => m[1])
902
+ .filter(t => !/^--(_|astryx-)/.test(t)),
903
+ );
904
+ return decl.includes(token) && tokens.size > 1 ? decl : `var(${token})`;
905
+ };
906
+ for (const g of Object.keys(GROUPS))
907
+ for (const r of C.partReads(part, g) ?? [])
908
+ if (mainWhen(r.when?.length ? r.when : ['']))
909
+ for (const prop of r.props ?? []) {
910
+ const key = `base||${prop}`;
911
+ const w = (r.when?.length ? r.when : ['']).find(
912
+ (/** @type {string} */ x) => mainWhen([x]),
913
+ );
914
+ if (!raw.has(key)) raw.set(key, declOf(prop, w ?? '', r.token));
915
+ }
916
+ for (const g of Object.keys(GROUPS))
917
+ for (const r of C.partReads(part, g) ?? [])
918
+ for (const prop of r.props ?? [])
919
+ for (const w of r.when?.length ? r.when : [''])
920
+ if (!/::|:active|:hover|:focus|:checked|:disabled/.test(w)) {
921
+ const key = `${w ? w.replace('=', ':') : 'base'}||${prop}`;
922
+ // A variant with no rule of its own takes the part's own base
923
+ // rule over the token it reads.
924
+ if (!raw.has(key))
925
+ raw.set(
926
+ key,
927
+ own.get(`base||${prop}`) ?? declOf(prop, w, r.token),
928
+ );
929
+ }
930
+ /** @type {Map<string, {light: string, dark: string, raw: string}>} */
931
+ const out = new Map();
932
+ for (const [k, v] of raw)
933
+ out.set(k, {
934
+ light: resolveIn(v, scoped('light', k.split('|')[0]), 'light'),
935
+ dark: resolveIn(v, scoped('dark', k.split('|')[0]), 'dark'),
936
+ raw: v,
937
+ });
938
+ return out;
939
+ }
940
+
780
941
  /**
781
942
  * Hold the after build to the intent; why it does not fit, or null.
782
943
  * @param {any} ctx
@@ -788,11 +949,11 @@ const luminance = c => c[0] * 0.299 + c[1] * 0.587 + c[2] * 0.114;
788
949
  * @param {'light' | 'dark' | null} [visible] the one mode a one-mode theme shows
789
950
  */
790
951
  function measureFit(ctx, base, was, now, intent, steps, visible = null) {
791
- const tw = ownTokens(was, base);
792
- const tn = ownTokens(now, base);
952
+ const tw = ownTokens(was, base, ctx.project?.core);
953
+ const tn = ownTokens(now, base, ctx.project?.core);
793
954
  const C = ctx.C;
794
955
  /** @param {string} part */
795
- const members = part => FAMILIES[part] ?? [part];
956
+ const members = part => groupsOf(ctx)[part] ?? [part];
796
957
  // A kept part, or one state or variant of it (`part@when|state|`).
797
958
  /** @type {Array<{part: string, prefix: string}>} */
798
959
  const keeps = intent.keep.flatMap(k => {
@@ -801,109 +962,12 @@ function measureFit(ctx, base, was, now, intent, steps, visible = null) {
801
962
  });
802
963
  const subjects = new Set(intent.subjects.flatMap(members));
803
964
  /**
804
- * The values a part shows, by `when|state|prop` and mode: its own
805
- * compiled rules, then each token it reads for a property.
806
965
  * @param {any} compiled
807
966
  * @param {{light: Record<string, string>, dark: Record<string, string>}} toks
808
967
  * @param {string} part
809
968
  */
810
- const shown = (compiled, toks, part) => {
811
- // Each rule of the part: the base theme's own declarations with the
812
- // theme's on top, condition by condition (a theme rule that sets one
813
- // property keeps the base rule's others).
814
- /** @type {Record<string, Record<string, any>>} */
815
- const rules = {};
816
- for (const src of [
817
- base.components?.[part] ?? {},
818
- compiled.components?.[part] ?? {},
819
- ])
820
- for (const [when, rule] of Object.entries(src))
821
- rules[when] =
822
- rule && typeof rule === 'object' && !Array.isArray(rule)
823
- ? {...(rules[when] ?? {}), ...rule}
824
- : rule;
825
- const own = partValues(rules);
826
- // A token the part's own rule sets (a part-scoped dial's --spacing-4)
827
- // is the value inside the part.
828
- // A token a variant's rule sets holds in that variant, over the part's.
829
- const scoped = (
830
- /** @type {'light' | 'dark'} */ m,
831
- /** @type {string} */ when,
832
- ) => {
833
- /** @type {Record<string, string>} */
834
- const t = {...toks[m]};
835
- for (const w of when === 'base' ? ['base'] : ['base', when])
836
- for (const [k, v] of Object.entries(rules[w] ?? {}))
837
- if (k.startsWith('--') && typeof v === 'string') t[k] = v;
838
- return t;
839
- };
840
- /** @type {Map<string, string>} */
841
- const raw = new Map(own);
842
- // The part at rest in its main variant is its `base` too (a set with no
843
- // --when writes base).
844
- const mainWhen = (/** @type {string[]} */ ws) =>
845
- ws.some(
846
- w =>
847
- w === '' ||
848
- /^variant=(default|primary|accent|neutral)$|^size=md$/.test(w),
849
- );
850
- // What Core writes for a property in a rule (a card's padding is its
851
- // container padding less the border width): the whole declaration, so
852
- // a value is never read from one token of several.
853
- const declOf = (
854
- /** @type {string} */ prop,
855
- /** @type {string} */ w,
856
- /** @type {string} */ token,
857
- ) => {
858
- const at = C.MAP[part]?.at?.[prop] ?? {};
859
- const attrs = w ? w.split(' ') : [];
860
- const key = Object.keys(at).find(k =>
861
- attrs.every(x => k.split(',').includes(x)),
862
- );
863
- // (Only a declaration of several theme tokens: one token alone is
864
- // read as that token.)
865
- const decl = key ? String(at[key]) : '';
866
- const tokens = new Set(
867
- [...decl.matchAll(/var\(\s*(--[a-z][a-z0-9-]*)/g)]
868
- .map(m => m[1])
869
- .filter(t => !/^--(_|astryx-)/.test(t)),
870
- );
871
- return decl.includes(token) && tokens.size > 1 ? decl : `var(${token})`;
872
- };
873
- for (const g of Object.keys(GROUPS))
874
- for (const r of C.partReads(part, g) ?? [])
875
- if (mainWhen(r.when?.length ? r.when : ['']))
876
- for (const prop of r.props ?? []) {
877
- const key = `base||${prop}`;
878
- const w = (r.when?.length ? r.when : ['']).find(
879
- (/** @type {string} */ x) => mainWhen([x]),
880
- );
881
- if (!raw.has(key)) raw.set(key, declOf(prop, w ?? '', r.token));
882
- }
883
- for (const g of Object.keys(GROUPS))
884
- for (const r of C.partReads(part, g) ?? [])
885
- for (const prop of r.props ?? [])
886
- for (const w of r.when?.length ? r.when : [''])
887
- if (!/::|:active|:hover|:focus|:checked|:disabled/.test(w)) {
888
- const key = `${w ? w.replace('=', ':') : 'base'}||${prop}`;
889
- // A variant with no rule of its own takes the part's own base
890
- // rule over the token it reads.
891
- if (!raw.has(key))
892
- raw.set(
893
- key,
894
- own.get(`base||${prop}`) ?? declOf(prop, w, r.token),
895
- );
896
- }
897
- /** @type {Map<string, {light: string, dark: string, raw: string}>} */
898
- const out = new Map();
899
- for (const [k, v] of raw)
900
- out.set(k, {
901
- light: resolveIn(v, scoped('light', k.split('|')[0]), 'light'),
902
- dark: resolveIn(v, scoped('dark', k.split('|')[0]), 'dark'),
903
- raw: v,
904
- });
905
- return out;
906
- };
969
+ const shown = (compiled, toks, part) =>
970
+ partShows(C, base.components, compiled, toks, part);
907
971
  // Parts the question keeps: every value they show is the same after.
908
972
  for (const {part, prefix} of keeps) {
909
973
  const a = shown(was, tw, part);
@@ -1090,7 +1154,17 @@ function measureFit(ctx, base, was, now, intent, steps, visible = null) {
1090
1154
  (Boolean(intent.dir) &&
1091
1155
  intent.families.some(f => f === 'border' || f === 'shadow'));
1092
1156
  if (lineAsk) {
1093
- const why = lineWay(C, was, now, tw, tn, steps, intent, visible);
1157
+ const why = lineWay(
1158
+ C,
1159
+ was,
1160
+ now,
1161
+ tw,
1162
+ tn,
1163
+ steps,
1164
+ intent,
1165
+ visible,
1166
+ groupsOf(ctx),
1167
+ );
1094
1168
  if (why) return why;
1095
1169
  }
1096
1170
  const typed = new Set(intent.typed.map(x => x.toLowerCase()));
@@ -1148,6 +1222,15 @@ function measureFit(ctx, base, was, now, intent, steps, visible = null) {
1148
1222
  ? a.get('base||border-width')
1149
1223
  : a.get(`base||${prop}`));
1150
1224
  if (o && o.light === v.light && o.dark === v.dark) continue;
1225
+ // The see-through border a border color brings to a part that draws
1226
+ // none (set writes it with the color) is that color's line: asked
1227
+ // with it, never a change of its own.
1228
+ if (
1229
+ prop === 'border' &&
1230
+ /\btransparent\b/.test(`${v.light} ${v.dark}`) &&
1231
+ steps.some(st => BORDER_COLOR_PROP.test(String(st.thing)))
1232
+ )
1233
+ continue;
1151
1234
  const fam = familyOf(prop);
1152
1235
  if (!fam) continue;
1153
1236
  // A property a typed value writes is asked: the question wrote it.
@@ -1447,7 +1530,7 @@ function measureFit(ctx, base, was, now, intent, steps, visible = null) {
1447
1530
  * @param {import('./_settings.mjs').ThemeData} d
1448
1531
  * @param {Step} st
1449
1532
  */
1450
- function apply(ctx, slug, d, st) {
1533
+ export function apply(ctx, slug, d, st) {
1451
1534
  const unset = st.verb === 'undo';
1452
1535
  const s = checkSetting(
1453
1536
  ctx,
@@ -1455,9 +1538,28 @@ function apply(ctx, slug, d, st) {
1455
1538
  d,
1456
1539
  st.thing,
1457
1540
  st.value,
1458
- {on: st.on, when: st.when, state: st.state, mode: st.mode, only: st.only},
1541
+ {
1542
+ on: st.on,
1543
+ when: st.when,
1544
+ state: st.state,
1545
+ mode: st.mode,
1546
+ only: st.only,
1547
+ // A box shorthand `set` writes as its sides is checked the same way.
1548
+ ...(unset ? {} : {sides: true}),
1549
+ },
1459
1550
  unset,
1460
1551
  );
1552
+ // The sides replace the typed shorthand and each its own earlier entry,
1553
+ // as set writes them.
1554
+ if (!unset && s.sides?.length) {
1555
+ const typed = keyOf(s);
1556
+ d.settings = d.settings.filter(x => keyOf(x) !== typed);
1557
+ for (const side of s.sides) {
1558
+ d.settings = d.settings.filter(x => keyOf(x) !== keyOf(side));
1559
+ d.settings.push(side);
1560
+ }
1561
+ return;
1562
+ }
1461
1563
  if (!unset && s.thing === 'mode') {
1462
1564
  d.mode = /** @type {'both' | 'light-only' | 'dark-only'} */ (s.value);
1463
1565
  return;
@@ -1468,7 +1570,17 @@ function apply(ctx, slug, d, st) {
1468
1570
  [],
1469
1571
  ERROR_CODES.ERR_INVALID_ARGUMENT,
1470
1572
  );
1573
+ // A border color on a part that draws no border brings the border it
1574
+ // needs, as set writes it.
1575
+ const edge = unset ? null : borderFor(ctx, slug, d, s);
1471
1576
  const k = keyOf(s);
1577
+ // (With a border brought, the color goes after it, as set writes them:
1578
+ // a color the theme saves already moves last, never stays before the
1579
+ // border, whose shorthand would reset it.)
1580
+ if (edge) {
1581
+ d.settings = d.settings.filter(x => keyOf(x) !== k);
1582
+ d.settings.splice(broughtBorderAt(ctx, d.settings, edge), 0, edge);
1583
+ }
1472
1584
  const i = d.settings.findIndex(x => keyOf(x) === k);
1473
1585
  if (unset) {
1474
1586
  if (i < 0)