@astryxdesign/cli 0.7.17 → 0.7.18-canary.gb660bba

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 (215) 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/doctor/_adapter.d.mts +11 -62
  5. package/api/doctor/_adapter.mjs +242 -472
  6. package/api/doctor/doctor.d.mts +1 -1
  7. package/api/doctor/doctor.mjs +1 -1
  8. package/api/doctor/theme-checks.mjs +37 -45
  9. package/api/error.d.mts +21 -0
  10. package/api/error.mjs +89 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/icon.doc.mjs +1 -1
  13. package/api/icon/icon.type.mjs +1 -1
  14. package/api/icon/search/search.d.mts +4 -1
  15. package/api/icon/search/search.mjs +41 -4
  16. package/api/render/_adapter.mjs +233 -40
  17. package/api/render/render.type.d.mts +1 -1
  18. package/api/render/render.type.mjs +1 -1
  19. package/api/search/ORDERING.md +2 -2
  20. package/api/search/_candidate-score.mjs +32 -8
  21. package/api/search/_cards.json +1 -1
  22. package/api/search/_compound.d.mts +0 -1
  23. package/api/search/_compound.mjs +93 -2
  24. package/api/search/_lexical.mjs +177 -17
  25. package/api/search/_order.d.mts +3 -1
  26. package/api/search/_order.mjs +16 -5
  27. package/api/search/_result.d.mts +9 -0
  28. package/api/search/_result.mjs +10 -0
  29. package/api/search/_score.mjs +21 -3
  30. package/api/swizzle/_moduleGraph.d.mts +8 -0
  31. package/api/swizzle/_moduleGraph.mjs +61 -3
  32. package/api/template/copy/copy.mjs +5 -3
  33. package/api/theme/_adapter.mjs +48 -12
  34. package/api/theme/build/build.d.mts +4 -0
  35. package/api/theme/build/build.mjs +69 -18
  36. package/api/theme/build/style-keys.mjs +4 -5
  37. package/api/theme/build/theme-object.mjs +5 -0
  38. package/api/theme/palette/generate/color.d.mts +47 -0
  39. package/api/theme/palette/generate/color.mjs +58 -1
  40. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  41. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  42. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  43. package/api/theme/palette/generate/editor-look.mjs +550 -0
  44. package/api/theme/palette/generate/mapping.d.mts +94 -9
  45. package/api/theme/palette/generate/mapping.mjs +94 -22
  46. package/api/theme-edit/_adapter.mjs +10 -1
  47. package/api/theme-edit/_catalog.d.mts +13 -13
  48. package/api/theme-edit/_catalog.mjs +38 -16
  49. package/api/theme-edit/_check.d.mts +82 -6
  50. package/api/theme-edit/_check.mjs +1270 -238
  51. package/api/theme-edit/_color.d.mts +74 -0
  52. package/api/theme-edit/_color.mjs +168 -3
  53. package/api/theme-edit/_compiler.d.mts +3 -5
  54. package/api/theme-edit/_compiler.mjs +122 -23
  55. package/api/theme-edit/_context.d.mts +46 -5
  56. package/api/theme-edit/_context.mjs +97 -49
  57. package/api/theme-edit/_css.d.mts +11 -0
  58. package/api/theme-edit/_css.mjs +40 -0
  59. package/api/theme-edit/_edit.d.mts +13 -0
  60. package/api/theme-edit/_edit.mjs +1450 -128
  61. package/api/theme-edit/_how-commands.d.mts +12 -0
  62. package/api/theme-edit/_how-commands.mjs +96 -14
  63. package/api/theme-edit/_how-question.d.mts +73 -29
  64. package/api/theme-edit/_how-question.mjs +8233 -1207
  65. package/api/theme-edit/_how-sides.d.mts +22 -0
  66. package/api/theme-edit/_how-sides.mjs +173 -0
  67. package/api/theme-edit/_how-steps.d.mts +42 -0
  68. package/api/theme-edit/_how-steps.mjs +208 -0
  69. package/api/theme-edit/_how-values.d.mts +29 -0
  70. package/api/theme-edit/_how-values.mjs +111 -0
  71. package/api/theme-edit/_how-words.d.mts +15 -0
  72. package/api/theme-edit/_how-words.mjs +239 -0
  73. package/api/theme-edit/_how.d.mts +1 -1
  74. package/api/theme-edit/_how.mjs +412 -37
  75. package/api/theme-edit/_missed.d.mts +2 -1
  76. package/api/theme-edit/_missed.mjs +125 -13
  77. package/api/theme-edit/_normal.d.mts +5 -3
  78. package/api/theme-edit/_normal.mjs +54 -14
  79. package/api/theme-edit/_palette.d.mts +204 -4
  80. package/api/theme-edit/_palette.mjs +901 -25
  81. package/api/theme-edit/_part-pieces.d.mts +54 -0
  82. package/api/theme-edit/_part-pieces.mjs +179 -0
  83. package/api/theme-edit/_part-words.mjs +33 -5
  84. package/api/theme-edit/_parts.d.mts +133 -0
  85. package/api/theme-edit/_parts.mjs +599 -10
  86. package/api/theme-edit/_picture-traits.d.mts +259 -0
  87. package/api/theme-edit/_picture-traits.mjs +1030 -0
  88. package/api/theme-edit/_preview.d.mts +84 -4
  89. package/api/theme-edit/_preview.mjs +260 -24
  90. package/api/theme-edit/_project.d.mts +14 -4
  91. package/api/theme-edit/_project.mjs +95 -26
  92. package/api/theme-edit/_set-line.d.mts +29 -0
  93. package/api/theme-edit/_set-line.mjs +100 -0
  94. package/api/theme-edit/_settings.d.mts +625 -28
  95. package/api/theme-edit/_settings.mjs +4587 -880
  96. package/api/theme-edit/_tables.d.mts +25 -1
  97. package/api/theme-edit/_tables.mjs +115 -11
  98. package/api/theme-edit/_text-looks.d.mts +78 -0
  99. package/api/theme-edit/_text-looks.mjs +376 -0
  100. package/api/theme-edit/_vet.d.mts +3 -26
  101. package/api/theme-edit/_vet.mjs +5 -89
  102. package/api/theme-edit/how/how.d.mts +1 -1
  103. package/api/theme-edit/how/how.mjs +1 -1
  104. package/api/theme-edit/theme-edit.type.d.mts +54 -1
  105. package/api/theme-edit/theme-edit.type.mjs +17 -2
  106. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  107. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  108. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  109. package/api/theme-edit/themeEditShow.doc.mjs +4 -0
  110. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  111. package/assets/component-list.generated.json +1 -1
  112. package/assets/docs/author-a-theme.doc.mjs +7 -4
  113. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  114. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  115. package/assets/docs/use-a-theme.doc.mjs +89 -17
  116. package/assets/docs-routes.generated.json +1 -1
  117. package/assets/docs.generated.json +2 -2
  118. package/assets/icons/definitions/article.doc.mjs +9 -0
  119. package/assets/icons/template-icons.json +5 -0
  120. package/assets/search-catalog.generated.json +2 -2
  121. package/assets/self-audit.generated.json +1 -1
  122. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  123. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  124. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  125. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  126. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  127. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  128. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  129. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  130. package/assets/templates/components.generated.json +1 -1
  131. package/assets/templates/pages/ide/page.tsx +5 -10
  132. package/assets/templates/pages/payment-form/page.tsx +16 -60
  133. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  134. package/authoring/debug/parse.d.mts +1 -1
  135. package/authoring/doctypes/_schema.d.mts +13 -13
  136. package/authoring/gap-report/parse.d.mts +1 -1
  137. package/clients/cli/build-id.generated.json +1 -1
  138. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  139. package/clients/cli/commands/experimental/theme.mjs +46 -6
  140. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  141. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  142. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  143. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  144. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  145. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  146. package/clients/cli/commands/hook.mjs +7 -0
  147. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  148. package/clients/cli/index.mjs +6 -2
  149. package/clients/cli/lib/hook-format.mjs +41 -1
  150. package/clients/cli/lib/json-shim.mjs +34 -14
  151. package/clients/cli/lib/other-cli-words.mjs +7 -0
  152. package/clients/cli/lib/unknown-command.mjs +345 -46
  153. package/clients/cli/manifest.generated.json +1 -1
  154. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  155. package/foundation/agent-docs/agent-docs.mjs +51 -8
  156. package/foundation/config/project.d.mts +11 -1
  157. package/foundation/config/project.mjs +11 -2
  158. package/foundation/discovery/component-replacement.d.mts +5 -8
  159. package/foundation/discovery/component-replacement.mjs +12 -14
  160. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  161. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  162. package/foundation/discovery/core-elements.d.mts +6 -0
  163. package/foundation/discovery/core-elements.mjs +10 -2
  164. package/foundation/discovery/core-prop-types.d.mts +5 -0
  165. package/foundation/discovery/core-prop-types.mjs +10 -3
  166. package/foundation/discovery/core-props.d.mts +8 -0
  167. package/foundation/discovery/core-props.mjs +29 -13
  168. package/foundation/discovery/official-list.d.mts +17 -0
  169. package/foundation/discovery/official-list.mjs +77 -0
  170. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  171. package/foundation/discovery/unknown-core-props.mjs +601 -0
  172. package/foundation/discovery/written-prop-values.d.mts +35 -0
  173. package/foundation/discovery/written-prop-values.mjs +258 -0
  174. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  175. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  176. package/foundation/fs/package-name.d.mts +10 -0
  177. package/foundation/fs/package-name.mjs +37 -0
  178. package/foundation/fs/project-source-files.d.mts +27 -0
  179. package/foundation/fs/project-source-files.mjs +115 -0
  180. package/foundation/fs/project-sources.d.mts +25 -0
  181. package/foundation/fs/project-sources.mjs +83 -0
  182. package/foundation/fs/read-record.d.mts +18 -0
  183. package/foundation/fs/read-record.mjs +36 -2
  184. package/foundation/integrations/integration-warnings.d.mts +39 -7
  185. package/foundation/integrations/integration-warnings.mjs +141 -19
  186. package/foundation/integrations/missing-dependency.d.mts +11 -0
  187. package/foundation/integrations/missing-dependency.mjs +20 -5
  188. package/foundation/release/folder-lock.d.mts +5 -2
  189. package/foundation/release/folder-lock.mjs +9 -3
  190. package/foundation/release/notices.mjs +2 -8
  191. package/foundation/render/cut-short.d.mts +8 -2
  192. package/foundation/render/cut-short.mjs +50 -5
  193. package/foundation/render/drawn-contrast.d.mts +38 -0
  194. package/foundation/render/drawn-contrast.mjs +237 -0
  195. package/foundation/render/file-header.mjs +4 -0
  196. package/foundation/render/layers.d.mts +2 -1
  197. package/foundation/render/layers.mjs +22 -1
  198. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  199. package/foundation/render/package-resolve-hooks.mjs +124 -32
  200. package/foundation/render/page-worker.mjs +95 -23
  201. package/foundation/render/part-boxes.d.mts +27 -0
  202. package/foundation/render/part-boxes.mjs +45 -0
  203. package/foundation/render/picture-chrome.mjs +36 -4
  204. package/foundation/render/picture-playwright.mjs +26 -2
  205. package/foundation/render/picture-window.d.mts +29 -2
  206. package/foundation/render/picture-window.mjs +99 -1
  207. package/foundation/render/render-page.d.mts +39 -6
  208. package/foundation/render/render-page.mjs +26 -10
  209. package/foundation/render/ts-paths.mjs +2 -1
  210. package/foundation/response/error-codes.doc.mjs +1 -1
  211. package/foundation/response/error-codes.mjs +1 -1
  212. package/foundation/response/response-types.doc.mjs +1 -1
  213. package/foundation/text/written-string.d.mts +4 -1
  214. package/foundation/text/written-string.mjs +4 -1
  215. package/package.json +8 -7
