@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16

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 (120) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/README.md +1 -1
  3. package/api/build/_adapter.d.mts +9 -0
  4. package/api/build/_adapter.mjs +24 -0
  5. package/api/build/kit/shell.weights.json +1 -0
  6. package/api/build/kit/shellcall.d.mts +26 -0
  7. package/api/build/kit/shellcall.mjs +87 -0
  8. package/api/build/kit/start.mjs +67 -4
  9. package/api/build/kit/weights.d.mts +15 -0
  10. package/api/build/kit/weights.mjs +27 -0
  11. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  12. package/api/doctor/_adapter.d.mts +3 -2
  13. package/api/doctor/_adapter.mjs +7 -1
  14. package/api/doctor/doctor.d.mts +8 -0
  15. package/api/doctor/doctor.mjs +53 -8
  16. package/api/doctor/theme-checks.mjs +157 -8
  17. package/api/icon/_adapter.d.mts +7 -3
  18. package/api/icon/_adapter.mjs +12 -3
  19. package/api/icon/icon.type.d.mts +15 -0
  20. package/api/icon/icon.type.mjs +10 -3
  21. package/api/icon/iconUse.doc.mjs +19 -5
  22. package/api/icon/list/list.mjs +7 -1
  23. package/api/icon/use/use.d.mts +8 -5
  24. package/api/icon/use/use.mjs +95 -13
  25. package/api/init/run/run.mjs +1 -0
  26. package/api/template/template.type.d.mts +6 -2
  27. package/api/template/template.type.mjs +2 -1
  28. package/api/theme/_adapter.mjs +16 -2
  29. package/api/theme/build/build.d.mts +10 -6
  30. package/api/theme/build/build.mjs +42 -29
  31. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  32. package/api/theme/palette/generate/generator.mjs +141 -2
  33. package/api/theme/theme.type.d.mts +39 -0
  34. package/api/theme/theme.type.mjs +21 -0
  35. package/api/theme/themeBuild.doc.mjs +1 -1
  36. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  37. package/api/theme-edit/_adapter.d.mts +1 -0
  38. package/api/theme-edit/_adapter.mjs +79 -21
  39. package/api/theme-edit/_check.d.mts +25 -2
  40. package/api/theme-edit/_check.mjs +251 -61
  41. package/api/theme-edit/_context.d.mts +2 -1
  42. package/api/theme-edit/_context.mjs +19 -1
  43. package/api/theme-edit/_edit.d.mts +16 -0
  44. package/api/theme-edit/_edit.mjs +360 -59
  45. package/api/theme-edit/_how-question.d.mts +8 -0
  46. package/api/theme-edit/_how-question.mjs +169 -22
  47. package/api/theme-edit/_marks.d.mts +13 -0
  48. package/api/theme-edit/_marks.mjs +15 -0
  49. package/api/theme-edit/_palette.d.mts +27 -0
  50. package/api/theme-edit/_palette.mjs +112 -8
  51. package/api/theme-edit/_preview-app.d.mts +46 -1
  52. package/api/theme-edit/_preview-app.mjs +367 -36
  53. package/api/theme-edit/_preview.d.mts +55 -0
  54. package/api/theme-edit/_preview.mjs +231 -6
  55. package/api/theme-edit/_project.d.mts +4 -0
  56. package/api/theme-edit/_project.mjs +27 -6
  57. package/api/theme-edit/_settings.d.mts +61 -2
  58. package/api/theme-edit/_settings.mjs +317 -115
  59. package/api/theme-edit/_tables.mjs +1 -1
  60. package/api/theme-edit/theme-edit.type.d.mts +30 -2
  61. package/api/theme-edit/theme-edit.type.mjs +10 -2
  62. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  63. package/assets/docs/author-a-theme.doc.mjs +1 -1
  64. package/assets/docs/theme.doc.dense.mjs +1 -1
  65. package/assets/docs/theme.doc.mjs +1 -1
  66. package/assets/docs/theme.doc.zh.mjs +4 -3
  67. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  68. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  69. package/assets/docs.generated.json +2 -2
  70. package/assets/self-audit.generated.json +1 -1
  71. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  72. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  73. package/assets/templates/components.generated.json +1 -1
  74. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  75. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  76. package/authoring/config/config.doc.mjs +8 -0
  77. package/authoring/config/parse.d.mts +1 -0
  78. package/authoring/config/parse.mjs +12 -0
  79. package/authoring/config/type.ts +8 -0
  80. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  81. package/clients/cli/build-id.generated.json +1 -1
  82. package/clients/cli/commands/experimental/icon.mjs +61 -6
  83. package/clients/cli/commands/experimental/theme.mjs +9 -2
  84. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  85. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  86. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  87. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  88. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  89. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  90. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  91. package/clients/cli/commands/theme.doc.mjs +7 -2
  92. package/clients/cli/commands/theme.mjs +41 -18
  93. package/clients/cli/commands.generated.json +1 -1
  94. package/clients/cli/index.mjs +25 -5
  95. package/clients/cli/manifest.generated.json +1 -1
  96. package/foundation/agent-docs/agent-docs.mjs +1 -1
  97. package/foundation/config/config-writer.d.mts +23 -0
  98. package/foundation/config/config-writer.mjs +150 -56
  99. package/foundation/config/project.mjs +43 -2
  100. package/foundation/discovery/component-discovery.mjs +6 -5
  101. package/foundation/discovery/icon-set-checks.mjs +164 -48
  102. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  103. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  104. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  105. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  106. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  107. package/foundation/discovery/icon-set-writer.mjs +57 -16
  108. package/foundation/discovery/template-icons.d.mts +27 -10
  109. package/foundation/discovery/template-icons.mjs +142 -26
  110. package/foundation/discovery/theme-discovery.d.mts +25 -0
  111. package/foundation/discovery/theme-discovery.mjs +48 -7
  112. package/foundation/fs/gather-cache.mjs +6 -2
  113. package/foundation/integrations/autolink.d.mts +4 -2
  114. package/foundation/integrations/autolink.mjs +4 -2
  115. package/foundation/integrations/cli-requirement.d.mts +16 -5
  116. package/foundation/integrations/cli-requirement.mjs +27 -6
  117. package/foundation/integrations/may-have-integrations.mjs +5 -2
  118. package/foundation/integrations/missing-dependency.d.mts +9 -0
  119. package/foundation/integrations/missing-dependency.mjs +100 -0
  120. package/package.json +6 -6
