@astryxdesign/cli 0.7.13 → 0.7.14-canary.d08ce65

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 (146) hide show
  1. package/README.md +18 -18
  2. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  3. package/api/doctor/doctor.mjs +3 -7
  4. package/api/experimental.d.mts +2 -0
  5. package/api/experimental.mjs +10 -0
  6. package/api/icon/_adapter.d.mts +10 -0
  7. package/api/icon/_adapter.mjs +31 -2
  8. package/api/icon/_authoring.d.mts +2 -1
  9. package/api/icon/_authoring.mjs +91 -6
  10. package/api/icon/_options.mjs +1 -0
  11. package/api/icon/_records.d.mts +18 -0
  12. package/api/icon/_records.mjs +26 -0
  13. package/api/icon/add/add.mjs +7 -1
  14. package/api/icon/definitions/definitions.d.mts +12 -0
  15. package/api/icon/definitions/definitions.mjs +83 -0
  16. package/api/icon/icon.doc.mjs +5 -4
  17. package/api/icon/icon.mjs +5 -16
  18. package/api/icon/icon.type.d.mts +29 -2
  19. package/api/icon/icon.type.mjs +17 -3
  20. package/api/icon/iconAdd.doc.mjs +1 -1
  21. package/api/icon/iconMap.doc.mjs +2 -2
  22. package/api/icon/iconNewSet.doc.mjs +8 -2
  23. package/api/icon/map/map.mjs +21 -2
  24. package/api/icon/new-set/new-set.mjs +14 -2
  25. package/api/icon/search/search.mjs +2 -15
  26. package/api/icon/use/use.mjs +4 -3
  27. package/api/integration/validate-integration.mjs +6 -1
  28. package/api/integration/validate-integration.type.d.mts +12 -0
  29. package/api/integration/validate-integration.type.mjs +5 -0
  30. package/api/theme-edit/_adapter.d.mts +96 -0
  31. package/api/theme-edit/_adapter.mjs +1039 -0
  32. package/api/theme-edit/_catalog.d.mts +59 -0
  33. package/api/theme-edit/_catalog.mjs +564 -0
  34. package/api/theme-edit/_check.d.mts +49 -0
  35. package/api/theme-edit/_check.mjs +842 -0
  36. package/api/theme-edit/_color.d.mts +35 -0
  37. package/api/theme-edit/_color.mjs +125 -0
  38. package/api/theme-edit/_compiler.d.mts +61 -0
  39. package/api/theme-edit/_compiler.mjs +522 -0
  40. package/api/theme-edit/_css-properties.d.mts +10 -0
  41. package/api/theme-edit/_css-properties.mjs +556 -0
  42. package/api/theme-edit/_parts.d.mts +111 -0
  43. package/api/theme-edit/_parts.mjs +409 -0
  44. package/api/theme-edit/_png.d.mts +40 -0
  45. package/api/theme-edit/_png.mjs +187 -0
  46. package/api/theme-edit/_preview.d.mts +86 -0
  47. package/api/theme-edit/_preview.mjs +564 -0
  48. package/api/theme-edit/_project.d.mts +83 -0
  49. package/api/theme-edit/_project.mjs +289 -0
  50. package/api/theme-edit/_settings.d.mts +222 -0
  51. package/api/theme-edit/_settings.mjs +848 -0
  52. package/api/theme-edit/_tables.d.mts +130 -0
  53. package/api/theme-edit/_tables.mjs +697 -0
  54. package/api/theme-edit/theme-edit.d.mts +89 -0
  55. package/api/theme-edit/theme-edit.mjs +119 -0
  56. package/api/theme-edit/theme-edit.type.d.mts +270 -0
  57. package/api/theme-edit/theme-edit.type.mjs +155 -0
  58. package/api/theme-edit/themeEditExplain.doc.d.mts +6 -0
  59. package/api/theme-edit/themeEditExplain.doc.mjs +88 -0
  60. package/api/theme-edit/themeEditNew.doc.d.mts +6 -0
  61. package/api/theme-edit/themeEditNew.doc.mjs +89 -0
  62. package/api/theme-edit/themeEditPreview.doc.d.mts +6 -0
  63. package/api/theme-edit/themeEditPreview.doc.mjs +96 -0
  64. package/api/theme-edit/themeEditReset.doc.d.mts +6 -0
  65. package/api/theme-edit/themeEditReset.doc.mjs +161 -0
  66. package/api/theme-edit/themeEditSet.doc.d.mts +6 -0
  67. package/api/theme-edit/themeEditSet.doc.mjs +165 -0
  68. package/api/theme-edit/themeEditShow.doc.d.mts +6 -0
  69. package/api/theme-edit/themeEditShow.doc.mjs +86 -0
  70. package/api/theme-edit/themeEditUndo.doc.d.mts +6 -0
  71. package/api/theme-edit/themeEditUndo.doc.mjs +80 -0
  72. package/assets/docs/color.doc.mjs +5 -5
  73. package/assets/docs/tree/icon-sets.doc.mjs +6 -2
  74. package/assets/docs/tree/tokens-border.doc.mjs +1 -1
  75. package/assets/docs/tree/tokens-color.doc.mjs +2 -2
  76. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  77. package/assets/docs/tree/tokens-duration.doc.mjs +1 -1
  78. package/assets/docs/tree/tokens-ease.doc.mjs +1 -1
  79. package/assets/docs/tree/tokens-focus.doc.mjs +1 -1
  80. package/assets/docs/tree/tokens-font-weight.doc.mjs +1 -1
  81. package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
  82. package/assets/docs/tree/tokens-shadow.doc.mjs +1 -1
  83. package/assets/docs/tree/tokens-size.doc.mjs +1 -1
  84. package/assets/docs/tree/tokens-spacing.doc.mjs +1 -1
  85. package/assets/docs/tree/tokens-syntax.doc.mjs +1 -1
  86. package/assets/docs/tree/tokens-text-size.doc.mjs +1 -1
  87. package/assets/docs/tree/tokens-type-scale.doc.mjs +1 -1
  88. package/assets/docs/tree/tokens-typography.doc.mjs +1 -1
  89. package/assets/icons/definitions/bank.doc.mjs +1 -1
  90. package/assets/icons/definitions/save.doc.mjs +1 -1
  91. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +2 -1
  92. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +2 -1
  93. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider03RtlDirection.doc.mjs +2 -1
  94. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +2 -1
  95. package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
  96. package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
  97. package/authoring/doctypes/_schema.d.mts +1 -0
  98. package/authoring/doctypes/_schema.mjs +1 -0
  99. package/authoring/doctypes/command/command.doc.mjs +7 -0
  100. package/authoring/doctypes/command/type.ts +3 -0
  101. package/authoring/doctypes/icon-set/parse.d.mts +7 -0
  102. package/authoring/doctypes/icon-set/parse.mjs +18 -8
  103. package/clients/cli/commands/doctor.mjs +33 -3
  104. package/clients/cli/commands/experimental/icon.mjs +67 -14
  105. package/clients/cli/commands/experimental/index.mjs +2 -0
  106. package/clients/cli/commands/experimental/theme.mjs +542 -0
  107. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +7 -1
  108. package/clients/cli/commands/experimental-icon.doc.mjs +3 -2
  109. package/clients/cli/commands/experimental-theme-add.doc.mjs +78 -0
  110. package/clients/cli/commands/experimental-theme-compile.doc.mjs +97 -0
  111. package/clients/cli/commands/experimental-theme-eject.doc.mjs +71 -0
  112. package/clients/cli/commands/experimental-theme-explain.doc.mjs +84 -0
  113. package/clients/cli/commands/experimental-theme-list.doc.mjs +49 -0
  114. package/clients/cli/commands/experimental-theme-new.doc.mjs +66 -0
  115. package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +73 -0
  116. package/clients/cli/commands/experimental-theme-palette.doc.mjs +37 -0
  117. package/clients/cli/commands/experimental-theme-preview.doc.mjs +76 -0
  118. package/clients/cli/commands/experimental-theme-remove.doc.mjs +55 -0
  119. package/clients/cli/commands/experimental-theme-reset.doc.mjs +103 -0
  120. package/clients/cli/commands/experimental-theme-set.doc.mjs +121 -0
  121. package/clients/cli/commands/experimental-theme-show.doc.mjs +66 -0
  122. package/clients/cli/commands/experimental-theme-targets.doc.mjs +61 -0
  123. package/clients/cli/commands/experimental-theme-template.doc.mjs +61 -0
  124. package/clients/cli/commands/experimental-theme-undo.doc.mjs +55 -0
  125. package/clients/cli/commands/experimental-theme-use.doc.mjs +55 -0
  126. package/clients/cli/commands/experimental-theme.doc.mjs +66 -0
  127. package/clients/cli/commands/experimental.doc.mjs +10 -3
  128. package/clients/cli/commands/theme.mjs +101 -34
  129. package/clients/cli/index.mjs +16 -0
  130. package/clients/cli/lib/define-command.mjs +3 -0
  131. package/foundation/discovery/icon-set-checks.d.mts +16 -1
  132. package/foundation/discovery/icon-set-checks.mjs +68 -7
  133. package/foundation/discovery/icon-set-discovery.d.mts +21 -6
  134. package/foundation/discovery/icon-set-discovery.mjs +17 -8
  135. package/foundation/discovery/template-icon-meanings.d.mts +39 -0
  136. package/foundation/discovery/template-icon-meanings.mjs +95 -0
  137. package/foundation/discovery/theming-targets.d.mts +6 -0
  138. package/foundation/discovery/theming-targets.mjs +33 -0
  139. package/foundation/response/error-codes.d.mts +12 -1
  140. package/foundation/response/error-codes.doc.mjs +66 -0
  141. package/foundation/response/error-codes.mjs +55 -0
  142. package/foundation/response/response-types.doc.mjs +43 -0
  143. package/foundation/text/template-meanings-line.d.mts +16 -0
  144. package/foundation/text/template-meanings-line.mjs +37 -0
  145. package/foundation/xle/browser.d.mts +2 -2
  146. package/package.json +6 -6
