@astryxdesign/cli 0.7.14 → 0.7.15-canary.g79b95eb

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 (129) hide show
  1. package/api/doctor/_adapter.d.mts +1 -0
  2. package/api/doctor/_adapter.mjs +8 -0
  3. package/api/doctor/_authoring-audit.d.mts +42 -0
  4. package/api/doctor/_authoring-audit.mjs +106 -0
  5. package/api/doctor/doctor.d.mts +7 -0
  6. package/api/doctor/doctor.mjs +24 -39
  7. package/api/search/_adapter.mjs +124 -3
  8. package/api/search/_candidate-score.mjs +63 -9
  9. package/api/search/_entries.d.mts +10 -0
  10. package/api/search/_entries.mjs +68 -1
  11. package/api/search/_gather-templates.d.mts +11 -0
  12. package/api/search/_gather-templates.mjs +22 -2
  13. package/api/search/_words.mjs +26 -6
  14. package/api/swizzle/copy/copy.mjs +1 -1
  15. package/api/theme/_adapter.mjs +20 -9
  16. package/api/theme/build/build.d.mts +15 -1
  17. package/api/theme/build/build.mjs +132 -32
  18. package/api/theme/targets/targets.d.mts +8 -0
  19. package/api/theme/targets/targets.mjs +14 -1
  20. package/api/theme/themeBuild.doc.mjs +6 -3
  21. package/api/theme/themeEject.doc.mjs +3 -3
  22. package/api/theme/themeTargets.doc.mjs +1 -1
  23. package/api/theme-edit/_adapter.d.mts +46 -3
  24. package/api/theme-edit/_adapter.mjs +372 -109
  25. package/api/theme-edit/_check.d.mts +6 -3
  26. package/api/theme-edit/_check.mjs +665 -87
  27. package/api/theme-edit/_color.mjs +4 -2
  28. package/api/theme-edit/_compiler.d.mts +2 -1
  29. package/api/theme-edit/_compiler.mjs +27 -13
  30. package/api/theme-edit/_context.d.mts +2 -1
  31. package/api/theme-edit/_context.mjs +47 -8
  32. package/api/theme-edit/_edit.d.mts +9 -3
  33. package/api/theme-edit/_edit.mjs +484 -66
  34. package/api/theme-edit/_how-commands.d.mts +33 -7
  35. package/api/theme-edit/_how-commands.mjs +57 -45
  36. package/api/theme-edit/_how-question.d.mts +4 -0
  37. package/api/theme-edit/_how-question.mjs +1004 -223
  38. package/api/theme-edit/_how.mjs +96 -9
  39. package/api/theme-edit/_palette.d.mts +38 -13
  40. package/api/theme-edit/_palette.mjs +620 -223
  41. package/api/theme-edit/_parts.mjs +63 -7
  42. package/api/theme-edit/_png.d.mts +4 -4
  43. package/api/theme-edit/_png.mjs +4 -2
  44. package/api/theme-edit/_preview-app.d.mts +6 -0
  45. package/api/theme-edit/_preview-app.mjs +1194 -207
  46. package/api/theme-edit/_preview.mjs +2 -2
  47. package/api/theme-edit/_project.d.mts +12 -1
  48. package/api/theme-edit/_project.mjs +37 -6
  49. package/api/theme-edit/_settings.d.mts +104 -33
  50. package/api/theme-edit/_settings.mjs +818 -118
  51. package/api/theme-edit/_tables.d.mts +7 -0
  52. package/api/theme-edit/_tables.mjs +61 -0
  53. package/api/theme-edit/theme-edit.type.d.mts +11 -1
  54. package/api/theme-edit/theme-edit.type.mjs +4 -3
  55. package/api/theme-edit/themeEditHow.doc.mjs +6 -0
  56. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  57. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  58. package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
  59. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
  60. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  61. package/api/upgrade/_adapter.d.mts +1 -0
  62. package/assets/codemods/run-codemod.mjs +61 -0
  63. package/assets/codemods/runner.mjs +5 -4
  64. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
  65. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
  66. package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
  67. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
  68. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
  69. package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
  70. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
  71. package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
  72. package/assets/docs/tree/calendars.doc.mjs +1 -3
  73. package/assets/docs.generated.json +2 -1
  74. package/assets/self-audit.generated.json +1 -0
  75. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
  76. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
  77. package/assets/templates/components.generated.json +1 -1
  78. package/clients/cli/bin/astryx.mjs +19 -15
  79. package/clients/cli/build-id.generated.json +1 -0
  80. package/clients/cli/commands/ensure-core-built.mjs +12 -5
  81. package/clients/cli/commands/experimental/theme.mjs +178 -78
  82. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  83. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
  84. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
  85. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  86. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  87. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  88. package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
  89. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  90. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  91. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
  93. package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
  94. package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
  95. package/clients/cli/commands/manifest.mjs +5 -2
  96. package/clients/cli/commands/theme.mjs +118 -22
  97. package/clients/cli/index.mjs +9 -3
  98. package/clients/cli/lib/manifest.mjs +37 -0
  99. package/clients/cli/lib/resolve-theme.mjs +2 -1
  100. package/clients/cli/manifest.generated.json +1 -0
  101. package/foundation/discovery/module-exports.mjs +16 -2
  102. package/foundation/discovery/stored-self-audit.d.mts +31 -0
  103. package/foundation/discovery/stored-self-audit.mjs +119 -0
  104. package/foundation/discovery/template-adapter.d.mts +48 -2
  105. package/foundation/discovery/template-adapter.mjs +51 -19
  106. package/foundation/discovery/template-needs.d.mts +6 -0
  107. package/foundation/discovery/template-needs.mjs +20 -1
  108. package/foundation/discovery/template-source-tree.d.mts +7 -0
  109. package/foundation/discovery/template-source-tree.mjs +15 -0
  110. package/foundation/discovery/theme-discovery.d.mts +2 -1
  111. package/foundation/discovery/theme-discovery.mjs +2 -8
  112. package/foundation/discovery/theme-module-extensions.d.mts +18 -0
  113. package/foundation/discovery/theme-module-extensions.mjs +30 -0
  114. package/foundation/doc-compiler/import.mjs +12 -11
  115. package/foundation/doc-compiler/stored-docs.d.mts +18 -12
  116. package/foundation/doc-compiler/stored-docs.mjs +52 -19
  117. package/foundation/env/private-dir.d.mts +17 -0
  118. package/foundation/env/private-dir.mjs +42 -0
  119. package/foundation/fs/gather-cache.d.mts +108 -0
  120. package/foundation/fs/gather-cache.mjs +716 -0
  121. package/foundation/fs/module-loader.mjs +7 -1
  122. package/foundation/fs/read-record.d.mts +31 -1
  123. package/foundation/fs/read-record.mjs +93 -6
  124. package/foundation/integrations/validate-contributions.mjs +24 -11
  125. package/foundation/release/cache.d.mts +11 -2
  126. package/foundation/release/cache.mjs +59 -10
  127. package/foundation/release/folder-lock.d.mts +21 -0
  128. package/foundation/release/folder-lock.mjs +171 -0
  129. package/package.json +8 -6