@@ -32,11 +32,15 @@ import {
32
32
  resolveRecordedTheme,
33
33
  resolveThemeModule,
34
34
  SOURCE_EXTENSIONS,
35
+ isPrivateVarRefusal,
35
36
  missingThemePackage,
36
37
  packageInstallCommand,
37
38
  themeBuild,
38
39
  themeRecordOwner,
39
40
  validateThemePrivateInputs,
41
+ GENERATED_MARKER,
42
+ APP_COPY_MARK,
43
+ EDITOR_GENERATED_MARK,
40
44
  } from './_adapter.mjs';
41
45
  import {
42
46
  getCliInvocation,
@@ -215,6 +219,123 @@ function sourceImportEvidence(root, generatedModule) {
215
219
  return {found: false, parseFailures};
216
220
  }
217
221
 
222
+ /**
223
+ * Whether the file's leading comment says the CLI generated it: a theme
224
+ * build, or a file of the theme editor (its settings module, its app copy).
225
+ * @param {string} source
226
+ */
227
+ function generatedThemeFile(source) {
228
+ const leading =
229
+ /^\s*(?:\/\*[\s\S]*?\*\/|(?:\/\/[^\n]*(?:\n|$)\s*)+)/.exec(source)?.[0] ??
230
+ '';
231
+ return [GENERATED_MARKER, EDITOR_GENERATED_MARK, APP_COPY_MARK].some(m =>
232
+ leading.includes(m),
233
+ );
234
+ }
235
+
236
+ /**
237
+ * The specifiers a file imports only to extend a theme: every binding of
238
+ * the import is used solely as the `extends` value of a `defineTheme({...})`
239
+ * call. Any other use of a binding (a switcher, a render, a re-export) keeps
240
+ * the import, and so does a second import of the same specifier.
241
+ * @param {any} ast
242
+ * @returns {Set<string>}
243
+ */
244
+ function extendOnlySpecifiers(ast) {
245
+ /** @type {Map<string, string>} binding -> specifier */
246
+ const bindings = new Map();
247
+ /** @type {Map<string, number>} */
248
+ const importsOf = new Map();
249
+ for (const node of ast.program?.body ?? []) {
250
+ if (node.type !== 'ImportDeclaration' || node.importKind === 'type')
251
+ continue;
252
+ const from = node.source.value;
253
+ importsOf.set(from, (importsOf.get(from) ?? 0) + 1);
254
+ for (const s of node.specifiers ?? []) bindings.set(s.local.name, from);
255
+ }
256
+ /** @type {Map<string, {extends: number, other: number}>} */
257
+ const uses = new Map();
258
+ /**
259
+ * @param {any} node
260
+ * @param {any} parent
261
+ * @param {any} grand
262
+ * @param {any} great
263
+ */
264
+ const visit = (node, parent, grand, great) => {
265
+ if (node == null || typeof node !== 'object') return;
266
+ if (Array.isArray(node)) {
267
+ for (const n of node) visit(n, parent, grand, great);
268
+ return;
269
+ }
270
+ if (
271
+ node.type === 'Identifier' &&
272
+ bindings.has(node.name) &&
273
+ ![
274
+ 'ImportSpecifier',
275
+ 'ImportDefaultSpecifier',
276
+ 'ImportNamespaceSpecifier',
277
+ ].includes(parent?.type) &&
278
+ !(
279
+ parent?.type === 'ObjectProperty' &&
280
+ parent.key === node &&
281
+ !parent.computed &&
282
+ parent.value !== node
283
+ )
284
+ ) {
285
+ const u = uses.get(node.name) ?? {extends: 0, other: 0};
286
+ // The `extends` of a `defineTheme({...})` call, as the check reads a
287
+ // theme's base everywhere else.
288
+ const asExtends = definedThemeBase(great) === node;
289
+ if (asExtends) u.extends++;
290
+ else u.other++;
291
+ uses.set(node.name, u);
292
+ }
293
+ if (typeof node.type !== 'string') return;
294
+ for (const [key, child] of Object.entries(node)) {
295
+ if (['loc', 'start', 'end', 'extra'].includes(key)) continue;
296
+ visit(child, node, parent, grand);
297
+ }
298
+ };
299
+ visit(ast.program, null, null, null);
300
+ // Every other way the file loads a module (`import()`, `require()`,
301
+ // `export … from`): a specifier loaded so is not only extended.
302
+ /** @type {Set<string>} */
303
+ const loadedOtherwise = new Set();
304
+ walkAst(ast.program, node => {
305
+ if (
306
+ ['ExportNamedDeclaration', 'ExportAllDeclaration'].includes(node.type) &&
307
+ typeof node.source?.value === 'string'
308
+ )
309
+ loadedOtherwise.add(node.source.value);
310
+ if (
311
+ node.type === 'ImportExpression' &&
312
+ typeof node.source?.value === 'string'
313
+ )
314
+ loadedOtherwise.add(node.source.value);
315
+ if (
316
+ node.type === 'CallExpression' &&
317
+ (node.callee?.type === 'Import' || node.callee?.name === 'require') &&
318
+ typeof node.arguments?.[0]?.value === 'string'
319
+ )
320
+ loadedOtherwise.add(node.arguments[0].value);
321
+ });
322
+ /** @type {Map<string, boolean>} */
323
+ const only = new Map();
324
+ for (const [name, from] of bindings) {
325
+ const u = uses.get(name) ?? {extends: 0, other: 0};
326
+ const ok = u.extends > 0 && u.other === 0;
327
+ only.set(from, (only.get(from) ?? true) && ok);
328
+ }
329
+ return new Set(
330
+ [...only]
331
+ .filter(
332
+ ([from, ok]) =>
333
+ ok && importsOf.get(from) === 1 && !loadedOtherwise.has(from),
334
+ )
335
+ .map(([from]) => from),
336
+ );
337
+ }
338
+
218
339
  /**
219
340
  * Find a source file that imports one added built module without its paired CSS.
220
341
  * @param {string} root
@@ -235,6 +356,10 @@ function themeImportPairEvidence(root, generatedModule, themes) {
235
356
  } catch {
236
357
  continue;
237
358
  }
359
+ // A file the CLI generates (a theme build, the editor's files) only
360
+ // extends another theme's module, never renders it. The app's theme
361
+ // module stays checked.
362
+ if (file !== generatedModule && generatedThemeFile(source)) continue;
238
363
  const candidates = themes.filter(theme =>
239
364
  source.includes(
240
365
  theme.source === 'local'
@@ -246,6 +371,11 @@ function themeImportPairEvidence(root, generatedModule, themes) {
246
371
  let specifiers;
247
372
  try {
248
373
  specifiers = moduleSpecifiers(source);
374
+ // An import used only as a theme's `extends` (a theme source) does not
375
+ // render that theme: its stylesheet is not asked for.
376
+ if (file !== generatedModule)
377
+ for (const from of extendOnlySpecifiers(parseModule(source)))
378
+ specifiers.delete(from);
249
379
  } catch {
250
380
  unproven.push(relative(root, file));
251
381
  continue;
@@ -1085,6 +1215,9 @@ export async function checkAppThemes(cwd) {
1085
1215
  });
1086
1216
  } else {
1087
1217
  const stale = [];
1218
+ /** Local themes the build refused for a private var: not checked. */
1219
+ /** @type {string[]} */
1220
+ const refused = [];
1088
1221
  /** @type {Map<string, string[]>} theme slugs by the package they import and the app lacks */
1089
1222
  const missingPackages = new Map();
1090
1223
  const previousSilent = logger.silent;
@@ -1111,6 +1244,12 @@ export async function checkAppThemes(cwd) {
1111
1244
  stale.push(theme.slug);
1112
1245
  }
1113
1246
  } catch (error) {
1247
+ // A theme that sets a private var is the "Private theme
1248
+ // variables" check's to report, not a stale output.
1249
+ if (isPrivateVarRefusal(error)) {
1250
+ refused.push(theme.slug);
1251
+ continue;
1252
+ }
1114
1253
  const missing = missingThemePackage(error);
1115
1254
  if (missing) {
1116
1255
  missingPackages.set(missing, [
@@ -1151,7 +1290,7 @@ export async function checkAppThemes(cwd) {
1151
1290
  .map(([pkg, slugs]) => `${pkg} (${slugs.join(', ')})`)
1152
1291
  .join(
1153
1292
  '; ',
1154
- )}.${stale.length > 0 ? ` Local theme outputs are also missing or stale: ${stale.join(', ')}.` : ''}`,
1293
+ )}.${stale.length > 0 ? ` Local theme outputs are also missing or stale: ${stale.join(', ')}.` : ''}${refused.length > 0 ? ` Not checked (a private theme variable; see theme-private-variables): ${refused.join(', ')}.` : ''}`,
1155
1294
  fix: [
1156
1295
  install?.installCommand ??
1157
1296
  install?.noCommandReason ??
@@ -1164,15 +1303,25 @@ export async function checkAppThemes(cwd) {
1164
1303
  id: 'theme-local-builds',
1165
1304
  label: 'Local theme build freshness',
1166
1305
  status: 'fail',
1167
- message: `Local theme outputs are missing or stale: ${stale.join(', ')}.`,
1306
+ message: `Local theme outputs are missing or stale: ${stale.join(', ')}.${refused.length > 0 ? ` Not checked (a private theme variable; see theme-private-variables): ${refused.join(', ')}.` : ''}`,
1168
1307
  fix: refresh.join(' '),
1169
1308
  }
1170
- : {
1171
- id: 'theme-local-builds',
1172
- label: 'Local theme build freshness',
1173
- status: 'pass',
1174
- message: 'Every added local theme output matches its source.',
1175
- },
1309
+ : refused.length > 0
1310
+ ? {
1311
+ // Not a pass: the build refused these, so their outputs
1312
+ // were never compared with their sources.
1313
+ id: 'theme-local-builds',
1314
+ label: 'Local theme build freshness',
1315
+ status: 'info',
1316
+ message: `Not checked: ${refused.join(', ')} ${refused.length === 1 ? 'sets' : 'set'} a private theme variable, so the build refuses ${refused.length === 1 ? 'it' : 'them'} and ${refused.length === 1 ? 'its' : 'their'} outputs were not compared with ${refused.length === 1 ? 'its source' : 'their sources'}.`,
1317
+ fix: 'Follow the fix on the theme-private-variables check, then run doctor again.',
1318
+ }
1319
+ : {
1320
+ id: 'theme-local-builds',
1321
+ label: 'Local theme build freshness',
1322
+ status: 'pass',
1323
+ message: 'Every added local theme output matches its source.',
1324
+ },
1176
1325
  );
1177
1326
  }
1178
1327
 
@@ -37,17 +37,20 @@ export function loadIconProject(cwd: string): Promise<{
37
37
  projectDir: string;
38
38
  sets: import("../../foundation/discovery/icon-set-discovery.mjs").DiscoveredIconSet[];
39
39
  withdrawn: import("../../foundation/discovery/icon-set-discovery.mjs").WithdrawnIconSet[];
40
+ variant: string | null;
40
41
  }>;
41
42
  /**
42
43
  * Why a CLI the project may run would refuse its astryx.config once it sets
43
44
  * `experimental.iconSet`, read from the project's package.json; null when
44
45
  * nothing says so.
45
46
  * @param {string} projectDir
46
- * @param {{list?: boolean}} [options] `list`: the value written is a list
47
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value
48
+ * written is a list; `variant`: `experimental.iconVariant` is written too
47
49
  * @returns {string | null}
48
50
  */
49
51
  export function iconSetConfigCliWarning(projectDir: string, options?: {
50
52
  list?: boolean;
53
+ variant?: boolean;
51
54
  }): string | null;
52
55
  /**
53
56
  * The icon definitions the bundled templates use that a set of the local
@@ -59,11 +62,12 @@ export function iconSetConfigCliWarning(projectDir: string, options?: {
59
62
  */
60
63
  export function templateMeaningsOf(cwd: string, selector: string | undefined): Promise<import("./icon.type.mjs").IconTemplateMeanings | null>;
61
64
  export { astryxIconDefinitions } from "../../foundation/discovery/icon-definition-discovery.mjs";
65
+ export { lookThemeMap } from "../../foundation/discovery/icon-set-theme-maps.mjs";
62
66
  export { exportValueKind } from "../../foundation/discovery/module-exports.mjs";
63
67
  export { templateIconMeanings } from "../../foundation/discovery/template-icon-meanings.mjs";
64
68
  export { iconRecord, importLine, leadingReading, matchIcon, answeringMatches, rankIcons, scoreIcon } from "../../foundation/discovery/icon-ranking.mjs";
65
- export { iconSetKey, ICON_USE_ORDER_COMMAND, unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
66
- export { setConfigString, setConfigValue } from "../../foundation/config/config-writer.mjs";
69
+ export { iconSetKey, ICON_USE_ORDER_COMMAND, iconSetLook, iconUseCommand, unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
70
+ export { setConfigString, setConfigValues } from "../../foundation/config/config-writer.mjs";
67
71
  export { assertIconExport, checkNewDefinition, definitionNameFromInput, definitionFile, findLocalIconSet, writeDefinitionFile, iconIdOf, closestNames, libraryIcons, mappableDefinitions, resolveIconSource, generatedModulePath, generatedNamesOf, generatedOrigins, iconModulePackage, sameIconModule, iconExportName, iconNaming, modulePrefix, moduleNaming, iconNamingWithoutLook, splitLook, setModuleNote, variantExportName, writeGeneratedIcons, writeIconSetData, definitionNameOf, iconIdIn, iconsWithWord, localSourceNote, THEME_MAP_NAME } from "../../foundation/discovery/icon-set-writer.mjs";
68
72
  export { addIconDefinition, addIconSet } from "./_authoring.mjs";
69
73
  export { checkVariantLook, drawnLooks } from "./_default-look.mjs";
@@ -41,10 +41,13 @@ export {astryxIconDefinitions} from '../../foundation/discovery/icon-definition-
41
41
  export {iconSetKey} from '../../foundation/discovery/icon-set-discovery.mjs';
42
42
  export {
43
43
  setConfigString,
44
- setConfigValue,
44
+ setConfigValues,
45
45
  } from '../../foundation/config/config-writer.mjs';
46
+ export {lookThemeMap} from '../../foundation/discovery/icon-set-theme-maps.mjs';
46
47
  export {
47
48
  ICON_USE_ORDER_COMMAND,
49
+ iconSetLook,
50
+ iconUseCommand,
48
51
  unlistedIconSets,
49
52
  } from '../../foundation/discovery/icon-set-discovery.mjs';
50
53
  export {
@@ -167,7 +170,12 @@ export async function loadIconSets(cwd) {
167
170
  export async function loadIconProject(cwd) {
168
171
  const project = await Project.load(cwd);
169
172
  const {sets, withdrawn} = await project.iconSets({experimental: true});
170
- return {projectDir: findProjectDir(cwd), sets, withdrawn};
173
+ return {
174
+ projectDir: findProjectDir(cwd),
175
+ sets,
176
+ withdrawn,
177
+ variant: project.config.experimental?.iconVariant ?? null,
178
+ };
171
179
  }
172
180
 
173
181
  /**
@@ -190,7 +198,8 @@ function findProjectDir(cwd) {
190
198
  * `experimental.iconSet`, read from the project's package.json; null when
191
199
  * nothing says so.
192
200
  * @param {string} projectDir
193
- * @param {{list?: boolean}} [options] `list`: the value written is a list
201
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value
202
+ * written is a list; `variant`: `experimental.iconVariant` is written too
194
203
  * @returns {string | null}
195
204
  */
196
205
  export function iconSetConfigCliWarning(projectDir, options = {}) {
@@ -136,6 +136,10 @@ export type IconSetEntry = {
136
136
  * - The set's position in the list, the main set at 1; null when it is not listed.
137
137
  */
138
138
  rank: number | null;
139
+ /**
140
+ * - Present when the project names a variant: the look this set's icons draw, the variant when the set declares it, else its default look; null when the list leaves the set out or it declares no variants.
141
+ */
142
+ look?: string | null | undefined;
139
143
  };
140
144
  /**
141
145
  * Which icon definitions one set's `map` covers.
@@ -179,6 +183,7 @@ export type IconListResponse = {
179
183
  projectSet: string | null;
180
184
  reason: string;
181
185
  order: string[];
186
+ variant: string | null;
182
187
  backups: Array<{
183
188
  iconSet: string;
184
189
  status: "selected" | "ambiguous" | "missing" | "withdrawn";
@@ -201,11 +206,21 @@ export type IconUseResponse = {
201
206
  iconSet: string;
202
207
  set: string;
203
208
  }>;
209
+ variant: string | null;
204
210
  config: string;
205
211
  created: boolean;
206
212
  previous: string | string[] | null;
213
+ previousVariant: string | null;
207
214
  changed: boolean;
208
215
  unlisted: string[];
216
+ looks?: {
217
+ set: string;
218
+ variant: string | null;
219
+ }[] | undefined;
220
+ themeMap?: {
221
+ module: string;
222
+ export: string;
223
+ } | undefined;
209
224
  next?: string | undefined;
210
225
  warning?: string | undefined;
211
226
  };
@@ -86,6 +86,7 @@
86
86
  * @property {boolean} project - Whether this is the project's icon set.
87
87
  * @property {'main' | 'backup' | null} role - The set's place in the project's list: its main set, a backup, or not listed.
88
88
  * @property {number | null} rank - The set's position in the list, the main set at 1; null when it is not listed.
89
+ * @property {string | null} [look] - Present when the project names a variant: the look this set's icons draw, the variant when the set declares it, else its default look; null when the list leaves the set out or it declares no variants.
89
90
  */
90
91
 
91
92
  /**
@@ -116,6 +117,7 @@
116
117
  * @property {string | null} data.projectSet - The project's set, as `<package>/<set>`, when selected.
117
118
  * @property {string} data.reason - Why the project has that set, or none.
118
119
  * @property {string[]} data.order - The project's list as `<package>/<set>`: the main set, then each backup that resolves; empty when no main set is selected.
120
+ * @property {string | null} data.variant - The look the project's icons draw, as `experimental.iconVariant` names it; null when it names none.
119
121
  * @property {Array<{iconSet: string, status: 'selected' | 'ambiguous' | 'missing' | 'withdrawn', reason: string}>} data.backups - Each backup the list names, and whether it resolves.
120
122
  * @property {string} [data.next] - Present when two or more sets are installed and none is the main set: the command that chooses the order.
121
123
  * @property {IconSetEntry[]} data.sets - Installed sets in list order: the main set, its backups, then the rest.
@@ -131,16 +133,21 @@
131
133
  * @property {string} data.iconSet - The main set, as written to `experimental.iconSet` (alone, or first in the list).
132
134
  * @property {string} data.set - The main set it names, as `<package>/<set>`.
133
135
  * @property {Array<{iconSet: string, set: string}>} data.backups - The backup sets, in order, as written and as `<package>/<set>`; empty when there are none.
136
+ * @property {string | null} data.variant - The look every icon draws, as written to `experimental.iconVariant`; null when none is named, and the key is removed, so each set draws its default look.
134
137
  * @property {string} data.config - The config file, relative to the project.
135
138
  * @property {boolean} data.created - Whether the config file was created.
136
139
  * @property {string | string[] | null} data.previous - The `experimental.iconSet` value it replaced.
140
+ * @property {string | null} data.previousVariant - The `experimental.iconVariant` value it replaced.
137
141
  * @property {boolean} data.changed - Whether anything was written.
138
142
  * @property {string[]} data.unlisted - Installed sets the list leaves out, as `<package>/<set>`. Doctor fails a project that installs more than one set and leaves one out.
143
+ * @property {Array<{set: string, variant: string | null}>} [data.looks] - Present when a variant is named: each set in the list, main set first, as `<package>/<set>`, with the look its icons draw: the variant, or the set's default look when it declares no variant of that name (null when it declares no variants).
144
+ * @property {{module: string, export: string}} [data.themeMap] - Present when a variant is named and the main set has a theme map for that look: the export a theme sets as `icons` to draw the built-in icons in it (`themeIconsFilled`), and the module it is imported from.
139
145
  * @property {string} [data.next] - Present when `unlisted` is not empty: the command that adds them as backups.
140
146
  * @property {string} [data.warning] - Present when the project's
141
- * `@astryxdesign/cli` range admits a release before 0.7.4, which refuses
142
- * an astryx.config that sets `experimental.iconSet`: what fails, and the
143
- * range to require.
147
+ * `@astryxdesign/cli` range admits a release that refuses the config
148
+ * written: before 0.7.4 for `experimental.iconSet`, before 0.7.12 for it
149
+ * as a list, and before 0.7.16 for `experimental.iconVariant`. It says
150
+ * what fails, and the range to require.
144
151
  */
145
152
 
146
153
  /**
@@ -10,12 +10,12 @@ export const doc = {
10
10
  namespace: 'cli/api',
11
11
  stability: 'experimental',
12
12
  displayName: 'iconUse()',
13
- summary: "Choose the project's main icon set and backups.",
13
+ summary: "Choose the project's main icon set, backups, and look.",
14
14
  description:
15
- "Writes `experimental.iconSet` in the project's astryx.config (creating astryx.config.mjs when there is none), so templates and blocks the project copies use that set's icons. With no backups it writes the set name as a string. With backups it writes a list, the main set first and then each backup in order: a copied template takes each icon from the first set in the list that has its meaning, and draws a placeholder the copied file declares when none has it. Every set must be installed; a name two installed packages both ship is refused with each `<package>/<set>` form. The receipt lists installed sets the list leaves out (`unlisted`), which Doctor fails, with the command that adds them. Experimental: it may change or be removed in a patch release.",
15
+ "Writes `experimental.iconSet` in the project's astryx.config (creating astryx.config.mjs when there is none), so templates and blocks the project copies use that set's icons. With no backups it writes the set name as a string. With backups it writes a list, the main set first and then each backup in order: a copied template takes each icon from the first set in the list that has its meaning, and draws a placeholder the copied file declares when none has it. With `variant`, it writes `experimental.iconVariant` in the same write: the look every icon draws, one of the main set's variants. Each set in the list draws its variant of that name, or its default look when it declares none (`looks`), and `themeMap` names the export a theme sets as `icons` to draw the built-in icons in that look. Without `variant`, it removes `experimental.iconVariant`, so each set draws its default look. Every set must be installed; a name two installed packages both ship is refused with each `<package>/<set>` form. The receipt lists installed sets the list leaves out (`unlisted`), which Doctor fails, with the command that adds them. Experimental: it may change or be removed in a patch release.",
16
16
  importPath: '@astryxdesign/cli/api',
17
17
  signature:
18
- 'iconUse(set: string, options?: {cwd?: string, backups?: string[]}): Promise<IconUseResponse>',
18
+ 'iconUse(set: string, options?: {cwd?: string, backups?: string[], variant?: string}): Promise<IconUseResponse>',
19
19
  keywords: [
20
20
  'icon',
21
21
  'icon set',
@@ -23,6 +23,10 @@ export const doc = {
23
23
  'backup',
24
24
  'main set',
25
25
  'experimental.iconSet',
26
+ 'experimental.iconVariant',
27
+ 'variant',
28
+ 'outline',
29
+ 'filled',
26
30
  'config',
27
31
  ],
28
32
  params: [
@@ -43,12 +47,18 @@ export const doc = {
43
47
  description:
44
48
  'Backup sets, by name or `<package>/<set>`, in the order a copied template tries them after the main set.',
45
49
  },
50
+ {
51
+ name: 'options.variant',
52
+ type: 'string',
53
+ description:
54
+ "The look every icon draws, such as `outline` or `filled`: one of the main set's variants. Leave it out to remove `experimental.iconVariant`, so each set draws its default look.",
55
+ },
46
56
  ],
47
57
  returns: [
48
58
  {
49
59
  type: 'icon.use',
50
60
  description:
51
- "The main set and the backups written, the sets they name, the config file, whether it was created, the value it replaced, the installed sets the list leaves out (`unlisted`, with a `next` command), and a `warning` when the project's @astryxdesign/cli range admits a release that refuses the value: before 0.7.4 for a string, before 0.7.12 for a list.",
61
+ "The main set and the backups written, the sets they name, the variant written (`variant`, or null), the config file, whether it was created, the values it replaced (`previous`, `previousVariant`), the installed sets the list leaves out (`unlisted`, with a `next` command), with a variant the look each listed set draws (`looks`) and the main set's theme map for that look (`themeMap`), and a `warning` when the project's @astryxdesign/cli range admits a release that refuses the config: before 0.7.4 for a string, before 0.7.12 for a list, before 0.7.16 for a variant.",
52
62
  },
53
63
  ],
54
64
  throws: [
@@ -58,7 +68,7 @@ export const doc = {
58
68
  },
59
69
  {
60
70
  code: 'ERR_INVALID_ARGUMENT',
61
- when: 'two installed packages ship a set with the name, or the list names one set twice',
71
+ when: "two installed packages ship a set with the name, the list names one set twice, or the main set declares no variant `variant` names (the error lists the main set's variants, each with the command that picks it)",
62
72
  },
63
73
  {
64
74
  code: 'ERR_WRITE_FAILED',
@@ -87,6 +97,10 @@ export const doc = {
87
97
  label: 'Use a main set with a backup',
88
98
  code: "await iconUse('outline', {backups: ['@acme/brand-icons/brand']});",
89
99
  },
100
+ {
101
+ label: 'Draw every icon in one look',
102
+ code: "await iconUse('brand', {variant: 'filled'});",
103
+ },
90
104
  ],
91
105
  command: 'experimental icon use',
92
106
  related: ['icon', 'iconMap', 'iconAdd'],
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @file `icon.list` leaf (AST-084 FR7): every installed icon set with the
5
5
  * icon definitions its `map` covers, the project's main set and backups in
6
- * order, and the sets withdrawn with why.
6
+ * order, the look the project's icons draw, and the sets withdrawn with why.
7
7
  *
8
8
  * @output the `icon.list` envelope
9
9
  * @position api/icon/list — dispatched by ../icon.mjs
@@ -13,6 +13,7 @@ import {
13
13
  astryxIconDefinitions,
14
14
  ICON_USE_ORDER_COMMAND,
15
15
  iconSetKey,
16
+ iconSetLook,
16
17
  loadIconSets,
17
18
  } from '../_adapter.mjs';
18
19
 
@@ -36,6 +37,7 @@ export async function iconList({cwd}) {
36
37
  : null,
37
38
  reason: choice.reason,
38
39
  order: order.map(iconSetKey),
40
+ variant: choice.variant ?? null,
39
41
  backups: (choice.backups ?? []).map(each => ({
40
42
  iconSet: each.selector,
41
43
  status: each.status,
@@ -78,6 +80,10 @@ export async function iconList({cwd}) {
78
80
  ? /** @type {const} */ ('backup')
79
81
  : null,
80
82
  rank: rank === -1 ? null : rank + 1,
83
+ // A set the list leaves out draws no look in the project.
84
+ ...(choice.variant
85
+ ? {look: rank === -1 ? null : iconSetLook(set, choice.variant)}
86
+ : {}),
81
87
  };
82
88
  }),
83
89
  withdrawn: withdrawn.map(each => ({
@@ -3,17 +3,20 @@
3
3
 
4
4
  /**
5
5
  * Make an installed set the project's main icon set, with backup sets in
6
- * order. A copied template takes each icon from the first set in the list
7
- * that has its meaning.
6
+ * order, and choose the look its icons draw. A copied template takes each
7
+ * icon from the first set in the list that has its meaning, in the project's
8
+ * variant when that set's icon has it.
8
9
  * Experimental (spec:AST-017 FR27): may change or be removed in a patch
9
10
  * release.
10
11
  * @experimental
11
12
  * @param {string} selector a set name, or `<package>/<set>`
12
- * @param {{cwd?: string, backups?: string[]}} [options] `backups`: the
13
- * backup sets, in order
13
+ * @param {{cwd?: string, backups?: string[], variant?: string}} [options]
14
+ * `backups`: the backup sets, in order; `variant`: the look every icon
15
+ * draws, one of the main set's variants
14
16
  * @returns {Promise<import('../icon.type.mjs').IconUseResponse>}
15
17
  */
16
- export function iconUse(selector: string, { cwd, backups }?: {
18
+ export function iconUse(selector: string, { cwd, backups, variant }?: {
17
19
  cwd?: string;
18
20
  backups?: string[];
21
+ variant?: string;
19
22
  }): Promise<import("../icon.type.mjs").IconUseResponse>;