@@ -9,17 +9,33 @@
9
9
  * @returns {string | null}
10
10
  */
11
11
  export function familyOf(project: import("./_project.mjs").ThemeProject, name: string): string | null;
12
+ /**
13
+ * Whether a section's own page draws a component in a cell of its own. On
14
+ * the overlays section's page, a part of an overlay (a dialog's header, a
15
+ * command palette's list) shows inside the overlay it belongs to, never
16
+ * alone beside it, and inside it only while the overlay is open: that page
17
+ * stays one or two screens. The whole sheet draws it alone.
18
+ * @param {import('./_project.mjs').ThemeProject} project
19
+ * @param {string} name
20
+ * @param {string | null | undefined} group the section drawn, none for the whole sheet
21
+ */
22
+ export function shownOnSection(project: import("./_project.mjs").ThemeProject, name: string, group: string | null | undefined): boolean;
12
23
  /**
13
24
  * The sections of the theme-building page whose parts the theme's settings
14
25
  * set on their own (`--on badge`, or a group of parts such as `--on
15
26
  * inputs`): the components each part names a class of, each in its section. A setting for the whole theme (a color, the
16
27
  * corners) sets no section here: the sample page and the open states show
17
28
  * it.
18
- * @param {import('./_project.mjs').ThemeProject} project
29
+ * A family role (`--on option-rows`) is read from the census, as the
30
+ * change itself reads it, so the pictured set is what the change touched.
31
+ * @param {{project: import('./_project.mjs').ThemeProject, C?: any}} ctx
19
32
  * @param {import('./_settings.mjs').ThemeData} data
20
33
  * @returns {string[]}
21
34
  */