@@ -23,18 +23,23 @@ import {
23
23
  FAMILIES,
24
24
  GROUPS,
25
25
  HOW,
26
+ LIKE,
26
27
  P,
27
28
  familyOf,
28
29
  } from './_tables.mjs';
29
30
  import {colorsAt, decodePng, mainColors} from './_png.mjs';
30
- import {loadTheme, nearest, refuse} from './_settings.mjs';
31
+ import {baseThemeFile, installLine} from './_project.mjs';
32
+ import {loadTheme, nearest, refuse, themeSourceProblem} from './_settings.mjs';
31
33
  import {ASPECTS} from './_check.mjs';
32
34
  import {MODAL} from './_compiler.mjs';
33
35
  import {PALETTE_DIALS, mappingRows, paletteFiles} from './_palette.mjs';
34
36
  import {requireProject, context} from './_context.mjs';
35
37
  import {checked, exampleStep, howTheme, render} from './_how-commands.mjs';
36
38
  import {draftAnswer} from './_how-question.mjs';
37
- import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
39
+ import {
40
+ getCliInvocation,
41
+ quoteCommandArgument,
42
+ } from '../../foundation/env/package-manager.mjs';
38
43
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
39
44
 
40
45
  const E = ERROR_CODES;
@@ -75,6 +80,19 @@ export function isPicture(subject, cwd) {
75
80
  }
76
81
  }
77
82
 
