@astryxdesign/cli 0.7.14-canary.gfdb9213 → 0.7.14

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 (95) hide show
  1. package/CHANGELOG.md +197 -0
  2. package/api/theme/_adapter.d.mts +33 -0
  3. package/api/theme/_adapter.mjs +352 -16
  4. package/api/theme/build/build.mjs +261 -10
  5. package/api/theme/eject/eject.mjs +13 -1
  6. package/api/theme/list/list.mjs +11 -2
  7. package/api/theme/template/template.mjs +139 -6
  8. package/api/theme/theme.type.d.mts +15 -1
  9. package/api/theme/theme.type.mjs +9 -3
  10. package/api/theme/themeAdd.doc.mjs +1 -1
  11. package/api/theme/themeBuild.doc.mjs +10 -2
  12. package/api/theme/themeEject.doc.mjs +2 -2
  13. package/api/theme/themeListAvailable.doc.mjs +1 -1
  14. package/api/theme/themeRemove.doc.mjs +1 -1
  15. package/api/theme/themeTemplate.doc.mjs +8 -0
  16. package/api/theme/themeUse.doc.mjs +1 -1
  17. package/api/theme-edit/_adapter.d.mts +10 -2
  18. package/api/theme-edit/_adapter.mjs +52 -31
  19. package/api/theme-edit/_check.d.mts +28 -25
  20. package/api/theme-edit/_check.mjs +586 -548
  21. package/api/theme-edit/_color.d.mts +28 -2
  22. package/api/theme-edit/_color.mjs +306 -68
  23. package/api/theme-edit/_compiler.d.mts +8 -4
  24. package/api/theme-edit/_compiler.mjs +30 -27
  25. package/api/theme-edit/_context.d.mts +10 -4
  26. package/api/theme-edit/_context.mjs +21 -4
  27. package/api/theme-edit/_edit.mjs +300 -43
  28. package/api/theme-edit/_how-commands.d.mts +91 -0
  29. package/api/theme-edit/_how-commands.mjs +269 -0
  30. package/api/theme-edit/_how-question.d.mts +57 -0
  31. package/api/theme-edit/_how-question.mjs +2574 -0
  32. package/api/theme-edit/_how.d.mts +25 -17
  33. package/api/theme-edit/_how.mjs +727 -305
  34. package/api/theme-edit/_palette.d.mts +127 -19
  35. package/api/theme-edit/_palette.mjs +1313 -399
  36. package/api/theme-edit/_parts.mjs +36 -3
  37. package/api/theme-edit/_png.d.mts +18 -6
  38. package/api/theme-edit/_png.mjs +135 -25
  39. package/api/theme-edit/_preview-app.d.mts +26 -7
  40. package/api/theme-edit/_preview-app.mjs +1611 -280
  41. package/api/theme-edit/_preview.d.mts +4 -2
  42. package/api/theme-edit/_preview.mjs +18 -7
  43. package/api/theme-edit/_settings.d.mts +56 -5
  44. package/api/theme-edit/_settings.mjs +197 -49
  45. package/api/theme-edit/_tables.d.mts +0 -12
  46. package/api/theme-edit/_tables.mjs +24 -97
  47. package/api/theme-edit/theme-edit.type.d.mts +22 -5
  48. package/api/theme-edit/theme-edit.type.mjs +17 -6
  49. package/api/theme-edit/themeEditHow.doc.mjs +13 -3
  50. package/api/theme-edit/themeEditNew.doc.mjs +2 -1
  51. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +16 -4
  52. package/api/theme-edit/themeEditPreviewApp.doc.mjs +12 -4
  53. package/api/theme-edit/themeEditPreviewList.doc.mjs +9 -1
  54. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +27 -2
  55. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  56. package/assets/docs.generated.json +1 -0
  57. package/assets/preview-app/gitignore +3 -0
  58. package/assets/templates/components.generated.json +1 -0
  59. package/clients/cli/bin/astryx.mjs +37 -5
  60. package/clients/cli/commands/experimental/theme.mjs +231 -31
  61. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +14 -5
  62. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -1
  63. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  64. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +3 -2
  65. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
  66. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +2 -2
  67. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  68. package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -1
  69. package/clients/cli/commands/experimental-theme.doc.mjs +2 -2
  70. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  71. package/clients/cli/commands/theme-eject.doc.mjs +3 -3
  72. package/clients/cli/commands/theme-remove.doc.mjs +2 -2
  73. package/clients/cli/commands/theme-template.doc.mjs +11 -4
  74. package/clients/cli/commands/theme.mjs +104 -40
  75. package/clients/cli/commands.generated.json +1 -0
  76. package/clients/cli/index.mjs +96 -4
  77. package/clients/cli/lib/json-shim.mjs +29 -1
  78. package/foundation/config/project.d.mts +16 -2
  79. package/foundation/config/project.mjs +40 -6
  80. package/foundation/config/theme-state.d.mts +9 -0
  81. package/foundation/config/theme-state.mjs +20 -1
  82. package/foundation/discovery/template-adapter.d.mts +12 -1
  83. package/foundation/discovery/template-adapter.mjs +24 -1
  84. package/foundation/discovery/template-needs.d.mts +7 -0
  85. package/foundation/discovery/template-needs.mjs +117 -8
  86. package/foundation/discovery/template-source-tree.d.mts +5 -1
  87. package/foundation/discovery/template-source-tree.mjs +6 -4
  88. package/foundation/discovery/theme-discovery.d.mts +14 -3
  89. package/foundation/discovery/theme-discovery.mjs +45 -12
  90. package/foundation/doc-compiler/import.mjs +68 -3
  91. package/foundation/doc-compiler/stored-docs.d.mts +27 -0
  92. package/foundation/doc-compiler/stored-docs.mjs +65 -0
  93. package/foundation/fs/fs-error.d.mts +17 -0
  94. package/foundation/fs/fs-error.mjs +34 -0
  95. package/package.json +6 -6