22
- export function touchedFamilies(project: import("./_project.mjs").ThemeProject, data: import("./_settings.mjs").ThemeData): string[];
35
+ export function touchedFamilies(ctx: {
36
+ project: import("./_project.mjs").ThemeProject;
37
+ C?: any;
38
+ }, data: import("./_settings.mjs").ThemeData): string[];
23
39
  /**
24
40
  * Items of the theme-building page: each component once per variant
25
41
  * (overlays open), the sample page, and template pages
@@ -276,8 +292,9 @@ export function screenshot(project: import("./_project.mjs").ThemeProject, html:
276
292
  * took the picture, each with whether its part keeping its width draws it
277
293
  * whole; absent when that browser's script measured nothing.
278
294
  * @param {import('./_project.mjs').ThemeProject} project
279
- * @param {Array<{html: string, png: string, mode: 'light' | 'dark'}>} jobs
280
- * absolute paths
295
+ * @param {Array<{html: string, png: string, mode: 'light' | 'dark', boxes?: string[]}>} jobs
296
+ * absolute paths; `boxes`: parts whose drawn sizes the picture measures
297
+ * (its result's `boxes`)
281
298
  * @param {PictureRun} [run] what earlier pictures of the same run learned:
282
299
  * a browser that failed or hung there is not tried again
283
300
  * @returns {Promise<PictureResult[]>}
@@ -286,7 +303,61 @@ export function screenshots(project: import("./_project.mjs").ThemeProject, jobs
286
303
  html: string;
287
304
  png: string;
288
305
  mode: "light" | "dark";
306
+ boxes?: string[];
289
307
  }>, run?: PictureRun): Promise<PictureResult[]>;
308
+ /**
309
+ * How much each part's drawn size changes from one page to another (the
310
+ * sheet before a change and after it): both pictured in one browser run,
311
+ * each part's boxes measured, and the largest growth of a box at the same
312
+ * place in the page taken, in px. A part not drawn on both pages is
313
+ * counted as not drawn. The pictures themselves are not kept.
314
+ * @param {import('./_project.mjs').ThemeProject} project
315
+ * @param {string} before absolute path of the page before
316
+ * @param {string} after absolute path of the page after
317
+ * @param {string[]} parts
318
+ * @param {'light' | 'dark'} mode
319
+ * @returns {Promise<{changes: Array<{part: string, width: number, height: number, drawn: number}>} | {problem: string}>}
320
+ */
321
+ export function partSizeChanges(project: import("./_project.mjs").ThemeProject, before: string, after: string, parts: string[], mode: "light" | "dark"): Promise<{
322
+ changes: Array<{
323
+ part: string;
324
+ width: number;
325
+ height: number;
326
+ drawn: number;
327
+ }>;
328
+ } | {
329
+ problem: string;
330
+ }>;
331
+ /**
332
+ * How much each part's drawn boxes grow from one measurement to another:
333
+ * the largest growth in width and in height of a box at the same place in
334
+ * the page, in px, to a hundredth (0 when none grows; a box that shrinks
335
+ * does not count), and how many boxes both measurements draw.
336
+ * @param {string[]} parts
337
+ * @param {Record<string, Array<[number, number]>>} was
338
+ * @param {Record<string, Array<[number, number]>>} now
339
+ * @returns {Array<{part: string, width: number, height: number, drawn: number}>}
340
+ */
341
+ export function boxChanges(parts: string[], was: Record<string, Array<[number, number]>>, now: Record<string, Array<[number, number]>>): Array<{
342
+ part: string;
343
+ width: number;
344
+ height: number;
345
+ drawn: number;
346
+ }>;
347
+ /**
348
+ * What a change of size says about the parts it measured: how much each
349
+ * part that grows grows, else that they keep their size; null when none
350
+ * of them is drawn.
351
+ * @param {Array<{part: string, width: number, height: number, drawn: number}>} changes
352
+ * @param {string} cause what grew them ("the added border")
353
+ * @returns {string | null}
354
+ */
355
+ export function sizeChangeNote(changes: Array<{
356
+ part: string;
357
+ width: number;
358
+ height: number;
359
+ drawn: number;
360
+ }>, cause: string): string | null;
290
361
  /**
291
362
  * What a picture shows in place of a font stack: a role whose stack ends in
292
363
  * a generic of a kind (serif, monospace, cursive) and none of whose named
@@ -444,11 +515,20 @@ export type PictureResult = {
444
515
  ok: true;
445
516
  file: string;
446
517
  notes?: string[];
518
+ boxes?: Record<string, Array<[number, number]>>;
447
519
  cutShort?: Array<{
448
520
  part: string | null;
449
521
  text: string;
450
522
  whole: boolean;
451
523
  broken?: boolean;
524
+ overlaps?: boolean;
525
+ }>;
526
+ lowContrast?: Array<{
527
+ part: string;
528
+ text: string;
529
+ ratio: number;
530
+ fg: string;
531
+ bg: string;
452
532
  }>;
453
533
  } | {
454
534
  ok: false;
@@ -53,6 +53,7 @@ import {
53
53
  themeFiles,
54
54
  APP_COPY_BUILT,
55
55
  appCopyNames,
56
+ groupsOf,
56
57
  } from './_settings.mjs';
57
58
  import {readRegularFile, writeWhole} from './_palette.mjs';
58
59
  import {cliVersion} from '../../foundation/release/run-context.mjs';
@@ -60,7 +61,6 @@ import {importPathOf, installLine} from './_project.mjs';
60
61
  import {
61
62
  COLOR_PROP_PARTS,
62
63
  DIRECT,
63
- FAMILIES,
64
64
  P,
65
65
  SHOWCASE_GROUPS,
66
66
  wordTable,
@@ -75,6 +75,8 @@ import {compareText} from '../../foundation/text/compare-text.mjs';
75
75
  import {PICTURE_TAKEN} from '../../foundation/render/picture-window.mjs';
76
76
  import {FONT_PROBE_PREFIX} from '../../foundation/render/font-probe.mjs';
77
77
  import {CUT_SHORT_PREFIX} from '../../foundation/render/cut-short.mjs';
78
+ import {LOW_CONTRAST_PREFIX} from '../../foundation/render/drawn-contrast.mjs';
79
+ import {PART_BOXES_PREFIX} from '../../foundation/render/part-boxes.mjs';
78
80
 
79
81
  const TEMPLATES_DIR = path.resolve(
80
82
  path.dirname(fileURLToPath(import.meta.url)),
@@ -176,22 +178,42 @@ export function familyOf(project, name) {
176
178
  return groupOf(name, info?.category || parent?.category || '');
177
179
  }
178
180
 
181
+ /**
182
+ * Whether a section's own page draws a component in a cell of its own. On
183
+ * the overlays section's page, a part of an overlay (a dialog's header, a
184
+ * command palette's list) shows inside the overlay it belongs to, never
185
+ * alone beside it, and inside it only while the overlay is open: that page
186
+ * stays one or two screens. The whole sheet draws it alone.
187
+ * @param {import('./_project.mjs').ThemeProject} project
188
+ * @param {string} name
189
+ * @param {string | null | undefined} group the section drawn, none for the whole sheet
190
+ */
191
+ export function shownOnSection(project, name, group) {
192
+ return !(
193
+ group === 'overlays' &&
194
+ familyOf(project, name) === 'overlays' &&
195
+ project.components[name]?.subComponentOf
196
+ );
197
+ }
198
+
179
199
  /**
180
200
  * The sections of the theme-building page whose parts the theme's settings
181
201
  * set on their own (`--on badge`, or a group of parts such as `--on
182
202
  * inputs`): the components each part names a class of, each in its section. A setting for the whole theme (a color, the
183
203
  * corners) sets no section here: the sample page and the open states show
184
204
  * it.
185
- * @param {import('./_project.mjs').ThemeProject} project
205
+ * A family role (`--on option-rows`) is read from the census, as the
206
+ * change itself reads it, so the pictured set is what the change touched.
207
+ * @param {{project: import('./_project.mjs').ThemeProject, C?: any}} ctx
186
208
  * @param {import('./_settings.mjs').ThemeData} data
187
209
  * @returns {string[]}
188
210
  */