83
+ /**
84
+ * A dial's help, with what `set` does now where that differs from it: Core
85
+ * gives headings the body family when the theme names no heading family,
86
+ * so `font --on body` moves headings too.
87
+ * @param {string} key
88
+ * @param {{bodyFontReachesHeadings: boolean}} env
89
+ */
90
+ function dialHelp(key, env) {
91
+ return key === 'font' && env.bodyFontReachesHeadings
92
+ ? `${DIALS.font.help} Note: font --on body also sets the heading font while the theme sets no heading font; for body text alone, set --font-family-body.`
93
+ : DIALS[key].help;
94
+ }
95
+
78
96
  /**
79
97
  * Explain anything a theme change can name, or answer a question about one:
80
98
  * a part (what it reads for each aspect, under which `--when` or `--state`,
@@ -93,6 +111,34 @@ export async function themeEditHow(subject, options = {}) {
93
111
  const {cwd = process.cwd()} = options;
94
112
  requireProject(cwd);
95
113
  try {
114
+ if (options.words) {
115
+ // The words as typed: a picture first takes only a count after it;
116
+ // anything else is one subject.
117
+ const words = options.words;
118
+ const picture = isPicture(words[0] ?? '', cwd);
119
+ const again = `${HOW} ${quoteCommandArgument(words[0] ?? '')} 5`;
120
+ if (picture && words.length > 2)
121
+ throw new AstryxError(
122
+ `After a picture, give only how many colors to list, not "${words.slice(1).join(' ')}".`,
123
+ [{name: again, reason: 'do this instead'}],
124
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
125
+ );
126
+ // A missing picture is the first thing to say, before a bad count.
127
+ if (
128
+ picture &&
129
+ words.length === 2 &&
130
+ !/^[1-9]\d*$/.test(words[1]) &&
131
+ fs.existsSync(path.resolve(cwd, words[0]))
132
+ )
133
+ throw new AstryxError(
134
+ `The count after a picture must be a positive whole number, not "${words[1]}".`,
135
+ [{name: again, reason: 'do this instead'}],
136
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
137
+ );
138
+ subject = picture ? words[0] : words.join(' ');
139
+ if (picture && words.length === 2)
140
+ options = {...options, count: Number(words[1])};
141
+ }
96
142
  const data = await answer(subject, options, cwd);
97
143
  return {type: 'themeEdit.how', data: withPrefix(data, cwd)};
98
144
  } catch (e) {
@@ -141,7 +187,17 @@ async function answer(subject, options, cwd) {
141
187
  refuse(E.ERR_INVALID_ARGUMENT, '--theme was given no name.', {
142
188
  run: [`${HOW} ${t ? JSON.stringify(t) : 'card'}`],
143
189
  });
144
- if (options.theme != null) loadTheme(cwd, options.theme);
190
+ if (options.theme != null) {
191
+ loadTheme(cwd, options.theme);
192
+ // A theme whose source no longer extends its settings takes no setting:
193
+ // an answer would suggest commands that cannot run.
194
+ const broken = themeSourceProblem(cwd, options.theme);
195
+ if (broken)
196
+ refuse(
197
+ E.ERR_THEME_INVALID,
198
+ `${broken}, so settings cannot take effect and no command here would change the theme. Put back the import, extends and name lines in themes/${options.theme}/${options.theme}.theme.ts, then ask again.`,
199
+ );
200
+ }
145
201
  if (list != null) {
146
202
  if (at.length)
147
203
  refuse(
@@ -253,12 +309,15 @@ async function answer(subject, options, cwd) {
253
309
  if (key === 'text' || key === 'background')
254
310
  results.unshift(
255
311
  ...['accent', 'neutral'].map(d => ({
256
- text: DIALS[d].help,
312
+ text: dialHelp(d, env),
257
313
  commands: dialCommands(d),
258
314
  })),
259
315
  );
260
316
  if (dial)
261
- results.unshift({text: DIALS[dial].help, commands: dialCommands(dial)});
317
+ results.unshift({
318
+ text: dialHelp(dial, env),
319
+ commands: dialCommands(dial),
320
+ });
262
321
  results.push({
263
322
  text: `for one part: ${HOW} <part> lists what it reads for ${key}`,
264
323
  commands: [`${HOW} button`],
@@ -267,12 +326,33 @@ async function answer(subject, options, cwd) {
267
326
  }
268
327
  if (Object.hasOwn(DIALS, key)) {
269
328
  const d = DIALS[key];
329
+ // A base is named only when it is installed here; the others are
330
+ // listed with the line that installs them.
331
+ const installed = (/** @type {string} */ b) => {
332
+ try {
333
+ baseThemeFile(ctx.project, b);
334
+ return true;
335
+ } catch {
336
+ return false;
337
+ }
338
+ };
339
+ const missing = key === 'base' ? LIKE.filter(b => !installed(b)) : [];
270
340
  return {
271
341
  kind: 'setting',
272
342
  subject: t,
273
343
  source: 'dial',
274
- values: d.values,
275
- help: d.help,
344
+ values:
345
+ key === 'base'
346
+ ? [...LIKE.filter(installed), 'none'].join('|')
347
+ : d.values,
348
+ help:
349
+ dialHelp(key, env) +
350
+ (missing.length
351
+ ? ` Not installed here: ${missing.join(', ')} (${installLine(
352
+ ctx.project.cwd,
353
+ missing.map(b => `@astryxdesign/theme-${b}`),
354
+ )}).`
355
+ : ''),
276
356
  ...(PALETTE_DIALS.includes(key) ? {shades: mappingRows(key)} : {}),
277
357
  ...themeFields,
278
358
  examples: dialCommands(key),
@@ -320,6 +400,13 @@ async function answer(subject, options, cwd) {
320
400
  const tok = /--[a-z0-9-]+/i.exec(t)?.[0]?.toLowerCase();
321
401
  if (tok && Object.hasOwn(ctx.project.core.tokenDefaults, tok))
322
402
  return tokenAnswer(ctx, env, t, tok, unknown, themeFields);
403
+ // "what does spacing more do": the dial's own lookup, its values and
404
+ // what each does.
405
+ const dial = Object.keys(DIALS).find(d =>
406
+ new RegExp(`\\b${d}\\b`, 'i').test(t.replace(/--[a-z0-9-]+/gi, ' ')),
407
+ );
408
+ if (dial && !/\b(on|for)\s+(the\s+)?[a-z]+s?\b/i.test(t))
409
+ return {...(await answer(dial, options, cwd)), subject: t};
323
410
  const q = draftAnswer(ctx, env, t);
324
411
  const groups = q.aspects.filter(a => Object.hasOwn(GROUPS, a));
325
412
  const results = q.parts
@@ -385,7 +472,7 @@ function finish(env, drafts) {
385
472
  const lookups = d.lookup ? [d.lookup] : [];
386
473
  if (!commands.length && d.options.length && !lookups.length) {
387
474
  out.push({
388
- text: `${d.text}: no command does it on ${env.slug}`,
475
+ text: `${d.text}: no command does it on ${env.slug}${refused[0] ? `: ${refused[0].why}` : ''}`,
389
476
  commands: [],
390
477
  refused,
391
478
  });
@@ -798,7 +885,7 @@ async function listItems(kind, filter, cwd) {
798
885
  .map(([name, d]) => ({
799
886
  name,
800
887
  values: d.values,
801
- help: d.help,
888
+ help: dialHelp(name, env),
802
889
  examples: d.examples
803
890
  .map(exampleStep)
804
891
  .filter(st => st != null)
@@ -32,16 +32,13 @@ export function paletteFiles(slug: string): {
32
32
  */
33
33
  export function seedOf(value: string): string | null;
34
34
  /**
35
- * How well citation text (`--color-text-secondary`) reads on the accent
36
- * tint (`--color-accent-muted`) in the official neutral theme, per mode:
37
- * both tokens' stops come from its theme source and their colors from its
38
- * selected palette stops, read from the installed package. Without the
39
- * package, the same official stops of a plain gray ramp from the
40
- * generator. Null when neither can be read.
41
- * @param {Mode} m
42
- * @returns {number | null}
35
+ * The modes a theme has: one for a one-mode theme, else light and dark.
36
+ * @param {{mode?: string}} data
37
+ * @returns {Mode[]}
43
38
  */
44
- export function officialCitation(m: Mode): number | null;
39
+ export function modesOf(data: {
40
+ mode?: string;
41
+ }): Mode[];
45
42
  /**
46
43
  * The palette config a theme's settings ask for (see {@link planPalette}),
47
44
  * or null when it would hold no family.
@@ -83,10 +80,13 @@ export function syncPalette(cwd: string, slug: string, data: {
83
80
  dark: Record<string, string>;
84
81
  }): string[];
85
82
  /**
86
- * Whether a theme's palette file was edited by hand: its bytes match no
87
- * receipt, and, formatting aside, it is not what the generator writes for
88
- * the request it came from (the receipt's, else the config's). False when
89
- * there is no palette file.
83
+ * Whether a theme's palette file was edited by hand. Its bytes match its
84
+ * receipt, or its colors (read as data, so formatting, a BOM or semicolons
85
+ * never count) are the ones the generator gives for the request it came
86
+ * from: the receipt's, else the config the editor wrote. Without a receipt
87
+ * and with a config edited by hand since, the request is unknown; then the
88
+ * file counts as the editor's when it holds every shade the theme ships
89
+ * (the selected-stops file) unchanged. False when there is no palette file.
90
90
  * @param {string} cwd
91
91
  * @param {string} slug
92
92
  */
@@ -133,6 +133,13 @@ export function paletteMapping(cwd: string, slug: string, data: import("./_setti
133
133
  light: Record<string, string>;
134
134
  dark: Record<string, string>;
135
135
  }, tokenDefaults: Record<string, unknown>): PaletteMapping | null;
136
+ /**
137
+ * The color dial whose generated colors a token belongs to, or null: an
138
+ * exact setting of it changes what that dial's mapping picks around it.
139
+ * @param {string} token
140
+ * @returns {string | null}
141
+ */
142
+ export function paletteDialOf(token: string): string | null;
136
143
  /**
137
144
  * Where each token starts, for `how`: `token: light stop L, dark stop D`.
138
145
  * @param {string} dial
@@ -175,6 +182,7 @@ export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: str
175
182
  * @property {number} needs
176
183
  * @property {boolean} pass
177
184
  * @property {string} [note] - The whole sentence to report, when the check is not a plain stop move.
185
+ * @property {string[]} [dials] - The color dials whose notes report it, when its token belongs to none of them.
178
186
  */
179
187
  /**
180
188
  * The palette mapping of a theme.
@@ -186,12 +194,21 @@ export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: str
186
194
  * @property {number} vibrancy - The generator's vibrancy, 0 to 100.
187
195
  * @property {Record<string, Partial<Record<Mode, string>>>} exact - Main tokens the theme sets exactly, the value per mode: the dial's fill gives way to them.
188
196
  * @property {string[]} notes - What the config writer kept or replaced of a hand edit.
197
+ * @property {Record<string, Partial<Record<Mode, StopRef>>> | null} lift - Lifted secondary text per background token of LIFT_PARTS (the accent tint, the neutral track), per mode, from the neutral color; null without one.
189
198
  */
190
199
  /** The color dials. Each one is a palette family of the same id. */
191
200
  export const PALETTE_DIALS: string[];
192
201
  /** The generator's vibrancy when the theme sets none. */
193
202
  export const VIBRANCY_DEFAULT: 50;
194
203
  export function paletteToken(dial: string): string;
204
+ /**
205
+ * The parts whose secondary text the official neutral theme lifts, with
206
+ * the block it lifts it in and what the text sits on: the accent tint
207
+ * under selected items and tree rows, a dropzone and numbered citations;
208
+ * the translucent neutral track (`--color-neutral`) under segmented-control
209
+ * labels.
210
+ */
211
+ export const LIFT_PARTS: Array<[string, string, string]>;
195
212
  export function paletteImport(slug: string): string;
196
213
  export function isGraySeed(seed: string | null): boolean;
197
214
  /** Every token a color dial can point at a generated shade. */
@@ -261,6 +278,10 @@ export type ContrastCheck = {
261
278
  * - The whole sentence to report, when the check is not a plain stop move.
262
279
  */
263
280
  note?: string | undefined;
281
+ /**
282
+ * - The color dials whose notes report it, when its token belongs to none of them.
283
+ */
284
+ dials?: string[] | undefined;
264
285
  };
265
286
  /**
266
287
  * The palette mapping of a theme.
@@ -291,4 +312,8 @@ export type PaletteMapping = {
291
312
  * - What the config writer kept or replaced of a hand edit.
292
313
  */
293
314
  notes: string[];
315
+ /**
316
+ * - Lifted secondary text per background token of LIFT_PARTS (the accent tint, the neutral track), per mode, from the neutral color; null without one.
317
+ */
318
+ lift: Record<string, Partial<Record<Mode, StopRef>>> | null;
294
319
  };