@@ -21,35 +21,103 @@ export function paletteFiles(slug: string): {
21
21
  config: string;
22
22
  palette: string;
23
23
  receipt: string;
24
+ refs: string;
24
25
  importPath: string;
26
+ refsImportPath: string;
25
27
  };
26
28
  /**
27
- * The seed a color dial value grows from, or null for a value with no fixed
28
- * color (a variable, a keyword, `color-mix()`).
29
+ * The seed a color dial value grows from, or null for a value with no fixed,
30
+ * opaque color (a variable, a keyword, `color-mix()`, a translucent color).
29
31
  * @param {string} value
30
32
  */
31
33
  export function seedOf(value: string): string | null;
32
34
  /**
33
- * The palette config a theme's settings ask for: the existing config, with
34
- * each color dial's family written in place and families the dials no longer
35
- * set removed, and `vibrancy` as the vibrancy dial sets it (absent without
36
- * the dial). Other families and fields are kept. Null when the config would
37
- * hold no family.
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}
43
+ */
44
+ export function officialCitation(m: Mode): number | null;
45
+ /**
46
+ * The palette config a theme's settings ask for (see {@link planPalette}),
47
+ * or null when it would hold no family.
38
48
  * @param {string} cwd
39
49
  * @param {string} slug
40
- * @param {import('./_settings.mjs').ThemeData} data
50
+ * @param {{mode?: string, settings: Setting[]}} data
51
+ * @param {{light: Record<string, string>, dark: Record<string, string>}} [base]
41
52
  * @returns {any}
42
53
  */
