@astryxdesign/cli 0.7.18-canary.gb89ee6e → 0.7.18-canary.gfacee17

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 (82) hide show
  1. package/api/doctor/doctor.mjs +2 -2
  2. package/api/icon/_adapter.d.mts +8 -0
  3. package/api/icon/_adapter.mjs +17 -0
  4. package/api/icon/_authoring.mjs +6 -6
  5. package/api/icon/_default-look.mjs +16 -16
  6. package/api/icon/add/add.mjs +3 -3
  7. package/api/icon/exportIconIndex.doc.mjs +2 -2
  8. package/api/icon/icon.doc.mjs +1 -1
  9. package/api/icon/icon.type.d.mts +4 -0
  10. package/api/icon/icon.type.mjs +1 -0
  11. package/api/icon/search/icon-index.mjs +16 -3
  12. package/api/icon/search/search.d.mts +11 -4
  13. package/api/icon/search/search.mjs +33 -12
  14. package/api/icon/use/use.mjs +4 -4
  15. package/api/integration/pack-check.d.mts +2 -2
  16. package/api/integration/pack-check.mjs +2 -2
  17. package/api/search/_adapter.mjs +4 -0
  18. package/api/search/_icons.d.mts +4 -2
  19. package/api/search/_icons.mjs +4 -2
  20. package/api/template/template.type.d.mts +3 -3
  21. package/api/template/template.type.mjs +3 -3
  22. package/api/theme/build/build.d.mts +5 -5
  23. package/api/theme/build/build.mjs +7 -11
  24. package/api/theme-edit/_adapter.mjs +3 -1
  25. package/api/theme-edit/_catalog.mjs +28 -12
  26. package/api/theme-edit/_context.d.mts +9 -7
  27. package/api/theme-edit/_context.mjs +17 -11
  28. package/api/theme-edit/_edit.d.mts +2 -2
  29. package/api/theme-edit/_edit.mjs +19 -5
  30. package/api/theme-edit/_how-commands.d.mts +104 -0
  31. package/api/theme-edit/_how-commands.mjs +132 -102
  32. package/api/theme-edit/_how-question.d.mts +1 -0
  33. package/api/theme-edit/_how-question.mjs +364 -132
  34. package/api/theme-edit/_how.mjs +10 -0
  35. package/api/theme-edit/_resolved.d.mts +46 -0
  36. package/api/theme-edit/_resolved.mjs +800 -0
  37. package/api/theme-edit/_settings.mjs +280 -8
  38. package/api/theme-edit/show/show.d.mts +4 -3
  39. package/api/theme-edit/show/show.mjs +3 -2
  40. package/api/theme-edit/theme-edit.type.d.mts +63 -0
  41. package/api/theme-edit/theme-edit.type.mjs +29 -1
  42. package/api/theme-edit/themeEditShow.doc.mjs +18 -3
  43. package/assets/component-list.generated.json +1 -1
  44. package/assets/docs/icons.doc.mjs +7 -6
  45. package/assets/docs/theme.doc.dense.mjs +10 -0
  46. package/assets/docs/theme.doc.mjs +10 -0
  47. package/assets/docs/theme.doc.zh.mjs +10 -0
  48. package/assets/docs-routes.generated.json +1 -1
  49. package/assets/docs.generated.json +2 -2
  50. package/assets/search-catalog.generated.json +2 -2
  51. package/assets/self-audit.generated.json +1 -1
  52. package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +9 -1
  53. package/assets/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonShowcase.doc.mjs +9 -2
  54. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.doc.mjs +3 -2
  55. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -1
  56. package/assets/templates/blocks/components/SideNavItem/SideNavItemShowcase.doc.mjs +3 -2
  57. package/assets/templates/blocks/components/SideNavSection/SideNavSectionShowcase.doc.mjs +2 -1
  58. package/assets/templates/components.generated.json +1 -1
  59. package/authoring/config/parse.mjs +1 -1
  60. package/authoring/doctypes/icon-definition/parse.mjs +2 -2
  61. package/authoring/doctypes/icon-set/parse.mjs +1 -1
  62. package/authoring/doctypes/template/parse.mjs +1 -4
  63. package/clients/cli/build-id.generated.json +1 -1
  64. package/clients/cli/commands/experimental/icon.mjs +7 -7
  65. package/clients/cli/commands/experimental/theme.mjs +129 -7
  66. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  67. package/clients/cli/commands/template.mjs +1 -1
  68. package/clients/cli/manifest.generated.json +1 -1
  69. package/foundation/discovery/icon-ranking.d.mts +5 -2
  70. package/foundation/discovery/icon-ranking.mjs +101 -18
  71. package/foundation/discovery/icon-set-checks.mjs +1 -1
  72. package/foundation/discovery/icon-set-writer.mjs +1 -1
  73. package/foundation/discovery/template-icon-notes.mjs +3 -3
  74. package/foundation/discovery/template-icons.mjs +2 -2
  75. package/foundation/discovery/template-placeholders.mjs +1 -1
  76. package/foundation/render/drawn-contrast.d.mts +4 -2
  77. package/foundation/render/drawn-contrast.mjs +134 -16
  78. package/foundation/response/response-types.doc.mjs +8 -4
  79. package/foundation/suggest/other-command.mjs +25 -1
  80. package/foundation/text/icon-set-next.d.mts +1 -1
  81. package/foundation/text/icon-set-next.mjs +2 -2
  82. package/package.json +7 -7
