@astryxdesign/cli 0.7.17 → 0.7.18-canary.g57306fd

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 (241) 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/theme/_adapter.mjs +48 -12
  48. package/api/theme/build/build.d.mts +4 -0
  49. package/api/theme/build/build.mjs +69 -18
  50. package/api/theme/build/style-keys.mjs +4 -5
  51. package/api/theme/build/theme-object.mjs +5 -0
  52. package/api/theme/palette/generate/color.d.mts +47 -0
  53. package/api/theme/palette/generate/color.mjs +58 -1
  54. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  55. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  56. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  57. package/api/theme/palette/generate/editor-look.mjs +550 -0
  58. package/api/theme/palette/generate/mapping.d.mts +94 -9
  59. package/api/theme/palette/generate/mapping.mjs +94 -22
  60. package/api/theme-edit/_adapter.mjs +13 -2
  61. package/api/theme-edit/_catalog.d.mts +13 -13
  62. package/api/theme-edit/_catalog.mjs +66 -28
  63. package/api/theme-edit/_check.d.mts +82 -6
  64. package/api/theme-edit/_check.mjs +1270 -238
  65. package/api/theme-edit/_color.d.mts +74 -0
  66. package/api/theme-edit/_color.mjs +168 -3
  67. package/api/theme-edit/_compiler.d.mts +3 -5
  68. package/api/theme-edit/_compiler.mjs +122 -23
  69. package/api/theme-edit/_context.d.mts +55 -12
  70. package/api/theme-edit/_context.mjs +114 -60
  71. package/api/theme-edit/_css.d.mts +11 -0
  72. package/api/theme-edit/_css.mjs +40 -0
  73. package/api/theme-edit/_edit.d.mts +15 -2
  74. package/api/theme-edit/_edit.mjs +1469 -133
  75. package/api/theme-edit/_how-commands.d.mts +116 -0
  76. package/api/theme-edit/_how-commands.mjs +227 -115
  77. package/api/theme-edit/_how-question.d.mts +74 -29
  78. package/api/theme-edit/_how-question.mjs +8514 -1256
  79. package/api/theme-edit/_how-sides.d.mts +22 -0
  80. package/api/theme-edit/_how-sides.mjs +173 -0
  81. package/api/theme-edit/_how-steps.d.mts +42 -0
  82. package/api/theme-edit/_how-steps.mjs +208 -0
  83. package/api/theme-edit/_how-values.d.mts +29 -0
  84. package/api/theme-edit/_how-values.mjs +111 -0
  85. package/api/theme-edit/_how-words.d.mts +15 -0
  86. package/api/theme-edit/_how-words.mjs +239 -0
  87. package/api/theme-edit/_how.d.mts +1 -1
  88. package/api/theme-edit/_how.mjs +422 -37
  89. package/api/theme-edit/_missed.d.mts +2 -1
  90. package/api/theme-edit/_missed.mjs +125 -13
  91. package/api/theme-edit/_normal.d.mts +5 -3
  92. package/api/theme-edit/_normal.mjs +54 -14
  93. package/api/theme-edit/_palette.d.mts +204 -4
  94. package/api/theme-edit/_palette.mjs +901 -25
  95. package/api/theme-edit/_part-pieces.d.mts +54 -0
  96. package/api/theme-edit/_part-pieces.mjs +179 -0
  97. package/api/theme-edit/_part-words.mjs +33 -5
  98. package/api/theme-edit/_parts.d.mts +133 -0
  99. package/api/theme-edit/_parts.mjs +599 -10
  100. package/api/theme-edit/_picture-traits.d.mts +259 -0
  101. package/api/theme-edit/_picture-traits.mjs +1030 -0
  102. package/api/theme-edit/_preview.d.mts +95 -4
  103. package/api/theme-edit/_preview.mjs +284 -31
  104. package/api/theme-edit/_project.d.mts +14 -4
  105. package/api/theme-edit/_project.mjs +95 -26
  106. package/api/theme-edit/_resolved.d.mts +46 -0
  107. package/api/theme-edit/_resolved.mjs +800 -0
  108. package/api/theme-edit/_set-line.d.mts +29 -0
  109. package/api/theme-edit/_set-line.mjs +100 -0
  110. package/api/theme-edit/_settings.d.mts +625 -28
  111. package/api/theme-edit/_settings.mjs +4867 -888
  112. package/api/theme-edit/_tables.d.mts +25 -1
  113. package/api/theme-edit/_tables.mjs +115 -11
  114. package/api/theme-edit/_text-looks.d.mts +78 -0
  115. package/api/theme-edit/_text-looks.mjs +376 -0
  116. package/api/theme-edit/_vet.d.mts +3 -26
  117. package/api/theme-edit/_vet.mjs +5 -89
  118. package/api/theme-edit/how/how.d.mts +1 -1
  119. package/api/theme-edit/how/how.mjs +1 -1
  120. package/api/theme-edit/show/show.d.mts +4 -3
  121. package/api/theme-edit/show/show.mjs +3 -2
  122. package/api/theme-edit/theme-edit.type.d.mts +117 -1
  123. package/api/theme-edit/theme-edit.type.mjs +46 -3
  124. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  125. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  126. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  127. package/api/theme-edit/themeEditShow.doc.mjs +22 -3
  128. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  129. package/assets/component-list.generated.json +1 -1
  130. package/assets/docs/author-a-theme.doc.mjs +7 -4
  131. package/assets/docs/theme.doc.dense.mjs +10 -0
  132. package/assets/docs/theme.doc.mjs +10 -0
  133. package/assets/docs/theme.doc.zh.mjs +10 -0
  134. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  135. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  136. package/assets/docs/use-a-theme.doc.mjs +89 -17
  137. package/assets/docs-routes.generated.json +1 -1
  138. package/assets/docs.generated.json +2 -2
  139. package/assets/icons/definitions/article.doc.mjs +9 -0
  140. package/assets/icons/template-icons.json +5 -0
  141. package/assets/search-catalog.generated.json +2 -2
  142. package/assets/self-audit.generated.json +1 -1
  143. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  144. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  145. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  146. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  147. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  148. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  149. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  150. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  151. package/assets/templates/components.generated.json +1 -1
  152. package/assets/templates/pages/ide/page.tsx +5 -10
  153. package/assets/templates/pages/payment-form/page.tsx +16 -60
  154. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  155. package/authoring/debug/parse.d.mts +1 -1
  156. package/authoring/doctypes/_schema.d.mts +13 -13
  157. package/authoring/gap-report/parse.d.mts +1 -1
  158. package/clients/cli/build-id.generated.json +1 -1
  159. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  160. package/clients/cli/commands/experimental/icon.mjs +7 -7
  161. package/clients/cli/commands/experimental/theme.mjs +175 -13
  162. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  163. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  164. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  165. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  166. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  167. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  168. package/clients/cli/commands/hook.mjs +7 -0
  169. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  170. package/clients/cli/index.mjs +6 -2
  171. package/clients/cli/lib/hook-format.mjs +41 -1
  172. package/clients/cli/lib/json-shim.mjs +34 -14
  173. package/clients/cli/lib/other-cli-words.mjs +7 -0
  174. package/clients/cli/lib/unknown-command.mjs +345 -46
  175. package/clients/cli/manifest.generated.json +1 -1
  176. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  177. package/foundation/agent-docs/agent-docs.mjs +51 -8
  178. package/foundation/config/project.d.mts +11 -1
  179. package/foundation/config/project.mjs +11 -2
  180. package/foundation/discovery/component-replacement.d.mts +5 -8
  181. package/foundation/discovery/component-replacement.mjs +12 -14
  182. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  183. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  184. package/foundation/discovery/core-elements.d.mts +6 -0
  185. package/foundation/discovery/core-elements.mjs +10 -2
  186. package/foundation/discovery/core-prop-types.d.mts +5 -0
  187. package/foundation/discovery/core-prop-types.mjs +10 -3
  188. package/foundation/discovery/core-props.d.mts +8 -0
  189. package/foundation/discovery/core-props.mjs +29 -13
  190. package/foundation/discovery/icon-ranking.d.mts +5 -2
  191. package/foundation/discovery/icon-ranking.mjs +101 -18
  192. package/foundation/discovery/icon-set-checks.mjs +1 -1
  193. package/foundation/discovery/icon-set-writer.mjs +1 -1
  194. package/foundation/discovery/official-list.d.mts +17 -0
  195. package/foundation/discovery/official-list.mjs +77 -0
  196. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  197. package/foundation/discovery/unknown-core-props.mjs +601 -0
  198. package/foundation/discovery/written-prop-values.d.mts +35 -0
  199. package/foundation/discovery/written-prop-values.mjs +258 -0
  200. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  201. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  202. package/foundation/fs/package-name.d.mts +10 -0
  203. package/foundation/fs/package-name.mjs +37 -0
  204. package/foundation/fs/project-source-files.d.mts +27 -0
  205. package/foundation/fs/project-source-files.mjs +115 -0
  206. package/foundation/fs/project-sources.d.mts +25 -0
  207. package/foundation/fs/project-sources.mjs +83 -0
  208. package/foundation/fs/read-record.d.mts +18 -0
  209. package/foundation/fs/read-record.mjs +36 -2
  210. package/foundation/integrations/integration-warnings.d.mts +39 -7
  211. package/foundation/integrations/integration-warnings.mjs +141 -19
  212. package/foundation/integrations/missing-dependency.d.mts +11 -0
  213. package/foundation/integrations/missing-dependency.mjs +20 -5
  214. package/foundation/release/folder-lock.d.mts +5 -2
  215. package/foundation/release/folder-lock.mjs +9 -3
  216. package/foundation/release/notices.mjs +2 -8
  217. package/foundation/render/cut-short.d.mts +8 -2
  218. package/foundation/render/cut-short.mjs +50 -5
  219. package/foundation/render/drawn-contrast.d.mts +40 -0
  220. package/foundation/render/drawn-contrast.mjs +355 -0
  221. package/foundation/render/file-header.mjs +4 -0
  222. package/foundation/render/layers.d.mts +2 -1
  223. package/foundation/render/layers.mjs +22 -1
  224. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  225. package/foundation/render/package-resolve-hooks.mjs +124 -32
  226. package/foundation/render/page-worker.mjs +95 -23
  227. package/foundation/render/part-boxes.d.mts +27 -0
  228. package/foundation/render/part-boxes.mjs +45 -0
  229. package/foundation/render/picture-chrome.mjs +36 -4
  230. package/foundation/render/picture-playwright.mjs +26 -2
  231. package/foundation/render/picture-window.d.mts +29 -2
  232. package/foundation/render/picture-window.mjs +99 -1
  233. package/foundation/render/render-page.d.mts +39 -6
  234. package/foundation/render/render-page.mjs +26 -10
  235. package/foundation/render/ts-paths.mjs +2 -1
  236. package/foundation/response/error-codes.doc.mjs +1 -1
  237. package/foundation/response/error-codes.mjs +1 -1
  238. package/foundation/response/response-types.doc.mjs +9 -5
  239. package/foundation/text/written-string.d.mts +4 -1
  240. package/foundation/text/written-string.mjs +4 -1
  241. package/package.json +8 -7
@@ -18,7 +18,7 @@ import {
18
18
  vendorProperties,
19
19
  } from './_css.mjs';
20
20
  import * as path from 'node:path';