@@ -0,0 +1,697 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The data behind `astryx experimental theme`: the dials and their
5
+ * rungs, the part families, the built-in themes a theme can build on, and the
6
+ * words `how` understands. A new dial, rung, family or word is a table entry
7
+ * here with a test, not new code.
8
+ *
9
+ * @position api/theme-edit — data read by the engine and the help text
10
+ */
11
+
12
+ /** The command prefix every suggested command starts with. */
13
+ export const P = 'astryx experimental theme';
14
+
15
+ /** The built-in themes a theme can build on (`new --like`, `set base`). */
16
+ export const LIKE = [
17
+ 'neutral',
18
+ 'stone',
19
+ 'matcha',
20
+ 'y2k',
21
+ 'gothic',
22
+ 'chocolate',
23
+ 'butter',
24
+ ];
25
+
26
+ /**
27
+ * Parts that should look alike. `--on <family>` styles every member.
28
+ * @type {Record<string, string[]>}
29
+ */
30
+ export const FAMILIES = {
31
+ inputs: [
32
+ 'text-input',
33
+ 'text-area',
34
+ 'number-input',
35
+ 'date-input',
36
+ 'time-input',
37
+ 'date-time-input',
38
+ 'date-range-input',
39
+ 'selector',
40
+ 'multi-selector',
41
+ 'complex-selector',
42
+ 'typeahead',
43
+ 'tokenizer',
44
+ ],
45
+ containers: [
46
+ 'card',
47
+ 'dialog',
48
+ 'drawer',
49
+ 'popover',
50
+ 'hover-card',
51
+ 'bottom-sheet',
52
+ 'selectable-card',
53
+ 'clickable-card',
54
+ ],
55
+ checks: ['checkbox-indicator', 'radio-indicator'],
56
+ menus: [
57
+ 'dropdown-menu',
58
+ 'selector-popup',
59
+ 'multi-selector-popup',
60
+ 'typeahead-dropdown',
61
+ 'context-menu',
62
+ ],
63
+ };
64
+
65
+ /**
66
+ * Families whose members always look alike: styling one member styles them
67
+ * all unless `--only` is given. Other families spread only when `--on`
68
+ * names the family itself.
69
+ */
70
+ export const AUTO_SPREAD = ['inputs', 'checks'];
71
+
72
+ /** @param {string} target @returns {string | null} */
73
+ export const familyOf = target =>
74
+ Object.entries(FAMILIES).find(([, members]) =>
75
+ members.includes(target),
76
+ )?.[0] ?? null;
77
+
78
+ /** @type {Array<[string, number]>} */
79
+ export const CORNERS = [
80
+ ['square', 0],
81
+ ['small', 8],
82
+ ['medium', 10],
83
+ ['large', 12],
84
+ ['round', 16],
85
+ ['pill', 9999],
86
+ ];
87
+ /** @type {Array<[string, number]>} */
88
+ export const SPACING = [
89
+ ['tight', 0.75],
90
+ ['compact', 0.875],
91
+ ['medium', 1],
92
+ ['roomy', 1.125],
93
+ ['spacious', 1.25],
94
+ ];
95
+ /** @type {Array<[string, number]>} */
96
+ export const TEXT_SIZE = [
97
+ ['small', 13],
98
+ ['medium', 14],
99
+ ['large', 15],
100
+ ['larger', 16],
101
+ ];
102
+
103
+ /**
104
+ * Font presets: the family, then its fallbacks.
105
+ * @type {Record<string, [string, string]>}
106
+ */
107
+ export const FONTS = {
108
+ system: ['system-ui', '-apple-system, "Segoe UI", Roboto, sans-serif'],
109
+ tahoma: ['Tahoma', 'Verdana, "Segoe UI", sans-serif'],
110
+ verdana: ['Verdana', 'Tahoma, sans-serif'],
111
+ segoe: ['Segoe UI', 'Tahoma, sans-serif'],
112
+ helvetica: ['Helvetica', 'Arial, sans-serif'],
113
+ georgia: ['Georgia', '"Times New Roman", serif'],
114
+ serif: ['Georgia', '"Times New Roman", serif'],
115
+ mono: ['ui-monospace', '"SF Mono", Menlo, Consolas, monospace'],
116
+ courier: ['Courier New', 'Courier, monospace'],
117
+ rounded: ['Nunito', '"Varela Round", system-ui, sans-serif'],
118
+ comic: ['Comic Sans MS', '"Comic Neue", cursive'],
119
+ };
120
+ /** Presets every desktop system already has, so no font file is needed. */
121
+ export const SYSTEM_FONTS = [
122
+ 'system',
123
+ 'tahoma',
124
+ 'verdana',
125
+ 'segoe',
126
+ 'helvetica',
127
+ 'georgia',
128
+ 'serif',
129
+ 'mono',
130
+ 'courier',
131
+ ];
132
+
133
+ /**
134
+ * Open fonts with a package that loads them: preset -> family, fallbacks,
135
+ * and the package. When the package is installed, previews show the font;
136
+ * the app loads it by importing the package once.
137
+ * @type {Record<string, {family: string, fallbacks: string, pkg: string}>}
138
+ */
139
+ export const OPEN_FONTS = {
140
+ inter: {
141
+ family: 'Inter',
142
+ fallbacks: 'system-ui, sans-serif',
143
+ pkg: '@fontsource/inter',
144
+ },
145
+ roboto: {
146
+ family: 'Roboto',
147
+ fallbacks: 'system-ui, sans-serif',
148
+ pkg: '@fontsource/roboto',
149
+ },
150
+ poppins: {
151
+ family: 'Poppins',
152
+ fallbacks: 'system-ui, sans-serif',
153
+ pkg: '@fontsource/poppins',
154
+ },
155
+ figtree: {
156
+ family: 'Figtree',
157
+ fallbacks: 'system-ui, sans-serif',
158
+ pkg: '@fontsource/figtree',
159
+ },
160
+ 'dm-sans': {
161
+ family: 'DM Sans',
162
+ fallbacks: 'system-ui, sans-serif',
163
+ pkg: '@fontsource/dm-sans',
164
+ },
165
+ manrope: {
166
+ family: 'Manrope',
167
+ fallbacks: 'system-ui, sans-serif',
168
+ pkg: '@fontsource/manrope',
169
+ },
170
+ 'space-grotesk': {
171
+ family: 'Space Grotesk',
172
+ fallbacks: 'system-ui, sans-serif',
173
+ pkg: '@fontsource/space-grotesk',
174
+ },
175
+ 'ibm-plex-sans': {
176
+ family: 'IBM Plex Sans',
177
+ fallbacks: 'system-ui, sans-serif',
178
+ pkg: '@fontsource/ibm-plex-sans',
179
+ },
180
+ 'ibm-plex-mono': {
181
+ family: 'IBM Plex Mono',
182
+ fallbacks: 'ui-monospace, monospace',
183
+ pkg: '@fontsource/ibm-plex-mono',
184
+ },
185
+ 'jetbrains-mono': {
186
+ family: 'JetBrains Mono',
187
+ fallbacks: 'ui-monospace, monospace',
188
+ pkg: '@fontsource/jetbrains-mono',
189
+ },
190
+ nunito: {
191
+ family: 'Nunito',
192
+ fallbacks: 'system-ui, sans-serif',
193
+ pkg: '@fontsource/nunito',
194
+ },
195
+ 'source-serif': {
196
+ family: 'Source Serif 4',
197
+ fallbacks: 'Georgia, serif',
198
+ pkg: '@fontsource/source-serif-4',
199
+ },
200
+ 'mona-sans': {
201
+ family: 'Mona Sans',
202
+ fallbacks: 'system-ui, sans-serif',
203
+ pkg: '@fontsource/mona-sans',
204
+ },
205
+ geist: {
206
+ family: 'Geist Sans',
207
+ fallbacks: 'system-ui, sans-serif',
208
+ pkg: '@fontsource/geist-sans',
209
+ },
210
+ 'geist-mono': {
211
+ family: 'Geist Mono',
212
+ fallbacks: 'ui-monospace, monospace',
213
+ pkg: '@fontsource/geist-mono',
214
+ },
215
+ };
216
+
217
+ /**
218
+ * Brand fonts no package loads, and the closest open font, for the warning
219
+ * a theme that names one gets.
220
+ * @type {Record<string, string>}
221
+ */
222
+ export const CLOSEST_OPEN_FONT = {
223
+ 'sf pro': 'inter',
224
+ 'sf pro text': 'inter',
225
+ 'sf pro display': 'inter',
226
+ 'san francisco': 'inter',
227
+ '-apple-system': 'inter',
228
+ söhne: 'inter',
229
+ sohne: 'inter',
230
+ cereal: 'manrope',
231
+ 'airbnb cereal': 'manrope',
232
+ circular: 'dm-sans',
233
+ 'gt walsheim': 'dm-sans',
234
+ 'helvetica neue': 'inter',
235
+ 'segoe ui variable': 'inter',
236
+ 'gg sans': 'nunito',
237
+ whitney: 'nunito',
238
+ graphik: 'inter',
239
+ 'proxima nova': 'figtree',
240
+ avenir: 'nunito',
241
+ 'avenir next': 'nunito',
242
+ futura: 'poppins',
243
+ menlo: 'jetbrains-mono',
244
+ 'sf mono': 'jetbrains-mono',
245
+ };
246
+
247
+ /** Heading weights (`headings` dial): rung -> font-weight. */
248
+ export const HEADING_WEIGHTS = /** @type {Record<string, string>} */ ({
249
+ light: '300',
250
+ regular: '400',
251
+ medium: '500',
252
+ semibold: '600',
253
+ bold: '700',
254
+ heavy: '800',
255
+ });
256
+ /** Heading letter spacing (`headings` dial): rung -> letter-spacing. */
257
+ export const HEADING_TRACKING = /** @type {Record<string, string>} */ ({
258
+ tight: '-0.02em',
259
+ tighter: '-0.04em',
260
+ normal: '0',
261
+ wide: '0.02em',
262
+ });
263
+
264
+ /** The `surfaces` dial: how every container sits on the page. */
265
+ export const SURFACES = /** @type {Record<string, Record<string, string>>} */ ({
266
+ flat: {
267
+ borderStyle: 'none',
268
+ boxShadow: 'none',
269
+ backgroundColor: 'var(--color-background-muted)',
270
+ },
271
+ outlined: {
272
+ borderStyle: 'solid',
273
+ borderWidth: '1px',
274
+ borderColor: 'var(--color-border)',
275
+ boxShadow: 'none',
276
+ },
277
+ raised: {borderStyle: 'none', boxShadow: 'var(--shadow-med)'},
278
+ glass: {
279
+ backgroundColor:
280
+ 'color-mix(in srgb, var(--color-background-card) 72%, transparent)',
281
+ backdropFilter: 'blur(14px) saturate(1.4)',
282
+ borderStyle: 'solid',
283
+ borderWidth: '1px',
284
+ borderColor: 'rgb(255 255 255 / 0.22)',
285
+ boxShadow: 'var(--shadow-low)',
286
+ },
287
+ });
288
+ /** The parts the `surfaces` dial moves. */
289
+ export const SURFACE_PARTS = [
290
+ 'card',
291
+ 'dialog',
292
+ 'popover',
293
+ 'drawer',
294
+ 'hover-card',
295
+ 'dropdown-menu',
296
+ 'selector-popup',
297
+ 'banner-frame',
298
+ ];
299
+
300
+ /** The `type` dial: heading scale ratio, heading weight, heading letter spacing. */
301
+ export const TYPE_STYLES =
302
+ /** @type {Record<string, {ratio: number, weight: string | null, tracking: string | null}>} */ ({
303
+ compact: {ratio: 1.15, weight: '600', tracking: '0'},
304
+ standard: {ratio: 1.2, weight: null, tracking: null},
305
+ editorial: {ratio: 1.3, weight: '600', tracking: '-0.02em'},
306
+ display: {ratio: 1.4, weight: '800', tracking: '-0.035em'},
307
+ });
308
+
309
+ /**
310
+ * @typedef {object} Dial
311
+ * @property {string} help - What the dial does, its rungs, and where it applies.
312
+ * @property {string} values - The values it takes, `|`-separated.
313
+ * @property {string[]} examples - Commands after the prefix; `my` is the theme.
314
+ * @property {string} words - Words `how` matches to the dial.
315
+ */
316
+
317
+ /** @type {Record<string, Dial>} */
318
+ export const DIALS = {
319
+ corners: {
320
+ help:
321
+ 'How round corners are. Rungs: ' +
322
+ CORNERS.map(
323
+ ([n, v]) => `${n} (${v === 9999 ? 'fully round' : `${v}px`})`,
324
+ ).join(', ') +
325
+ ", or a size like 6px. Whole theme: sets the 4 corner tokens in fixed ratios. With --on <part or family>: that part's border-radius. Corners are a size, so they are the same in light and dark.",
326
+ values: 'square|small|medium|large|round|pill|more|less|<size like 6px>',
327
+ examples: [
328
+ 'set my corners pill',
329
+ 'set my corners more',
330
+ 'set my corners square --on button',
331
+ 'set my corners large --on containers',
332
+ ],
333
+ words:
334
+ 'round rounded radius corner corners curve curved circle circular pill sharp square border-radius bubbly soft',
335
+ },
336
+ spacing: {
337
+ help:
338
+ 'How much room there is: padding, gaps and control heights together. Rungs: ' +
339
+ SPACING.map(([n, f]) => `${n} (x${f})`).join(', ') +
340
+ '. Whole theme: scales every spacing token and control height. With --on <part or family>: only inside it.',
341
+ values: 'tight|compact|medium|roomy|spacious|more|less',
342
+ examples: [
343
+ 'set my spacing compact',
344
+ 'set my spacing more',
345
+ 'set my spacing roomy --on card',
346
+ ],
347
+ words:
348
+ 'spacing space room roomy airy dense density compact tight padding gap gaps margin breathing cramped spread spacious',
349
+ },
350
+ accent: {
351
+ help: 'The main brand color (primary buttons, links, selection, focus). Keeps the color EXACT and derives the rest: text-accent (darkened if needed for 4.5:1 text), a lighter text/icon accent for dark mode, accent-muted, and on-accent (white or black, whichever reads). With --mode: only that mode.',
352
+ values: '<color>',
353
+ examples: [
354
+ 'set my accent "#7c3aed"',
355
+ 'set my accent "#16a34a" --mode dark',
356
+ ],
357
+ words:
358
+ 'accent brand primary main color colour key highlight link selection',
359
+ },
360
+ font: {
361
+ help:
362
+ 'The typeface. System presets (always show): ' +
363
+ SYSTEM_FONTS.join(', ') +
364
+ '. Open fonts with a loading package: ' +
365
+ Object.keys(OPEN_FONTS).join(', ') +
366
+ ' (previews show them when the package is installed; the result names the import line for the app). Also: rounded, comic, any family name in quotes, or a whole stack with commas ("Inter, Helvetica, sans-serif"). Whole theme: body and headings. With --on heading|body|code: only that role. Any other font must be loaded by the app.',
367
+ values: `${[...Object.keys(FONTS), ...Object.keys(OPEN_FONTS)].join('|')}|"<family or stack>"`,
368
+ examples: [
369
+ 'set my font mono',
370
+ 'set my font serif --on heading',
371
+ 'set my font "Inter"',
372
+ ],
373
+ words:
374
+ 'font typeface type family letters serif sans mono monospace typography',
375
+ },
376
+ headings: {
377
+ help:
378
+ 'How headings look, all levels and display sizes together. Weight: ' +
379
+ Object.entries(HEADING_WEIGHTS)
380
+ .map(([n, v]) => `${n} (${v})`)
381
+ .join(', ') +
382
+ '. Tracking (letter spacing): ' +
383
+ Object.entries(HEADING_TRACKING)
384
+ .map(([n, v]) => `${n} (${v})`)
385
+ .join(', ') +
386
+ '. Set one word at a time: weight words and tracking words are separate settings. Whole theme only; for one heading level use font-weight --on heading --when level:<1-6>.',
387
+ values: [
388
+ ...Object.keys(HEADING_WEIGHTS),
389
+ ...Object.keys(HEADING_TRACKING),
390
+ ].join('|'),
391
+ examples: ['set my headings bold', 'set my headings tight'],
392
+ words:
393
+ 'heading headings title titles display headline bold heavy weight tracking letter spacing tight',
394
+ },
395
+ surfaces: {
396
+ help: 'How panels (cards, dialogs, popovers, menus, the banner) sit on the page. flat: no border, no shadow, a tinted fill. outlined: a 1px border, no shadow. raised: no border, a soft shadow. glass: see-through fill with a blur and a faint light edge. Moves every container at once.',
397
+ values: Object.keys(SURFACES).join('|'),
398
+ examples: ['set my surfaces outlined', 'set my surfaces raised'],
399
+ words:
400
+ 'surface surfaces panel panels flat outlined raised elevated glass frosted blur depth',
401
+ },
402
+ buttons: {
403
+ help: 'The button style, all variants together. solid: filled primary (the default). outline: primary is an accent outline with accent text. soft: primary is a light accent tint with accent text. caps: solid with uppercase, bold, spaced labels that never shrink. Corners come from the corners dial (corners pill --on button).',
404
+ values: 'solid|outline|soft|caps',
405
+ examples: ['set my buttons outline', 'set my buttons caps'],
406
+ words: 'cta solid outline outlined soft tint caps uppercase filled',
407
+ },
408
+ type: {
409
+ help: 'The type personality: how far headings step up from body text and how they are set. compact: small steps (x1.15), semibold. standard: the default (x1.2). editorial: bigger steps (x1.3), tight tracking, semibold. display: big steps (x1.4), heavy weight, tighter tracking (a marketing feel). Works with text-size and headings.',
410
+ values: Object.keys(TYPE_STYLES).join('|'),
411
+ examples: ['set my type display', 'set my type editorial'],
412
+ words:
413
+ 'typography personality editorial display marketing scale hierarchy hero',
414
+ },
415
+ 'text-size': {
416
+ help:
417
+ 'Base text size; every heading size scales from it. Rungs: ' +
418
+ TEXT_SIZE.map(([n, v]) => `${n} (${v}px)`).join(', ') +
419
+ ', or a number.',
420
+ values: 'small|medium|large|larger|more|less|<number>',
421
+ examples: ['set my text-size small', 'set my text-size more'],
422
+ words: 'text size font size small big large scale',
423
+ },
424
+ base: {
425
+ help: `The built-in theme this theme builds on: ${LIKE.join(', ')}, or none. Changing it keeps all your settings.`,
426
+ values: `${LIKE.join('|')}|none`,
427
+ examples: ['set my base neutral', 'set my base none'],
428
+ words: 'base start starting built-in extends foundation',
429
+ },
430
+ mode: {
431
+ help: "Which color modes the theme supports. light-only / dark-only: colors get one value and previews render in that mode. both (default): colors without --mode apply to both; --mode light|dark sets one side, and the other side keeps the base theme's value.",
432
+ values: 'both|light-only|dark-only',
433
+ examples: ['set my mode dark-only'],
434
+ words: 'mode light dark only night day scheme',
435
+ },
436
+ };
437
+
438
+ /** CSS properties grouped by the aspect of a part they change. */
439
+ export const GROUPS = /** @type {Record<string, string[]>} */ ({
440
+ text: ['color', 'fill', '-webkit-text-fill-color', 'caret-color'],
441
+ background: ['background-color', 'background-image', 'background'],
442
+ border: [
443
+ 'border-color',
444
+ 'border-top-color',
445
+ 'border-bottom-color',
446
+ 'border-left-color',
447
+ 'border-right-color',
448
+ 'border-block-color',
449
+ 'border-inline-color',
450
+ 'border-width',
451
+ 'border-style',
452
+ 'outline-color',
453
+ ],
454
+ corners: [
455
+ 'border-radius',
456
+ 'border-start-start-radius',
457
+ 'border-start-end-radius',
458
+ 'border-end-start-radius',
459
+ 'border-end-end-radius',
460
+ 'border-top-left-radius',
461
+ 'border-top-right-radius',
462
+ 'border-bottom-left-radius',
463
+ 'border-bottom-right-radius',
464
+ ],
465
+ shadow: ['box-shadow'],
466
+ spacing: [
467
+ 'padding',
468
+ 'padding-block',
469
+ 'padding-inline',
470
+ 'padding-top',
471
+ 'padding-bottom',
472
+ 'padding-inline-start',
473
+ 'padding-inline-end',
474
+ 'padding-left',
475
+ 'padding-right',
476
+ 'gap',
477
+ 'row-gap',
478
+ 'column-gap',
479
+ 'margin',
480
+ 'margin-block',
481
+ 'margin-inline',
482
+ ],
483
+ font: [
484
+ 'font-family',
485
+ 'font-size',
486
+ 'font-weight',
487
+ 'line-height',
488
+ 'letter-spacing',
489
+ 'text-transform',
490
+ ],
491
+ size: [
492
+ 'height',
493
+ 'min-height',
494
+ 'width',
495
+ 'min-width',
496
+ 'block-size',
497
+ 'inline-size',
498
+ ],
499
+ });
500
+
501
+ /** The CSS property that sets each aspect directly, whatever token it reads. */
502
+ export const DIRECT = /** @type {Record<string, string>} */ ({
503
+ text: 'color',
504
+ background: 'background',
505
+ border: 'border',
506
+ corners: 'border-radius',
507
+ shadow: 'box-shadow',
508
+ spacing: 'padding',
509
+ font: 'font-weight',
510
+ size: 'min-height',
511
+ });
512
+
513
+ /** Properties whose value is one plain color. */
514
+ export const COLOR_PROPS =
515
+ /^(color|background-color|border(-(top|right|bottom|left|block|inline))?-color|outline-color|fill|stroke|caret-color|text-decoration-color)$/;
516
+
517
+ /** Tokens `show` prints the resolved value of. */
518
+ export const KEY_TOKENS = [
519
+ '--color-accent',
520
+ '--color-text-accent',
521
+ '--color-on-accent',
522
+ '--color-background-body',
523
+ '--color-background-surface',
524
+ '--color-background-card',
525
+ '--color-text-primary',
526
+ '--color-text-secondary',
527
+ '--color-border',
528
+ '--radius-element',
529
+ '--radius-container',
530
+ '--spacing-4',
531
+ '--font-family-body',
532
+ ];
533
+
534
+ /** The CSS properties `explain --list properties` shows without a filter. */
535
+ export const COMMON_PROPERTIES = [
536
+ 'background',
537
+ 'background-color',
538
+ 'color',
539
+ 'border',
540
+ 'border-color',
541
+ 'border-width',
542
+ 'border-style',
543
+ 'border-radius',
544
+ 'box-shadow',
545
+ 'padding',
546
+ 'gap',
547
+ 'min-height',
548
+ 'font-family',
549
+ 'font-size',
550
+ 'font-weight',
551
+ 'letter-spacing',
552
+ 'text-transform',
553
+ 'opacity',
554
+ 'outline',
555
+ ];
556
+
557
+ /**
558
+ * Words people use for a thing that is not a dial, token or property, and
559
+ * the commands that do what they mean.
560
+ * @type {Record<string, (value: string, on: string | undefined) => string[]>}
561
+ */
562
+ export const THING_HINTS = {
563
+ gradient: (v, on) => [
564
+ `${P} set <theme> background "linear-gradient(${v || '#ffffff, #dddddd'})" --on ${on ?? '<part>'}`,
565
+ ],
566
+ bevel: (_v, on) => [
567
+ `${P} set <theme> box-shadow "inset 1px 1px 0 #ffffff, inset -1px -1px 0 #9ca3af" --on ${on ?? '<part>'}`,
568
+ ],
569
+ shadow: (_v, on) => [
570
+ `${P} set <theme> box-shadow "0 2px 6px rgb(0 0 0 / 0.3)" --on ${on ?? '<part>'}`,
571
+ ],
572
+ radius: (v, on) => [
573
+ `${P} set <theme> corners ${v || 'medium'}${on ? ` --on ${on}` : ''}`,
574
+ ],
575
+ rounded: (_v, on) => [
576
+ `${P} set <theme> corners round${on ? ` --on ${on}` : ''}`,
577
+ ],
578
+ padding: (_v, on) => [
579
+ `${P} set <theme> spacing roomy${on ? ` --on ${on}` : ''}`,
580
+ `${P} set <theme> padding 12px --on ${on ?? '<part>'}`,
581
+ ],
582
+ density: () => [`${P} set <theme> spacing compact`],
583
+ bold: (_v, on) => [`${P} set <theme> font-weight 700 --on ${on ?? '<part>'}`],
584
+ 'text-color': (_v, on) => [`${P} explain "text color on ${on ?? '<part>'}"`],
585
+ };
586
+
587
+ /**
588
+ * Words for parts, and the parts (or families, or `part:prop:value`) they
589
+ * mean. The first match order is the answer order.
590
+ * @type {Array<[RegExp, string[]]>}
591
+ */
592
+ export const PART_WORDS = [
593
+ [
594
+ /\b(header|top ?bar|title ?bar|nav ?bar|app ?bar|masthead)\b/,
595
+ ['app-shell-header'],
596
+ ],
597
+ [
598
+ /\b(nav(igation)? (links?|items?)|menu items?|top ?nav items?)\b/,
599
+ ['top-nav-item', 'side-nav-item'],
600
+ ],
601
+ [
602
+ /\b(app (name|title)|logo|brand name|site title|product name)\b/,
603
+ ['top-nav-heading'],
604
+ ],
605
+ [
606
+ /\b(side ?nav|sidebar|side ?panel|left (panel|column))\b/,
607
+ ['side-nav', 'side-nav-item'],
608
+ ],
609
+ [
610
+ /\b(content area|main area|behind the cards|main content)\b/,
611
+ ['layout-content'],
612
+ ],
613
+ [
614
+ /\b(page|desktop|backdrop|whole background|app background)\b/,
615
+ ['app-shell'],
616
+ ],
617
+ [/\b(windows?|panels?|cards?|boxes|tiles?)\b/, ['containers']],
618
+ [/\b(primary|main|blue) buttons?\b/, ['button:variant:primary']],
619
+ [/\b(secondary|other) buttons?\b/, ['button:variant:secondary']],
620
+ [/\b(ghost|text|link|cancel) buttons?\b/, ['button:variant:ghost']],
621
+ [
622
+ /\b(destructive|danger|delete|red) buttons?\b/,
623
+ ['button:variant:destructive'],
624
+ ],
625
+ [/\bbuttons?\b/, ['button']],
626
+ [/\b(banner|alert|notice|announcement|info box)\b/, ['banner']],
627
+ [
628
+ /\b(inputs?|text ?box(es)?|text ?fields?|fields?|forms?|dropdowns?|selects?)\b/,
629
+ ['inputs'],
630
+ ],
631
+ [/\b(checkbox(es)?|check ?marks?)\b/, ['checks']],
632
+ [/\b(toggles?|switch(es)?)\b/, ['switch']],
633
+ [/\b(progress|loading bar)\b/, ['progress-bar-fill', 'progress-bar-track']],
634
+ [/\b(table header|column headers?)\b/, ['table-header-cell']],
635
+ [/\b(table|rows?)\b/, ['table-row', 'table-cell']],
636
+ [/\b(tabs?)\b/, ['tab', 'tab-indicator']],
637
+ [/\b(badges?|pills?|chips?|tags?)\b/, ['badge']],
638
+ [/\b(status dots?|dots?)\b/, ['status-dot']],
639
+ [/\b(headings?|titles?)\b/, ['heading']],
640
+ [/\b(dialogs?|modals?|popups?)\b/, ['dialog']],
641
+ [/\b(tooltips?)\b/, ['tooltip']],
642
+ [/\b(toasts?)\b/, ['toast']],
643
+ ];
644
+
645
+ /**
646
+ * Words for aspects of a part. `background` comes last: color words mean it
647
+ * only when no other aspect matched them.
648
+ * @type {Array<[string, RegExp]>}
649
+ */
650
+ export const INTENTS = [
651
+ [
652
+ 'text',
653
+ /\b(text|font colou?r|writing|words|white text|dark text|readable|unreadable|links?|labels?)\b/,
654
+ ],
655
+ [
656
+ 'font',
657
+ /\b(font|typeface|bold|weight|heavier|lighter|italic|uppercase|letter ?spacing)\b/,
658
+ ],
659
+ [
660
+ 'corners',
661
+ /\b(round(ed|er)?|corners?|radius|curv\w*|circular|circle|pill|sharp|square)\b/,
662
+ ],
663
+ [
664
+ 'shadow',
665
+ /\b(shadows?|depth|elevat\w*|bevel\w*|raised|3d|glow|sunken|inset)\b/,
666
+ ],
667
+ ['border', /\b(borders?|outlines?|edges?|frames?|strokes?|thick)\b/],
668
+ [
669
+ 'spacing',
670
+ /\b(spacing|space|padding|gaps?|margins?|room|roomy|dense|compact|tight|cramped|airy)\b/,
671
+ ],
672
+ ['size', /\b(taller|shorter|height|bigger|smaller)\b/],
673
+ [
674
+ 'background',
675
+ /\b(background|bg|fill|filled|gradient|glossy|tint|paint|colou?r(ed)?|blue|red|green|white|black|dark|light|cream|beige)\b/,
676
+ ],
677
+ ];
678
+
679
+ /** Sample values for design words in a `how` question. */
680
+ export const DESIGN = /** @type {Record<string, string>} */ ({
681
+ gradient: '"linear-gradient(#ffffff, #d1d5db)"',
682
+ glossy: '"linear-gradient(#ffffff 0%, #c7d2fe 45%, #6366f1 100%)"',
683
+ bevel: '"inset 1px 1px 0 #ffffff, inset -1px -1px 0 #9ca3af"',
684
+ raised: '"0 1px 2px rgb(0 0 0 / 0.3)"',
685
+ flat: 'none',
686
+ sunken: '"inset 1px 1px 2px rgb(0 0 0 / 0.3)"',
687
+ });
688
+
689
+ /** States every part takes, beyond the ones its doc lists. */
690
+ export const COMMON_STATES = [
691
+ 'hover',
692
+ 'active',
693
+ 'focus',
694
+ 'focus-visible',
695
+ 'focus-within',
696
+ 'disabled',
697
+ ];