@@ -1681,7 +1681,7 @@ export function checkIconSets(ctx) {
1681
1681
  status: 'fail',
1682
1682
  message:
1683
1683
  declared.length === 0
1684
- ? `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no variants: it draws one look.`
1684
+ ? `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no variants, so it has none to pick.`
1685
1685
  : `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no such variant. Its variants: ${declared.join(', ')}.`,
1686
1686
  fix:
1687
1687
  declared.length === 0
@@ -1738,7 +1738,7 @@ export function checkIconSets(ctx) {
1738
1738
  id,
1739
1739
  label,
1740
1740
  status: 'pass',
1741
- message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}${choice.variant ? ` Each icon draws its "${choice.variant}" look where its set has one.` : ''}`,
1741
+ message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}${choice.variant ? ` Each icon draws its "${choice.variant}" variant where its set has one.` : ''}`,
1742
1742
  };
1743
1743
  }
1744
1744
 
@@ -37,6 +37,14 @@ export function loadIconSets(cwd: string): Promise<{
37
37
  * @returns {Promise<boolean>}
38
38
  */
39
39
  export function discoverListsIconSet(cwd: string): Promise<boolean>;
40
+ /**
41
+ * The names of the components of the Core the project in `cwd` reads: an
42
+ * icon query's words that name one say where the icon goes (spec:AST-084
43
+ * FR6). Empty when there is no Core.
44
+ * @param {string} cwd
45
+ * @returns {string[]}
46
+ */
47
+ export function coreComponentNames(cwd: string): string[];
40
48
  /**
41
49
  * The project directory, its installed icon sets, and the sets withdrawn,
42
50
  * for `experimental icon use`.
@@ -13,6 +13,7 @@
13
13
  import * as fs from 'node:fs';
14
14
  import * as path from 'node:path';
15
15
  import {Project} from '../../foundation/config/project.mjs';
16
+ import {discoverComponents} from '../../foundation/discovery/component-discovery.mjs';
16
17
  import {AstryxError} from '../error.mjs';
17
18
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
18
19
  import {
@@ -178,6 +179,22 @@ export async function discoverListsIconSet(cwd) {
178
179
  return listsToAdd(project, ICON_PACK_QUERY, 'icon-set');
179
180
  }
180
181
 
182
+ /**
183
+ * The names of the components of the Core the project in `cwd` reads: an
184
+ * icon query's words that name one say where the icon goes (spec:AST-084
185
+ * FR6). Empty when there is no Core.
186
+ * @param {string} cwd
187
+ * @returns {string[]}
188
+ */
189
+ export function coreComponentNames(cwd) {
190
+ const project = Project.lastLoaded(cwd);
191
+ try {
192
+ return Object.values(discoverComponents(project?.coreDir() ?? null)).flat();
193
+ } catch {
194
+ return [];
195
+ }
196
+ }
197
+
181
198
  /**
182
199
  * The project directory, its installed icon sets, and the sets withdrawn,
183
200
  * for `experimental icon use`.
@@ -737,7 +737,7 @@ async function redeclareIconSet(
737
737
  .map(icon => icon.id);
738
738
  if (asExtra.length > 0) {
739
739
  throw new AstryxError(
740
- `"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another look (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
740
+ `"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another variant (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
741
741
  undefined,
742
742
  ERROR_CODES.ERR_INVALID_ARGUMENT,
743
743
  );
@@ -800,7 +800,7 @@ async function redeclareIconSet(
800
800
  : `Updated icon set "${name}" in place; its icons, map and generated module are unchanged.`,
801
801
  ...(added.length > 0
802
802
  ? [
803
- `Give each icon its ${added.join(', ')} look: ${added.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${fromFor(variant)} --all --set ${name}\``).join(', ')}, or one icon with \`astryx experimental icon add <Export> --from <module> --id <icon> --variant <name> --set ${name}\`.`,
803
+ `Give each icon its ${added.join(', ')} variant${added.length > 1 ? 's' : ''}: ${added.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${fromFor(variant)} --all --set ${name}\``).join(', ')}, or one icon with \`astryx experimental icon add <Export> --from <module> --id <icon> --variant <name> --set ${name}\`.`,
804
804
  ]
805
805
  : []),
806
806
  ];
@@ -827,10 +827,10 @@ function lookNotes(summary, count, from, looks, name) {
827
827
  variant => variant !== looks?.default && styles.has(variant),
828
828
  );
829
829
  return [
830
- `Found ${count} icons in ${from}, each drawn in several looks (${described}) by ${summary.exports} exports. The set wraps each icon once, in the ${taken} look, named without the look words (\`x\`, \`XIcon\`).`,
830
+ `Found ${count} icons in ${from}, each drawn in several styles, sizes and weights (${described}) by ${summary.exports} exports. The set wraps each icon once, as its ${taken} export, named without those words (\`x\`, \`XIcon\`).`,
831
831
  others.length > 0
832
- ? `Add the ${others.join(', ')} look${others.length > 1 ? 's' : ''} as variant${others.length > 1 ? 's' : ''}: ${others.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${from} --all --set ${name}\``).join(', ')}.`
833
- : `To offer another look as a variant, declare it with \`astryx experimental icon new-set ${name} --variants ${[...summary.preferred].reverse()[0]},<look>\` (no --from: the set's icons stay as they are) and run \`astryx experimental icon add --variant <look> --from ${from} --all --set ${name}\`.`,
832
+ ? `Add ${others.join(', ')} as ${others.length > 1 ? 'variants' : 'a variant'}: ${others.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${from} --all --set ${name}\``).join(', ')}.`
833
+ : `To offer another variant, declare it with \`astryx experimental icon new-set ${name} --variants ${[...summary.preferred].reverse()[0]},<variant>\` (no --from: the set's icons stay as they are) and run \`astryx experimental icon add --variant <variant> --from ${from} --all --set ${name}\`.`,
834
834
  ];
835
835
  }
836
836
 
@@ -1154,7 +1154,7 @@ async function refreshIconSet(
1154
1154
  .map(icon => icon.id);
1155
1155
  if (asExtra.length > 0) {
1156
1156
  throw new AstryxError(
1157
- `"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another look (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
1157
+ `"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another variant (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
1158
1158
  undefined,
1159
1159
  ERROR_CODES.ERR_INVALID_ARGUMENT,
1160
1160
  );
@@ -184,10 +184,10 @@ export function drawnLooks(set, packageDir, positionsOf, options = {}) {
184
184
  */
185
185
  function unknownLook(word, flag, module, positions) {
186
186
  return new AstryxError(
187
- `"${word}" is no look of ${module}: its exports name their looks with ${describedLooks(sortedWords(positions))}. Name one of these words, so each icon's export draws that look.`,
187
+ `"${word}" is no look word of ${module}: its exports name their look words with ${describedLooks(sortedWords(positions))}. Name one of these words, so each icon's export draws that variant.`,
188
188
  styleWords(positions).map(each => ({
189
189
  name: `${flag} ${each}`,
190
- reason: `a look ${module} names`,
190
+ reason: `a look word ${module} names`,
191
191
  })),
192
192
  ERROR_CODES.ERR_INVALID_ARGUMENT,
193
193
  );
@@ -214,11 +214,11 @@ function refreshCommand(name, module, looks) {
214
214
  */
215
215
  function inPlaceMove(name, count, now, looks, module, current) {
216
216
  return new AstryxError(
217
- `Icon set "${name}" can't ${current != null ? `move its default variant from "${current}" to "${looks.default}"` : `take "${looks.default}" as its default variant`} in place: each of its ${count} icons still draws "${now}". Wrap the library again with the new default, so each icon takes that look.`,
217
+ `Icon set "${name}" can't ${current != null ? `move its default variant from "${current}" to "${looks.default}"` : `take "${looks.default}" as its default variant`} in place: each of its ${count} icons still draws "${now}". Wrap the library again with the new default, so each icon takes that variant.`,
218
218
  [
219
219
  {
220
220
  name: refreshCommand(name, module, looks),
221
- reason: 'wrap the library again in the new default look',
221
+ reason: 'wrap the library again in the new default variant',
222
222
  },
223
223
  ],
224
224
  ERROR_CODES.ERR_INVALID_ARGUMENT,
@@ -237,7 +237,7 @@ function inPlaceMove(name, count, now, looks, module, current) {
237
237
  function unencodedMove(name, count, current, looks) {
238
238
  const variants = [...new Set([current, ...looks.variants])];
239
239
  return new AstryxError(
240
- `Icon set "${name}" can't move its default variant from "${current}" to "${looks.default}": its icons' export names name no looks, so each of its ${count} icons draws "${current}", the look its icons' module draws. Keep "${current}" as the default, declare "${looks.default}" as a variant, and add it from the module that draws it (fill <module> with that module).`,
240
+ `Icon set "${name}" can't move its default variant from "${current}" to "${looks.default}": its icons' export names carry no look words, so each of its ${count} icons draws "${current}", the variant its icons' module draws. Keep "${current}" as the default, declare "${looks.default}" as a variant, and add it from the module that draws it (fill <module> with that module).`,
241
241
  [
242
242
  {
243
243
  name: `astryx experimental icon new-set ${name} --variants ${variants.join(',')} --default-variant ${current}`,
@@ -245,7 +245,7 @@ function unencodedMove(name, count, current, looks) {
245
245
  },
246
246
  {
247
247
  name: `astryx experimental icon add --variant ${looks.default} --from <module> --all --set ${name}`,
248
- reason: `give each icon its ${looks.default} look from the module that draws it`,
248
+ reason: `give each icon its ${looks.default} variant from the module that draws it`,
249
249
  },
250
250
  ],
251
251
  ERROR_CODES.ERR_INVALID_ARGUMENT,
@@ -265,15 +265,15 @@ function unencodedMove(name, count, current, looks) {
265
265
  function droppedDefault(name, count, current, looks, from) {
266
266
  const others = looks.variants.filter(variant => variant !== current);
267
267
  return new AstryxError(
268
- `--variants (${looks.variants.join(', ')}) leaves out "${current}", the default variant of icon set "${name}". Its icons' export names name no looks, so each of its ${count} icons still draws "${current}", the look its icons' module draws. List "${current}" in --variants, and add each other look as a variant from the module that draws it (fill <module> with that module).`,
268
+ `--variants (${looks.variants.join(', ')}) leaves out "${current}", the default variant of icon set "${name}". Its icons' export names carry no look words, so each of its ${count} icons still draws "${current}", the variant its icons' module draws. List "${current}" in --variants, and add each other variant from the module that draws it (fill <module> with that module).`,
269
269
  [
270
270
  {
271
271
  name: `astryx experimental icon new-set ${name}${from} --variants ${[current, ...others].join(',')}`,
272
- reason: `keep ${current}, the look each icon draws, as the default`,
272
+ reason: `keep ${current}, the variant each icon draws, as the default`,
273
273
  },
274
274
  ...others.map(variant => ({
275
275
  name: `astryx experimental icon add --variant ${variant} --from <module> --all --set ${name}`,
276
- reason: `give each icon its ${variant} look from the module that draws it`,
276
+ reason: `give each icon its ${variant} variant from the module that draws it`,
277
277
  })),
278
278
  ],
279
279
  ERROR_CODES.ERR_INVALID_OPTION,
@@ -350,13 +350,13 @@ export function resolveDefaultLook({
350
350
  const words = now != null ? now.words : preferredLook(positions, []);
351
351
  const look = drawnWord(positions, words, given.variants);
352
352
  if (look == null || !given.variants.includes(look)) {
353
- const shown = look ?? '<look>';
353
+ const shown = look ?? '<variant>';
354
354
  throw new AstryxError(
355
- `None of --variants (${given.variants.join(', ')}) is the look ${now != null ? `the set's ${now.icons} icons draw` : `${module} is wrapped in by default`} ("${shown}"), and each icon's own export draws the default variant. List it in --variants, or name the default with --default-variant.`,
355
+ `None of --variants (${given.variants.join(', ')}) is the variant ${now != null ? `the set's ${now.icons} icons draw` : `${module} is wrapped in by default`} ("${shown}"), and each icon's own export draws the default variant. List it in --variants, or name the default with --default-variant.`,
356
356
  [
357
357
  {
358
358
  name: `astryx experimental icon new-set ${name}${refresh ? ` --from ${shellArg(/** @type {string} */ (module))}` : ''} --variants ${[shown, ...given.variants].join(',')}`,
359
- reason: `declare ${shown}, the look each icon draws, as the default`,
359
+ reason: `declare ${shown}, the variant each icon draws, as the default`,
360
360
  },
361
361
  ],
362
362
  ERROR_CODES.ERR_INVALID_OPTION,
@@ -386,7 +386,7 @@ function unencodedDefault({name, given, current, icons, module, refresh}) {
386
386
  }
387
387
  if (current == null && icons > 0) {
388
388
  throw new AstryxError(
389
- `Icon set "${name}" declares no default variant, and its icons' export names name none of ${given.variants.join(', ')}. Name the look its ${icons} icons draw with --default-variant.`,
389
+ `Icon set "${name}" declares no default variant, and its icons' export names name none of ${given.variants.join(', ')}. Name the variant its ${icons} icons draw with --default-variant.`,
390
390
  given.variants.map(variant => ({
391
391
  name: `astryx experimental icon new-set ${name}${from} --variants ${given.variants.join(',')} --default-variant ${variant}`,
392
392
  reason: `if each icon draws ${variant}`,
@@ -433,7 +433,7 @@ export function declareVariantSuggestion(set, variant, drawn) {
433
433
  name: `astryx experimental icon new-set ${set.name} --variants ${variants.join(',')} --default-variant ${kept}`,
434
434
  reason:
435
435
  kept === '<default>'
436
- ? 'declare the variants; fill <default> with the look the icons draw'
436
+ ? 'declare the variants; fill <default> with the variant the icons draw'
437
437
  : 'declare the variants',
438
438
  };
439
439
  }
@@ -458,7 +458,7 @@ export function checkVariantLook({set, variant, module, positions, drawn}) {
458
458
  const drawnHere = index >= 0 ? drawn?.words[index] : null;
459
459
  if (set.data.default?.variant === variant || drawnHere === variant) {
460
460
  throw new AstryxError(
461
- `"${variant}" is the look each icon's own export in "${set.name}" already draws${set.data.default?.variant === variant ? ' (its default variant)' : ''}, so a variant of it would export the same artwork twice.`,
461
+ `"${variant}" is the variant each icon's own export in "${set.name}" already draws${set.data.default?.variant === variant ? ' (its default variant)' : ''}, so adding it as a variant would export the same artwork twice.`,
462
462
  undefined,
463
463
  ERROR_CODES.ERR_INVALID_ARGUMENT,
464
464
  );
@@ -466,7 +466,7 @@ export function checkVariantLook({set, variant, module, positions, drawn}) {
466
466
  const declared = set.data.variants ?? [];
467
467
  if (!declared.includes(variant)) {
468
468
  throw new AstryxError(
469
- `Icon set "${set.name}" declares no variant "${variant}"${declared.length > 0 ? ` (it declares ${declared.join(', ')})` : ''}. Declare it first${keptDefault(set, drawn) == null ? ', and name the look its icons draw now as the default variant in place of <default>' : ''}.`,
469
+ `Icon set "${set.name}" declares no variant "${variant}"${declared.length > 0 ? ` (it declares ${declared.join(', ')})` : ''}. Declare it first${keptDefault(set, drawn) == null ? ', and name the variant its icons draw now as the default variant in place of <default>' : ''}.`,
470
470
  [declareVariantSuggestion(set, variant, drawn)],
471
471
  ERROR_CODES.ERR_INVALID_ARGUMENT,
472
472
  );
@@ -357,7 +357,7 @@ export async function iconAdd(exportName, options) {
357
357
  sameIconModule(own.module, source.module)
358
358
  ) {
359
359
  throw new AstryxError(
360
- `"${sourceExport}" is icon "${id}"'s own export, which draws its default look, so it can't be its ${variant} variant too.`,
360
+ `"${sourceExport}" is icon "${id}"'s own export, which draws its default variant, so it can't be its ${variant} variant too.`,
361
361
  undefined,
362
362
  ERROR_CODES.ERR_INVALID_ARGUMENT,
363
363
  );
@@ -759,11 +759,11 @@ async function addVariantForAll({cwd, from, selector, variant}) {
759
759
  ...(set.data.variants ?? []).filter(each => each !== variant),
760
760
  ];
761
761
  throw new AstryxError(
762
- `"${source.module}" is the module the ${own.length} icons of "${set.name}" come from: its exports are those icons in the look they draw now, so "${variant}" is that look and can't be a variant of them. "${set.name}" declares no default variant; declare "${variant}" as the default first.`,
762
+ `"${source.module}" is the module the ${own.length} icons of "${set.name}" come from: its exports already draw those icons as "${variant}", so "${variant}" can't be another variant of them. "${set.name}" declares no default variant; declare "${variant}" as the default first.`,
763
763
  [
764
764
  {
765
765
  name: `astryx experimental icon new-set ${set.name} --variants ${variants.join(',')} --default-variant ${variant}`,
766
- reason: `declare ${variant}, the look each icon draws, as the default`,
766
+ reason: `declare ${variant}, the variant each icon draws, as the default`,
767
767
  },
768
768
  ],
769
769
  ERROR_CODES.ERR_INVALID_ARGUMENT,
@@ -17,7 +17,7 @@ export const doc = {
17
17
  summary:
18
18
  'The icon sets icon() searches in a folder, as plain JSON to store and rank later with rankIconIndex().',
19
19
  description:
20
- "Reads the icon sets `icon()` would search in `cwd` and returns them as `{version, sets, withdrawn}`. Reading them loads each installed package's integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankIconIndex}. With `package`, the index keeps only the sets that package ships, for a catalog that stores one index per package. Paths into the folder are left out, so an index reads the same wherever it was made. A set in the list of the folder's project carries the look that project picks (`look`), so its matches draw that look as `icon()` draws it there. The sets are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
20
+ "Reads the icon sets `icon()` would search in `cwd` and returns them as `{version, sets, withdrawn, components}`. Reading them loads each installed package's integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankIconIndex}. With `package`, the index keeps only the sets that package ships, for a catalog that stores one index per package. Paths into the folder are left out, so an index reads the same wherever it was made. A set in the list of the folder's project carries the look that project picks (`look`), so its matches draw that look as `icon()` draws it there. The sets are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
21
21
  importPath: '@astryxdesign/cli/api',
22
22
  signature:
23
23
  'exportIconIndex(options?: {cwd?: string, package?: string}): Promise<IconIndex>',
@@ -40,7 +40,7 @@ export const doc = {
40
40
  {
41
41
  type: 'IconIndex',
42
42
  description:
43
- '`version`, the CLI version that made it; `sets`, the valid sets in tie order as plain JSON; and `withdrawn`, the sets read but withdrawn, and why.',
43
+ "`version`, the CLI version that made it; `sets`, the valid sets in tie order as plain JSON; `withdrawn`, the sets read but withdrawn, and why; and `components`, the names of the folder's Core components, so a query's words that name one rank as `icon()` ranks them there.",
44
44
  },
45
45
  ],
46
46
  throws: [
@@ -16,7 +16,7 @@ export const doc = {
16
16
  summary:
17
17
  'Find an icon by meaning in the installed icon sets, read one icon, or list the sets.',
18
18
  description:
19
- "Reads every installed icon set's data file, never the icon modules. With words it ranks icons by meaning: an icon definition the set's `map` names the icon for, then exact matches on its id or words, then a word that starts with the query, then partial matches, and for a query of several words that none of those answer, the icons that carry some of its words, rarer words counting more within a set. A word written as an export name (`SearchIcon`) also reads as its words, and the reading with the better match answers. Equal scores keep the project's set first, then integration load order; within a set, a whole-id name match before an id-part one and a meaning match by its tag position; then an icon whose id the query names in full; then id order. With `<set>/<id>` it reads one icon with every variant's import line. With `list` it lists the installed sets, how many icon definitions each one's `map` covers (built-in and all of Astryx's) and its own definitions, and any set withdrawn and why. `search()` and `astryx search` with no `type` answer from the same ranking when a query asks for an icon (one word as typed is `icon` or `icons`, an installed set's name, or an icon export name such as `SearchIcon`, and is not the name of a component or hook; an `icon` or `icons` right after `with`, with only `a`, `an` or `the` between, that no `of` or `for` follows names a feature of an answered component or template, as in `card with an icon`, and asks for none, while `card with an icon of a star` still asks): after `results` they return `icons`, `{matchCount, results}`, with at most 3 icons (fewer when `limit` is smaller), each with `domain: 'icon'`, `name` (`<set>/<id>`), `set`, `id`, `package`, `score`, `reason`, `import` and `command`; text mode lists them last, one line each. It never changes search's `results` or `matchCount`, and it is absent when no icon answers. Experimental: it may change or be removed in a patch release.",
19
+ "Reads every installed icon set's data file, never the icon modules. With words it ranks icons by meaning: an icon definition the set's `map` names the icon for, then exact matches on its id or words, then a word that starts with the query, then partial matches, and for a query of several words that none of those answer, the icons that carry some of its words, rarer words counting more within a set and the words after the icon word that name a component of the project's Core (`information icon popover links`) counting only to break a tie. A word written as an export name (`SearchIcon`) also reads as its words, and the reading with the better match answers. Equal scores keep the project's set first, then integration load order; within a set, a whole-id name match before an id-part one and a meaning match by its tag position; then an icon whose id the query names in full; then id order. With `<set>/<id>` it reads one icon with every variant's import line. With `list` it lists the installed sets, how many icon definitions each one's `map` covers (built-in and all of Astryx's) and its own definitions, and any set withdrawn and why. `search()` and `astryx search` with no `type` answer from the same ranking when a query asks for an icon (one word as typed is `icon` or `icons`, an installed set's name, or an icon export name such as `SearchIcon`, and is not the name of a component or hook; an `icon` or `icons` right after `with`, with only `a`, `an` or `the` between, that no `of` or `for` follows names a feature of an answered component or template, as in `card with an icon`, and asks for none, while `card with an icon of a star` still asks): after `results` they return `icons`, `{matchCount, results}`, with at most 3 icons (fewer when `limit` is smaller), each with `domain: 'icon'`, `name` (`<set>/<id>`), `set`, `id`, `package`, `score`, `reason`, `import` and `command`; text mode lists them last, one line each. It never changes search's `results` or `matchCount`, and it is absent when no icon answers. Experimental: it may change or be removed in a patch release.",
20
20
  importPath: '@astryxdesign/cli/api',
21
21
  signature:
22
22
  'icon(query?: string, options?: IconOptions): Promise<IconSearchResponse | IconDetailResponse | IconListResponse>',
@@ -786,4 +786,8 @@ export type IconIndex = {
786
786
  package: string;
787
787
  reason: string;
788
788
  }>;
789
+ /**
790
+ * - The names of the folder's Core components, so a query's words that name one say where the icon goes, as with `icon()`.
791
+ */
792
+ components?: string[] | undefined;
789
793
  };
@@ -447,6 +447,7 @@
447
447
  * are the ranker's input, not a contract: they may change in any release,
448
448
  * which is why `version` must match.
449
449
  * @property {Array<{name: string, package: string, reason: string}>} withdrawn - The sets read but withdrawn, and why, so a `set` that names one gives the same error as `icon()`.
450
+ * @property {string[]} [components] - The names of the folder's Core components, so a query's words that name one say where the icon goes, as with `icon()`.
450
451
  */
451
452
 
452
453
  export {};
@@ -14,7 +14,11 @@
14
14
  import {cliVersion} from '../../../foundation/release/run-context.mjs';
15
15
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
16
16
  import {AstryxError} from '../../error.mjs';
17
- import {loadIconSets, ownReplacedDefinitions} from '../_adapter.mjs';
17
+ import {
18
+ coreComponentNames,
19
+ loadIconSets,
20
+ ownReplacedDefinitions,
21
+ } from '../_adapter.mjs';
18
22
  import {
19
23
  REFERENCE_RE,
20
24
  checkIconLimit,
@@ -80,6 +84,7 @@ export async function exportIconIndex(options = {}) {
80
84
  withdrawn: withdrawn
81
85
  .filter(kept)
82
86
  .map(({name, package: pkg, reason}) => ({name, package: pkg, reason})),
87
+ components: coreComponentNames(cwd),
83
88
  };
84
89
  }
85
90
 
@@ -121,10 +126,12 @@ export async function rankIconIndex(query, indexes, options = {}) {
121
126
  const sets = [];
122
127
  /** @type {Array<{name: string, package: string, reason: string}>} */
123
128
  const withdrawn = [];
129
+ /** @type {Set<string>} */
130
+ const components = new Set();
124
131
  for (const index of list) {
125
132
  if (index == null || !Array.isArray(index.sets)) {
126
133
  throw new AstryxError(
127
- 'An icon index is {version, sets, withdrawn}, as exportIconIndex() returns it.',
134
+ 'An icon index is {version, sets, withdrawn, components}, as exportIconIndex() returns it.',
128
135
  undefined,
129
136
  ERROR_CODES.ERR_INVALID_ARGUMENT,
130
137
  );
@@ -138,6 +145,7 @@ export async function rankIconIndex(query, indexes, options = {}) {
138
145
  }
139
146
  sets.push(...index.sets);
140
147
  withdrawn.push(...(index.withdrawn ?? []));
148
+ for (const name of index.components ?? []) components.add(name);
141
149
  }
142
150
  // A stored set holds exactly the fields the ranking reads.
143
151
  const ranked = /** @type {Parameters<typeof rankIconSets>[0]} */ (
@@ -148,5 +156,10 @@ export async function rankIconIndex(query, indexes, options = {}) {
148
156
  for (const each of sets) {
149
157
  if (each.look) looks[`${each.package}/${each.name}`] = each.look;
150
158
  }
151
- return rankIconSets(ranked, withdrawn, term, {set, limit, looks});
159
+ return rankIconSets(ranked, withdrawn, term, {
160
+ set,
161
+ limit,
162
+ looks,
163
+ componentNames: () => components,
164
+ });
152
165
  }
@@ -48,20 +48,23 @@ export function projectLooks(choice: import("../../../foundation/discovery/icon-
48
48
  * @param {Parameters<typeof rankIcons>[0]} sets in tie order
49
49
  * @param {Array<{name: string, package: string, reason: string}>} withdrawn
50
50
  * @param {string} query
51
- * @param {{set?: string, limit: number, looks?: Record<string, string>, discoverListsPacks?: boolean}} options
51
+ * @param {{set?: string, limit: number, looks?: Record<string, string>, discoverListsPacks?: boolean, componentNames?: () => Iterable<string>}} options
52
52
  * `looks`: the look each set draws, by `<package>/<set>`;
53
- * `discoverListsPacks`: discover lists an icon set the project could add
53
+ * `discoverListsPacks`: discover lists an icon set the project could add;
54
+ * `componentNames`: the component names a query's words may name to say
55
+ * where the icon goes
54
56
  * @returns {import('../icon.type.mjs').IconSearchResponse}
55
57
  */
56
58
  export function rankIconSets(sets: Parameters<typeof rankIcons>[0], withdrawn: Array<{
57
59
  name: string;
58
60
  package: string;
59
61
  reason: string;
60
- }>, query: string, { set, limit, looks, discoverListsPacks }: {
62
+ }>, query: string, { set, limit, looks, discoverListsPacks, componentNames }: {
61
63
  set?: string;
62
64
  limit: number;
63
65
  looks?: Record<string, string>;
64
66
  discoverListsPacks?: boolean;
67
+ componentNames?: () => Iterable<string>;
65
68
  }): import("../icon.type.mjs").IconSearchResponse;
66
69
  /**
67
70
  * The icon definitions that answer a query, each with its score, ranked as
@@ -70,9 +73,13 @@ export function rankIconSets(sets: Parameters<typeof rankIcons>[0], withdrawn: A
70
73
  * @param {import('../../../authoring/doctypes/icon-definition/type').IconDefinitionDoc[]} [docs]
71
74
  * @param {Replacements} [replacements] the old names of a set's own
72
75
  * definitions among `docs`, so that a name they replaced answers too
76
+ * @param {{componentNames?: () => Iterable<string>}} [options] the
77
+ * component names a query's words may name to say where the icon goes
73
78
  * @returns {Array<{doc: import('../../../authoring/doctypes/icon-definition/type').IconDefinitionDoc, score: number}>}
74
79
  */
75
- export function definitionMatches(query: string, docs?: import("../../../authoring/doctypes/icon-definition/type").IconDefinitionDoc[], replacements?: Replacements): Array<{
80
+ export function definitionMatches(query: string, docs?: import("../../../authoring/doctypes/icon-definition/type").IconDefinitionDoc[], replacements?: Replacements, { componentNames }?: {
81
+ componentNames?: () => Iterable<string>;
82
+ }): Array<{
76
83
  doc: import("../../../authoring/doctypes/icon-definition/type").IconDefinitionDoc;
77
84
  score: number;
78
85
  }>;
@@ -12,6 +12,7 @@
12
12
 
13
13
  import {
14
14
  astryxIconDefinitions,
15
+ coreComponentNames,
15
16
  discoverListsIconSet,
16
17
  definitionRelatives,
17
18
  iconExportName,
@@ -78,11 +79,14 @@ export async function iconSetIcons({cwd, set}) {
78
79
  export async function iconSearch(query, {cwd, set, limit}) {
79
80
  const {sets, withdrawn, choice} = await loadIconSets(cwd);
80
81
  const noSet = sets.length === 0 && withdrawn.length === 0;
82
+ /** @type {string[] | undefined} */
83
+ let names;
81
84
  return rankIconSets(sets, withdrawn, query, {
82
85
  set,
83
86
  limit,
84
87
  looks: projectLooks(choice),
85
88
  discoverListsPacks: noSet && (await discoverListsIconSet(cwd)),
89
+ componentNames: () => (names ??= coreComponentNames(cwd)),
86
90
  });
87
91
  }
88
92
 
@@ -98,9 +102,11 @@ export async function iconSearch(query, {cwd, set, limit}) {
98
102
  * @param {string} query
99
103
  * @param {Parameters<typeof rankIcons>[0]} sets the searched sets, whose own
100
104
  * definitions rank with Astryx's
105
+ * @param {() => Iterable<string>} [componentNames] the component names a
106
+ * query's words may name to say where the icon goes
101
107
  * @returns {import('../icon.type.mjs').IconMatchEntry[]}
102
108
  */
103
- function withMeaningImports(matches, query, sets) {
109
+ function withMeaningImports(matches, query, sets, componentNames) {
104
110
  if (!matches.some(match => match.definitions.length > 0)) return matches;
105
111
  /** @type {Map<unknown, (name: string) => number>} */
106
112
  const ranks = new Map();
@@ -114,7 +120,7 @@ function withMeaningImports(matches, query, sets) {
114
120
  const key = own.length > 0 ? set : null;
115
121
  let rank = ranks.get(key);
116
122
  if (!rank) {
117
- rank = meaningRank(query, set);
123
+ rank = meaningRank(query, set, componentNames);
118
124
  ranks.set(key, rank);
119
125
  }
120
126
  return rank;
@@ -145,9 +151,11 @@ function withMeaningImports(matches, query, sets) {
145
151
  * @param {string} query
146
152
  * @param {Parameters<typeof rankIcons>[0][number] | undefined} set the
147
153
  * match's set
154
+ * @param {() => Iterable<string>} [componentNames] the component names a
155
+ * query's words may name to say where the icon goes
148
156
  * @returns {(name: string) => number}
149
157
  */
150
- function meaningRank(query, set) {
158
+ function meaningRank(query, set, componentNames) {
151
159
  const own = set?.definitions ?? [];
152
160
  const astryx = astryxIconDefinitions().definitions.map(each => each.doc);
153
161
  const names = new Set(astryx.map(doc => doc.name));
@@ -155,7 +163,7 @@ function meaningRank(query, set) {
155
163
  ...astryx,
156
164
  ...own.map(each => each.doc).filter(doc => !names.has(doc.name)),
157
165
  ];
158
- const matched = definitionMatches(query, docs, set).map(
166
+ const matched = definitionMatches(query, docs, set, {componentNames}).map(
159
167
  match => match.doc.name,
160
168
  );
161
169
  const place = new Map(matched.map((name, index) => [name, index]));
@@ -194,16 +202,18 @@ export function projectLooks(choice) {
194
202
  * @param {Parameters<typeof rankIcons>[0]} sets in tie order
195
203
  * @param {Array<{name: string, package: string, reason: string}>} withdrawn
196
204
  * @param {string} query
197
- * @param {{set?: string, limit: number, looks?: Record<string, string>, discoverListsPacks?: boolean}} options
205
+ * @param {{set?: string, limit: number, looks?: Record<string, string>, discoverListsPacks?: boolean, componentNames?: () => Iterable<string>}} options
198
206
  * `looks`: the look each set draws, by `<package>/<set>`;
199
- * `discoverListsPacks`: discover lists an icon set the project could add
207
+ * `discoverListsPacks`: discover lists an icon set the project could add;
208
+ * `componentNames`: the component names a query's words may name to say
209
+ * where the icon goes
200
210
  * @returns {import('../icon.type.mjs').IconSearchResponse}
201
211
  */
202
212
  export function rankIconSets(
203
213
  sets,
204
214
  withdrawn,
205
215
  query,
206
- {set, limit, looks = {}, discoverListsPacks = false},
216
+ {set, limit, looks = {}, discoverListsPacks = false, componentNames},
207
217
  ) {
208
218
  let searched = sets;
209
219
  if (set != null) {
@@ -212,9 +222,9 @@ export function rankIconSets(
212
222
  }
213
223
  // A withdrawn set is installed: `--list` says why it cannot be used.
214
224
  if (sets.length === 0 && withdrawn.length === 0) {
215
- return noIconSet(query, limit, discoverListsPacks);
225
+ return noIconSet(query, limit, discoverListsPacks, componentNames);
216
226
  }
217
- const ranked = rankIcons(searched, query, {words: true});
227
+ const ranked = rankIcons(searched, query, {words: true, componentNames});
218
228
  // A word start (`start` for `star`) answers only when nothing matches a
219
229
  // whole word, and a partial match (`pin` inside `shopping`) only when
220
230
  // nothing matches a whole word or a word start.
@@ -232,6 +242,7 @@ export function rankIconSets(
232
242
  ),
233
243
  query,
234
244
  searched,
245
+ componentNames,
235
246
  ),
236
247
  },
237
248
  };
@@ -299,12 +310,16 @@ function inLook(match, sets, looks) {
299
310
  * @param {string} query
300
311
  * @param {number} limit
301
312
  * @param {boolean} discoverListsPacks
313
+ * @param {() => Iterable<string>} [componentNames] the component names a
314
+ * query's words may name to say where the icon goes
302
315
  * @returns {import('../icon.type.mjs').IconSearchResponse}
303
316
  */
304
- function noIconSet(query, limit, discoverListsPacks) {
317
+ function noIconSet(query, limit, discoverListsPacks, componentNames) {
305
318
  const docs = astryxIconDefinitions().definitions.map(each => each.doc);
306
319
  const byName = new Map(docs.map(doc => [doc.name, doc]));
307
- const found = definitionMatches(query).map(match => match.doc);
320
+ const found = definitionMatches(query, docs, {}, {componentNames}).map(
321
+ match => match.doc,
322
+ );
308
323
  const matched = new Set(
309
324
  found.filter(doc => doc.builtIn).map(doc => doc.name),
310
325
  );
@@ -368,16 +383,22 @@ function noIconSet(query, limit, discoverListsPacks) {
368
383
  * @param {import('../../../authoring/doctypes/icon-definition/type').IconDefinitionDoc[]} [docs]
369
384
  * @param {Replacements} [replacements] the old names of a set's own
370
385
  * definitions among `docs`, so that a name they replaced answers too
386
+ * @param {{componentNames?: () => Iterable<string>}} [options] the
387
+ * component names a query's words may name to say where the icon goes
371
388
  * @returns {Array<{doc: import('../../../authoring/doctypes/icon-definition/type').IconDefinitionDoc, score: number}>}
372
389
  */
373
390
  export function definitionMatches(
374
391
  query,
375
392
  docs = astryxIconDefinitions().definitions.map(each => each.doc),
376
393
  replacements = {},
394
+ {componentNames} = {},
377
395
  ) {
378
396
  const byId = new Map(docs.map(doc => [definitionId(doc.name), doc]));
379
397
  return answeringMatches(
380
- rankIcons([definitionSet(docs, replacements)], query, {words: true}),
398
+ rankIcons([definitionSet(docs, replacements)], query, {
399
+ words: true,
400
+ componentNames,
401
+ }),
381
402
  ).map(match => ({
382
403
  doc: /** @type {(typeof docs)[number]} */ (byId.get(match.id)),
383
404
  score: match.score,
@@ -77,21 +77,21 @@ function checkVariant(main, selector, backups, variant) {
77
77
  const fallback = main.data.default?.variant;
78
78
  throw new AstryxError(
79
79
  declared.length === 0
80
- ? `Icon set "${iconSetKey(main)}" declares no variants: it draws one look, so it takes no --variant.`
80
+ ? `Icon set "${iconSetKey(main)}" declares no variants, so it takes no --variant.`
81
81
  : `Icon set "${iconSetKey(main)}" declares no "${variant}" variant. Its variants: ${declared.join(', ')}.`,
82
82
  declared.length === 0
83
83
  ? [
84
84
  {
85
85
  name: iconUseCommand(selector, backups),
86
- reason: 'use it in its one look',
86
+ reason: 'use it as it is',
87
87
  },
88
88
  ]
89
89
  : declared.map(each => ({
90
90
  name: iconUseCommand(selector, backups, each),
91
91
  reason:
92
92
  each === fallback
93
- ? `its default look, ${each}`
94
- : `its ${each} look`,
93
+ ? `its default variant, ${each}`
94
+ : `its ${each} variant`,
95
95
  })),
96
96
  ERROR_CODES.ERR_INVALID_ARGUMENT,
97
97
  );
@@ -6,8 +6,8 @@
6
6
  * CLI/Core version, or build command look like source drift. Normalization
7
7
  * applies only to a file whose first comment is the generated header with
8
8
  * exactly one well-formed Source, CLI, and Core line; it covers those lines
9
- * and, in a built module, the one `built by` line that names the command
10
- * (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
9
+ * and, in a built module, each `built by` line that names the command, one
10
+ * per theme (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
11
11
  * malformed, reordered, or any other bytes stay significant. `theme build
12
12
  * --check` stays strict about the Source and Core lines; the CLI line and the
13
13
  * command in the built-by line count for neither.
@@ -109,8 +109,8 @@ const CORE_VERSION_LINE = /^( \* Core: @astryxdesign\/core@)(\S+)(\s*)$/u;
109
109
  * CLI/Core version, or build command look like source drift. Normalization
110
110
  * applies only to a file whose first comment is the generated header with
111
111
  * exactly one well-formed Source, CLI, and Core line; it covers those lines
112
- * and, in a built module, the one `built by` line that names the command
113
- * (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
112
+ * and, in a built module, each `built by` line that names the command, one
113
+ * per theme (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
114
114
  * malformed, reordered, or any other bytes stay significant. `theme build
115
115
  * --check` stays strict about the Source and Core lines; the CLI line and the
116
116
  * command in the built-by line count for neither.
@@ -68,6 +68,9 @@ export async function searchIconSection(
68
68
  if (!iconFeatureGate(project).on) return null;
69
69
  const loaded = /** @type {Project} */ (project);
70
70
  const {iconSection} = await import('./_icons.mjs');
71
+ const {coreComponentNames} = await import('../icon/_adapter.mjs');
72
+ /** @type {string[] | undefined} */
73
+ let names;
71
74
  return iconSection(
72
75
  query,
73
76
  {
@@ -87,6 +90,7 @@ export async function searchIconSection(
87
90
  };
88
91
  }
89
92
  },
93
+ componentNames: () => (names ??= coreComponentNames(cwd)),
90
94
  },
91
95
  {declaredNames, resultDomains, limit},
92
96
  );