@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
@@ -25,8 +25,10 @@ import {
25
25
  LIKE,
26
26
  P,
27
27
  familyOf,
28
+ pageColorNote,
28
29
  } from './_tables.mjs';
29
30
  import {colorsAt, decodePng, mainColors} from './_png.mjs';
31
+ import {pixelScale, readTraits} from './_picture-traits.mjs';
30
32
  import {baseInstalled, installLine} from './_project.mjs';
31
33
  import {
32
34
  editedThemes,
@@ -40,6 +42,11 @@ import {
40
42
  themeSourceParseError,
41
43
  themeSourceProblem,
42
44
  baseRedraws,
45
+ groupsOf,
46
+ selfSizedBox,
47
+ selfSizedBoxLines,
48
+ selfSizedWhy,
49
+ sizesItsOwnBox,
43
50
  } from './_settings.mjs';
44
51
  import {missedSteps} from './_missed.mjs';
45
52
  import {ASPECTS, settableStates} from './_check.mjs';
@@ -47,7 +54,8 @@ import {MODAL} from './_compiler.mjs';
47
54
  import {PALETTE_DIALS, mappingRows, paletteFiles} from './_palette.mjs';
48
55
  import {requireProject, context} from './_context.mjs';
49
56
  import {checked, exampleStep, howTheme, render} from './_how-commands.mjs';
50
- import {draftAnswer, partLexicon, valueAsked} from './_how-question.mjs';
57
+ import {draftAnswer, partLexicon} from './_how-question.mjs';
58
+ import {valueAsked} from './_how-values.mjs';
51
59
  import {
52
60
  getCliInvocation,
53
61
  quoteCommandArgument,
@@ -114,7 +122,7 @@ function dialHelp(key, env) {
114
122
  * setting (a dial's rungs, a token's type and readers, a CSS property), an
115
123
  * aspect (text, corners...: the whole-theme tokens and dial), `colors` (how
116
124
  * the theme's colors are made), a plain-words question (exact commands), a
117
- * PNG picture (its main colors, or the color at points), or with `list` a
125
+ * PNG picture (its main colors and the look's traits measured from it, or the color at points), or with `list` a
118
126
  * list of dials, tokens, parts, groups or CSS properties.
119
127
  * @experimental
120
128
  * @param {string} subject a part, group, setting, aspect, question, or PNG file; with `list`, a filter
@@ -172,12 +180,14 @@ export async function themeEditHow(subject, options = {}) {
172
180
  * @returns {T}
173
181
  */
174
182
  function withPrefix(value, cwd) {
175
- const stem = `${getCliInvocation(cwd)} experimental theme`;
176
- if (stem === 'astryx experimental theme') return value;
183
+ const cli = getCliInvocation(cwd);
184
+ if (cli === 'astryx') return value;
185
+ // (A line may name the stable theme commands too, "astryx theme add
186
+ // neutral"; each runs as the app runs the CLI.)
177
187
  /** @param {any} v @returns {any} */
178
188
  const walk = v =>
179
189
  typeof v === 'string'
180
- ? v.split('astryx experimental theme').join(stem)
190
+ ? v.replace(/\bastryx (experimental theme|theme)\b/g, `${cli} $1`)
181
191
  : Array.isArray(v)
182
192
  ? v.map(walk)
183
193
  : v && typeof v === 'object'
@@ -190,9 +200,11 @@ function withPrefix(value, cwd) {
190
200
  * @param {string} subject
191
201
  * @param {import('./theme-edit.type.mjs').ThemeEditHowOptions} options
192
202
  * @param {string} cwd
203
+ * @param {boolean} [blindSaid] the color-blind pieces were answered
204
+ * already: the rest is asked as said, never split for them again
193
205
  * @returns {Promise<import('./theme-edit.type.mjs').ThemeEditHowResponse['data']>}
194
206
  */
195
- async function answer(subject, options, cwd) {
207
+ async function answer(subject, options, cwd, blindSaid = false) {
196
208
  const {list, at = [], count} = options;
197
209
  // "½rem": a fraction is a number before anything reads the question.
198
210
  const t = (subject ?? '')
@@ -289,8 +301,16 @@ async function answer(subject, options, cwd) {
289
301
  };
290
302
  return {kind: 'list', subject: t, ...(await listItems(kind, t, cwd))};
291
303
  }
292
- if (isPicture(t, cwd))
293
- return {kind: 'picture', subject: t, ...pictureColors(t, cwd, at, count)};
304
+ if (isPicture(t, cwd)) {
305
+ const {traits, ...read} = pictureColors(t, cwd, at, count);
306
+ if (!traits) return {kind: 'picture', subject: t, ...read};
307
+ return {
308
+ kind: 'picture',
309
+ subject: t,
310
+ ...read,
311
+ ...(await pictureLook(cwd, options.theme, traits)),
312
+ };
313
+ }
294
314
  // What runs instead: the same subject without the picture option (a
295
315
  // real command), never a made-up file name.
296
316
  const without = t ? `${HOW} ${quoteCommandArgument(t)}` : `${HOW} --help`;
@@ -366,12 +386,12 @@ async function answer(subject, options, cwd) {
366
386
  const kind = listKind(key);
367
387
  return {kind: 'list', subject: '', ...(await listItems(kind, '', cwd))};
368
388
  }
369
- if (Object.hasOwn(FAMILIES, key)) {
389
+ if (Object.hasOwn(groupsOf(ctx), key)) {
370
390
  return {
371
391
  kind: 'group',
372
392
  subject: t,
373
393
  group: key,
374
- members: FAMILIES[key],
394
+ members: groupsOf(ctx)[key],
375
395
  spreads: AUTO_SPREAD.includes(key),
376
396
  };
377
397
  }
@@ -580,6 +600,27 @@ async function answer(subject, options, cwd) {
580
600
  ?.toLowerCase() ?? 'kinds';
581
601
  return answer('', {...options, list: kind}, cwd);
582
602
  }
603
+ // (Color-blind readers asked about in a list of asks: the other pieces
604
+ // are answered as typed, in their case and order, and the color-blind
605
+ // answer follows them, before the first offer, as every answer does.)
606
+ const blind = blindSaid
607
+ ? {blind: false, rest: ''}
608
+ : colorBlindPieces(t.trim().replace(/[?.!]+$/, ''));
609
+ if (!tool && blind.blind && blind.rest) {
610
+ const rest = await answer(blind.rest, options, cwd, true);
611
+ const results = rest.results ?? [];
612
+ const firstOffer = results.findIndex(r => r.offer);
613
+ const at = firstOffer < 0 ? results.length : firstOffer;
614
+ return {
615
+ ...rest,
616
+ subject: t,
617
+ results: [
618
+ ...results.slice(0, at),
619
+ ...colorBlindAnswer(env),
620
+ ...results.slice(at),
621
+ ],
622
+ };
623
+ }
583
624
  if (tool)
584
625
  return {
585
626
  kind: 'question',
@@ -635,7 +676,7 @@ async function answer(subject, options, cwd) {
635
676
  const q = draftAnswer(ctx, env, t);
636
677
  const groups = q.aspects.filter(a => Object.hasOwn(GROUPS, a));
637
678
  const results = q.parts
638
- .map(p => (FAMILIES[p] ? FAMILIES[p][0] : p))
679
+ .map(p => (groupsOf(ctx)[p] ? groupsOf(ctx)[p][0] : p))
639
680
  .filter(p => ctx.project.target.has(p))
640
681
  .map(p => {
641
682
  const toks = (groups.length ? groups : [null]).flatMap(g =>
@@ -680,7 +721,11 @@ async function answer(subject, options, cwd) {
680
721
  if (matchAsk && env.exists) {
681
722
  const q = draftAnswer(ctx, env, t.replace(matchAsk[0], ' '));
682
723
  const parts = q.parts.flatMap(p =>
683
- FAMILIES[p] ? FAMILIES[p] : ctx.project.target.has(p) ? [p] : [],
724
+ groupsOf(ctx)[p]
725
+ ? groupsOf(ctx)[p]
726
+ : ctx.project.target.has(p)
727
+ ? [p]
728
+ : [],
684
729
  );
685
730
  if (parts.length) {
686
731
  const res = await resolvedTokens(ctx, env.slug).catch(() => null);
@@ -729,7 +774,11 @@ async function answer(subject, options, cwd) {
729
774
  h.aspects.some(a => a === 'background' || a === 'text'))
730
775
  ) {
731
776
  const parts = h.parts.flatMap(p =>
732
- FAMILIES[p] ? FAMILIES[p] : ctx.project.target.has(p) ? [p] : [],
777
+ groupsOf(ctx)[p]
778
+ ? groupsOf(ctx)[p]
779
+ : ctx.project.target.has(p)
780
+ ? [p]
781
+ : [],
733
782
  );
734
783
  const res = await resolvedTokens(ctx, env.slug).catch(() => null);
735
784
  // (A missed entry never says otherwise than the question: where the
@@ -781,6 +830,7 @@ async function answer(subject, options, cwd) {
781
830
  }
782
831
  const results = finish(env, h.drafts);
783
832
  const empty = !results.some(r => r.commands.length);
833
+ const already = results.length > 0 && results.every(r => ALREADY.has(r));
784
834
  return {
785
835
  kind: 'question',
786
836
  subject: t,
@@ -788,21 +838,25 @@ async function answer(subject, options, cwd) {
788
838
  ...themeFields,
789
839
  results,
790
840
  ...unknown,
791
- ...(empty
841
+ ...(empty && already
792
842
  ? {
793
- hint: `${
794
- results.length
795
- ? `No command does all of "${t}" on ${env.slug}; each result says why.`
796
- : `No match for "${t}". Name the part (header, nav links, card, button, banner, input...) and what to change (text color, background, gradient, corners, border, shadow, spacing, bold), in English.`
797
- } See ${HOW} --help for the asks it understands.`,
798
- run: [
799
- `${HOW} --help`,
800
- `${HOW} --list parts`,
801
- `${HOW} "rounder buttons"`,
802
- `${HOW} colors`,
803
- ],
843
+ hint: `"${t}" is already so in ${env.slug}: nothing to change. Each result says what it found.`,
804
844
  }
805
- : {}),
845
+ : empty
846
+ ? {
847
+ hint: `${
848
+ results.length
849
+ ? `No command does all of "${t}" on ${env.slug}; each result says why.`
850
+ : `No match for "${t}". Name the part (header, nav links, card, button, banner, input...) and what to change (text color, background, gradient, corners, border, shadow, spacing, bold), in English.`
851
+ } See ${HOW} --help for the asks it understands.`,
852
+ run: [
853
+ `${HOW} --help`,
854
+ `${HOW} --list parts`,
855
+ `${HOW} "rounder buttons"`,
856
+ `${HOW} colors`,
857
+ ],
858
+ }
859
+ : {}),
806
860
  };
807
861
  }
808
862
 
@@ -885,8 +939,10 @@ export function questionOnly(q) {
885
939
  t,
886
940
  ) ||
887
941
  /^(?:why not|what about|how about|what if)\b/.test(t) ||
888
- // ("why are my headings not bold": a complaint is an ask.)
889
- /^why\b.*\b(?:not|n'?t)\b/.test(t)
942
+ // ("why are my headings not bold", "why is everything so round": a
943
+ // complaint is an ask.)
944
+ /^why\b.*\b(?:not|n'?t)\b/.test(t) ||
945
+ /^why (?:is|are)\b.*\bso [a-z]+\b/.test(t)
890
946
  )
891
947
  return false;
892
948
  // A verb that asks for a change anywhere after the question's first
@@ -908,6 +964,13 @@ export function questionOnly(q) {
908
964
  .some(seg => seg.trim() && !QUESTION_LEAD.test(seg.trim()));
909
965
  }
910
966
 
967
+ /**
968
+ * The results that say the theme already does what was asked: when every
969
+ * result is one, the answer leads with that, never with a failure.
970
+ * @type {WeakSet<object>}
971
+ */
972
+ const ALREADY = new WeakSet();
973
+
911
974
  /**
912
975
  * Check each draft's commands and keep what passes; a draft whose commands
913
976
  * are all refused says why, and points to the lookup that helps.
@@ -915,7 +978,7 @@ export function questionOnly(q) {
915
978
  * @param {import('./_how-question.mjs').Draft[]} drafts
916
979
  */
917
980
  function finish(env, drafts) {
918
- /** @type {Array<{text: string, commands: string[], sequence?: boolean, refused?: Array<{command: string, why: string, run?: string[]}>}>} */
981
+ /** @type {Array<{text: string, commands: string[], sequence?: boolean, refused?: Array<{command: string, why: string, run?: string[]}>, offer?: boolean}>} */
919
982
  const out = [];
920
983
  // The measured check runs first on the drafts that carry what their
921
984
  // clause asks; a draft that joins them ("all of it, in order") then keeps
@@ -937,12 +1000,18 @@ function finish(env, drafts) {
937
1000
  const kept = new Set();
938
1001
  /** @type {Map<object, string[]>} */
939
1002
  const unmetOf = new Map();
1003
+ // ("…, and make headings bigger": where an answer's first line fails the
1004
+ // check and a later line of it passes, a joined answer takes that line
1005
+ // in its place, never drops the ask unsaid.)
1006
+ /** @type {Map<string, import('./_how-commands.mjs').Step[]>} */
1007
+ const joinsInstead = new Map();
940
1008
  if (typeof env.measure === 'function')
941
1009
  for (const d of drafts) {
942
1010
  if (!d.intent) continue;
943
1011
  const intent = d.intent;
944
1012
  /** @type {string[]} */
945
1013
  const unmet = [];
1014
+ const first = d.options[0];
946
1015
  d.options = d.options.flatMap(o => {
947
1016
  const why = env.measure(o, intent);
948
1017
  if (why) {
@@ -964,6 +1033,8 @@ function finish(env, drafts) {
964
1033
  if (why) unmet.push(why);
965
1034
  return why ? [] : [o];
966
1035
  });
1036
+ if (first?.length === 1 && d.options.length && d.options[0] !== first)
1037
+ joinsInstead.set(key(first[0]), d.options[0]);
967
1038
  // One change in growing amounts: the first kept is the answer, and
968
1039
  // the smaller amounts that fell short are no reason to tell.
969
1040
  if (d.smallest && d.options.length) {
@@ -975,7 +1046,13 @@ function finish(env, drafts) {
975
1046
  for (const d of drafts) {
976
1047
  if (!d.intent && dropped.size) {
977
1048
  d.options = d.options
978
- .map(o => o.filter(st => !dropped.has(key(st)) || kept.has(key(st))))
1049
+ .map(o =>
1050
+ o.flatMap(st =>
1051
+ !dropped.has(key(st)) || kept.has(key(st))
1052
+ ? [st]
1053
+ : (joinsInstead.get(key(st)) ?? []),
1054
+ ),
1055
+ )
979
1056
  .filter(o => o.length);
980
1057
  // A joined answer left holding what another answer already says is
981
1058
  // that answer: it is not given twice (and never as "all of it").
@@ -1032,11 +1109,48 @@ function finish(env, drafts) {
1032
1109
  continue;
1033
1110
  }
1034
1111
  const {commands, refused} = checked(env, d.options);
1112
+ // (A choice whose options hold more than one step, a fill with the text
1113
+ // that reads on it: each option is one line, so a line is one whole
1114
+ // choice.)
1115
+ if (d.joined) {
1116
+ const whole = d.options
1117
+ .map(o => checked(env, [o]))
1118
+ .filter(r => r.commands.length && !r.refused.length)
1119
+ .map(r => r.commands.join(' && '));
1120
+ commands.splice(0, commands.length, ...whole);
1121
+ }
1035
1122
  const lookups = d.lookup ? [d.lookup] : [];
1123
+ // (The draft found it in place already: said, with no command.)
1124
+ if (d.already) {
1125
+ const r = {text: d.text, commands: lookups};
1126
+ ALREADY.add(r);
1127
+ out.push(r);
1128
+ continue;
1129
+ }
1036
1130
  if (!commands.length && !d.options.length && unmet.length) {
1037
1131
  out.push({text: d.text, commands: lookups});
1038
1132
  continue;
1039
1133
  }
1134
+ // (What the ask writes is in place already: said so, first, with no
1135
+ // command, so an offer beside it is never taken for the answer.)
1136
+ if (
1137
+ !commands.length &&
1138
+ d.options.length &&
1139
+ !d.offer &&
1140
+ refused.length &&
1141
+ refused.every(r => /^it changes nothing/.test(r.why))
1142
+ ) {
1143
+ const steps = d.options[0];
1144
+ const values = [...new Set(steps.map(st => String(st.value)))];
1145
+ const parts = [...new Set(steps.map(st => st.on).filter(Boolean))];
1146
+ const r = {
1147
+ text: `already ${values.join(', ')}${parts.length ? ` on the ${parts.join(', ')}` : ''} in ${env.slug}, nothing to change (${d.text})`,
1148
+ commands: lookups,
1149
+ };
1150
+ ALREADY.add(r);
1151
+ out.push(r);
1152
+ continue;
1153
+ }
1040
1154
  if (!commands.length && d.options.length && !lookups.length) {
1041
1155
  out.push({
1042
1156
  text: `${d.text}: no command does it on ${env.slug}${refused[0] ? `: ${refused[0].why}` : ''}`,
@@ -1053,6 +1167,7 @@ function finish(env, drafts) {
1053
1167
  commands: [...commands, ...lookups],
1054
1168
  ...(d.sequence && commands.length ? {sequence: true} : {}),
1055
1169
  ...(refused.length ? {refused} : {}),
1170
+ ...(d.offer ? {offer: true} : {}),
1056
1171
  });
1057
1172
  }
1058
1173
  if (!env.exists && out.some(r => r.commands.some(c => / set /.test(c))))
@@ -1064,8 +1179,16 @@ function finish(env, drafts) {
1064
1179
  // Changes first; a lookup ("how card") after the commands that change.
1065
1180
  const changes = (/** @type {{commands: string[]}} */ r) =>
1066
1181
  r.commands.some(c => / editor (set|undo|new) /.test(c)) ? 0 : 1;
1182
+ // An offer, more than the ask, is never first or the answer: it follows
1183
+ // every other result; left alone, a first line says the ask itself
1184
+ // writes nothing here.
1185
+ const offered = (/** @type {{offer?: boolean}} */ r) => (r.offer ? 1 : 0);
1186
+ // (Its words first, with no command: "the mode the app shows first is
1187
+ // set where it renders the theme"; the line it offers follows.)
1188
+ if (out.length && out.every(r => r.offer))
1189
+ out.unshift({text: out[0].text, commands: []});
1067
1190
  return out
1068
- .sort((a, b) => changes(a) - changes(b))
1191
+ .sort((a, b) => offered(a) - offered(b) || changes(a) - changes(b))
1069
1192
  .filter(r => {
1070
1193
  const k = `${r.text}\n${r.commands.join('\n')}`;
1071
1194
  if (seen.has(k)) return false;
@@ -1088,7 +1211,7 @@ function lookupKey(t, ctx) {
1088
1211
  .trim();
1089
1212
  if (/\s/.test(k)) return t;
1090
1213
  const known = (/** @type {string} */ x) =>
1091
- Object.hasOwn(FAMILIES, x) ||
1214
+ Object.hasOwn(groupsOf(ctx), x) ||
1092
1215
  ctx.project.target.has(x) ||
1093
1216
  ASPECTS.includes(x) ||
1094
1217
  Object.hasOwn(DIALS, x) ||
@@ -1137,7 +1260,7 @@ function partAnswer(ctx, env, subject, key, unknown, themeFields) {
1137
1260
  const v = blocks[t]?.base?.[token];
1138
1261
  const to =
1139
1262
  typeof v === 'string'
1140
- ? /^var\((--[\w-]+)\)$/.exec(v.trim())?.[1]
1263
+ ? /^var\(\s*(--[\w-]+)\s*\)$/.exec(v.trim())?.[1]
1141
1264
  : null;
1142
1265
  if (to) return {token: to, on: t};
1143
1266
  }
@@ -1192,7 +1315,7 @@ function partAnswer(ctx, env, subject, key, unknown, themeFields) {
1192
1315
  components,
1193
1316
  recorded,
1194
1317
  group,
1195
- groupMembers: group ? FAMILIES[group] : [],
1318
+ groupMembers: group ? groupsOf(ctx)[group] : [],
1196
1319
  spreads: group ? AUTO_SPREAD.includes(group) : false,
1197
1320
  variants: C.variantValues(key),
1198
1321
  states,
@@ -1424,6 +1547,10 @@ function tokenAnswer(ctx, env, subject, key, unknown, themeFields) {
1424
1547
  return {
1425
1548
  kind: 'setting',
1426
1549
  subject,
1550
+ // (The page color shows inside AppShell only: said first.)
1551
+ ...(key === '--color-background-body'
1552
+ ? {note: pageColorNote(env.data?.mode)}
1553
+ : {}),
1427
1554
  source: 'token',
1428
1555
  tokenType: type,
1429
1556
  default: String(ctx.project.core.tokenDefaults[key]),
@@ -1491,6 +1618,88 @@ function colorsAnswer(env, dialCommands) {
1491
1618
  ];
1492
1619
  }
1493
1620
 
1621
+ /** A word for color-vision deficiency, as a pattern's source. */
1622
+ const COLOR_BLIND_WORD = String.raw`(?:colou?r[- ]?blind\w*|colou?r[- ]vision|cvd|deuteran\w*|protan\w*|tritan\w*)`;
1623
+ const COLOR_BLIND = new RegExp(String.raw`\b${COLOR_BLIND_WORD}\b`, 'i');
1624
+
1625
+ /**
1626
+ * An ask's pieces, split at commas and at an "and" that joins two asks
1627
+ * ("color-blind friendly statuses and a blue accent"; "red and green for
1628
+ * color-blind people" is one ask): whether a piece asks about color-blind
1629
+ * readers, and the pieces that do not.
1630
+ * @param {string} q
1631
+ */
1632
+ function colorBlindPieces(q) {
1633
+ const pieces = q
1634
+ .split(
1635
+ new RegExp(
1636
+ String.raw`[,;:]|\s(?:and|plus|&)\s(?!(?:[\w-]+\s+){0,3}${COLOR_BLIND_WORD})`,
1637
+ 'i',
1638
+ ),
1639
+ )
1640
+ .map(x => x.trim())
1641
+ .filter(Boolean);
1642
+ const blind = pieces.filter(x => COLOR_BLIND.test(x));
1643
+ if (!blind.length) return {blind: false, rest: ''};
1644
+ // (A color-blind piece that says a change, "warnings darker for
1645
+ // color-blind users", is asked as said; a piece that is only about
1646
+ // color-blind readers is read as the status colors it is about, so the
1647
+ // list keeps its shape.)
1648
+ const own = (/** @type {string} */ x) => {
1649
+ const left = x
1650
+ .replace(
1651
+ new RegExp(
1652
+ String.raw`\s*\b(?:that|which|so(?:\s+that)?|for|to)\s+(?:[\w-]+\s+){0,3}?${COLOR_BLIND_WORD}(?:\s+[\w-]+){0,5}\s*$`,
1653
+ 'i',
1654
+ ),
1655
+ '',
1656
+ )
1657
+ .replace(
1658
+ new RegExp(
1659
+ String.raw`\b${COLOR_BLIND_WORD}(?:[- ](?:friendly|safe|proof|readers?|users?|people))?`,
1660
+ 'gi',
1661
+ ),
1662
+ '',
1663
+ )
1664
+ .replace(/\s+/g, ' ')
1665
+ .trim();
1666
+ // (What is left is a change unless it is only words about the ask
1667
+ // itself: "color-blind friendly statuses", "a color-blind safe
1668
+ // palette".)
1669
+ const said = left
1670
+ .replace(
1671
+ /\b(?:make|makes|making|it|its|this|that|the|a|an|be|is|are|please|our|my|your|theme|app|site|ui|friendly|safe|proof|accessible|people|users?|readers?|staff|folks|viewers?|visitors?|for|with|to|so|also|and|status(?:es)?|colou?rs?|palette|statuses|can|tell|apart|them)\b/gi,
1672
+ '',
1673
+ )
1674
+ .replace(/[^\w#]+/g, '');
1675
+ return said ? x : 'status colors';
1676
+ };
1677
+ const kept = blind.map(own);
1678
+ if (blind.length === pieces.length && kept.every(x => x === 'status colors'))
1679
+ return {blind: true, rest: ''};
1680
+ const rest = blind
1681
+ .reduce((t, x, k) => t.replace(x, ` ${kept[k]} `), q)
1682
+ .replace(/\s+/g, ' ')
1683
+ .trim();
1684
+ return {blind: true, rest};
1685
+ }
1686
+
1687
+ /**
1688
+ * The answer about color-blind readers.
1689
+ * @param {import('./_how-commands.mjs').HowTheme} env
1690
+ */
1691
+ function colorBlindAnswer(env) {
1692
+ return [
1693
+ {
1694
+ text: `color-blind readers: the editor checks that the status fills (info, success, warning, danger) stay apart for someone red-weak or green-weak, and show and set note a pair that may look alike, with a line that moves one of them lighter or darker. A status shown with its words or an icon does not rest on color alone; a status dot does, so its colors need lightness apart too. To choose the colors yourself, set each status color; keep warning light and danger dark so lightness, not only hue, tells them apart.`,
1695
+ commands: [
1696
+ ...(env.exists ? [`${P} show ${env.slug}`] : []),
1697
+ `${HOW} "status colors"`,
1698
+ ],
1699
+ },
1700
+ ];
1701
+ }
1702
+
1494
1703
  /**
1495
1704
  * The answer to a question about the tool itself: help, a list, how to see
1496
1705
  * a change, or the difference between two things it names. 'list' means
@@ -1522,6 +1731,10 @@ function toolAnswer(t, env, targets) {
1522
1731
  )
1523
1732
  )
1524
1733
  return 'list';
1734
+ // (Only an ask about color-blind readers alone; in a list of asks the
1735
+ // other pieces are answered too (answer).)
1736
+ if (colorBlindPieces(q).blind && !colorBlindPieces(q).rest)
1737
+ return colorBlindAnswer(env);
1525
1738
  if (/\b(see|view|preview|check) (my |the )?(changes?|theme|edits?)\b/.test(q))
1526
1739
  return [
1527
1740
  {
@@ -1619,7 +1832,10 @@ function toolAnswer(t, env, targets) {
1619
1832
  // A question about a part's value now is answered with that value.
1620
1833
  (asks && !valueAsked(q)) ||
1621
1834
  /^which parts (are|does|do)\b/.test(q) ||
1622
- (/^why (is|are|does|do)\b/.test(q) && !/\bnot\b|n'?t\b/.test(q))
1835
+ (/^why (is|are|does|do)\b/.test(q) &&
1836
+ !/\bnot\b|n'?t\b/.test(q) &&
1837
+ // ("why is everything so round": a complaint, an ask.)
1838
+ !/^why (?:is|are)\b.*\bso [a-z]+\b/.test(q))
1623
1839
  ) {
1624
1840
  // The part or setting the question names gets its own lookup.
1625
1841
  const named = q
@@ -1779,7 +1995,7 @@ async function listItems(kind, filter, cwd) {
1779
1995
  if (kind === 'groups')
1780
1996
  return {
1781
1997
  list: kind,
1782
- items: Object.entries(FAMILIES)
1998
+ items: Object.entries(groupsOf(await context(cwd)))
1783
1999
  .filter(([k, v]) => f(k) || v.some(f))
1784
2000
  .map(([name, members]) => ({
1785
2001
  name,
@@ -1953,8 +2169,10 @@ function pictureColors(file, cwd, at, count) {
1953
2169
  );
1954
2170
  /** @type {import('./_png.mjs').Picture} */
1955
2171
  let pic;
2172
+ /** @type {Buffer} */
2173
+ let bytes;
1956
2174
  try {
1957
- pic = decodePng(fs.readFileSync(abs));
2175
+ pic = decodePng((bytes = fs.readFileSync(abs)));
1958
2176
  } catch (e) {
1959
2177
  throw new AstryxError(
1960
2178
  `Could not read ${file} as a PNG picture: ${e instanceof Error ? e.message : String(e)}.`,
@@ -1986,6 +2204,8 @@ function pictureColors(file, cwd, at, count) {
1986
2204
  };
1987
2205
  }
1988
2206
  const colors = mainColors(pic, count ?? 14);
2207
+ // The look's traits, measured from the same pixels.
2208
+ const traits = colors.length ? readTraits(pic, pixelScale(bytes)) : null;
1989
2209
  // Every pixel see-through: no color shows, as with a 0-pixel picture.
1990
2210
  if (!colors.length)
1991
2211
  throw new AstryxError(
@@ -1999,5 +2219,170 @@ function pictureColors(file, cwd, at, count) {
1999
2219
  height: pic.height,
2000
2220
  colors,
2001
2221
  points: null,
2222
+ traits,
2223
+ };
2224
+ }
2225
+
2226
+ /**
2227
+ * The aspects a setting changes, so a dial and the tokens it writes count as
2228
+ * one: corners (the corners dial and every radius token), the control size
2229
+ * (its size tokens, and the spacing dial, which scales control heights), the
2230
+ * spacing tokens (and the spacing dial), the line height (the leading
2231
+ * tokens), the text size (the text-size dial and the text
2232
+ * size tokens), and the heading weight (the headings dial, and the type
2233
+ * dial, which sets it). A checks size is its box: its width and its height.
2234
+ * Anything else is its own aspect.
2235
+ * @param {string} thing
2236
+ * @returns {string[]}
2237
+ */
2238
+ function aspectsOf(thing) {
2239
+ if (thing === 'corners' || /^--radius-/.test(thing)) return ['corners'];
2240
+ if (/^--size-element-/.test(thing)) return ['control-size'];
2241
+ if (thing === 'spacing') return ['control-size', 'spacing'];
2242
+ if (/^--spacing-/.test(thing)) return ['spacing'];
2243
+ if (/^--text-[\w-]*leading$|^--line-height/.test(thing)) return ['leading'];
2244
+ if (thing === 'text-size' || /^--text-[\w-]*-size$/.test(thing))
2245
+ return ['text-size'];
2246
+ if (thing === 'headings' || thing === 'type') return ['heading-weight'];
2247
+ if (thing === 'width' || thing === 'height') return ['box-size'];
2248
+ return [thing];
2249
+ }
2250
+
2251
+ /**
2252
+ * The lines that give the checks a measured box: width and height at the
2253
+ * same px on each member that sizes its own box (sizesItsOwnBox), so a box
2254
+ * stays square and a radio stays round. The measured box is the size drawn;
2255
+ * each size moves by the same step from its own box (selfSizedBox), with a
2256
+ * `--when size:` line per size when the member has more than one, one
2257
+ * `--on checks` line where every member has the same box, else a line per
2258
+ * member. A size whose box the editor does not know keeps its own, named in
2259
+ * `kept`. No steps, with why, when no size can be read.
2260
+ * @param {import('./_settings.mjs').Ctx} ctx
2261
+ * @param {import('./_settings.mjs').Setting[]} settings
2262
+ * @param {number} px the measured box
2263
+ * @returns {{steps: import('./_how-commands.mjs').Step[], kept: string[], why?: undefined} | {steps?: undefined, kept?: undefined, why: string}}
2264
+ */
2265
+ function checksBoxSteps(ctx, settings, px) {
2266
+ const C = /** @type {any} */ (ctx).C;
2267
+ const members = (FAMILIES.checks ?? []).filter(m => sizesItsOwnBox(C, m));
2268
+ if (!members.length) return {why: 'no member of checks sets its own box'};
2269
+ const drawn = selfSizedBox(ctx, settings, members[0]);
2270
+ if (!drawn)
2271
+ return {
2272
+ why:
2273
+ selfSizedWhy(ctx, settings, members[0]) ?? 'no size the editor knows',
2274
+ };
2275
+ const step = px - drawn.h;
2276
+ const sizes = /** @type {string[]} */ (
2277
+ C.variantValues(members[0])?.size ?? []
2278
+ );
2279
+ const {lines, unknown} = selfSizedBoxLines(
2280
+ ctx,
2281
+ settings,
2282
+ 'checks',
2283
+ sizes.length > 1 ? sizes : [undefined],
2284
+ box => {
2285
+ const side = Math.max(1, Math.round(Math.max(box.w, box.h) + step));
2286
+ return {w: side, h: side};
2287
+ },
2288
+ sizes.length > 1,
2289
+ );
2290
+ const kept = unknown.map(u => `${u.sz ? `size ${u.sz}: ` : ''}${u.why}`);
2291
+ /** @type {import('./_how-commands.mjs').Step[]} */
2292
+ const steps = lines.flatMap(l => [
2293
+ {verb: 'set', thing: 'width', value: `${l.next.w}px`, ...l.flags},
2294
+ {verb: 'set', thing: 'height', value: `${l.next.h}px`, ...l.flags},
2295
+ ]);
2296
+ if (!steps.length) return {why: kept.join('; ')};
2297
+ return {steps, kept};
2298
+ }
2299
+
2300
+ /**
2301
+ * The commands that make a picture's measured look, each checked as `set`
2302
+ * checks it: one result per trait, saying where it was read and how sure.
2303
+ * A trait the theme already sets keeps the theme's own value (what was typed
2304
+ * wins) and is named with the picture's reading instead.
2305
+ * @param {string} cwd
2306
+ * @param {string | undefined} name the theme asked for
2307
+ * @param {ReturnType<typeof readTraits>} read
2308
+ */
2309
+ async function pictureLook(cwd, name, read) {
2310
+ const ctx = await context(cwd);
2311
+ const groups = groupsOf(ctx);
2312
+ /** @param {string} family @param {string} on */
2313
+ const familyHolds = (family, on) => {
2314
+ const families =
2315
+ family === 'controls' ? ['button-like', 'inputs'] : [family];
2316
+ // (The family itself holds what is set on it: a height set on a
2317
+ // control is saved on the controls.)
2318
+ return (
2319
+ on === family ||
2320
+ families.some(f => on === f || (groups[f] ?? []).includes(on))
2321
+ );
2322
+ };
2323
+ const env = await howTheme(ctx, cwd, name);
2324
+ const own = env.data.settings;
2325
+ /** @type {Array<{text: string, commands: string[], refused?: Array<{command: string, why: string, run?: string[]}>}>} */
2326
+ const results = [];
2327
+ const unsure = read.unsure.map(u => ({
2328
+ text: `${u.trait} on ${u.on}: ${u.why}`,
2329
+ ...(u.options ? {options: u.options.map(st => render(st, env.slug))} : {}),
2330
+ }));
2331
+ for (const tr of read.traits) {
2332
+ const step = tr.step;
2333
+ // What the theme sets itself wins over a reading of the same aspect
2334
+ // (the corners dial and the radius tokens are one aspect, as are the
2335
+ // control size tokens), unless the two are on different parts.
2336
+ // A checks size is its box: width and height at the same px, per size.
2337
+ const checksSize = step.on === 'checks' && step.thing === 'height';
2338
+ // (A box the theme sizes, on the checks or on any one of them with
2339
+ // --only, its width or its height, is the theme's own.)
2340
+ const kept = own.find(s =>
2341
+ checksSize
2342
+ ? /^(?:width|height)$/.test(s.thing) &&
2343
+ (s.on === 'checks' ||
2344
+ (FAMILIES.checks ?? []).includes(String(s.on ?? '')))
2345
+ : aspectsOf(s.thing).some(a => aspectsOf(step.thing).includes(a)) &&
2346
+ // (A part's own setting keeps a reading only for the family the
2347
+ // reading is of, or a member of it: `corners --on button` keeps a
2348
+ // button-like reading, never a theme-wide radius the card sets
2349
+ // apart from.)
2350
+ (!s.on || familyHolds(step.on ?? tr.on, String(s.on))),
2351
+ );
2352
+ const box = checksSize
2353
+ ? checksBoxSteps(ctx, own, Number.parseFloat(String(step.value)))
2354
+ : null;
2355
+ if (kept) {
2356
+ unsure.push({
2357
+ text: `${tr.trait} on ${tr.on}: the picture reads ${tr.value} (${tr.read}); ${env.slug} sets ${kept.thing}${kept.on ? ` on ${kept.on}` : ''} ${kept.value} already, which stays`,
2358
+ options: (box?.steps ?? [step]).map(st => render(st, env.slug)),
2359
+ });
2360
+ continue;
2361
+ }
2362
+ if (box?.why) {
2363
+ unsure.push({
2364
+ text: `${tr.trait} on ${tr.on}: the picture reads ${tr.value} (${tr.read}); ${box.why}, so the box is not written`,
2365
+ });
2366
+ continue;
2367
+ }
2368
+ const {commands, refused} = checked(env, [box?.steps ?? [step]]);
2369
+ results.push({
2370
+ text: `${tr.trait} on ${tr.on}: ${tr.value}, read from ${tr.read}${tr.sure === 'about' ? ' (about: few boxes)' : ''}${box?.kept?.length ? `; width and height at each size, by the same step; kept: ${box.kept.join('; ')}` : box?.steps ? '; width and height at each size, by the same step' : ''}`,
2371
+ commands,
2372
+ ...(refused.length ? {refused} : {}),
2373
+ });
2374
+ }
2375
+ return {
2376
+ theme: env.slug,
2377
+ themeChosenBy: env.chosenBy,
2378
+ ...(env.note ? {themeNote: env.note} : {}),
2379
+ look: {
2380
+ source: 'picture',
2381
+ scale: read.scale,
2382
+ traits: read.traits.map(({step: _step, ...tr}) => tr),
2383
+ slots: read.slots,
2384
+ },
2385
+ results,
2386
+ unsure,
2002
2387
  };
2003
2388
  }