43
- export function paletteConfig(cwd: string, slug: string, data: import("./_settings.mjs").ThemeData): any;
54
+ export function paletteConfig(cwd: string, slug: string, data: {
55
+ mode?: string;
56
+ settings: Setting[];
57
+ }, base?: {
58
+ light: Record<string, string>;
59
+ dark: Record<string, string>;
60
+ }): any;
44
61
  /**
45
62
  * Write the palette config, palette and receipt the settings ask for, with
46
- * the same generator as `theme palette generate --out`; remove all three
47
- * when no family is left. Files are only rewritten when the config changes.
63
+ * the same generator as `theme palette generate --out`; remove them all
64
+ * when no family is left. The palette is generated again when the config
65
+ * changes, when a file is missing, or when it came from another generator
66
+ * version. A palette edited by hand ({@link paletteEdited}) is never
67
+ * overwritten: a change that would rewrite it is refused with the commands
68
+ * that keep or discard the edit; a change that leaves it alone goes ahead. Gives back what the config writer kept or replaced
69
+ * of a hand edit, for the result notes.
48
70
  * @param {string} cwd
49
71
  * @param {string} slug
50
- * @param {import('./_settings.mjs').ThemeData} data
72
+ * @param {{mode?: string, settings: Setting[], palette?: string}} data
73
+ * `palette`: the hash of the config the editor wrote, kept in the settings
74
+ * @param {{light: Record<string, string>, dark: Record<string, string>}} [base]
75
+ * @returns {string[]}
76
+ */
77
+ export function syncPalette(cwd: string, slug: string, data: {
78
+ mode?: string;
79
+ settings: Setting[];
80
+ palette?: string;
81
+ }, base?: {
82
+ light: Record<string, string>;
83
+ dark: Record<string, string>;
84
+ }): string[];
85
+ /**
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.
90
+ * @param {string} cwd
91
+ * @param {string} slug
92
+ */
93
+ export function paletteEdited(cwd: string, slug: string): boolean;
94
+ /**
95
+ * Refuse generated text that still holds a stop placeholder: the CSS would
96
+ * carry it as a value no browser reads.
97
+ * @param {string} file shown in the refusal
98
+ * @param {string} text
51
99
  */
52
- export function syncPalette(cwd: string, slug: string, data: import("./_settings.mjs").ThemeData): void;
100
+ export function assertNoPlaceholder(file: string, text: string): void;
101
+ /**
102
+ * The module of only the stops a generated settings source reads, in the
103
+ * shape `scripts/generate-selected-palette-refs.mjs` gives the official
104
+ * themes, or null when it reads none.
105
+ * @param {string} slug
106
+ * @param {Candidate} candidate
107
+ * @param {string} source
108
+ * @returns {string | null}
109
+ */
110
+ export function paletteRefsSource(slug: string, candidate: Candidate, source: string): string | null;
111
+ /**
112
+ * Write the selected stops module beside the palette for a generated
113
+ * settings source, or remove it when the source reads no stop. A source
114
+ * that still holds a stop placeholder is refused.
115
+ * @param {string} cwd
116
+ * @param {string} slug
117
+ * @param {string} source the generated settings source
118
+ * @param {PaletteMapping | null} pal
119
+ */
120
+ export function syncPaletteRefs(cwd: string, slug: string, source: string, pal: PaletteMapping | null): void;
53
121
  /**
54
122
  * The colors and token mapping of a theme's palette, or null when it sets no
55
123
  * color dial. Reads the config the settings ask for and runs the generator
@@ -72,8 +140,10 @@ export function paletteMapping(cwd: string, slug: string, data: import("./_setti
72
140
  */
73
141
  export function mappingRows(dial: string): string[];
74
142
  /**
75
- * What one color dial did, for the result notes: the shade of its main token
143
+ * What one color dial did, for the result notes: what its main token uses
76
144
  * in each mode, every token contrast moved, and last the generated files.
145
+ * What the config writer kept or replaced of a hand edit comes from the
146
+ * build ({@link syncPalette}).
77
147
  * @param {PaletteMapping | null} pal
78
148
  * @param {string} dial
79
149
  * @param {string} slug
@@ -82,14 +152,16 @@ export function mappingRows(dial: string): string[];
82
152
  */
83
153
  export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: string, modes?: Mode[]): string[];
84
154
  /** @typedef {'light' | 'dark'} Mode */
155
+ /** @typedef {import('./_settings.mjs').Setting} Setting */
85
156
  /** @typedef {import('../theme/theme.type.mjs').TonalPaletteCandidate} Candidate */
86
157
  /**
87
158
  * One token pointed at a palette stop in each mode.
88
159
  * @typedef {object} StopRef
89
160
  * @property {number} stop
90
- * @property {Mode} [from] - The ramp the stop is from when it is not the token's own mode: a dark fill that keeps the exact color takes the light ramp's stop.
91
161
  * @property {string} color - The stop's color, with `alpha` appended when set.
92
162
  * @property {string} [alpha] - Two hex digits of opacity.
163
+ * @property {string} [family] - The family the stop is from when it is not the token's own: `neutral` for text on a fill, or `black` / `white`, the palette's own ends.
164
+ * @property {boolean} [exact] - The stop holds the seed's exact color (an exact anchor).
93
165
  */