21
- import {AstryxError} from '../error.mjs';
21
+ import {AstryxError, brokenInstallError} from '../error.mjs';
22
22
  import {
23
23
  followLine,
24
24
  readSetLine,
@@ -45,7 +45,6 @@ import {
45
45
  CSS_PSEUDO_ELEMENTS,
46
46
  ONE_COLON_PSEUDO_ELEMENTS,
47
47
  DIALS,
48
- FAMILIES,
49
48
  FONT_ROLES,
50
49
  HEADING_TRACKING,
51
50
  HEADING_WEIGHTS,
@@ -57,6 +56,7 @@ import {
57
56
  familyOf,
58
57
  wordTable,
59
58
  onlyMeans,
59
+ pageColorNote,
60
60
  } from './_tables.mjs';
61
61
  import {
62
62
  commitTheme,
@@ -72,6 +72,14 @@ import {
72
72
  printedEntry,
73
73
  readSavedStates,
74
74
  keyOf,
75
+ sharedControlHeight,
76
+ setsControlHeight,
77
+ narrowedGroupHeight,
78
+ CONTROL_SIZES,
79
+ partHasWhen,
80
+ isControlHeight,
81
+ growsWithContent,
82
+ notGrowingWhens,
75
83
  loadTheme,
76
84
  maskedSettings,
77
85
  modesOf,
@@ -117,6 +125,8 @@ import {
117
125
  refuseThemeParse,
118
126
  ownSourceTokens,
119
127
  ownSourceTokenValues,
128
+ baseTopTokens,
129
+ baseComponentReads,
120
130
  ownTokenEntries,
121
131
  fontOf,
122
132
  ownThemeInput,
@@ -138,6 +148,7 @@ import {
138
148
  dialValueFits,
139
149
  holdAfterBuild,
140
150
  cornersPlain,
151
+ pillShapes,
141
152
  setArgs,
142
153
  editedThemes,
143
154
  entryFieldNames,
@@ -150,20 +161,28 @@ import {
150
161
  OPEN_SECTION,
151
162
  FOLLOWS,
152
163
  baseRedraws,
164
+ groupsOf,
165
+ savedSetting,
166
+ membersOf,
167
+ controlHeightValue,
153
168
  } from './_settings.mjs';
154
169
  import {
170
+ BORDER_COLOR_PROP,
171
+ BORDER_TO_COLOR,
172
+ borderFor,
173
+ broughtBorderAt,
174
+ turnsBorderOff,
155
175
  checkSetting,
156
176
  indicatorLines,
157
177
  selectedBoxes,
158
178
  coveredPaints,
159
179
  dividerParts,
160
180
  normalizeEntry,
161
- pillDrawnRadios,
162
- pillParts,
163
181
  propertyValueProblem,
164
182
  storedProblems,
165
183
  unknownVarRef,
166
184
  STATE_WORDS,
185
+ partNamed,
167
186
  } from './_check.mjs';
168
187
  import {MODAL, isColorToken} from './_compiler.mjs';
169
188
  import {fontShorthandFamilyList} from '../theme/build/font-warning.mjs';
@@ -189,7 +208,7 @@ import {
189
208
  cycleProblem,
190
209
  writtenPrimitive,
191
210
  } from '../theme/build/written-values.mjs';
192
- import {colorProblem, hex, parseColor} from './_color.mjs';
211
+ import {alphaOf, colorProblem, hex, parseColor} from './_color.mjs';
193
212
  import {hexToOklch, oklchClampedHex} from '../theme/palette/generate/color.mjs';
194
213
  import {
195
214
  PALETTE_DIALS,
@@ -207,10 +226,19 @@ import {
207
226
  seedOf,
208
227
  seedsInEffect,
209
228
  isEditorTemp,
229
+ isLookToken,
230
+ exactTokens,
231
+ lookCollapsed,
232
+ categoryNotes,
233
+ vibrancyTakes,
234
+ derivedStatusWords,
235
+ paletteRecipeUnknown,
210
236
  } from './_palette.mjs';
211
237
  import {
212
238
  renderPreview,
213
239
  renderSheet,
240
+ partSizeChanges,
241
+ sizeChangeNote,
214
242
  pageInTheWay,
215
243
  inTheWayPhrase,
216
244
  previewIsCurrent,
@@ -220,6 +248,7 @@ import {
220
248
  copyFontsCss,
221
249
  writeAppCopy,
222
250
  touchedFamilies,
251
+ shownOnSection,
223
252
  } from './_preview.mjs';
224
253
  import {appWiring, refreshPreviewRoute, seeLine} from './_preview-app.mjs';
225
254
  /** The preview command, as a person runs it. */
@@ -245,6 +274,7 @@ import {
245
274
  cutShortProblem,
246
275
  openStatesPage,
247
276
  fontNotes,
277
+ fontsNotLoaded,
248
278
  themeImageNotes,
249
279
  styledChanges,
250
280
  previewAfter,
@@ -1884,6 +1914,110 @@ export function stoppedAfterSave(
1884
1914
  };
1885
1915
  }
1886
1916
 
1917
+ /**
1918
+ * The width a border at the theme's border width draws, as the build
1919
+ * resolves --border-width (its mode's value; the light one when the theme
1920
+ * shows both).
1921
+ * @param {{light: Record<string, string>, dark: Record<string, string>} | undefined} res
1922
+ * @param {import('./_settings.mjs').ThemeData} data
1923
+ */
1924
+ function borderWidthOf(res, data) {
1925
+ const mode = data.mode === 'dark-only' ? 'dark' : 'light';
1926
+ const v = String(res?.[mode]?.['--border-width'] ?? '').trim();
1927
+ return /^\d*\.?\d+(?:px|rem|em)$/.test(v) ? v : 'theme-width';
1928
+ }
1929
+
1930
+ /**
1931
+ * The sheet as the theme's build draws it now, written to the project's
1932
+ * cache to be measured: before a change is built, it is the theme as it
1933
+ * was. Only the section of the measured part's family is drawn when the
1934
+ * part sits in one (its boxes are the same there as on the whole sheet);
1935
+ * the whole sheet otherwise. Null when it cannot be made (the measure then
1936
+ * says so).
1937
+ * @param {import('./_settings.mjs').Ctx} ctx
1938
+ * @param {string} slug
1939
+ * @param {import('./_settings.mjs').ThemeData} data
1940
+ * @param {'before' | 'after'} tag
1941
+ * @param {import('./_settings.mjs').Setting} measured the setting whose part is measured
1942
+ * @returns {Promise<{file: string} | {problem: string}>}
1943
+ */
1944
+ async function sizeSheet(ctx, slug, data, tag, measured) {
1945
+ if (!ctx.project.cacheDir)
1946
+ return {problem: 'the sheet has no cache folder to be drawn in'};
1947
+ const out = path.join(
1948
+ ctx.project.cacheDir,
1949
+ `size-${slug}-${process.pid}-${tag}.html`,
1950
+ );
1951
+ const families = touchedFamilies(ctx, {
1952
+ ...data,
1953
+ settings: [measured],
1954
+ });
1955
+ // (One section's page, the faster sheet, only where it draws each part
1956
+ // measured in a cell of its own: a dialog's header shows only inside the
1957
+ // open dialog, so the whole sheet measures it.)
1958
+ const measuredParts = new Set(partsOf(ctx, measured));
1959
+ const section =
1960
+ families.length === 1 &&
1961
+ Object.entries(ctx.project.components).every(
1962
+ ([name, info]) =>
1963
+ !info.targets.some(t =>
1964
+ measuredParts.has(t.className.replace(/^astryx-/, '')),
1965
+ ) || shownOnSection(ctx.project, name, families[0]),
1966
+ )
1967
+ ? families[0]
1968
+ : null;
1969
+ try {
1970
+ await renderSheet(ctx, slug, data, {
1971
+ out,
1972
+ ...(section ? {group: section} : {}),
1973
+ });
1974
+ return {file: out};
1975
+ } catch (e) {
1976
+ if (/** @type {any} */ (e)?.lockLost) throw e;
1977
+ return {
1978
+ problem: `the sheet could not be drawn (${e instanceof Error ? e.message.split('\n')[0] : String(e)})`,
1979
+ };
1980
+ }
1981
+ }
1982
+
1983
+ /**
1984
+ * What the border brought for a color moves on the page: the part's boxes
1985
+ * on the sheet before and after the change, at rest and in each state the
1986
+ * sheet draws, measured in one browser run. Says how much the part grows,
1987
+ * that it keeps its size, or why it was not measured.
1988
+ * @param {import('./_settings.mjs').Ctx} ctx
1989
+ * @param {string} slug
1990
+ * @param {import('./_settings.mjs').ThemeData} data
1991
+ * @param {import('./_settings.mjs').Setting} added
1992
+ * @param {{file: string} | {problem: string}} before
1993
+ * @returns {Promise<string>}
1994
+ */
1995
+ async function borderSizeNote(ctx, slug, data, added, before) {
1996
+ const unmeasured = (/** @type {string} */ why) =>
1997
+ `the size change the added border makes on ${added.on} was not measured: ${why}`;
1998
+ if ('problem' in before) return unmeasured(before.problem);
1999
+ const after = await sizeSheet(ctx, slug, data, 'after', added);
2000
+ try {
2001
+ if ('problem' in after) return unmeasured(after.problem);
2002
+ const parts = partsOf(ctx, added);
2003
+ const r = await partSizeChanges(
2004
+ ctx.project,
2005
+ before.file,
2006
+ after.file,
2007
+ parts,
2008
+ data.mode === 'dark-only' ? 'dark' : 'light',
2009
+ );
2010
+ if ('problem' in r) return unmeasured(r.problem);
2011
+ return (
2012
+ sizeChangeNote(r.changes, 'the added border') ??
2013
+ unmeasured(`${parts.join(', ')} is not drawn on the sheet`)
2014
+ );
2015
+ } finally {
2016
+ for (const f of [before.file, 'file' in after ? after.file : null])
2017
+ if (f) fs.rmSync(f, {force: true});
2018
+ }
2019
+ }
2020
+
1887
2021
  /**
1888
2022
  * The preview after a change, with the in-app preview route kept in step:
1889
2023
  * its imports follow the theme, such as the stylesheet of a font package
@@ -2066,8 +2200,8 @@ async function labelRead(scope, cwd) {
2066
2200
  const target = await openProject(cwd)
2067
2201
  .then(p => p.target)
2068
2202
  .catch(() => null);
2069
- if (target?.has(word) || FAMILIES[word]) return {on: word};
2070
- const parts = [...(target?.keys() ?? []), ...Object.keys(FAMILIES)];
2203
+ if (target?.has(word) || groupsOf(null)[word]) return {on: word};
2204
+ const parts = [...(target?.keys() ?? []), ...Object.keys(groupsOf(null))];
2071
2205
  if (parts.filter(n => typoNear(word, n)).length === 1)
2072
2206
  return {on: scope.label.trim()};
2073
2207
  // A state (`(hover)`) is that state.
@@ -2328,9 +2462,67 @@ async function loadedForCheck(cwd, slug, skip) {
2328
2462
  }
2329
2463
  }
2330
2464
 
2465
+ /**
2466
+ * A look set on one member of a family role ("set … background-image …
2467
+ * --on toggle-button", "border-radius 4px --on side-nav-item --state
2468
+ * selected"): the family's other members that draw alike but do not share
2469
+ * it (the theme set nothing of that kind on them), named, with the one line
2470
+ * that gives it to the family. The set itself stays on the member asked.
2471
+ * @param {any} ctx @param {string} slug
2472
+ * @param {import('./_settings.mjs').ThemeData} data
2473
+ * @param {import('./_settings.mjs').Setting} s
2474
+ * @returns {Array<{note: string, run: string[]}>}
2475
+ */
2476
+ function familyLeftOut(ctx, slug, data, s) {
2477
+ const thing = kebab(String(s.thing));
2478
+ const selected = /^(?:selected|active)$/.test(String(s.state ?? ''));
2479
+ const look = selected
2480
+ ? /^(?:background(?:-color|-image)?|border-radius|corners)$/.test(thing)
2481
+ : !s.state &&
2482
+ !/^(?:none|0|0px|transparent|initial|unset)$/i.test(
2483
+ String(s.value ?? '').trim(),
2484
+ ) &&
2485
+ (/^(?:background-image|box-shadow|border)$/.test(thing) ||
2486
+ (thing === 'background' && /gradient\(/.test(String(s.value))));
2487
+ const groups = groupsOf(ctx);
2488
+ const rule =
2489
+ !s.state &&
2490
+ /^border-(?:bottom|top|block-end|block-start)$/.test(thing) &&
2491
+ (groups['overlay-headers'] ?? []).includes(String(s.on));
2492
+ if (!look && !rule) return [];
2493
+ const role = rule
2494
+ ? 'overlay-headers'
2495
+ : (selected
2496
+ ? ['selected-items']
2497
+ : ['button-like', 'overlays', 'option-rows', 'status-surfaces']
2498
+ ).find(r => (groups[r] ?? []).includes(String(s.on)));
2499
+ if (!role) return [];
2500
+ const others = (groups[role] ?? []).filter(
2501
+ m =>
2502
+ m !== s.on &&
2503
+ ctx.project.target.has(m) &&
2504
+ !data.settings.some(
2505
+ x =>
2506
+ x.on === m &&
2507
+ kebab(String(x.thing)) === thing &&
2508
+ (x.state ?? '') === (s.state ?? ''),
2509
+ ),
2510
+ );
2511
+ if (!others.length) return [];
2512
+ return [
2513
+ {
2514
+ note: `${others.join(', ')} ${others.length > 1 ? 'are' : 'is'} of ${s.on}'s family (${role}) but ${others.length > 1 ? 'do' : 'does'} not share this look; this gives it to the family (a member set on its own keeps its own):`,
2515
+ run: [
2516
+ `${P} set ${slug} ${s.thing} ${quoteCommandArgument(String(s.value))} --on ${role}${s.state ? ` --state ${s.state}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`,
2517
+ ],
2518
+ },
2519
+ ];
2520
+ }
2521
+
2331
2522
  /**
2332
2523
  * What a whole-theme change leaves out, by the census, each with the lines
2333
- * that reach it, one per part: square corners leave the parts drawn as
2524
+ * that reach it, one per part: corners leave the parts the theme gives
2525
+ * corners of their own as they are; square corners leave the parts drawn as
2334
2526
  * pills round (they read --radius-full); a wider or narrower
2335
2527
  * --border-width does not reach the surfaces that draw no border or a
2336
2528
  * fixed line of their own, and moves every divider's rule with it.
@@ -2342,35 +2534,58 @@ async function loadedForCheck(cwd, slug, skip) {
2342
2534
  * @returns {Array<{note: string, run: string[]}>}
2343
2535
  */
2344
2536
  function leftOutParts(ctx, slug, data, sub, s) {
2537
+ if (sub === 'set' && s.on && !s.when)
2538
+ return familyLeftOut(ctx, slug, data, s);
2345
2539
  if (sub !== 'set' || s.on || s.when || s.state) return [];
2346
2540
  const C = ctx.C;
2347
2541
  const has = (/** @type {string} */ p) => ctx.project.target.has(p);
2348
2542
  /** @type {Array<{note: string, run: string[]}>} */
2349
2543
  const out = [];
2544
+ // Whole-theme corners never reach a part the theme gives corners of its
2545
+ // own (border-radius 12px --on dialog, corners pill --on button): those
2546
+ // parts are named as kept, with the lines that hand them back to the
2547
+ // dial.
2548
+ if (s.source === 'dial' && s.thing === 'corners') {
2549
+ const own = data.settings.filter(
2550
+ x =>
2551
+ x.on &&
2552
+ !x.state &&
2553
+ (x.thing === 'corners' ||
2554
+ /^border-(?:(?:top|bottom)-(?:left|right)-|(?:start|end)-(?:start|end)-)?radius$/.test(
2555
+ String(x.thing),
2556
+ )),
2557
+ );
2558
+ const parts = [...new Set(own.map(x => String(x.on)))];
2559
+ if (parts.length)
2560
+ out.push({
2561
+ note: `${parts.join(', ')} ${parts.length > 1 ? 'keep their' : 'keeps its'} own corners (set on ${parts.length > 1 ? 'them' : 'it'} in this theme), which the corners dial does not change; ${own.length > 1 ? 'these hand them' : 'this hands it'} back to the dial:`,
2562
+ run: own.map(x => `${P} undo ${slug} ${undoArgs(x)}`),
2563
+ });
2564
+ }
2565
+ // Square corners square the pills that are a styling choice (the build
2566
+ // does), and corners of an explicit size (Bootstrap's 4px) give them that
2567
+ // size; the parts drawn as circles keep their shape either way, said,
2568
+ // with the lines that give them the corners too.
2569
+ const plain =
2570
+ s.source === 'dial' && s.thing === 'corners'
2571
+ ? cornersPlain(String(s.value))
2572
+ : null;
2573
+ const sized =
2574
+ plain != null && /^\d*\.?\d+px$/.test(plain) && cornerPx(plain) < 9999;
2350
2575
  if (
2351
- s.source === 'dial' &&
2352
- s.thing === 'corners' &&
2353
- ['square', '0px'].includes(cornersPlain(String(s.value)) ?? '') &&
2576
+ plain != null &&
2577
+ (['square', '0px'].includes(plain) || sized) &&
2354
2578
  !data.settings.some(x => x.thing === '--radius-full' && !x.on)
2355
2579
  ) {
2356
- const pills = pillParts(C).filter(has);
2357
- // On a Core that draws a radio's circle with the pill token, the radio
2358
- // marks keep it at Core's value (pillDrawnRadios).
2359
- const radios = pillDrawnRadios(C).filter(has);
2360
- const round = String(
2361
- ctx.project.core.tokenDefaults?.['--radius-full'] ?? '9999px',
2362
- );
2363
- /** @param {string} m */
2364
- const only = m => (onlyMeans(m) === 'member' ? ' --only' : '');
2365
- if (pills.length)
2580
+ const circles = pillShapes(C).circles.filter(has);
2581
+ const square = ['square', '0px'].includes(plain);
2582
+ if (circles.length)
2366
2583
  out.push({
2367
- note: `the parts drawn as pills stay round (${pills.join(', ')}): they read --radius-full, which corners leaves as it is; ${radios.length ? `these square them and keep the radio marks round (${radios.join(', ')})` : 'this squares them'}:`,
2368
- run: [
2369
- `${P} set ${slug} --radius-full 0px`,
2370
- ...radios.map(
2371
- m => `${P} set ${slug} --radius-full ${round} --on ${m}${only(m)}`,
2372
- ),
2373
- ],
2584
+ note: `the parts drawn as circles stay round (${circles.join(', ')}): a circle is their shape, not a corner choice; ${square ? 'to square one:' : `to give them these ${plain} corners too:`}`,
2585
+ run: (square ? circles.slice(0, 3) : circles).map(
2586
+ m =>
2587
+ `${P} set ${slug} corners ${square ? 'square' : plain} --on ${m}`,
2588
+ ),
2374
2589
  });
2375
2590
  }
2376
2591
  if (s.source === 'token' && s.thing === '--border-width') {
@@ -2574,6 +2789,8 @@ async function withSavedRepair(e, slug, cwd) {
2574
2789
  when: scoped.when,
2575
2790
  state: scoped.state,
2576
2791
  mode: scoped.mode,
2792
+ // Checked as `set` runs the line: a box shorthand as its sides.
2793
+ sides: true,
2577
2794
  },
2578
2795
  false,
2579
2796
  );
@@ -2851,8 +3068,13 @@ async function swappedOrder(e, sub, words, options) {
2851
3068
  * @param {import('./_settings.mjs').ThemeData} data
2852
3069
  * @param {string | {thing: string, on?: string, when?: string, state?: string, mode?: string}} [skip]
2853
3070
  */
2854
- function refuseStoredTokens(ctx, slug, data, skip) {
2855
- const bad = storedProblems(ctx, slug, data, skip);
3071
+ function refuseStoredTokens(
3072
+ ctx,
3073
+ slug,
3074
+ data,
3075
+ skip,
3076
+ bad = storedProblems(ctx, slug, data, skip).filter(b => !b.noEffect),
3077
+ ) {
2856
3078
  if (!bad.length) return;
2857
3079
  // A repair offers only the value it holds, cleaned: never a stock value
2858
3080
  // the saved setting did not hold.
@@ -2964,6 +3186,66 @@ function refuseStoredTokens(ctx, slug, data, skip) {
2964
3186
  }
2965
3187
  }
2966
3188
 
3189
+ /**
3190
+ * Saved settings the editor no longer takes because they do not do there
3191
+ * what was meant (a color on a part an element inside it paints over, a
3192
+ * line-height its items set themselves: refused with no effect): the theme
3193
+ * still opens. Each is kept in the file and built as an earlier editor
3194
+ * built it, so nothing anyone sees changes, and named in a note with the
3195
+ * lines that clear it (the undo and set's repair, as a refusal of it gives
3196
+ * them). Any other saved damage stops the command, with its lines, as
3197
+ * before.
3198
+ * @param {import('./_settings.mjs').Ctx} ctx
3199
+ * @param {string} slug
3200
+ * @param {import('./_settings.mjs').ThemeData} data
3201
+ * @param {string} cwd
3202
+ * @param {string | {thing: string, on?: string, when?: string, state?: string, mode?: string}} [skip]
3203
+ * @returns {Promise<string[]>} the notes
3204
+ */
3205
+ async function leaveOutStored(ctx, slug, data, cwd, skip) {
3206
+ // Any other saved damage stops the command, with its lines.
3207
+ refuseStoredTokens(ctx, slug, data, skip);
3208
+ const quiet = storedProblems(ctx, slug, data, skip).filter(b => b.noEffect);
3209
+ if (!quiet.length) return [];
3210
+ /** @type {string[]} */
3211
+ let lines = [];
3212
+ try {
3213
+ refuseStoredTokens(ctx, slug, data, skip, quiet);
3214
+ } catch (e) {
3215
+ const repaired = await savedDamageRefusal(e, slug, cwd, {ctx, data});
3216
+ lines = (
3217
+ repaired instanceof AstryxError ? (repaired.suggestions ?? []) : []
3218
+ )
3219
+ .map(x => x.name)
3220
+ .filter(n => n.startsWith(`${P} `));
3221
+ }
3222
+ // (A top or bottom padding on a control that keeps Core's padding no
3223
+ // longer builds: the note says so, never that it builds as before.)
3224
+ const unbuilt = quiet.filter(b =>
3225
+ /keeps Core's top and bottom padding/.test(b.why),
3226
+ );
3227
+ const built = quiet.filter(b => !unbuilt.includes(b));
3228
+ const what = (/** @type {typeof quiet} */ list) =>
3229
+ list
3230
+ .map(b => `${describe(b.setting)} (${b.why.replace(/\.+$/, '')})`)
3231
+ .join('; ');
3232
+ const clear = lines.length
3233
+ ? `; to clear ${quiet.length === 1 ? 'it' : 'them'}: ${lines.join(', then ')}`
3234
+ : '';
3235
+ return [
3236
+ ...(built.length
3237
+ ? [
3238
+ `${slug}.settings.json holds what this editor no longer takes, as it does not do there what was meant: ${what(built)}. ${built.length === 1 ? 'It is' : 'They are'} kept and built as an earlier editor built ${built.length === 1 ? 'it' : 'them'}, so the theme opens as it was${unbuilt.length ? '' : clear}`,
3239
+ ]
3240
+ : []),
3241
+ ...(unbuilt.length
3242
+ ? [
3243
+ `${slug}.settings.json holds what this editor no longer takes: ${what(unbuilt)}. ${unbuilt.length === 1 ? 'It is' : 'They are'} kept, but those top and bottom sides no longer build${clear}`,
3244
+ ]
3245
+ : []),
3246
+ ];
3247
+ }
3248
+
2967
3249
  /**
2968
3250
  * For `compile`: a refusal of what the settings file holds, with the lines
2969
3251
  * every command gives it (the undo and set's repair).
@@ -2989,6 +3271,7 @@ export async function editorStoredRefusal(root, slug) {
2989
3271
  try {
2990
3272
  seen.ctx = await context(root);
2991
3273
  seen.data = loadTheme(root, slug);
3274
+ // A saved setting that never shows never stops a build (leaveOutStored).
2992
3275
  refuseStoredTokens(seen.ctx, slug, seen.data);
2993
3276
  return null;
2994
3277
  } catch (e) {
@@ -4648,7 +4931,9 @@ async function followChangeLine(sub, slug, line, cwd, skip) {
4648
4931
  structuredClone(data),
4649
4932
  read.thing,
4650
4933
  read.value,
4651
- read.flags,
4934
+ // A set line is checked the way it runs: a typed box shorthand as
4935
+ // its sides.
4936
+ sub === 'set' ? {...read.flags, sides: true} : read.flags,
4652
4937
  sub === 'undo',
4653
4938
  );
4654
4939
  return sub === 'undo' && !data.settings.some(x => keyOf(x) === keyOf(s))
@@ -5314,6 +5599,21 @@ async function change(sub, slug, thing, value, options) {
5314
5599
  }
5315
5600
  }
5316
5601
 
5602
+ /**
5603
+ * The parts a height setting reaches that are not controls (the text area
5604
+ * of the inputs) and have the variant it is set for: the parts the
5605
+ * controls' shared height does not reach.
5606
+ * @param {import('./_settings.mjs').Ctx} ctx
5607
+ * @param {import('./_settings.mjs').Setting} x
5608
+ * @returns {string[]}
5609
+ */
5610
+ function notControlsReached(ctx, x) {
5611
+ const controls = new Set(groupsOf(ctx).controls ?? []);
5612
+ return partsOf(ctx, x).filter(
5613
+ t => !controls.has(t) && partHasWhen(ctx, t, x.when),
5614
+ );
5615
+ }
5616
+
5317
5617
  /**
5318
5618
  * @param {'set' | 'undo'} sub
5319
5619
  * @param {string} slug
@@ -5385,15 +5685,16 @@ async function changeOnce(
5385
5685
  ctx.takesPictures = png ? {sheet: null} : null;
5386
5686
  // An undo of one setting only removes it, so it never waits on the
5387
5687
  // others being fixed.
5388
- if (sub !== 'undo') {
5389
- refuseStoredTokens(ctx, slug, data, {
5390
- thing,
5391
- on: options.on,
5392
- when: options.when,
5393
- state: options.state,
5394
- mode: options.mode,
5395
- });
5396
- }
5688
+ if (sub !== 'undo')
5689
+ fieldNotes.push(
5690
+ ...(await leaveOutStored(ctx, slug, data, cwd, {
5691
+ thing,
5692
+ on: options.on,
5693
+ when: options.when,
5694
+ state: options.state,
5695
+ mode: options.mode,
5696
+ })),
5697
+ );
5397
5698
  const flags = {
5398
5699
  on: options.on,
5399
5700
  when: options.when,
@@ -5554,7 +5855,15 @@ async function changeOnce(
5554
5855
  s =
5555
5856
  sub === 'undo' && rawIdx >= 0
5556
5857
  ? data.settings[rawIdx]
5557
- : checkSetting(ctx, slug, data, thing, value, flags, sub === 'undo');
5858
+ : checkSetting(
5859
+ ctx,
5860
+ slug,
5861
+ data,
5862
+ thing,
5863
+ value,
5864
+ sub === 'set' ? {...flags, sides: true} : flags,
5865
+ sub === 'undo',
5866
+ );
5558
5867
  } catch (e) {
5559
5868
  // A stored setting this Core no longer knows (a renamed part or
5560
5869
  // property, or a hand edit) can still be removed.
@@ -5780,6 +6089,28 @@ async function changeOnce(
5780
6089
  })),
5781
6090
  e.code,
5782
6091
  );
6092
+ // A part named in the setting's place (`undo t card`, `undo t card
6093
+ // padding`): the undo of each setting the theme holds on that part
6094
+ // (the one named after it, when one is), as --on reads it.
6095
+ const partWord =
6096
+ !matches.length && !flags.on ? partNamed(ctx, typed) : null;
6097
+ const after = String(value ?? '')
6098
+ .trim()
6099
+ .toLowerCase();
6100
+ const onPart = partWord
6101
+ ? data.settings.filter(
6102
+ x => x.on === partWord && (!after || x.thing === after),
6103
+ )
6104
+ : [];
6105
+ if (onPart.length)
6106
+ throw new AstryxError(
6107
+ `"${thing}" is a part, not a setting; ${slug} sets ${onPart.map(x => describe(x)).join(', ')}. Nothing was changed.`,
6108
+ onPart.slice(0, 5).map(x => ({
6109
+ name: `${P} undo ${slug} ${undoArgs(x)}`,
6110
+ reason: `do this instead: ${describe({...x, value: '?'}).replace(' = ?', '')}`,
6111
+ })),
6112
+ e.code,
6113
+ );
5783
6114
  // A step back takes back the last change, which may be another
5784
6115
  // setting: it says what it takes back, and a look at the theme
5785
6116
  // follows it.
@@ -5850,7 +6181,47 @@ async function changeOnce(
5850
6181
  data.settings.some(x => keyOf(x) === keyOf({...s, mode: ownMode}))
5851
6182
  )
5852
6183
  s = {...s, mode: ownMode};
6184
+ // A box shorthand written as its sides (a menu's padding of two to four
6185
+ // lengths): the first side is this change's setting, and the others are
6186
+ // written beside it in the same change, so one undo takes back all.
6187
+ /** @type {import('./_settings.mjs').Setting[]} */
6188
+ const sidesBeside = [];
6189
+ const shorthand = sub === 'set' && s.sides?.length ? s : null;
6190
+ if (shorthand?.sides) {
6191
+ const [first, ...rest] = shorthand.sides;
6192
+ s = first;
6193
+ sidesBeside.push(...rest);
6194
+ }
6195
+ // The sides this change writes or moves: the ones its undo takes back.
6196
+ /** @type {Set<import('./_settings.mjs').Setting>} */
6197
+ const sidesMoved = new Set();
6198
+ // A height set on a control is the height every control takes at that
6199
+ // size, so it is written as the size's token on the controls group.
6200
+ const sharedHeight = sub === 'set' ? sharedControlHeight(ctx, s) : null;
6201
+ const heightAsked = sharedHeight ? s : null;
6202
+ if (sharedHeight) s = sharedHeight.setting;
6203
+ // An undo of a control height named as it was set removes the size
6204
+ // token set wrote for it.
6205
+ if (sub === 'undo' && !data.settings.some(x => keyOf(x) === keyOf(s))) {
6206
+ const asSet = sharedControlHeight(ctx, {
6207
+ ...s,
6208
+ value: String(s.value ?? ''),
6209
+ });
6210
+ if (asSet && data.settings.some(x => keyOf(x) === keyOf(asSet.setting)))
6211
+ s = {...asSet.setting, value: s.value};
6212
+ }
5853
6213
  let k = keyOf(s);
6214
+ // (The settings as the theme held them before this change: what a carried
6215
+ // height read there.)
6216
+ const settingsBefore = [...data.settings];
6217
+ // (A saved control height the shared one gives way to is replaced below,
6218
+ // with the sizes it keeps.)
6219
+ if (
6220
+ sharedHeight &&
6221
+ rawIdx >= 0 &&
6222
+ setsControlHeight(ctx, data.settings[rawIdx], sharedHeight.size)
6223
+ )
6224
+ rawIdx = -1;
5854
6225
  let prevIdx =
5855
6226
  rawIdx >= 0
5856
6227
  ? rawIdx
@@ -5859,7 +6230,14 @@ async function changeOnce(
5859
6230
  data.settings.map(x => keyOf(x)).lastIndexOf(k);
5860
6231
  /** @type {string | null} */
5861
6232
  let vibrancyGone = null;
6233
+ /** The border a border color brought to a part that drew none. @type {import('./_settings.mjs').Setting | null} */
6234
+ let borderAdded = null;
5862
6235
  let prev = prevIdx >= 0 ? data.settings[prevIdx] : null;
6236
+ // (Whether the theme set its page color before this command: the note
6237
+ // about where it shows is said once, the first time.)
6238
+ const hadPageColor = data.settings.some(
6239
+ x => x.thing === '--color-background-body' && !x.on,
6240
+ );
5863
6241
  /** The other entries of a setting listed twice by hand that this command replaces or removes. @type {import('./_settings.mjs').Setting[]} */
5864
6242
  let alsoReplaced = [];
5865
6243
  // A value is compared as `set` reads it: case, spacing around commas,
@@ -5999,7 +6377,25 @@ async function changeOnce(
5999
6377
  );
6000
6378
  }
6001
6379
  }
6002
- const compiledBefore = compileTheme(ctx, data, base);
6380
+ // (Settings whose colors were changed by hand away from a palette kept
6381
+ // as saved cannot be built: a change that brings them back is the way
6382
+ // back, compared with nothing built before.)
6383
+ let beforeUnbuilt = false;
6384
+ const compiledBefore = (() => {
6385
+ try {
6386
+ return compileTheme(ctx, data, base);
6387
+ } catch (e) {
6388
+ if (
6389
+ /** @type {any} */ (e)?.code !== E.ERR_PALETTE_GENERATION ||
6390
+ !paletteRecipeUnknown(ctx.project.cwd, slug)
6391
+ )
6392
+ throw e;
6393
+ beforeUnbuilt = true;
6394
+ return /** @type {ReturnType<typeof compileTheme>} */ (
6395
+ /** @type {unknown} */ ({tokens: {}, components: {}})
6396
+ );
6397
+ }
6398
+ })();
6003
6399
  // The build notes the theme had before this change: only new ones are
6004
6400
  // this change's to report.
6005
6401
  const notesBefore = new Set(buildNotes(ctx));
@@ -6066,9 +6462,15 @@ async function changeOnce(
6066
6462
  was: before,
6067
6463
  parts: [],
6068
6464
  group: null,
6069
- changedTokens: r.changed,
6465
+ changedTokens: lookCollapsed(
6466
+ r.changed,
6467
+ derivedStatusWords(data),
6468
+ exactTokens(data),
6469
+ ).lines,
6070
6470
  changedPartTokens: r.changedParts ?? [],
6071
- styled: styledChanges(compiledBefore, compileTheme(ctx, data, after)),
6471
+ styled: beforeUnbuilt
6472
+ ? []
6473
+ : styledChanges(compiledBefore, compileTheme(ctx, data, after)),
6072
6474
  kept: [],
6073
6475
  lifted: r.lifted,
6074
6476
  leftOut: [],
@@ -6086,6 +6488,19 @@ async function changeOnce(
6086
6488
  ]
6087
6489
  : []),
6088
6490
  ...otherModeNotes(data),
6491
+ // (A theme made one-mode draws its page in that mode only: the
6492
+ // page note, once, when the theme has said no page color yet,
6493
+ // since that note would have come with it.)
6494
+ ...(s.thing === 'mode' &&
6495
+ (data.mode === 'light-only' || data.mode === 'dark-only') &&
6496
+ before !== data.mode &&
6497
+ before !== 'light-only' &&
6498
+ before !== 'dark-only' &&
6499
+ !data.settings.some(
6500
+ x => x.thing === '--color-background-body' && !x.on,
6501
+ )
6502
+ ? [pageColorNote(data.mode)]
6503
+ : []),
6089
6504
  // A theme the app lists takes its mode from the app's theme
6090
6505
  // module: `theme add` writes it again.
6091
6506
  ...(s.thing === 'mode' && before !== data.mode
@@ -6135,6 +6550,7 @@ async function changeOnce(
6135
6550
  x.thing,
6136
6551
  slug,
6137
6552
  modesOf(data),
6553
+ vibrancyTakes(data, ownSourceTokenValues(cwd, slug)),
6138
6554
  ).slice(0, -1),
6139
6555
  ),
6140
6556
  ...cutShort.map(cutShortNote),
@@ -6239,6 +6655,35 @@ async function changeOnce(
6239
6655
  // is named.
6240
6656
  alsoReplaced = data.settings.filter(x => keyOf(x) === k);
6241
6657
  data.settings = data.settings.filter(x => keyOf(x) !== k);
6658
+ // A border the theme turned off, undone: a border color it hid on
6659
+ // those parts brings the border it needs now, so it shows. (Only an
6660
+ // undone none or zero: undoing the brought border itself, or a width
6661
+ // or style that drew, leaves the colors as they are.)
6662
+ if (
6663
+ String(prev?.value ?? s.value).trim() !== BORDER_TO_COLOR &&
6664
+ turnsBorderOff({thing: s.thing, value: prev?.value ?? s.value})
6665
+ )
6666
+ for (const x of [...data.settings]) {
6667
+ if (
6668
+ x.source !== 'property' ||
6669
+ !BORDER_COLOR_PROP.test(x.thing) ||
6670
+ !partsOf(ctx, x).some(t => partsOf(ctx, s).includes(t))
6671
+ )
6672
+ continue;
6673
+ const edge = borderFor(ctx, slug, data, x);
6674
+ if (edge) {
6675
+ // (Before the part's own border settings and the color both.)
6676
+ data.settings.splice(
6677
+ Math.min(
6678
+ broughtBorderAt(ctx, data.settings, edge),
6679
+ data.settings.indexOf(x),
6680
+ ),
6681
+ 0,
6682
+ edge,
6683
+ );
6684
+ borderAdded = edge;
6685
+ }
6686
+ }
6242
6687
  // Vibrancy needs a color: undoing the last one takes it along, so the
6243
6688
  // theme never holds a state `set` refuses.
6244
6689
  if (
@@ -6257,7 +6702,8 @@ async function changeOnce(
6257
6702
  }
6258
6703
  } else if (
6259
6704
  prev &&
6260
- JSON.stringify(prev) === JSON.stringify(s) &&
6705
+ // (By what is saved: a note the command adds is no change.)
6706
+ JSON.stringify(savedSetting(prev)) === JSON.stringify(savedSetting(s)) &&
6261
6707
  // A later setting that covers the same parts hides it: set again, it
6262
6708
  // moves last and wins.
6263
6709
  !data.settings
@@ -6268,11 +6714,57 @@ async function changeOnce(
6268
6714
  partsOf(ctx, x).some(t => partsOf(ctx, s).includes(t)),
6269
6715
  )
6270
6716
  ) {
6271
- // The same setting again: nothing moves.
6717
+ // The same setting again: nothing moves, unless it is a border color
6718
+ // that has lost the border it needs (the none that hid it undone).
6719
+ const edge = sub === 'set' ? borderFor(ctx, slug, data, s) : null;
6720
+ if (edge) {
6721
+ data.settings.splice(
6722
+ Math.min(broughtBorderAt(ctx, data.settings, edge), prevIdx),
6723
+ 0,
6724
+ edge,
6725
+ );
6726
+ borderAdded = edge;
6727
+ }
6272
6728
  } else {
6273
6729
  // A changed setting goes last, so it wins over what came before it.
6274
6730
  if (prev) data.settings.splice(prevIdx, 1);
6731
+ // A border color on a part that draws no border brings the border it
6732
+ // needs, written before it in the same change.
6733
+ if (sub === 'set') {
6734
+ borderAdded = borderFor(ctx, slug, data, s);
6735
+ if (borderAdded)
6736
+ data.settings.splice(
6737
+ broughtBorderAt(ctx, data.settings, borderAdded),
6738
+ 0,
6739
+ borderAdded,
6740
+ );
6741
+ }
6275
6742
  data.settings.push(s);
6743
+ sidesMoved.add(s);
6744
+ }
6745
+ for (const side of sidesBeside) {
6746
+ // An unchanged side stays where it is, as the first side does, unless a
6747
+ // later setting covers it.
6748
+ const at = data.settings.map(x => keyOf(x)).lastIndexOf(keyOf(side));
6749
+ if (
6750
+ at >= 0 &&
6751
+ // (By what is saved: a note the side's check adds is no change.)
6752
+ JSON.stringify(savedSetting(data.settings[at])) ===
6753
+ JSON.stringify(savedSetting(side)) &&
6754
+ !data.settings
6755
+ .slice(at + 1)
6756
+ .some(
6757
+ x =>
6758
+ x.thing === side.thing &&
6759
+ partsOf(ctx, x).some(t => partsOf(ctx, side).includes(t)),
6760
+ )
6761
+ ) {
6762
+ data.settings[at] = side;
6763
+ continue;
6764
+ }
6765
+ data.settings = data.settings.filter(x => keyOf(x) !== keyOf(side));
6766
+ data.settings.push(side);
6767
+ sidesMoved.add(side);
6276
6768
  }
6277
6769
  // A setting listed twice by hand keeps only the entry this command left;
6278
6770
  // every other entry it replaces is named in the notes.
@@ -6293,6 +6785,256 @@ async function changeOnce(
6293
6785
  alsoReplaced = data.settings.filter(replaced);
6294
6786
  data.settings = data.settings.filter((x, i) => !replaced(x, i));
6295
6787
  }
6788
+ // The other heights that set controls at that size give way to it, so
6789
+ // every control at that size takes the one height.
6790
+ /** @type {import('./_settings.mjs').Setting[]} */
6791
+ // (The same setting set again is not replaced by itself. A height kept
6792
+ // on one control replaces nothing.)
6793
+ const heightsReplaced =
6794
+ sharedHeight && !sharedHeight.own
6795
+ ? data.settings.filter(
6796
+ x =>
6797
+ x !== s &&
6798
+ keyOf(x) !== keyOf(s) &&
6799
+ // (A height on a group that mixes controls with other parts
6800
+ // reaches its controls too: it gives way there, and stays on
6801
+ // the other parts.)
6802
+ setsControlHeight(ctx, x, sharedHeight.size),
6803
+ )
6804
+ : [];
6805
+ // A replaced height set for every size stays every control's height at
6806
+ // the other sizes: those sizes' tokens on controls take its place, where
6807
+ // no other control height is set at that size.
6808
+ /** @type {string[]} */
6809
+ const heightsKept = [];
6810
+ // A replaced height also set on parts that are not controls (the text
6811
+ // area of the inputs) stays on those parts: only the controls take the
6812
+ // shared height.
6813
+ /** @type {import('./_settings.mjs').Setting[]} */
6814
+ const heightsLeftOn = [];
6815
+ /** @param {import('./_settings.mjs').Setting} x */
6816
+ const leftOnOthers = x => {
6817
+ const kept = notControlsReached(ctx, x)
6818
+ // (A size token stays where the part reads it, or where what the
6819
+ // part reads is not known, as set saves it there.)
6820
+ .filter(t => {
6821
+ if (x.source !== 'token') return true;
6822
+ if (baseComponentReads(ctx.project.cwd, data.like, t).has(x.thing))
6823
+ return true;
6824
+ const failure = ctx.C.checkTokenOn(
6825
+ slug,
6826
+ t,
6827
+ x.thing,
6828
+ String(x.value),
6829
+ P,
6830
+ x.when,
6831
+ '',
6832
+ );
6833
+ return failure == null || !!failure.soft;
6834
+ })
6835
+ .map(
6836
+ t =>
6837
+ /** @type {import('./_settings.mjs').Setting} */ ({
6838
+ ...x,
6839
+ on: t,
6840
+ ...(onlyMeans(t) === 'member' ? {only: true} : {}),
6841
+ }),
6842
+ );
6843
+ heightsLeftOn.push(...kept);
6844
+ return kept;
6845
+ };
6846
+ /**
6847
+ * A carried height, as the build showed it: every control size token it
6848
+ * reads is read as the theme held it before this change, since this
6849
+ * change writes those tokens (one of them would read itself). Null when
6850
+ * that is not known.
6851
+ * @param {string} v
6852
+ * @returns {string | null}
6853
+ */
6854
+ const carried = v => {
6855
+ let known = true;
6856
+ const out = v.replace(
6857
+ /var\(\s*(--size-element-(?:sm|md|lg))\s*(?:,[^()]*)?\)/g,
6858
+ (_, token) => {
6859
+ const held = String(
6860
+ settingsBefore
6861
+ .filter(
6862
+ y =>
6863
+ y.source === 'token' &&
6864
+ y.thing === token &&
6865
+ (!y.on || y.on === 'controls') &&
6866
+ !y.when &&
6867
+ !y.state,
6868
+ )
6869
+ .at(-1)?.value ??
6870
+ ownSourceTokenValues(ctx.project.cwd, slug)[token] ??
6871
+ baseTopTokens(ctx.project.cwd, data.like).get(token) ??
6872
+ ctx.project.core.tokenDefaults?.[token] ??
6873
+ '',
6874
+ ).trim();
6875
+ if (!held || /var\(\s*--size-element-/.test(held)) known = false;
6876
+ return held;
6877
+ },
6878
+ );
6879
+ // (A word height is not a size: it is not carried as a size token.)
6880
+ return known && controlHeightValue(out) ? out : null;
6881
+ };
6882
+ // (Of several, the last one is the one the build showed there.)
6883
+ const lastEverySize = sharedHeight
6884
+ ? heightsReplaced
6885
+ .filter(x => x.source === 'property' && x.when == null)
6886
+ .at(-1)
6887
+ : undefined;
6888
+ if (sharedHeight)
6889
+ data.settings = data.settings.flatMap(x => {
6890
+ if (!heightsReplaced.includes(x)) return [x];
6891
+ const others =
6892
+ x.source === 'property' || groupsOf(ctx)[String(x.on)]
6893
+ ? leftOnOthers(x)
6894
+ : [];
6895
+ if (x !== lastEverySize) return others;
6896
+ return [
6897
+ ...others,
6898
+ ...CONTROL_SIZES.filter(
6899
+ size =>
6900
+ size !== sharedHeight.size &&
6901
+ !data.settings.some(
6902
+ y =>
6903
+ y !== x &&
6904
+ !heightsReplaced.includes(y) &&
6905
+ setsControlHeight(ctx, y, size),
6906
+ ) &&
6907
+ carried(String(x.value)) != null,
6908
+ ).map(size => {
6909
+ heightsKept.push(size);
6910
+ return /** @type {import('./_settings.mjs').Setting} */ ({
6911
+ thing: `--size-element-${size}`,
6912
+ value: /** @type {string} */ (carried(String(x.value))),
6913
+ source: 'token',
6914
+ on: 'controls',
6915
+ ...(x.mode ? {mode: x.mode} : {}),
6916
+ });
6917
+ }),
6918
+ ];
6919
+ });
6920
+ // A shared height replaces the heights kept on one control at that size
6921
+ // too (its own size token, or a height saved with --only): every control
6922
+ // at that size takes the one height. One kept for every size stays that
6923
+ // control's own height at the other sizes.
6924
+ /** @type {import('./_settings.mjs').Setting[]} */
6925
+ const ownHeightsReplaced =
6926
+ sharedHeight && !sharedHeight.own
6927
+ ? data.settings.filter(
6928
+ x =>
6929
+ x !== s &&
6930
+ keyOf(x) !== keyOf(s) &&
6931
+ !x.state &&
6932
+ (groupsOf(ctx).controls ?? []).includes(String(x.on)) &&
6933
+ ((x.source === 'token' &&
6934
+ x.thing === sharedHeight.token &&
6935
+ x.when == null) ||
6936
+ (x.source === 'property' &&
6937
+ x.only === true &&
6938
+ !narrowedGroupHeight(x) &&
6939
+ isControlHeight(ctx, x) &&
6940
+ (x.when == null || x.when === `size:${sharedHeight.size}`))),
6941
+ )
6942
+ : [];
6943
+ if (sharedHeight && ownHeightsReplaced.length)
6944
+ data.settings = data.settings.flatMap(x => {
6945
+ if (!ownHeightsReplaced.includes(x)) return [x];
6946
+ const value =
6947
+ x.source === 'property' && x.when == null
6948
+ ? carried(String(x.value))
6949
+ : null;
6950
+ if (value == null) return [];
6951
+ return CONTROL_SIZES.filter(
6952
+ z =>
6953
+ z !== sharedHeight.size &&
6954
+ !data.settings.some(
6955
+ y =>
6956
+ y.source === 'token' &&
6957
+ y.thing === `--size-element-${z}` &&
6958
+ y.on === x.on,
6959
+ ),
6960
+ ).map(
6961
+ z =>
6962
+ /** @type {import('./_settings.mjs').Setting} */ ({
6963
+ thing: `--size-element-${z}`,
6964
+ value,
6965
+ source: 'token',
6966
+ on: String(x.on),
6967
+ ...(onlyMeans(String(x.on)) === 'member' ? {only: true} : {}),
6968
+ ...(x.mode ? {mode: x.mode} : {}),
6969
+ }),
6970
+ );
6971
+ });
6972
+ // A height kept on one control (--only) replaces the plain heights saved
6973
+ // for that control at its size, which would beat its own size token. One
6974
+ // set on the control alone goes; one set on a group (the inputs) stays on
6975
+ // the group's other parts. One set for every size stays that control's
6976
+ // height at the other sizes, as its own size tokens there.
6977
+ const ownOn = sharedHeight?.own ? String(sharedHeight.setting.on) : null;
6978
+ /** @type {import('./_settings.mjs').Setting[]} */
6979
+ const ownReplaced = ownOn
6980
+ ? data.settings.filter(
6981
+ x =>
6982
+ x !== s &&
6983
+ x.source === 'property' &&
6984
+ !x.state &&
6985
+ isControlHeight(ctx, x) &&
6986
+ (x.when == null || x.when === `size:${sharedHeight?.size}`) &&
6987
+ partsOf(ctx, x).includes(ownOn),
6988
+ )
6989
+ : [];
6990
+ /** @type {string[]} */
6991
+ const ownNarrowed = [];
6992
+ if (ownOn && sharedHeight)
6993
+ data.settings = data.settings.flatMap(x => {
6994
+ if (!ownReplaced.includes(x)) return [x];
6995
+ const others = partsOf(ctx, x)
6996
+ .filter(t => t !== ownOn && partHasWhen(ctx, t, x.when))
6997
+ .map(
6998
+ t =>
6999
+ /** @type {import('./_settings.mjs').Setting} */ ({
7000
+ ...x,
7001
+ on: t,
7002
+ // (Marked as the group's height, never one kept on t.)
7003
+ ...(onlyMeans(t) === 'member'
7004
+ ? {only: true, narrowed: true}
7005
+ : {}),
7006
+ }),
7007
+ );
7008
+ ownNarrowed.push(...others.map(o => String(o.on)));
7009
+ const value = x.when == null ? carried(String(x.value)) : null;
7010
+ const sizes =
7011
+ value == null
7012
+ ? []
7013
+ : CONTROL_SIZES.filter(
7014
+ z =>
7015
+ z !== sharedHeight.size &&
7016
+ !data.settings.some(
7017
+ y =>
7018
+ y.source === 'token' &&
7019
+ y.thing === `--size-element-${z}` &&
7020
+ y.on === ownOn,
7021
+ ),
7022
+ );
7023
+ return [
7024
+ ...others,
7025
+ ...sizes.map(
7026
+ z =>
7027
+ /** @type {import('./_settings.mjs').Setting} */ ({
7028
+ thing: `--size-element-${z}`,
7029
+ value: /** @type {string} */ (value),
7030
+ source: 'token',
7031
+ on: ownOn,
7032
+ ...(onlyMeans(ownOn) === 'member' ? {only: true} : {}),
7033
+ ...(x.mode ? {mode: x.mode} : {}),
7034
+ }),
7035
+ ),
7036
+ ];
7037
+ });
6296
7038
  // A setting for both modes replaces the ones made for one mode, which it
6297
7039
  // would otherwise sit under.
6298
7040
  /** @type {import('./_settings.mjs').Setting[]} */
@@ -6317,43 +7059,56 @@ async function changeOnce(
6317
7059
  )
6318
7060
  : [];
6319
7061
  data.settings = data.settings.filter(x => !covered.includes(x));
6320
- // A shorthand set after its longhands on the same part replaces them.
6321
- const longhands =
6322
- sub === 'set' && s.source === 'property'
7062
+ // A shorthand set after its longhands on the same part replaces them
7063
+ // (each side a box shorthand is written as replaces its own).
7064
+ const written = [s, ...sidesBeside];
7065
+ // An earlier setting of the typed shorthand in the same place goes: the
7066
+ // sides written replace it, as a plain set replaces its value.
7067
+ const typedBefore = shorthand
7068
+ ? data.settings.filter(
7069
+ x => !written.includes(x) && keyOf(x) === keyOf(shorthand),
7070
+ )
7071
+ : [];
7072
+ data.settings = data.settings.filter(x => !typedBefore.includes(x));
7073
+ const sidesChanged = written.filter(w => sidesMoved.has(w));
7074
+ /** @param {import('./_settings.mjs').Setting} w */
7075
+ const longhandsOf = w =>
7076
+ sub === 'set' && w.source === 'property'
6323
7077
  ? data.settings.filter(
6324
7078
  x =>
6325
- x !== s &&
7079
+ !written.includes(x) &&
6326
7080
  x.source === 'property' &&
6327
7081
  // On the same part, or on a member of the group it is set on:
6328
7082
  // the later setting wins, whichever way Core writes it.
6329
- (x.on === s.on ||
6330
- (s.on != null &&
6331
- (FAMILIES[s.on] ?? []).includes(
7083
+ (x.on === w.on ||
7084
+ (w.on != null &&
7085
+ (groupsOf(ctx)[w.on] ?? []).includes(
6332
7086
  /** @type {string} */ (x.on),
6333
7087
  ))) &&
6334
- x.when === s.when &&
6335
- x.state === s.state &&
7088
+ x.when === w.when &&
7089
+ x.state === w.state &&
6336
7090
  // A shorthand for one mode replaces longhands of that mode only:
6337
7091
  // a longhand set for both modes still holds the other mode.
6338
- (!s.mode || x.mode === s.mode) &&
7092
+ (!w.mode || x.mode === w.mode) &&
6339
7093
  // A longhand the shorthand really sets (MDN's data), never a
6340
7094
  // property that only shares its name (overflow-wrap).
6341
- (coversProperty(s.thing, x.thing) ||
6342
- coversProperty(logicalSide(s.thing), logicalSide(x.thing))),
7095
+ (coversProperty(w.thing, x.thing) ||
7096
+ coversProperty(logicalSide(w.thing), logicalSide(x.thing))),
6343
7097
  )
6344
7098
  : [];
7099
+ const longhands = [...new Set(written.flatMap(longhandsOf))];
6345
7100
  // They go, as the note says: Core writes each side to its own variable,
6346
7101
  // where a later shorthand would not win over them (undo brings them back).
6347
7102
  data.settings = data.settings.filter(x => !longhands.includes(x));
6348
7103
  // A group setting covers part settings made before it for its members.
6349
7104
  const covers =
6350
- sub === 'set' && s.source === 'dial' && s.on && FAMILIES[s.on]
7105
+ sub === 'set' && s.source === 'dial' && s.on && groupsOf(ctx)[s.on]
6351
7106
  ? data.settings.filter(
6352
7107
  x =>
6353
7108
  x !== s &&
6354
7109
  x.thing === s.thing &&
6355
7110
  x.on &&
6356
- FAMILIES[/** @type {string} */ (s.on)].includes(x.on) &&
7111
+ groupsOf(ctx)[/** @type {string} */ (s.on)].includes(x.on) &&
6357
7112
  (x.when ?? '') === (s.when ?? '') &&
6358
7113
  (x.state ?? '') === (s.state ?? ''),
6359
7114
  )
@@ -6449,7 +7204,8 @@ async function changeOnce(
6449
7204
  !alsoReplaced.length &&
6450
7205
  !covered.length &&
6451
7206
  !longhands.length &&
6452
- !covers.length
7207
+ !covers.length &&
7208
+ !beforeUnbuilt
6453
7209
  ) {
6454
7210
  const trial = compileTheme(ctx, data, base);
6455
7211
  const raw = styledChanges(compiledBefore, trial, base);
@@ -6463,8 +7219,19 @@ async function changeOnce(
6463
7219
  data.settings = data.settings.filter(x => x !== s);
6464
7220
  }
6465
7221
  }
7222
+ // A border brought for a color: the sheet as the build draws it now,
7223
+ // before the change is built, to measure what the added width moves.
7224
+ // Measured every time, a rare path: the result says, never leaves it to
7225
+ // be asked for.
7226
+ const sizeBefore = borderAdded
7227
+ ? await sizeSheet(ctx, slug, data, 'before', borderAdded)
7228
+ : null;
6466
7229
  const r = await commitTheme(ctx, slug, data, {history: true});
6467
7230
  await sayNextStepClears(ctx, slug, s, r);
7231
+ const sizeNote =
7232
+ borderAdded && sizeBefore
7233
+ ? await borderSizeNote(ctx, slug, data, borderAdded, sizeBefore)
7234
+ : null;
6468
7235
  const compiledAfter = compileTheme(ctx, data, base);
6469
7236
  // What the spacing dial said of the sizes it could not keep apart.
6470
7237
  // What the build said of settings it could not write as they are.
@@ -6472,12 +7239,11 @@ async function changeOnce(
6472
7239
  const sizeNotes =
6473
7240
  /** @type {{sizeNotes?: string[]}} */ (/** @type {unknown} */ (ctx))
6474
7241
  .sizeNotes ?? [];
6475
- const styled = styledChanges(
6476
- compiledBefore,
6477
- compiledAfter,
6478
- base,
6479
- drawnAtRest,
6480
- );
7242
+ // (Nothing built before a change from unbuildable settings: no styles
7243
+ // are compared.)
7244
+ const styled = beforeUnbuilt
7245
+ ? []
7246
+ : styledChanges(compiledBefore, compiledAfter, base, drawnAtRest);
6481
7247
  const parts = partsOf(ctx, s);
6482
7248
  // Exact whole-theme tokens that win over what this dial writes: the dial
6483
7249
  // changes them only in a theme without them.
@@ -6774,9 +7540,84 @@ async function changeOnce(
6774
7540
  n =>
6775
7541
  n.includes('could not be read') || n.includes('there was no last build'),
6776
7542
  );
7543
+ // A sides change that moved no side and removed nothing (a repeat over a
7544
+ // stale build) adds no undo step, so its note claims none.
7545
+ const sidesStep = Boolean(
7546
+ sidesChanged.length ||
7547
+ typedBefore.length ||
7548
+ longhands.length ||
7549
+ alsoReplaced.length,
7550
+ );
7551
+ // The entries this change removed that undo puts back: undo leaves out
7552
+ // one the editor no longer accepts, so the note never promises it.
7553
+ const removedBefore = [
7554
+ ...new Set([...typedBefore, ...longhands, ...alsoReplaced]),
7555
+ ];
7556
+ const refusedBefore = new Set(
7557
+ shorthand && removedBefore.length
7558
+ ? storedProblems(ctx, slug, {...data, settings: removedBefore})
7559
+ .filter(p => !p.noEffect)
7560
+ .map(p => p.setting)
7561
+ : [],
7562
+ );
7563
+ const bringsBack = removedBefore.filter(x => !refusedBefore.has(x));
6777
7564
  /** @type {string[]} */
6778
7565
  const notes = [
7566
+ ...(shorthand && !r.unchanged && sidesStep
7567
+ ? [
7568
+ `wrote ${shorthand.thing} ${quoteCommandArgument(String(shorthand.value))} as its sides, ${written.map(x => `${x.thing} ${x.value}`).join(', ')}: ${shorthand.on} reads ${shorthand.thing} inside calc(), where one length works; undo ${slug} ${
7569
+ [
7570
+ sidesChanged.length === written.length
7571
+ ? `takes back all ${written.length}`
7572
+ : sidesChanged.length
7573
+ ? `takes back ${sidesChanged.map(x => x.thing).join(' and ')}, the ${sidesChanged.length === 1 ? 'side' : 'sides'} this changes or moves`
7574
+ : null,
7575
+ bringsBack.length
7576
+ ? `brings back ${bringsBack.map(describe).join(', ')}`
7577
+ : null,
7578
+ ]
7579
+ .filter(Boolean)
7580
+ .join(' and ') || 'takes back this change'
7581
+ }`,
7582
+ ]
7583
+ : []),
7584
+ ...(typedBefore.length
7585
+ ? [`replaces ${typedBefore.map(describe).join(', ')}`]
7586
+ : []),
6779
7587
  ...fieldNotes,
7588
+ ...(sharedHeight && heightAsked && sharedHeight.own
7589
+ ? [
7590
+ `${describe(heightAsked)} is ${heightAsked.on}'s own height at ${sharedHeight.size}: written as ${sharedHeight.token} on ${heightAsked.on} alone, so the other controls keep the height they share there${ownReplaced.length ? `; it replaces ${ownReplaced.map(describe).join(', ')}${ownNarrowed.length ? `, which stays on ${[...new Set(ownNarrowed)].join(', ')}` : ''}` : ''}`,
7591
+ ]
7592
+ : []),
7593
+ ...(sharedHeight && heightAsked && !sharedHeight.own
7594
+ ? [
7595
+ `${describe(heightAsked)} is the height every control takes at ${sharedHeight.size}: written as ${sharedHeight.token} on controls, so buttons, inputs, selectors and input groups at ${sharedHeight.size} are all ${s.value} (a selector, typeahead or tokenizer whose content is taller keeps its content's height; a complex selector keeps its own)${
7596
+ heightAsked.when
7597
+ ? ''
7598
+ : (() => {
7599
+ const kept = new Set(heightsKept);
7600
+ const left = CONTROL_SIZES.filter(
7601
+ z => z !== sharedHeight.size && !kept.has(z),
7602
+ );
7603
+ return left.length
7604
+ ? `; at ${left.join(' and ')} the controls keep their own heights (set one with --when size:${left[0]})`
7605
+ : '';
7606
+ })()
7607
+ }${heightsReplaced.length ? `; it replaces ${heightsReplaced.map(describe).join(', ')} at ${sharedHeight.size}` : ''}${heightsKept.length && lastEverySize ? `; ${carried(String(lastEverySize.value)) ?? lastEverySize.value} stays every control's height at ${[...new Set(heightsKept)].join(' and ')}` : ''}${ownHeightsReplaced.length ? `; it replaces ${ownHeightsReplaced.map(x => `${x.source === 'token' ? 'height' : x.thing} = ${x.value} on ${x.on}, which was kept on ${x.on} alone`).join('; ')}` : ''}${heightsLeftOn.length ? `; ${heightsLeftOn.map(x => `${x.on} keeps ${x.value}`).join(', ')}, as ${heightsLeftOn.length === 1 ? 'it is not a control' : 'they are not controls'}` : ''}${(() => {
7608
+ const notControls = notControlsReached(ctx, heightAsked);
7609
+ return notControls.length
7610
+ ? `; ${notControls.join(', ')} ${notControls.length === 1 ? 'is not a control and keeps its' : 'are not controls and keep their'} own height (for this height there too: ${notControls.map(t => `${P} set ${slug} height ${heightAsked.value} --on ${t}${heightAsked.when ? ` --when ${heightAsked.when}` : ''}`).join(', ')})`
7611
+ : '';
7612
+ })()}; to give one control alone another height: ${P} set ${slug} height ${s.value} --on ${groupsOf(ctx)[String(heightAsked.on)] ? (membersOf(ctx, String(heightAsked.on)).find(t => (groupsOf(ctx).controls ?? []).includes(t)) ?? 'button') : heightAsked.on} --only${heightAsked.when ? ` --when ${heightAsked.when}` : ''}`,
7613
+ ]
7614
+ : []),
7615
+ ...(borderAdded
7616
+ ? [
7617
+ `added a ${borderWidthOf(r.res, data)} border to ${borderAdded.on}${borderAdded.when ? ` when ${borderAdded.when}` : ''} so the color shows: ${borderAdded.on} drew none there; ${describe(borderAdded)}, see-through at rest, so ${borderAdded.on} keeps one size in every state; undo ${slug} takes back both`,
7618
+ ...(sizeNote ? [sizeNote] : []),
7619
+ ]
7620
+ : []),
6780
7621
  ...(alsoReplaced.length && prev
6781
7622
  ? [
6782
7623
  `${describe({...prev, value: '?'}).replace(' = ?', '')} was listed ${alsoReplaced.length === 1 ? 'twice' : `${alsoReplaced.length + 1} times`} (${[...alsoReplaced, prev].map(x => x.value).join(', ')}); each is ${sub === 'set' ? 'replaced' : 'removed'}`,
@@ -6842,9 +7683,15 @@ async function changeOnce(
6842
7683
  !s.on &&
6843
7684
  (['text-size', 'type'].includes(s.thing) ||
6844
7685
  /^--(font-size-|text-[a-z0-9-]+-(size|leading)$)/.test(s.thing))
6845
- ? [
6846
- 'phones (touch screens below 1024px wide) keep the base theme reading sizes; this applies on wider or mouse screens',
6847
- ]
7686
+ ? [PHONE_SIZES_NOTE]
7687
+ : []),
7688
+ // The page color shows inside AppShell only: said once for the theme,
7689
+ // with the first page color it sets.
7690
+ ...(sub === 'set' &&
7691
+ !s.on &&
7692
+ s.thing === '--color-background-body' &&
7693
+ !hadPageColor
7694
+ ? [pageColorNote(data.mode)]
6848
7695
  : []),
6849
7696
  // A scale step far outside reading sizes is named.
6850
7697
  ...(sub === 'set' && ['text-size', 'type'].includes(s.thing)
@@ -6934,14 +7781,19 @@ async function changeOnce(
6934
7781
  : []),
6935
7782
  ...(longhands.length
6936
7783
  ? [
6937
- `${s.thing} comes after ${longhands.map(x => x.thing).join(', ')} on ${s.on}, so it replaces them there`,
7784
+ `${shorthand ? `${shorthand.thing} ${quoteCommandArgument(String(shorthand.value))}` : s.thing} comes after ${longhands.map(x => x.thing).join(', ')} on ${s.on}, so it replaces them there`,
7785
+ ]
7786
+ : []),
7787
+ ...(shorthand && !r.unchanged && !sidesStep
7788
+ ? [
7789
+ `no change: ${describe({...s, thing: shorthand.thing, value: String(shorthand.value)})} (${written.map(x => `${x.thing} ${x.value}`).join(', ')}) is already set; the theme was built again, and no undo step was added`,
6938
7790
  ]
6939
7791
  : []),
6940
7792
  ...(r.unchanged
6941
7793
  ? [
6942
7794
  drawnAlready
6943
7795
  ? `no change: ${s.on} already draws ${drawnAlready.map(x => x.replace(/^[^:]*:\s*/, '')).join(', ')} at rest, so ${describe(s)} was not written; to change it, set another value`
6944
- : `no change: ${describe(s)} is already set, so nothing was built and no undo step was added`,
7796
+ : `no change: ${shorthand ? `${describe({...s, thing: shorthand.thing, value: String(shorthand.value)})} (${written.map(x => `${x.thing} ${x.value}`).join(', ')})` : describe(s)} is already set, so nothing was built and no undo step was added`,
6945
7797
  ]
6946
7798
  : []),
6947
7799
  // (A plain part rule whose value matches what the part draws today
@@ -6962,13 +7814,22 @@ async function changeOnce(
6962
7814
  ...r.notes,
6963
7815
  ];
6964
7816
  const group = s.on
6965
- ? FAMILIES[s.on]
7817
+ ? groupsOf(ctx)[s.on]
6966
7818
  ? s.on
6967
7819
  : parts.length > 1
6968
7820
  ? familyOf(s.on)
6969
7821
  : null
6970
7822
  : null;
6971
- if (s.note) notes.push(s.note);
7823
+ // Every side written carries its own check's note, and the typed
7824
+ // shorthand its note for the whole value.
7825
+ for (const note of new Set(
7826
+ [shorthand?.note, ...written.map(w => w.note)].filter(Boolean),
7827
+ ))
7828
+ notes.push(/** @type {string} */ (note));
7829
+ // (A state word the typed shorthand's check read as another state is
7830
+ // said once, for every side written.)
7831
+ const stateNote = shorthand?.stateNote ?? s.stateNote;
7832
+ if (stateNote) notes.push(stateNote);
6972
7833
  // A fill on the plain part covers the paints Core gives its variants and
6973
7834
  // states (a primary button's accent, a checked box's): said, with the
6974
7835
  // lines that change one of them, or only the part at rest.
@@ -6978,36 +7839,127 @@ async function changeOnce(
6978
7839
  !s.state &&
6979
7840
  !s.when &&
6980
7841
  /^background(-color)?$/.test(s.thing)
6981
- )
7842
+ ) {
7843
+ // One note for each cause: the parts of a group whose fill covers the
7844
+ // same paints (every input's status and disabled fills) are said
7845
+ // together, with lines on the group, not once for each part.
7846
+ /** @type {Map<string, {members: string[], rest: string | null, all: Set<string>, flags: Set<string>}>} */
7847
+ const causes = new Map();
6982
7848
  for (const t of parts) {
6983
7849
  const {rest, covered} = coveredPaints(ctx, t, s.thing);
6984
7850
  if (!covered.length) continue;
6985
- const all = [...new Set(covered.map(c => `${c.cond} (${c.token})`))];
7851
+ // (The cause is what the fill covers, by kind: the props and states
7852
+ // Core paints a fill for, whatever their order or count on a part.)
7853
+ const kinds = [
7854
+ ...new Set(covered.map(c => String(c.cond).split('=')[0])),
7855
+ ].sort();
7856
+ const key = JSON.stringify([kinds, rest ?? null]);
7857
+ const cause = causes.get(key) ?? {
7858
+ members: [],
7859
+ rest: rest ?? null,
7860
+ all: new Set(),
7861
+ flags: new Set(),
7862
+ };
7863
+ cause.members.push(t);
7864
+ for (const c of covered) {
7865
+ cause.all.add(`${c.cond} (${c.token})`);
7866
+ if (c.flags) cause.flags.add(String(c.flags));
7867
+ }
7868
+ causes.set(key, cause);
7869
+ }
7870
+ // Each chain starts with the undo of the fill just set: while it
7871
+ // stays, every variant and state keeps it.
7872
+ const undo = `${P} undo ${slug} ${undoArgs(s)}`;
7873
+ const modeFlag = s.mode ? ` --mode ${s.mode}` : '';
7874
+ for (const {
7875
+ members,
7876
+ rest,
7877
+ all: allSet,
7878
+ flags: flagSet,
7879
+ } of causes.values()) {
7880
+ const all = [...allSet].sort();
6986
7881
  const named = [
6987
7882
  ...all.slice(0, 4),
6988
7883
  ...(all.length > 4 ? [`${all.length - 4} more`] : []),
6989
7884
  ];
7885
+ const flags = [...flagSet];
7886
+ // Lines go on the part as set when the cause is every part it
7887
+ // styles (its group); else on each part the cause is.
7888
+ const targets =
7889
+ members.length === parts.length && s.on ? [s.on] : members;
6990
7890
  const lines = [
6991
7891
  ...new Set(
6992
- covered
6993
- .filter(c => c.flags)
6994
- .map(
6995
- c =>
6996
- `${P} set ${slug} background-color ${quoteCommandArgument(String(s.value))} --on ${t} ${c.flags}${s.mode ? ` --mode ${s.mode}` : ''}`,
7892
+ targets.flatMap(on =>
7893
+ flags.map(
7894
+ f =>
7895
+ `${P} set ${slug} background-color ${quoteCommandArgument(String(s.value))} --on ${on} ${f}${modeFlag}`,
6997
7896
  ),
7897
+ ),
6998
7898
  ),
6999
7899
  ];
7000
- // Each chain starts with the undo of the fill just set: while it
7001
- // stays, every variant and state keeps it.
7002
- const undo = `${P} undo ${slug} ${undoArgs(s)}`;
7900
+ const who =
7901
+ members.length > 3
7902
+ ? `${members.slice(0, 3).join(', ')} and ${members.length - 3} more`
7903
+ : members.join(', ');
7904
+ const own = members.length > 1 ? 'their' : 'its';
7003
7905
  notes.push(
7004
- `${s.mode ? `in ${s.mode} mode, ` : ''}${t}'s fill now covers the fill Core gives it ${named.length > 1 ? 'in each of' : 'in'} ${named.join(', ')}, so ${named.length > 1 ? 'those no longer differ' : 'that no longer shows'}${
7906
+ `${s.mode ? `in ${s.mode} mode, ` : ''}${who}${members.length > 1 ? "'s fills now cover" : "'s fill now covers"} the fill Core gives ${members.length > 1 ? 'them' : 'it'} ${named.length > 1 ? 'in each of' : 'in'} ${named.join(', ')}, so ${named.length > 1 ? 'those no longer differ' : 'that no longer shows'}${
7005
7907
  rest
7006
- ? `; to change only its fill at rest: ${undo}, then ${P} set ${slug} ${rest} ${quoteCommandArgument(String(s.value))} --on ${t}${s.mode ? ` --mode ${s.mode}` : ''}`
7908
+ ? `; to change only ${own} fill at rest: ${undo}, then ${targets.map(on => `${P} set ${slug} ${rest} ${quoteCommandArgument(String(s.value))} --on ${on}${modeFlag}`).join('; ')}`
7007
7909
  : ''
7008
7910
  }${lines.length ? `; to fill only one of them: ${undo}, then ${lines.slice(0, 3).join('; or ')}` : ''}`,
7009
7911
  );
7010
7912
  }
7913
+ }
7914
+ // A fill on a part whose own sub-parts keep a resting fill of their own
7915
+ // (a code block's header) leaves the part in two tones: said, with the
7916
+ // line that gives each the same fill.
7917
+ if (
7918
+ sub === 'set' &&
7919
+ s.on &&
7920
+ !s.state &&
7921
+ !s.when &&
7922
+ /^background(-color)?$/.test(s.thing)
7923
+ ) {
7924
+ const mode = /** @type {'light' | 'dark'} */ (
7925
+ s.mode ?? modesOf(data)[0] ?? 'light'
7926
+ );
7927
+ const tokens = /** @type {any} */ (r.res)?.[mode] ?? {};
7928
+ const now = parseColor(String(s.value));
7929
+ for (const t of parts) {
7930
+ const inner = /** @type {string[]} */ (
7931
+ /** @type {any} */ (ctx.C.MAP[t])?.contains ?? []
7932
+ ).filter(c => c.startsWith(`${t}-`));
7933
+ for (const c of inner) {
7934
+ if (
7935
+ data.settings.some(
7936
+ x =>
7937
+ x.on &&
7938
+ partsOf(ctx, x).includes(c) &&
7939
+ /^background(-color)?$/.test(x.thing) &&
7940
+ !x.state &&
7941
+ !x.when,
7942
+ )
7943
+ )
7944
+ continue;
7945
+ const read = (ctx.C.partReads(c, 'background') ?? []).find(
7946
+ q =>
7947
+ q.when.includes('') &&
7948
+ q.props.some((/** @type {string} */ p) =>
7949
+ /^background(-color)?$/.test(p),
7950
+ ) &&
7951
+ !/overlay|tint/.test(q.token),
7952
+ );
7953
+ const value = read ? String(tokens[read.token] ?? '') : '';
7954
+ const own = parseColor(value);
7955
+ if (!read || !own || alphaOf(value) < 1) continue;
7956
+ if (now && hex(now) === hex(own)) continue;
7957
+ notes.push(
7958
+ `${c} inside ${t} keeps its own fill (${read.token}, ${hex(own)}${s.mode ? ` in ${s.mode} mode` : ''}), so ${t} now shows two tones; to give it the same fill: ${P} set ${slug} background-color ${quoteCommandArgument(String(s.value))} --on ${c}${s.mode ? ` --mode ${s.mode}` : ''}`,
7959
+ );
7960
+ }
7961
+ }
7962
+ }
7011
7963
  // A color dial or token that a plain part's own fill covers no longer
7012
7964
  // reaches that part where Core paints with it: said.
7013
7965
  if (sub === 'set' && !s.on) {
@@ -7056,12 +8008,36 @@ async function changeOnce(
7056
8008
  notes.push(
7057
8009
  `a ${data.mode} theme shows ${s.mode} mode only where Core draws a ${s.mode} region (a toast, a lightbox), so this value applies there`,
7058
8010
  );
8011
+ // A padding with top or bottom sides reaches a control that grows with its
8012
+ // content at its sides only: its height sets the rest.
8013
+ if (
8014
+ sub === 'set' &&
8015
+ s.source === 'property' &&
8016
+ s.on &&
8017
+ /^padding(-(top|bottom|block(-start|-end)?))?$/.test(s.thing)
8018
+ ) {
8019
+ const grows = partsOf(ctx, s).filter(t => growsWithContent(ctx, t, s.when));
8020
+ if (grows.length)
8021
+ notes.push(
8022
+ `${grows.join(', ')} ${grows.length > 1 ? 'keep' : 'keeps'} Core's top and bottom padding, so a theme's padding never makes ${grows.length > 1 ? 'them' : 'it'} taller than the other controls: ${/^padding$/.test(s.thing) ? `only the sides of ${s.thing} reach ${grows.length > 1 ? 'them' : 'it'}` : `${s.thing} does not reach ${grows.length > 1 ? 'them' : 'it'}`}${grows
8023
+ .map(t => [t, notGrowingWhens(ctx, t, s.when)])
8024
+ .filter(([, w]) => w.length)
8025
+ .map(
8026
+ ([t, w]) =>
8027
+ `; ${t} takes them when ${/** @type {string[]} */ (w).join(' or ')}, where it does not grow`,
8028
+ )
8029
+ .join('')}`,
8030
+ );
8031
+ }
7059
8032
  // A group kept alike (inputs share one height) loses that when one member
7060
8033
  // changes its height alone.
7061
8034
  const family =
7062
8035
  s.on && s.only && onlyMeans(s.on) === 'member' ? familyOf(s.on) : null;
7063
8036
  if (
7064
8037
  family &&
8038
+ !(
8039
+ /^padding/.test(s.thing) && growsWithContent(ctx, String(s.on), s.when)
8040
+ ) &&
7065
8041
  (s.thing === 'spacing' ||
7066
8042
  /^--size-element-/.test(s.thing) ||
7067
8043
  /^(min-|max-)?(height|block-size)$|^padding(-block(-start|-end)?|-top|-bottom)?$/.test(
@@ -7114,7 +8090,13 @@ async function changeOnce(
7114
8090
  );
7115
8091
  if (PALETTE_DIALS.includes(s.thing) && sub === 'set')
7116
8092
  notes.push(
7117
- ...paletteNotes(dialPal, s.thing, slug, modesOf(data))
8093
+ ...paletteNotes(
8094
+ dialPal,
8095
+ s.thing,
8096
+ slug,
8097
+ modesOf(data),
8098
+ vibrancyTakes(data, ownSourceTokenValues(cwd, slug)),
8099
+ )
7118
8100
  // A shade the mapping would pick for a token the theme's own source
7119
8101
  // sets never shows: the file's value does (named once above).
7120
8102
  .filter(n => {
@@ -7156,9 +8138,13 @@ async function changeOnce(
7156
8138
  );
7157
8139
  if (pal?.families.some(x => x.dial === dialOfToken)) {
7158
8140
  notes.push(
7159
- ...paletteNotes(pal, dialOfToken, slug, modesOf(data)).filter(
7160
- n => !n.startsWith('the generated colors are in '),
7161
- ),
8141
+ ...paletteNotes(
8142
+ pal,
8143
+ dialOfToken,
8144
+ slug,
8145
+ modesOf(data),
8146
+ vibrancyTakes(data, ownSourceTokenValues(cwd, slug)),
8147
+ ).filter(n => !n.startsWith('the generated colors are in ')),
7162
8148
  );
7163
8149
  colorFails.push(
7164
8150
  ...newFailures(paletteFailures(pal, dialOfToken, modesOf(data))),
@@ -7255,9 +8241,9 @@ async function changeOnce(
7255
8241
  '--color-text-secondary',
7256
8242
  '--color-border-emphasized',
7257
8243
  ];
7258
- const moved = /** @type {unknown[]} */ (r.changed ?? []).map(
7259
- c => String(c).split(/[\s:]/)[0],
7260
- );
8244
+ const moved = /** @type {unknown[]} */ (r.changed ?? [])
8245
+ .map(c => String(c).split(/[\s:]/)[0])
8246
+ .filter(k => !isLookToken(k));
7261
8247
  if (!GRAYS_SHOWN.some(k => moved.includes(k)))
7262
8248
  notes.push(
7263
8249
  `neutral ${s.value} grows the same grays the ${data.like ?? 'base'} theme already shows, so its page, surfaces, text and borders keep their colors${moved.length ? ` (only ${[...new Set(moved)].join(', ')} changed)` : ''}: a gray sets the tint of the grays, not how light or dark the surfaces are. For dark surfaces: ${P} set ${slug} mode dark-only, or set --color-background-surface and --color-background-body to the colors you want`,
@@ -7270,15 +8256,30 @@ async function changeOnce(
7270
8256
  !x.when &&
7271
8257
  !x.state,
7272
8258
  );
8259
+ // (A page color the theme already sets is kept, and offered no line.)
7273
8260
  notes.push(
7274
8261
  `${pinned ? 'the page background keeps the color you set for it' : "the page background follows it too, at the official theme's page shade of this gray"}${
7275
- modes.includes('light')
7276
- ? `; for a white or off-white page: ${P} set ${slug} --color-background-body ${quoteCommandArgument('#ffffff')}${modes.length > 1 ? ' --mode light' : ''}`
7277
- : `; for another page color: ${P} set ${slug} --color-background-body ${quoteCommandArgument('#111111')}`
8262
+ pinned
8263
+ ? ''
8264
+ : modes.includes('light')
8265
+ ? `; for a white or off-white page: ${P} set ${slug} --color-background-body ${quoteCommandArgument('#ffffff')}${modes.length > 1 ? ' --mode light' : ''}`
8266
+ : `; for another page color: ${P} set ${slug} --color-background-body ${quoteCommandArgument('#111111')}`
7278
8267
  }`,
7279
8268
  );
7280
8269
  }
7281
- if (s.thing === 'accent' && sub === 'set') {
8270
+ // The status roles the look derives (deriveStatusColors) sit with the
8271
+ // palette already: only a role the look leaves unset is said.
8272
+ const grownRoles = new Set(
8273
+ Object.entries(
8274
+ (s.thing === 'accent' || s.thing === 'vibrancy'
8275
+ ? paletteMapping(cwd, slug, data, base, ctx.project.core.tokenDefaults)
8276
+ : null
8277
+ )?.statuses?.roles ?? {},
8278
+ )
8279
+ .filter(([, how]) => how === 'derived')
8280
+ .map(([role]) => role),
8281
+ );
8282
+ if (s.thing === 'accent' && sub === 'set' && !grownRoles.has('info')) {
7282
8283
  notes.push(
7283
8284
  ...infoClashNotes(data, base, slug, sourceSeed?.seed ?? String(s.value)),
7284
8285
  );
@@ -7289,7 +8290,7 @@ async function changeOnce(
7289
8290
  ? `every color this theme sets is made again at vibrancy ${s.value} (0 is gray, 100 the most vivid, ${VIBRANCY_DEFAULT} the default)`
7290
8291
  : `every color this theme sets is made again at the default vibrancy, ${VIBRANCY_DEFAULT}`,
7291
8292
  );
7292
- notes.push(...unsetColorNotes(data, base, slug));
8293
+ notes.push(...unsetColorNotes(data, base, slug, grownRoles));
7293
8294
  }
7294
8295
  // A font set (the dial, a part's own font-family, a font token): how
7295
8296
  // it loads.
@@ -7309,12 +8310,40 @@ async function changeOnce(
7309
8310
  // An earlier setting this one now covers (through a spread too) is named.
7310
8311
  else if (sub === 'set')
7311
8312
  for (const [m, why] of maskedSettings(data, ctx))
7312
- if (m !== s && why.startsWith(describe(s)))
8313
+ if (
8314
+ !written.includes(m) &&
8315
+ written.some(w => why.startsWith(describe(w)))
8316
+ )
7313
8317
  notes.push(`${describe(m)} no longer shows: ${why}`);
7314
8318
  if (s.thing === 'type' && sub === 'set' && TYPE_STYLES[s.value].ratio > 1.2)
7315
8319
  notes.push(
7316
8320
  'text below the base size keeps its standard sizes, so small text stays readable',
7317
8321
  );
8322
+ // A change that moved the category or chart colors says what they gave
8323
+ // up to stay written (an accent change says it with the accent's
8324
+ // notes).
8325
+ if (
8326
+ lookCollapsed(r.changed, derivedStatusWords(data), exactTokens(data)).look
8327
+ .length &&
8328
+ dialOfToken !== 'accent'
8329
+ ) {
8330
+ const look = paletteMapping(
8331
+ cwd,
8332
+ slug,
8333
+ data,
8334
+ base,
8335
+ ctx.project.core.tokenDefaults,
8336
+ );
8337
+ for (const n of look
8338
+ ? categoryNotes(
8339
+ look,
8340
+ '',
8341
+ slug,
8342
+ vibrancyTakes(data, ownSourceTokenValues(cwd, slug)),
8343
+ )
8344
+ : [])
8345
+ if (!notes.includes(n)) notes.push(n);
8346
+ }
7318
8347
  // A change that changed nothing writes nothing, the preview included,
7319
8348
  // once preview.html was rendered from the theme as it is now (a retry
7320
8349
  // after a render that failed renders it).
@@ -7348,10 +8377,21 @@ async function changeOnce(
7348
8377
  data: {
7349
8378
  theme: slug,
7350
8379
  action: sub,
8380
+ // (The state word a command read as another state is said in the
8381
+ // notes, never a field of the setting.)
7351
8382
  setting:
7352
8383
  sub === 'set'
7353
- ? s
8384
+ ? {...savedSetting(s), ...(s.note == null ? {} : {note: s.note})}
7354
8385
  : /** @type {import('./_settings.mjs').Setting} */ (prev),
8386
+ ...(shorthand
8387
+ ? {
8388
+ asSides: {
8389
+ thing: shorthand.thing,
8390
+ value: String(shorthand.value),
8391
+ sides: [s, ...sidesBeside],
8392
+ },
8393
+ }
8394
+ : {}),
7355
8395
  // On undo, the setting above is the one removed, named as such.
7356
8396
  ...(sub === 'undo' && prev
7357
8397
  ? {
@@ -7365,7 +8405,9 @@ async function changeOnce(
7365
8405
  // A plain value that replaced per-mode ones names the first of them;
7366
8406
  // the notes name them all.
7367
8407
  replaced:
7368
- sub === 'set' ? (prev ?? covered[0] ?? longhands[0] ?? null) : null,
8408
+ sub === 'set'
8409
+ ? (prev ?? typedBefore[0] ?? covered[0] ?? longhands[0] ?? null)
8410
+ : null,
7369
8411
  // A whole-theme dial names the value it replaced, as base and mode do.
7370
8412
  was:
7371
8413
  sub === 'set' && prev && prev.source === 'dial' && !prev.on
@@ -7377,15 +8419,32 @@ async function changeOnce(
7377
8419
  // What the whole-theme change leaves out, with the lines that reach
7378
8420
  // it; the text output prints it right under the status line.
7379
8421
  leftOut: leftOutParts(ctx, slug, data, sub, s),
8422
+ // A font this set names that does not load until its package is
8423
+ // installed: the text prints it under the status line too.
8424
+ ...(() => {
8425
+ const fonts =
8426
+ sub === 'set' &&
8427
+ (s.thing === 'font' ||
8428
+ s.thing === 'font-family' ||
8429
+ /^--font-family-/.test(s.thing))
8430
+ ? fontsNotLoaded(ctx, {...data, settings: [s]})
8431
+ : [];
8432
+ return fonts.length ? {fontNotLoaded: fonts} : {};
8433
+ })(),
7380
8434
  parts,
7381
8435
  group: group
7382
8436
  ? {
7383
8437
  name: group,
7384
8438
  members: parts,
7385
- onlyHint: onlyMeans(s.on) === 'member',
8439
+ onlyHint:
8440
+ !groupsOf(ctx)[s.on ?? ''] && onlyMeans(s.on) === 'member',
7386
8441
  }
7387
8442
  : null,
7388
- changedTokens: r.changed,
8443
+ changedTokens: lookCollapsed(
8444
+ r.changed,
8445
+ derivedStatusWords(data),
8446
+ exactTokens(data),
8447
+ ).lines,
7389
8448
  changedPartTokens: r.changedParts ?? [],
7390
8449
  styled,
7391
8450
  kept,
@@ -7401,7 +8460,19 @@ async function changeOnce(
7401
8460
  // the browser measured as keeping it whole.
7402
8461
  ...cutShort.map(c => cutShortProblem(ctx, slug, c)),
7403
8462
  ],
7404
- ...(await missedSummary(ctx, slug, data, r.res)),
8463
+ // Problems the theme had that this change moved but left failing,
8464
+ // each with what it was and its fix; left out when none.
8465
+ .../** @type {any} */ (
8466
+ r.leftProblems?.length
8467
+ ? {leftProblems: problemLines(/** @type {any} */ (r).leftProblems)}
8468
+ : {}
8469
+ ),
8470
+ // (What it brought is told apart from the misses it found: those
8471
+ // repeat after every change otherwise.)
8472
+ ...(await missedSummary(ctx, slug, data, r.res, {
8473
+ data: r.before,
8474
+ res: r.resBefore,
8475
+ })),
7405
8476
  warnings: r.warnings,
7406
8477
  ...p,
7407
8478
  },
@@ -7457,12 +8528,14 @@ function infoClashNotes(data, base, slug, accent) {
7457
8528
  * values whatever the vibrancy, with the commands that bring them in: each
7458
8529
  * seeded with the base theme's own color, so it is then generated at the
7459
8530
  * theme's vibrancy. Colored cards and other info-tinted surfaces follow info.
8531
+ * A role the look derives (`derived`) follows the vibrancy already.
7460
8532
  * @param {import('./_settings.mjs').ThemeData} data
7461
8533
  * @param {{light: Record<string, string>, dark: Record<string, string>}} base
7462
8534
  * @param {string} slug
8535
+ * @param {Set<string>} [derived]
7463
8536
  * @returns {string[]}
7464
8537
  */
7465
- function unsetColorNotes(data, base, slug) {
8538
+ function unsetColorNotes(data, base, slug, derived = new Set()) {
7466
8539
  const word = /** @type {Record<string, string>} */ ({
7467
8540
  info: '--color-info',
7468
8541
  success: '--color-success',
@@ -7470,7 +8543,9 @@ function unsetColorNotes(data, base, slug) {
7470
8543
  danger: '--color-error',
7471
8544
  });
7472
8545
  const unset = Object.keys(word).filter(
7473
- d => !data.settings.some(x => x.source === 'dial' && x.thing === d),
8546
+ d =>
8547
+ !derived.has(d) &&
8548
+ !data.settings.some(x => x.source === 'dial' && x.thing === d),
7474
8549
  );
7475
8550
  if (!unset.length) return [];
7476
8551
  return [
@@ -7554,16 +8629,31 @@ function problemLines(list) {
7554
8629
  return (list ?? []).map(x => ({problem: x.text, fix: x.fix}));
7555
8630
  }
7556
8631
 
8632
+ /** Where a whole-theme size change applies: phones keep their own. */
8633
+ const PHONE_SIZES_NOTE =
8634
+ 'phones (touch screens below 1024px wide) keep the base theme reading sizes; this applies on wider or mouse screens';
8635
+
7557
8636
  /**
7558
8637
  * Every setting of a theme, key resolved values, problems it caused, the
7559
8638
  * sample page and the theme-building page with every component.
7560
8639
  * @experimental
7561
8640
  * @param {string} theme
7562
8641
  * @param {import('./theme-edit.type.mjs').ThemeEditShowOptions} [options]
7563
- * @returns {Promise<import('./theme-edit.type.mjs').ThemeEditShowResponse>}
8642
+ * @returns {Promise<import('./theme-edit.type.mjs').ThemeEditShowResponse | import('./theme-edit.type.mjs').ThemeEditShowPartResponse>}
7564
8643
  */
7565
8644
  export async function themeEditShow(theme, options = {}) {
7566
8645
  const {cwd = process.cwd(), png = false} = options;
8646
+ if (options.on != null) {
8647
+ requireProject(cwd);
8648
+ if (png || options.section)
8649
+ refuse(
8650
+ E.ERR_INVALID_ARGUMENT,
8651
+ `--on looks up what one part shows and writes nothing; --png and --section are for the pages show writes, so drop ${png && options.section ? 'them' : png ? '--png' : '--section'}.`,
8652
+ {run: [`${P} show ${theme} --on ${options.on}`]},
8653
+ );
8654
+ const {themePartValues} = await import('./_resolved.mjs');
8655
+ return themePartValues(cwd, theme, String(options.on));
8656
+ }
7567
8657
  // Without the theme lock (it cannot be taken), show writes nothing: it
7568
8658
  // reports the last build as it is.
7569
8659
  const readOnly = Boolean(/** @type {any} */ (options).readOnly);
@@ -7589,7 +8679,7 @@ export async function themeEditShow(theme, options = {}) {
7589
8679
  // A saved value or scope set refuses gets set's lines (the undo and the
7590
8680
  // repair), as a change does.
7591
8681
  try {
7592
- refuseStoredTokens(ctx, theme, data);
8682
+ rebuiltNotes.push(...(await leaveOutStored(ctx, theme, data, cwd)));
7593
8683
  } catch (e) {
7594
8684
  throw await savedDamageRefusal(e, theme, cwd, {ctx, data});
7595
8685
  }
@@ -7626,11 +8716,17 @@ export async function themeEditShow(theme, options = {}) {
7626
8716
  // of it now makes as they are (it was compiled since): current, as
7627
8717
  // `compile --check` reads it, so the editor records the source it was
7628
8718
  // built with instead of building again. One rule for both.
8719
+ /** The warnings the build of the changed source gives. @type {string[]} */
8720
+ const sourceWarnings = [];
7629
8721
  if (
7630
8722
  stale === sourceChangedReason(theme) &&
7631
8723
  !brokenSource &&
7632
- !(await outputsDrift(ctx, theme))
8724
+ !(await outputsDrift(ctx, theme, sourceWarnings))
7633
8725
  ) {
8726
+ // Recorded as built without a build: the warnings that build gives
8727
+ // (a stylesheet the source imports that the outputs do not carry) are
8728
+ // said here, as a build says them.
8729
+ rebuiltNotes.push(...sourceWarnings);
7634
8730
  if (!readOnly) refreshSourceStamp(cwd, theme);
7635
8731
  stale = readOnly ? stale : staleBuild(cwd, theme, data);
7636
8732
  }
@@ -7654,7 +8750,10 @@ export async function themeEditShow(theme, options = {}) {
7654
8750
  n === path.basename(f.settingsTs) ||
7655
8751
  (n.startsWith(`${theme}.`) &&
7656
8752
  /\.(css|js|d\.ts|css\.d\.ts|variants\.d\.ts)$/.test(n)) ||
7657
- /^(sheet-[a-z-]+\.html|(sheet|preview)(-[a-z-]+)?\.png)$/.test(n),
8753
+ // (A picture cut from a tall one, sheet-inputs-2.png, too.)
8754
+ /^(sheet-[a-z-]+\.html|(sheet|preview)(-[a-z-]+)?(-\d+)?\.png)$/.test(
8755
+ n,
8756
+ ),
7658
8757
  )
7659
8758
  .map(n => [path.join(f.dir, n), fs.readFileSync(path.join(f.dir, n))]),
7660
8759
  );
@@ -7679,6 +8778,8 @@ export async function themeEditShow(theme, options = {}) {
7679
8778
  } catch (e) {
7680
8779
  putBack(kept, tokensDir);
7681
8780
  if (e instanceof AstryxError && e.code !== E.ERR_THEME_LOAD) throw e;
8781
+ const broken = brokenInstallError(e, cwd, 'Nothing was changed.');
8782
+ if (broken) throw broken;
7682
8783
  // An own theme source that no longer builds is named, as `set` names
7683
8784
  // it; the old build is never shown as current.
7684
8785
  const why = (e instanceof Error ? e.message : String(e))
@@ -7842,7 +8943,7 @@ export async function themeEditShow(theme, options = {}) {
7842
8943
  // Each takes a browser run, so --png pictures the families the theme sets
7843
8944
  // a part of (the buttons when it sets none); --section <family> takes any
7844
8945
  // other, and sheet.html holds every component.
7845
- const touched = touchedFamilies(ctx.project, data).filter(f =>
8946
+ const touched = touchedFamilies(ctx, data).filter(f =>
7846
8947
  FAMILY_SECTIONS.includes(f),
7847
8948
  );
7848
8949
  const families =
@@ -7877,7 +8978,7 @@ export async function themeEditShow(theme, options = {}) {
7877
8978
  }
7878
8979
  })
7879
8980
  : null;
7880
- /** @type {{files: string[], problem: string | null, cutShort: import('./_context.mjs').CutShort[]}} */
8981
+ /** @type {{files: string[], problem: string | null, cutShort: import('./_context.mjs').CutShort[], lowContrast?: import('./_context.mjs').LowContrast[]}} */
7881
8982
  const shots =
7882
8983
  png && !noPages
7883
8984
  ? await pictures(
@@ -7892,15 +8993,15 @@ export async function themeEditShow(theme, options = {}) {
7892
8993
  png: out,
7893
8994
  most: FAMILY_PICTURE_HEIGHT,
7894
8995
  })),
7895
- // A section is photographed from its own sheet, a family cut
7896
- // as above. The full sheet, every component, is too tall to
8996
+ // A section is photographed from its own sheet, a family or the
8997
+ // pages cut as above. The full sheet, every component, is too tall to
7897
8998
  // read whole and slow to take: it is not photographed.
7898
8999
  ...(section
7899
9000
  ? [
7900
9001
  {
7901
9002
  html: path.join(f.dir, `sheet-${section}.html`),
7902
9003
  png: path.join(f.dir, `sheet-${section}.png`),
7903
- ...(FAMILY_SECTIONS.includes(section)
9004
+ ...(section !== OPEN_SECTION
7904
9005
  ? {most: FAMILY_PICTURE_HEIGHT}
7905
9006
  : {}),
7906
9007
  },
@@ -7989,7 +9090,22 @@ export async function themeEditShow(theme, options = {}) {
7989
9090
  ...sheet.notes,
7990
9091
  // Text the sample page's pictures draw cut short.
7991
9092
  ...shots.cutShort.map(cutShortNote),
9093
+ // Text the pictures draw too faint to read that no check above
9094
+ // measures (a state, an open overlay, a variant the checks do not
9095
+ // draw).
9096
+ ...drawnContrastNotes(shots.lowContrast ?? [], checked),
7992
9097
  ...misplacedNotes(theme, data),
9098
+ // (A whole-theme size the theme sets, the text-size or type dial
9099
+ // or a size token, skips phones: a page measured on a touch screen
9100
+ // under 1024px shows the base theme's sizes, which is no fault.)
9101
+ ...(data.settings.some(
9102
+ x =>
9103
+ !x.on &&
9104
+ (['text-size', 'type'].includes(x.thing) ||
9105
+ /^--(font-size-|text-[a-z0-9-]+-(size|leading)$)/.test(x.thing)),
9106
+ )
9107
+ ? [`text sizes: ${PHONE_SIZES_NOTE}`]
9108
+ : []),
7993
9109
  ...(noReact
7994
9110
  ? [
7995
9111
  `react and react-dom cannot be found from this app, so the pages and pictures were not made again and the checks that render components were skipped; install them (${installLine(cwd, ['react', 'react-dom'])}), then run show again`,
@@ -8243,9 +9359,31 @@ function nowAppliesIn(ctx, data, removed, base) {
8243
9359
  compileTheme(ctx, d, base).tokens?.[removed.thing] ?? null,
8244
9360
  );
8245
9361
  const now = value(data);
9362
+ // (A palette kept as saved cannot be made again without a color dial:
9363
+ // the dial that writes the token is the one its saved mapping names.)
9364
+ const kept = paletteRecipeUnknown(ctx.project.cwd, String(data.name));
9365
+ const fed = kept
9366
+ ? /** @type {any} */ (
9367
+ paletteMapping(
9368
+ ctx.project.cwd,
9369
+ String(data.name),
9370
+ data,
9371
+ /** @type {any} */ (base),
9372
+ ctx.project.core.tokenDefaults,
9373
+ )?.tokens?.[removed.thing]
9374
+ )?.family
9375
+ : null;
8246
9376
  if (now !== 'null')
8247
9377
  for (const d of [...data.settings].reverse()) {
8248
9378
  if (d.source !== 'dial' || d.on) continue;
9379
+ if (
9380
+ kept &&
9381
+ (PALETTE_DIALS.includes(d.thing) || d.thing === 'vibrancy')
9382
+ ) {
9383
+ if (fed === d.thing)
9384
+ return `the generated ${d.thing} color (${describe(d)})`;
9385
+ continue;
9386
+ }
8249
9387
  const without = {...data, settings: data.settings.filter(x => x !== d)};
8250
9388
  if (value(without) !== now)
8251
9389
  return PALETTE_DIALS.includes(d.thing)
@@ -8383,10 +9521,40 @@ function otherModeNotes(data) {
8383
9521
  * @returns {Set<string>}
8384
9522
  */
8385
9523
  function dialTouched(ctx, data, s, base) {
9524
+ // (A palette a newer CLI made is kept as saved, from its color settings
9525
+ // as they are: they stay in both builds, so neither asks this CLI to
9526
+ // make that palette again with other colors.)
9527
+ const kept = paletteRecipeUnknown(ctx.project.cwd, String(data.name));
9528
+ // (A color dial of a palette kept as saved touches the tokens its family
9529
+ // gives, or every palette token for the vibrancy: the palette cannot be
9530
+ // made again without it to compare.)
9531
+ if (kept && (PALETTE_DIALS.includes(s.thing) || s.thing === 'vibrancy')) {
9532
+ const pal = paletteMapping(
9533
+ ctx.project.cwd,
9534
+ String(data.name),
9535
+ data,
9536
+ /** @type {any} */ (base),
9537
+ ctx.project.core.tokenDefaults,
9538
+ );
9539
+ return new Set(
9540
+ Object.entries(pal?.tokens ?? {})
9541
+ .filter(
9542
+ ([k, v]) =>
9543
+ k !== 'lifted parts' &&
9544
+ (s.thing === 'vibrancy' ||
9545
+ /** @type {any} */ (v)?.family === s.thing),
9546
+ )
9547
+ .map(([k]) => k),
9548
+ );
9549
+ }
8386
9550
  /** @param {import('./_settings.mjs').Setting[]} list */
8387
9551
  const dialsOnly = list => ({
8388
9552
  ...data,
8389
- settings: list.filter(x => x.source === 'dial'),
9553
+ settings: list.filter(
9554
+ x =>
9555
+ x.source === 'dial' ||
9556
+ (kept && x.source === 'token' && isColorToken(x.thing)),
9557
+ ),
8390
9558
  });
8391
9559
  const withDial = compileTheme(ctx, dialsOnly(data.settings), base);
8392
9560
  const without = compileTheme(
@@ -8746,10 +9914,14 @@ async function sayNextStepClears(ctx, slug, s, r) {
8746
9914
  * @param {{light: Record<string, string>, dark: Record<string, string>} | undefined} res
8747
9915
  * the theme's tokens as the change built them (a change that changed
8748
9916
  * nothing comes back with none: they are read again)
8749
- * @returns {Promise<{missed?: number, missedParts?: number, missedOn?: string[], missedWhere?: string[]}>}
9917
+ * @param {{data: import('./_settings.mjs').ThemeData | null | undefined, res: {light: Record<string, string>, dark: Record<string, string>} | null | undefined}} [prior]
9918
+ * for a change, the settings and tokens before it: the misses it brought
9919
+ * (`missedNew`) are told apart from the ones it found
9920
+ * @returns {Promise<{missed?: number, missedParts?: number, missedOn?: string[], missedWhere?: string[], missedNew?: number}>}
8750
9921
  */
8751
- async function missedSummary(ctx, slug, data, res) {
9922
+ async function missedSummary(ctx, slug, data, res, prior) {
8752
9923
  if (!data.settings.length) return {};
9924
+ const base = await baseResolved(ctx.project, data.like);
8753
9925
  const list = await missedParts(
8754
9926
  ctx,
8755
9927
  slug,
@@ -8757,10 +9929,11 @@ async function missedSummary(ctx, slug, data, res) {
8757
9929
  Object.keys(res?.light ?? {}).length
8758
9930
  ? /** @type {any} */ (res)
8759
9931
  : await resolvedTokens(ctx, slug),
8760
- await baseResolved(ctx.project, data.like),
9932
+ base,
8761
9933
  {count: true},
8762
9934
  ).catch(() => []);
8763
9935
  const on = [...new Set(list.map(m => m.part))];
9936
+ if (!list.length) return {};
8764
9937
  // (Where each part keeps the base look: the state named, or at rest.)
8765
9938
  const where = [
8766
9939
  ...new Set(
@@ -8770,14 +9943,110 @@ async function missedSummary(ctx, slug, data, res) {
8770
9943
  ),
8771
9944
  ),
8772
9945
  ];
8773
- return list.length
8774
- ? {
8775
- missed: list.length,
8776
- missedParts: on.length,
8777
- missedOn: on,
8778
- missedWhere: where,
8779
- }
8780
- : {};
9946
+ /** @param {{part: string, state?: string, why: string}} m */
9947
+ const key = m => `${m.part}|${m.state ?? ''}|${m.why}`;
9948
+ const had =
9949
+ prior?.data && prior.res && prior.data.settings.length
9950
+ ? new Set(
9951
+ (
9952
+ await missedParts(ctx, slug, prior.data, prior.res, base, {
9953
+ count: true,
9954
+ }).catch(() => [])
9955
+ ).map(key),
9956
+ )
9957
+ : prior
9958
+ ? new Set()
9959
+ : null;
9960
+ return {
9961
+ missed: list.length,
9962
+ missedParts: on.length,
9963
+ missedOn: on,
9964
+ missedWhere: where,
9965
+ ...(had ? {missedNew: list.filter(m => !had.has(key(m))).length} : {}),
9966
+ };
9967
+ }
9968
+
9969
+ /** The color dials a missed line can set (the status colors). */
9970
+ const STATUS_DIALS = new Set(['info', 'success', 'warning', 'danger']);
9971
+
9972
+ /**
9973
+ * A status color a missed line sets, as one its own contrast check passes:
9974
+ * the color asked for, else the nearest the check offers (a pale base
9975
+ * yellow as the warning dial stands out from the page too little, and
9976
+ * following that line would only bring a new problem).
9977
+ * @param {any} ctx
9978
+ * @param {string} slug
9979
+ * @param {import('./_settings.mjs').ThemeData} data
9980
+ * @param {Record<string, any>} base
9981
+ * @param {{thing: string, value: string, on?: string}} step
9982
+ * @returns {string}
9983
+ */
9984
+ function passingDialValue(ctx, slug, data, base, step) {
9985
+ if (step.on || !STATUS_DIALS.has(step.thing)) return step.value;
9986
+ // (A palette a newer CLI made is kept as saved: this CLI cannot make it
9987
+ // again with another color to see which reads.)
9988
+ if (paletteRecipeUnknown(ctx.project.cwd, slug)) return step.value;
9989
+ const pal = paletteMapping(
9990
+ ctx.project.cwd,
9991
+ slug,
9992
+ {
9993
+ ...data,
9994
+ settings: [
9995
+ ...data.settings.filter(
9996
+ x => !(x.source === 'dial' && x.thing === step.thing && !x.on),
9997
+ ),
9998
+ /** @type {any} */ ({
9999
+ source: 'dial',
10000
+ thing: step.thing,
10001
+ value: step.value,
10002
+ }),
10003
+ ],
10004
+ },
10005
+ /** @type {any} */ (base),
10006
+ ctx.project.core.tokenDefaults,
10007
+ );
10008
+ // (The check's own fix for the dial itself, never one for one mode.)
10009
+ const better = paletteFailures(pal, step.thing, modesOf(data))
10010
+ .map(f => /** @type {any} */ (f).fix)
10011
+ .find(
10012
+ f => f?.thing === step.thing && !f.mode && typeof f.value === 'string',
10013
+ );
10014
+ return better?.value ?? step.value;
10015
+ }
10016
+
10017
+ /**
10018
+ * Notes for the text the pictures draw too faint to read that no contrast
10019
+ * check measured: one for each part and mode, its texts, its ratios and
10020
+ * colors as drawn, and the picture it is on, with `how` for the part. A
10021
+ * part a check already names in that mode is left out: its problem or note
10022
+ * says it.
10023
+ * @param {import('./_context.mjs').LowContrast[]} drawn
10024
+ * @param {Array<{text: string}>} checked every contrast check's problem and note
10025
+ * @returns {string[]}
10026
+ */
10027
+ export function drawnContrastNotes(drawn, checked) {
10028
+ /** @type {Map<string, import('./_context.mjs').LowContrast[]>} */
10029
+ const byPart = new Map();
10030
+ for (const x of drawn) {
10031
+ const named = checked.some(
10032
+ c =>
10033
+ new RegExp(`(^|[\\s(])${x.part}\\b`).test(c.text) &&
10034
+ c.text.includes(` in ${x.mode}`),
10035
+ );
10036
+ if (named) continue;
10037
+ const k = `${x.part}\u0000${x.mode}`;
10038
+ byPart.set(k, [...(byPart.get(k) ?? []), x]);
10039
+ }
10040
+ return [...byPart.values()].map(list => {
10041
+ const [x] = list;
10042
+ const ratios = list.map(y => y.ratio);
10043
+ const lo = Math.min(...ratios);
10044
+ const hi = Math.max(...ratios);
10045
+ const texts = [...new Set(list.map(y => `"${y.text}"`))];
10046
+ // (The pictures' paths come as the results show them.)
10047
+ const files = [...new Set(list.map(y => y.file))];
10048
+ return `the pictures draw text in ${x.part} (${texts.slice(0, 3).join(', ')}${texts.length > 3 ? ` and ${texts.length - 3} more` : ''}) at ${lo === hi ? lo : `${lo}–${hi}`}:1 in ${x.mode} (${x.fg} on ${x.bg}, in ${files.join(', ')}), which no check above measures; text needs 4.5:1; what draws it: ${P} how ${x.part}`;
10049
+ });
8781
10050
  }
8782
10051
 
8783
10052
  /**
@@ -8825,8 +10094,9 @@ async function missedParts(ctx, slug, data, res, base, opts = {}) {
8825
10094
  /** @type {string[]} */
8826
10095
  const lines = [];
8827
10096
  let refused = false;
8828
- for (const st of x.steps) {
8829
- const typed = `${P} set ${slug} ${st.thing} ${quoteCommandArgument(st.value)}${st.on ? ` --on ${st.on}` : ''}${st.when ? ` --when ${st.when}` : ''}${st.state ? ` --state ${st.state}` : ''}${st.mode ? ` --mode ${st.mode}` : ''}`;
10097
+ for (const st0 of x.steps) {
10098
+ const st = {...st0, value: passingDialValue(ctx, slug, data, base, st0)};
10099
+ const typed = `${P} set ${slug} ${st.thing} ${quoteCommandArgument(st.value)}${st.on ? ` --on ${st.on}` : ''}${st.when ? ` --when ${st.when}` : ''}${st.state ? ` --state ${st.state}` : ''}${st.mode ? ` --mode ${st.mode}` : ''}${/** @type {any} */ (st).only ? ' --only' : ''}`;
8830
10100
  const followed = await followChangeLine(
8831
10101
  'set',
8832
10102
  slug,
@@ -8951,6 +10221,40 @@ function partValues(ctx, data, res, mode) {
8951
10221
  function colorsReport(pal, data, built, slug = '', own = {}) {
8952
10222
  if (!pal)
8953
10223
  return {vibrancy: null, colors: [], colorNotes: [], colorProblems: []};
10224
+ /**
10225
+ * The category colors (badges, tokens and card tints), chart colors and
10226
+ * status roles: what a themed look gave up to write them, or that the
10227
+ * build still shows the base theme's where the palette now derives them.
10228
+ */
10229
+ const lookNote = () => {
10230
+ const said = categoryNotes(pal, '', slug, vibrancyTakes(data, own));
10231
+ const c = pal.categories;
10232
+ if (!c || c.badges !== 'derived' || c.chart !== 'derived') return said;
10233
+ const words = derivedStatusWords(data);
10234
+ const status = new RegExp(
10235
+ `^--color-(?:(?:on|text|icon|border)-)?(?:${words.join('|') || '(?!)'})(?:-muted)?$`,
10236
+ );
10237
+ const behind = Object.entries(pal.tokens).filter(
10238
+ ([k, v]) =>
10239
+ (isLookToken(k) || status.test(k)) &&
10240
+ !(k in own) &&
10241
+ !data.settings.some(
10242
+ x => x.source === 'token' && x.thing === k && !x.on && !x.when,
10243
+ ) &&
10244
+ modes.some(
10245
+ m =>
10246
+ built?.[m]?.[k] &&
10247
+ built[m][k].trim().toLowerCase() !==
10248
+ String(v[m].color).toLowerCase(),
10249
+ ),
10250
+ );
10251
+ return behind.length
10252
+ ? [
10253
+ ...said,
10254
+ `category, chart and status colors still show the base theme's in this build (${behind.length} values): your palette grows them from your look now, and the next change rebuilds them, for example ${P} set ${slug} vibrancy ${pal.vibrancy}`,
10255
+ ]
10256
+ : said;
10257
+ };
8954
10258
  /** What the user set for each token exactly, in each mode. */
8955
10259
  const exactBy =
8956
10260
  /** @type {Record<string, {light?: string, dark?: string}>} */ ({});
@@ -9009,7 +10313,8 @@ function colorsReport(pal, data, built, slug = '', own = {}) {
9009
10313
  seed: fam.seed,
9010
10314
  tokens: Object.fromEntries(
9011
10315
  Object.entries(pal.tokens)
9012
- .filter(([, v]) => v.family === fam.id)
10316
+ // The category and chart colors are said in one note (lookNote).
10317
+ .filter(([k, v]) => v.family === fam.id && !isLookToken(k))
9013
10318
  .map(([k, v]) => [
9014
10319
  k,
9015
10320
  // Each mode says what it shows: the exact setting where one is
@@ -9042,6 +10347,7 @@ function colorsReport(pal, data, built, slug = '', own = {}) {
9042
10347
  ...pairings
9043
10348
  .filter(c => c.note || !c.pass || c.stop !== c.preferred)
9044
10349
  .map(pairingNote),
10350
+ ...lookNote(),
9045
10351
  ].filter(
9046
10352
  n =>
9047
10353
  !Object.keys(ownBy).some(k =>
@@ -9635,6 +10941,25 @@ async function undoTheme(theme, options) {
9635
10941
  )
9636
10942
  )
9637
10943
  : null;
10944
+ // (The shades a palette kept as saved showed at that step, each half a
10945
+ // stop of a palette color, white or black, or a color.)
10946
+ const half = (/** @type {any} */ h) =>
10947
+ h &&
10948
+ typeof h === 'object' &&
10949
+ typeof h.family === 'string' &&
10950
+ typeof h.stop === 'number';
10951
+ const stops =
10952
+ built?.stops &&
10953
+ typeof built.stops === 'object' &&
10954
+ Object.entries(built.stops).every(
10955
+ ([k, v]) =>
10956
+ k === 'lifted parts' ||
10957
+ (/^--[\w-]+$/.test(k) &&
10958
+ half(/** @type {any} */ (v)?.light) &&
10959
+ half(/** @type {any} */ (v)?.dark)),
10960
+ )
10961
+ ? /** @type {Record<string, any>} */ (built.stops)
10962
+ : null;
9638
10963
  // The step it goes back to is checked like the settings file itself. A
9639
10964
  // value the editor no longer accepts is left out of that step (with a
9640
10965
  // note); a step whose shape is broken is refused.
@@ -9657,9 +10982,15 @@ async function undoTheme(theme, options) {
9657
10982
  }
9658
10983
  // The checks that need this Core too (a token's type, a part, a state,
9659
10984
  // a name that is no token or property): what they refuse is left out of
9660
- // the step, with the same note, so the build stays valid.
10985
+ // the step, with the same note, so the build stays valid. One refused
10986
+ // only as doing nothing there is kept, as every command keeps it
10987
+ // (leaveOutStored).
9661
10988
  {
9662
- const bad = new Set(storedProblems(ctx, theme, prev).map(p => p.setting));
10989
+ const bad = new Set(
10990
+ storedProblems(ctx, theme, prev)
10991
+ .filter(p => !p.noEffect)
10992
+ .map(p => p.setting),
10993
+ );
9663
10994
  if (bad.size) {
9664
10995
  leftOut = [...leftOut, ...prev.settings.filter(s => bad.has(s))];
9665
10996
  prev = {...prev, settings: prev.settings.filter(s => !bad.has(s))};
@@ -9682,6 +11013,7 @@ async function undoTheme(theme, options) {
9682
11013
  history: false,
9683
11014
  historyAfter: history,
9684
11015
  radii,
11016
+ stops,
9685
11017
  });
9686
11018
  /** @type {string[]} */
9687
11019
  const undone = current
@@ -9777,7 +11109,11 @@ async function undoTheme(theme, options) {
9777
11109
  settings: prev.settings.length,
9778
11110
  stepsLeft: stepsLeft,
9779
11111
  // What the step back changed, as a change reports it.
9780
- changedTokens: committed.changed,
11112
+ changedTokens: lookCollapsed(
11113
+ committed.changed,
11114
+ derivedStatusWords(prev),
11115
+ exactTokens(prev),
11116
+ ).lines,
9781
11117
  changedPartTokens: committed.changedParts ?? [],
9782
11118
  problems: committed.problems,
9783
11119
  newProblems: [