189
- export function touchedFamilies(project, data) {
190
- // A group (`--on inputs`) sets each of its parts.
211
+ export function touchedFamilies(ctx, data) {
212
+ const {project} = ctx;
213
+ // A group (`--on inputs`, `--on option-rows`) sets each of its parts.
214
+ const groups = groupsOf(ctx);
191
215
  const parts = new Set(
192
- (data.settings ?? []).flatMap(s =>
193
- s.on ? (FAMILIES[s.on] ?? [s.on]) : [],
194
- ),
216
+ (data.settings ?? []).flatMap(s => (s.on ? (groups[s.on] ?? [s.on]) : [])),
195
217
  );
196
218
  /** @type {Set<string>} */
197
219
  const out = new Set();
@@ -204,6 +226,71 @@ export function touchedFamilies(project, data) {
204
226
  return [...out];
205
227
  }
206
228
 
229
+ /** The Astryx control each plain HTML text control is drawn as. */
230
+ const ASTRYX_CONTROLS = Object.freeze({
231
+ input: 'TextInput',
232
+ textarea: 'TextArea',
233
+ });
234
+
235
+ /** The input types a text input draws. */
236
+ const TEXT_TYPES = new Set([
237
+ '',
238
+ 'text',
239
+ 'email',
240
+ 'search',
241
+ 'url',
242
+ 'tel',
243
+ 'password',
244
+ ]);
245
+
246
+ /**
247
+ * A value with each plain HTML text control in a doc's sample (a field's
248
+ * `<input>`) drawn as the Astryx control for it, its label hidden, so the
249
+ * sheet shows the theme's own control where an app would use one: a bare
250
+ * browser control shows nothing of the theme. Every other value is the same
251
+ * object.
252
+ * @param {import('./_project.mjs').ThemeProject} project
253
+ * @param {unknown} v
254
+ * @returns {unknown}
255
+ */
256
+ function withAstryxControls(project, v) {
257
+ if (Array.isArray(v)) {
258
+ const out = v.map(x => withAstryxControls(project, x));
259
+ return out.every((x, i) => x === v[i]) ? v : out;
260
+ }
261
+ if (!v || typeof v !== 'object') return v;
262
+ if (isElement(v)) {
263
+ const own = /** @type {Record<string, string>} */ (ASTRYX_CONTROLS)[
264
+ v.__element
265
+ ];
266
+ const p = /** @type {Record<string, unknown>} */ (v.props ?? {});
267
+ if (
268
+ own &&
269
+ project.components[own] &&
270
+ (v.__element !== 'input' || TEXT_TYPES.has(String(p.type ?? '')))
271
+ )
272
+ return {
273
+ __element: own,
274
+ props: {
275
+ label: String(p['aria-label'] ?? p.placeholder ?? 'Text'),
276
+ isLabelHidden: true,
277
+ ...(p.placeholder != null ? {placeholder: p.placeholder} : {}),
278
+ ...(p.id != null ? {id: p.id} : {}),
279
+ },
280
+ };
281
+ const props = withAstryxControls(project, v.props);
282
+ const children = withAstryxControls(project, v.children);
283
+ return props === v.props && children === v.children
284
+ ? v
285
+ : {...v, props, children};
286
+ }
287
+ const entries = Object.entries(v);
288
+ const out = entries.map(([k, x]) => [k, withAstryxControls(project, x)]);
289
+ return out.every(([, x], i) => x === entries[i][1])
290
+ ? v
291
+ : {...v, ...Object.fromEntries(out)};
292
+ }
293
+
207
294
  /**
208
295
  * What the cached component items are built by ({@link codeFingerprint}):
209
296
  * this file and every file it imports, read the first time it is needed.
@@ -231,6 +318,7 @@ const itemsByFile = new Map();
231
318
  */
232
319
  function cachedComponentItems(project, group) {
233
320
  itemsKey ??= codeFingerprint(import.meta.url);
321
+ if (!project.cacheDir) return componentItems(project, group);
234
322
  const file = path.join(project.cacheDir, 'items.json');
235
323
  let kept = itemsByFile.get(file);
236
324
  if (!kept) {
@@ -306,22 +394,13 @@ function componentItems(project, group) {
306
394
  // so it would draw an empty cell: it gets none.
307
395
  if (!importPathOf(project, name)) continue;
308
396
  const info = project.components[name];
309
- // On the overlays section's own page, a part of an overlay (a dialog's
310
- // header, a command palette's list) shows inside the overlay it belongs
311
- // to, never alone beside it: that page stays one or two screens.
312
- if (group === 'overlays' && g === 'overlays' && info?.subComponentOf)
313
- continue;
397
+ if (!shownOnSection(project, name, group)) continue;
314
398
  // A deprecated part is not drawn: a theme styles the part that replaces
315
399
  // it. An overlay whose playground opens it over the page draws nothing
316
400
  // closed (a phone's navigation drawer, slid out of the window): where
317
- // the open states draw it open (below), that is its only cell.
401
+ // the open states draw it open, that is its only cell, on every page.
318
402
  if (info?.deprecated) continue;
319
- if (
320
- (!group || group === 'overlays') &&
321
- info?.overlay &&
322
- OPEN_SCENES.some(s => s.name === name)
323
- )
324
- continue;
403
+ if (info?.overlay && OPEN_SCENES.some(s => s.name === name)) continue;
325
404
  catalogVariants(project, name, 12, {shown: true}).forEach((v, i) =>
326
405
  items.push({
327
406
  group: g,
@@ -332,7 +411,13 @@ function componentItems(project, group) {
332
411
  // A doc's sample children may name a part by an older name (a
333
412
  // stack, a heading): each is drawn by the name Core exports.
334
413
  props: /** @type {Record<string, unknown>} */ (
335
- withCoreAliases(project, withSampleContent(project, name, v.props))
414
+ withAstryxControls(
415
+ project,
416
+ withCoreAliases(
417
+ project,
418
+ withSampleContent(project, name, v.props),
419
+ ),
420
+ )
336
421
  ),
337
422
  }),
338
423
  // An overlay shown open is drawn open: Core places a popover,
@@ -2101,7 +2186,7 @@ export async function screenshot(
2101
2186
  }
2102
2187
 
2103
2188
  /**
2104
- * @typedef {{ok: true, file: string, notes?: string[], cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>} | {ok: false, reason: string, stopped?: string}} PictureResult
2189
+ * @typedef {{ok: true, file: string, notes?: string[], boxes?: Record<string, Array<[number, number]>>, cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>, lowContrast?: Array<{part: string, text: string, ratio: number, fg: string, bg: string}>} | {ok: false, reason: string, stopped?: string}} PictureResult
2105
2190
  */
2106
2191
 
2107
2192
  /** The time a batch adds to its browser's bound for each page after the first. */
@@ -2121,8 +2206,9 @@ const PAGE_BOUND_MS = 20_000;
2121
2206
  * took the picture, each with whether its part keeping its width draws it
2122
2207
  * whole; absent when that browser's script measured nothing.
2123
2208
  * @param {import('./_project.mjs').ThemeProject} project
2124
- * @param {Array<{html: string, png: string, mode: 'light' | 'dark'}>} jobs
2125
- * absolute paths
2209
+ * @param {Array<{html: string, png: string, mode: 'light' | 'dark', boxes?: string[]}>} jobs
2210
+ * absolute paths; `boxes`: parts whose drawn sizes the picture measures
2211
+ * (its result's `boxes`)
2126
2212
  * @param {PictureRun} [run] what earlier pictures of the same run learned:
2127
2213
  * a browser that failed or hung there is not tried again
2128
2214
  * @returns {Promise<PictureResult[]>}
@@ -2229,6 +2315,8 @@ export async function screenshots(project, jobs, run = newPictureRun()) {
2229
2315
  ...pictureFontNotes(out),
2230
2316
  ],
2231
2317
  ...measuredCutShort(out),
2318
+ ...measuredLowContrast(out),
2319
+ ...measuredBoxes(out),
2232
2320
  });
2233
2321
  }
2234
2322
  if (results.length === jobs.length) return results;
@@ -2269,6 +2357,92 @@ export async function screenshots(project, jobs, run = newPictureRun()) {
2269
2357
  return results;
2270
2358
  }
2271
2359
 
2360
+ /**
2361
+ * How much each part's drawn size changes from one page to another (the
2362
+ * sheet before a change and after it): both pictured in one browser run,
2363
+ * each part's boxes measured, and the largest growth of a box at the same
2364
+ * place in the page taken, in px. A part not drawn on both pages is
2365
+ * counted as not drawn. The pictures themselves are not kept.
2366
+ * @param {import('./_project.mjs').ThemeProject} project
2367
+ * @param {string} before absolute path of the page before
2368
+ * @param {string} after absolute path of the page after
2369
+ * @param {string[]} parts
2370
+ * @param {'light' | 'dark'} mode
2371
+ * @returns {Promise<{changes: Array<{part: string, width: number, height: number, drawn: number}>} | {problem: string}>}
2372
+ */
2373
+ export async function partSizeChanges(project, before, after, parts, mode) {
2374
+ const pngs = [before, after].map(h => h.replace(/\.html$/, '.png'));
2375
+ /** @type {PictureResult[]} */
2376
+ let shots;
2377
+ try {
2378
+ shots = await screenshots(project, [
2379
+ {html: before, png: pngs[0], mode, boxes: parts},
2380
+ {html: after, png: pngs[1], mode, boxes: parts},
2381
+ ]);
2382
+ } finally {
2383
+ for (const p of pngs) fs.rmSync(p, {force: true});
2384
+ }
2385
+ const [a, b] = shots;
2386
+ if (!a?.ok || !b?.ok)
2387
+ return {
2388
+ problem:
2389
+ (a && !a.ok ? a.reason : b && !b.ok ? b.reason : null) ??
2390
+ 'no picture was taken',
2391
+ };
2392
+ return {changes: boxChanges(parts, a.boxes ?? {}, b.boxes ?? {})};
2393
+ }
2394
+
2395
+ /**
2396
+ * How much each part's drawn boxes grow from one measurement to another:
2397
+ * the largest growth in width and in height of a box at the same place in
2398
+ * the page, in px, to a hundredth (0 when none grows; a box that shrinks
2399
+ * does not count), and how many boxes both measurements draw.
2400
+ * @param {string[]} parts
2401
+ * @param {Record<string, Array<[number, number]>>} was
2402
+ * @param {Record<string, Array<[number, number]>>} now
2403
+ * @returns {Array<{part: string, width: number, height: number, drawn: number}>}
2404
+ */
2405
+ export function boxChanges(parts, was, now) {
2406
+ const round = (/** @type {number} */ n) => Math.round(n * 100) / 100;
2407
+ return parts.map(part => {
2408
+ const a = was[part] ?? [];
2409
+ const b = now[part] ?? [];
2410
+ const drawn = Math.min(a.length, b.length);
2411
+ let width = 0;
2412
+ let height = 0;
2413
+ for (let i = 0; i < drawn; i++) {
2414
+ width = Math.max(width, b[i][0] - a[i][0]);
2415
+ height = Math.max(height, b[i][1] - a[i][1]);
2416
+ }
2417
+ return {part, width: round(width), height: round(height), drawn};
2418
+ });
2419
+ }
2420
+
2421
+ /**
2422
+ * What a change of size says about the parts it measured: how much each
2423
+ * part that grows grows, else that they keep their size; null when none
2424
+ * of them is drawn.
2425
+ * @param {Array<{part: string, width: number, height: number, drawn: number}>} changes
2426
+ * @param {string} cause what grew them ("the added border")
2427
+ * @returns {string | null}
2428
+ */
2429
+ export function sizeChangeNote(changes, cause) {
2430
+ const drawn = changes.filter(x => x.drawn);
2431
+ if (!drawn.length) return null;
2432
+ const grows = drawn.filter(x => x.width > 0 || x.height > 0);
2433
+ if (!grows.length)
2434
+ return `${drawn.map(x => x.part).join(', ')} keeps its size with ${cause} (measured on the sheet, at rest and in each state it draws)`;
2435
+ return grows
2436
+ .map(
2437
+ x =>
2438
+ `${x.part} grows by ${[
2439
+ ...(x.height > 0 ? [`${x.height}px in height`] : []),
2440
+ ...(x.width > 0 ? [`${x.width}px in width`] : []),
2441
+ ].join(' and ')} (${cause}; measured on the sheet)`,
2442
+ )
2443
+ .join('; ');
2444
+ }
2445
+
2272
2446
  /** The generic families any font of a common kind stands in for. */
2273
2447
  const PLAIN_GENERICS = ['sans-serif', 'system-ui', 'ui-sans-serif'];
2274
2448
 
@@ -2315,7 +2489,7 @@ export function pictureFontNotes(stdout) {
2315
2489
  * The text a picture script measured cut short, from the line it prints
2316
2490
  * after `CUT_SHORT_PREFIX`; nothing when it printed none that reads.
2317
2491
  * @param {string} stdout what the picture script printed
2318
- * @returns {{cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>}}
2492
+ * @returns {{cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>}}
2319
2493
  */
2320
2494
  function measuredCutShort(stdout) {
2321
2495
  const line = stdout.split('\n').find(l => l.startsWith(CUT_SHORT_PREFIX));
@@ -2336,10 +2510,72 @@ function measuredCutShort(stdout) {
2336
2510
  text: x.text,
2337
2511
  whole: x.whole === true,
2338
2512
  ...(x.broken === true ? {broken: true} : {}),
2513
+ ...(x.overlaps === true ? {overlaps: true} : {}),
2339
2514
  })),
2340
2515
  };
2341
2516
  }
2342
2517
 
2518
+ /**
2519
+ * The text a picture script measured too faint to read, from the line it
2520
+ * prints after `LOW_CONTRAST_PREFIX`; nothing when it printed none that
2521
+ * reads.
2522
+ * @param {string} stdout what the picture script printed
2523
+ * @returns {{lowContrast?: Array<{part: string, text: string, ratio: number, fg: string, bg: string}>}}
2524
+ */
2525
+ function measuredLowContrast(stdout) {
2526
+ const line = stdout.split('\n').find(l => l.startsWith(LOW_CONTRAST_PREFIX));
2527
+ if (!line) return {};
2528
+ /** @type {unknown} */
2529
+ let found;
2530
+ try {
2531
+ found = JSON.parse(line.slice(LOW_CONTRAST_PREFIX.length));
2532
+ } catch {
2533
+ return {};
2534
+ }
2535
+ if (!Array.isArray(found)) return {};
2536
+ return {
2537
+ lowContrast: found.filter(
2538
+ x =>
2539
+ x &&
2540
+ typeof x.part === 'string' &&
2541
+ typeof x.text === 'string' &&
2542
+ typeof x.ratio === 'number' &&
2543
+ /^#[0-9a-f]{6}$/.test(String(x.fg)) &&
2544
+ /^#[0-9a-f]{6}$/.test(String(x.bg)),
2545
+ ),
2546
+ };
2547
+ }
2548
+
2549
+ /**
2550
+ * The part sizes a picture script measured, from the line it prints after
2551
+ * `PART_BOXES_PREFIX`; nothing when it printed none that reads.
2552
+ * @param {string} stdout what the picture script printed
2553
+ * @returns {{boxes?: Record<string, Array<[number, number]>>}}
2554
+ */
2555
+ function measuredBoxes(stdout) {
2556
+ const line = stdout.split('\n').find(l => l.startsWith(PART_BOXES_PREFIX));
2557
+ if (!line) return {};
2558
+ /** @type {unknown} */
2559
+ let found;
2560
+ try {
2561
+ found = JSON.parse(line.slice(PART_BOXES_PREFIX.length));
2562
+ } catch {
2563
+ return {};
2564
+ }
2565
+ if (!found || typeof found !== 'object' || Array.isArray(found)) return {};
2566
+ /** @type {Record<string, Array<[number, number]>>} */
2567
+ const boxes = {};
2568
+ for (const [part, list] of Object.entries(found))
2569
+ if (Array.isArray(list))
2570
+ boxes[part] = list.filter(
2571
+ (/** @type {unknown} */ b) =>
2572
+ Array.isArray(b) &&
2573
+ b.length === 2 &&
2574
+ b.every(n => typeof n === 'number'),
2575
+ );
2576
+ return {boxes};
2577
+ }
2578
+
2343
2579
  /** A Chrome or Chromium on this machine, at a usual place or on PATH. */
2344
2580
  function chromeBinary() {
2345
2581
  const names = [
@@ -6,11 +6,19 @@
6
6
  * of the node_modules that holds the Core the command reads (the
7
7
  * project's own, or a workspace root's). The locks and the part-data cache
8
8
  * both live here, so one command never finds two answers. Null without
9
- * Core.
9
+ * Core, and null under Yarn Plug'n'Play: there Core resolves into a
10
+ * read-only package archive, which is no node_modules.
10
11
  * @param {string} dir
11
12
  * @returns {string | null}
12
13
  */
13
14
  export function themeCacheRoot(dir: string): string | null;
15
+ /**
16
+ * Refuse a Yarn Plug'n'Play app: it has no node_modules for the editor to
17
+ * read Core from, or to keep its locks and cache in. Its .pnp.cjs sits at
18
+ * the app or at the workspace root above it.
19
+ * @param {string} dir the app folder, or a folder in it
20
+ */
21
+ export function refusePlugAndPlay(dir: string): void;
14
22
  /**
15
23
  * The step that adds packages to the app: the install guidance its
16
24
  * integrations give, else {@link packageManagerAddLine}.
@@ -80,12 +88,13 @@ export function baseThemeFile(project: ThemeProject, like: string): string;
80
88
  * Resolved tokens of the base theme in both modes.
81
89
  * @param {ThemeProject} project
82
90
  * @param {string | undefined} like
83
- * @returns {Promise<{light: Record<string, string>, dark: Record<string, string>, components: Record<string, any>}>}
91
+ * @returns {Promise<{light: Record<string, string>, dark: Record<string, string>, components: Record<string, any>, onDark: Record<string, string>}>}
84
92
  */
85
93
  export function baseResolved(project: ThemeProject, like: string | undefined): Promise<{
86
94
  light: Record<string, string>;
87
95
  dark: Record<string, string>;
88
96
  components: Record<string, any>;
97
+ onDark: Record<string, string>;
89
98
  }>;
90
99
  export function literals(type: string): string[];
91
100
  export function baseInstalled(from: ThemeProject | string, like: string): boolean;
@@ -101,9 +110,10 @@ export type ThemeProject = {
101
110
  */
102
111
  coreKey: string;
103
112
  /**
104
- * - node_modules/.cache/astryx-theme/<coreKey>
113
+ * - node_modules/.cache/astryx-theme/<coreKey>;
114
+ * null under Yarn Plug'n'Play, which has no node_modules to keep it in
105
115
  */
106
- cacheDir: string;
116
+ cacheDir: string | null;
107
117
  /**
108
118
  * - Core's theme module.
109
119
  */