94
166
  /**
95
167
  * One contrast check behind a stop choice.
@@ -102,6 +174,7 @@ export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: str
102
174
  * @property {number} ratio - The lowest ratio over everything it was measured on.
103
175
  * @property {number} needs
104
176
  * @property {boolean} pass
177
+ * @property {string} [note] - The whole sentence to report, when the check is not a plain stop move.
105
178
  */
106
179
  /**
107
180
  * The palette mapping of a theme.
@@ -111,26 +184,41 @@ export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: str
111
184
  * @property {Record<string, {family: string, light: StopRef, dark: StopRef}>} tokens
112
185
  * @property {ContrastCheck[]} contrast
113
186
  * @property {number} vibrancy - The generator's vibrancy, 0 to 100.
187
+ * @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
+ * @property {string[]} notes - What the config writer kept or replaced of a hand edit.
114
189
  */
115
190
  /** The color dials. Each one is a palette family of the same id. */
116
191
  export const PALETTE_DIALS: string[];
117
192
  /** The generator's vibrancy when the theme sets none. */
118
193
  export const VIBRANCY_DEFAULT: 50;
119
194
  export function paletteToken(dial: string): string;
195
+ export function paletteImport(slug: string): string;
120
196
  export function isGraySeed(seed: string | null): boolean;
121
197
  /** Every token a color dial can point at a generated shade. */
122
198
  export const PALETTE_TOKENS: Set<string>;
199
+ /**
200
+ * What the config writer decided: the config, what it kept or replaced of
201
+ * a hand edit, and for each accent or status color the stop of its exact
202
+ * color and whether dark mode holds it too (why not, when not).
203
+ */
204
+ export type PalettePlan = {
205
+ config: any;
206
+ notes: string[];
207
+ fills: Record<string, {
208
+ stop: number;
209
+ dark: boolean;
210
+ why: string;
211
+ ratio: number;
212
+ }>;
213
+ };
123
214
  export type Mode = "light" | "dark";
215
+ export type Setting = import("./_settings.mjs").Setting;
124
216
  export type Candidate = import("../theme/theme.type.mjs").TonalPaletteCandidate;
125
217
  /**
126
218
  * One token pointed at a palette stop in each mode.
127
219
  */
128
220
  export type StopRef = {
129
221
  stop: number;
130
- /**
131
- * - The ramp the stop is from when it is not the token's own mode: a dark fill that keeps the exact color takes the light ramp's stop.
132
- */
133
- from?: Mode | undefined;
134
222
  /**
135
223
  * - The stop's color, with `alpha` appended when set.
136
224
  */
@@ -139,6 +227,14 @@ export type StopRef = {
139
227
  * - Two hex digits of opacity.
140
228
  */
141
229
  alpha?: string | undefined;
230
+ /**
231
+ * - The family the stop is from when it is not the token's own: `neutral` for text on a fill, or `black` / `white`, the palette's own ends.
232
+ */
233
+ family?: string | undefined;
234
+ /**
235
+ * - The stop holds the seed's exact color (an exact anchor).
236
+ */
237
+ exact?: boolean | undefined;
142
238
  };
143
239
  /**
144
240
  * One contrast check behind a stop choice.
@@ -161,6 +257,10 @@ export type ContrastCheck = {
161
257
  ratio: number;
162
258
  needs: number;
163
259
  pass: boolean;
260
+ /**
261
+ * - The whole sentence to report, when the check is not a plain stop move.
262
+ */
263
+ note?: string | undefined;
164
264
  };
165
265
  /**
166
266
  * The palette mapping of a theme.
@@ -183,4 +283,12 @@ export type PaletteMapping = {
183
283
  * - The generator's vibrancy, 0 to 100.
184
284
  */
185
285
  vibrancy: number;
286
+ /**
287
+ * - Main tokens the theme sets exactly, the value per mode: the dial's fill gives way to them.
288
+ */
289
+ exact: Record<string, Partial<Record<Mode, string>>>;
290
+ /**
291
+ * - What the config writer kept or replaced of a hand edit.
292
+ */
293
+ notes: string[];
186
294
  };