@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
@@ -94,6 +94,18 @@ import {doc as themeTemplateFn} from '../../../api/theme/themeTemplate.doc.mjs';
94
94
  import {doc as themeTargetsFn} from '../../../api/theme/themeTargets.doc.mjs';
95
95
  import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGenerate.doc.mjs';
96
96
 
97
+ /**
98
+ * The words a theme command is run with: `theme build` here, and the copies
99
+ * under `experimental theme`, where `build` is called `compile`. The actions
100
+ * and API calls are the same; only these words and the docs differ.
101
+ * @typedef {object} ThemeCommandWords
102
+ * @property {string} group - The group's command path: `theme` or `experimental theme`.
103
+ * @property {string} build - The build subcommand's name: `build` or `compile`.
104
+ */
105
+
106
+ /** @type {ThemeCommandWords} */
107
+ const THEME_WORDS = {group: 'theme', build: 'build'};
108
+
97
109
  /**
98
110
  * Path to this CLI's real entry (clients/cli/bin/astryx.mjs), resolved from
99
111
  * this module's location (clients/cli/commands/theme.mjs → ../bin/
@@ -115,14 +127,16 @@ function resolveCliBin() {
115
127
  * level the user chose.
116
128
  * @param {(child: import('node:child_process').ChildProcess) => void} [onSpawn] -
117
129
  * Receives the child, so a watcher that stops can stop it too.
130
+ * @param {ThemeCommandWords} [words]
118
131
  * @returns {Promise<number>}
119
132
  */
120
- function runThemeBuildOnceChild(file, options, onSpawn) {
133
+ function runThemeBuildOnceChild(file, options, onSpawn, words = THEME_WORDS) {
121
134
  const cliBin = resolveCliBin();
135
+ const command = [...words.group.split(' '), words.build];
122
136
  // A detail level the user chose applies to every rebuild.
123
137
  const args = options.detail
124
- ? [cliBin, '--detail', options.detail, 'theme', 'build', file]
125
- : [cliBin, 'theme', 'build', file];
138
+ ? [cliBin, '--detail', options.detail, ...command, file]
139
+ : [cliBin, ...command, file];
126
140
  if (options.out) args.push('--out', options.out);
127
141
  if (options.iconsSpecifier)
128
142
  args.push('--icons-specifier', options.iconsSpecifier);
@@ -150,9 +164,10 @@ function runThemeBuildOnceChild(file, options, onSpawn) {
150
164
  * @param {Array<{file: string, filePath: string}>} entries - The theme file
151
165
  * arguments as the user passed them, with their resolved absolute paths.
152
166
  * @param {{out?: string, iconsSpecifier?: string, detail?: string}} options - Parsed command options, plus the detail level the user chose.
167
+ * @param {ThemeCommandWords} [words]
153
168
  * @returns {Promise<void>} Resolves when the watcher is stopped (Ctrl-C).
154
169
  */
155
- async function runThemeBuildWatch(entries, options) {
170
+ async function runThemeBuildWatch(entries, options, words = THEME_WORDS) {
156
171
  const rel = (/** @type {string} */ filePath) =>
157
172
  path.relative(process.cwd(), filePath);
158
173
  const watchingLine = `\nWatching ${entries
@@ -161,7 +176,7 @@ async function runThemeBuildWatch(entries, options) {
161
176
 
162
177
  // Initial build.
163
178
  for (const entry of entries) {
164
- await runThemeBuildOnceChild(entry.file, options);
179
+ await runThemeBuildOnceChild(entry.file, options, undefined, words);
165
180
  }
166
181
 
167
182
  let building = false;
@@ -185,9 +200,14 @@ async function runThemeBuildWatch(entries, options) {
185
200
  }
186
201
  building = true;
187
202
  emit(text(`\nChange detected — rebuilding ${rel(entry.filePath)}...`));
188
- const done = runThemeBuildOnceChild(entry.file, options, child => {
189
- rebuildChild = child;
190
- });
203
+ const done = runThemeBuildOnceChild(
204
+ entry.file,
205
+ options,
206
+ child => {
207
+ rebuildChild = child;
208
+ },
209
+ words,
210
+ );
191
211
  rebuildDone = done.then(() => {});
192
212
  await done;
193
213
  rebuildChild = null;
@@ -268,8 +288,9 @@ async function warnOnThemeIntegrationIssues(json) {
268
288
  * Print cleanup-stage `theme add --list`. Its JSON stays the released
269
289
  * `theme.list`; its text names the cleanup commands (AST-050 FR12).
270
290
  * @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry[]} themes
291
+ * @param {ThemeCommandWords} [words]
271
292
  */
272
- function printThemeAddList(themes) {
293
+ function printThemeAddList(themes, words = THEME_WORDS) {
273
294
  const run = getCliInvocation();
274
295
  // `theme list` shows what this project can add now. Themes in packages it
275
296
  // has not installed are `discover`'s.
@@ -289,7 +310,7 @@ function printThemeAddList(themes) {
289
310
  return theme.description ? [head, theme.description] : head;
290
311
  }),
291
312
  ),
292
- text(themeNextSteps(run)),
313
+ text(themeNextSteps(run, words)),
293
314
  more,
294
315
  );
295
316
  }
@@ -298,13 +319,14 @@ function printThemeAddList(themes) {
298
319
  * What to do with a listed theme. Outside a project there is no app to add one
299
320
  * to, so only the fork step is named (spec AST-081 FR3).
300
321
  * @param {string} run the CLI invocation
322
+ * @param {ThemeCommandWords} [words]
301
323
  * @returns {string}
302
324
  */
303
- function themeNextSteps(run) {
304
- const fork = `Fork source: ${run} theme eject <slug> [target-path]`;
325
+ function themeNextSteps(run, words = THEME_WORDS) {
326
+ const fork = `Fork source: ${run} ${words.group} eject <slug> [target-path]`;
305
327
  return isOutsideProject()
306
328
  ? fork
307
- : `Import one: ${run} theme add <slug> [--package <package>]\n${fork}`;
329
+ : `Import one: ${run} ${words.group} add <slug> [--package <package>]\n${fork}`;
308
330
  }
309
331
 
310
332
  /**
@@ -312,8 +334,9 @@ function themeNextSteps(run) {
312
334
  * because each record names its owner.
313
335
  * @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry[]} themes
314
336
  * @param {import('../../../api/theme/theme.type.mjs').ThemeUnmigratedCopy[]} [unmigratedCopies]
337
+ * @param {ThemeCommandWords} [words]
315
338
  */
316
- function printThemeList(themes, unmigratedCopies = []) {
339
+ function printThemeList(themes, unmigratedCopies = [], words = THEME_WORDS) {
317
340
  const run = getCliInvocation();
318
341
  const more = text(
319
342
  `More themes in packages you could add: ${run} discover theme`,
@@ -341,7 +364,7 @@ function printThemeList(themes, unmigratedCopies = []) {
341
364
  default: (/** @type {boolean} */ value) => (value ? 'yes' : 'no'),
342
365
  },
343
366
  }),
344
- text(themeNextSteps(run)),
367
+ text(themeNextSteps(run, words)),
345
368
  more,
346
369
  );
347
370
  }
@@ -420,8 +443,9 @@ function printThemeApp(result) {
420
443
  /**
421
444
  * Print every field in a source-fork receipt.
422
445
  * @param {import('../../../api/theme/theme.type.mjs').ThemeEjectResponse} result
446
+ * @param {ThemeCommandWords} [words]
423
447
  */
424
- function printThemeEject(result) {
448
+ function printThemeEject(result, words = THEME_WORDS) {
425
449
  const {data} = result;
426
450
  emit(
427
451
  section('Ejected theme'),
@@ -439,11 +463,40 @@ function printThemeEject(result) {
439
463
  layout: 'stacked',
440
464
  }),
441
465
  text(
442
- `This is a local fork. Build it with ${getCliInvocation()} theme build ${path.join(data.outputDir, data.entry)}.`,
466
+ `This is a local fork. Build it with ${getCliInvocation()} ${words.group} ${words.build} ${path.join(data.outputDir, data.entry)}.`,
443
467
  ),
444
468
  );
445
469
  }
446
470
 
471
+ /**
472
+ * The CommandDocs one copy of the theme subcommands is built from.
473
+ * @typedef {object} ThemeCommandDocs
474
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} palette
475
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} paletteGenerate
476
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} build
477
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} list
478
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} add
479
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} remove
480
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} use
481
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} eject
482
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} template
483
+ * @property {import('@astryxdesign/cli/authoring').CommandDoc} targets
484
+ */
485
+
486
+ /** @type {ThemeCommandDocs} */
487
+ const THEME_DOCS = {
488
+ palette: themePaletteGroup,
489
+ paletteGenerate: themePaletteGenerateCommand,
490
+ build: themeBuildCommand,
491
+ list: themeListCommand,
492
+ add: themeAddCommand,
493
+ remove: themeRemoveCommand,
494
+ use: themeUseCommand,
495
+ eject: themeEjectCommand,
496
+ template: themeTemplateCommand,
497
+ targets: themeTargetsCommand,
498
+ };
499
+
447
500
  /**
448
501
  * @param {import('commander').Command} program
449
502
  */
@@ -487,7 +540,21 @@ export function registerTheme(program) {
487
540
  ` ${getCliInvocation()} docs theme How component overrides work\n`,
488
541
  );
489
542
 
490
- const palette = defineCommand(theme, themePaletteGroup, {
543
+ registerThemeSubcommands(theme, program, THEME_DOCS, THEME_WORDS);
544
+ }
545
+
546
+ /**
547
+ * Register the theme subcommands under a group: palette (generate), build,
548
+ * list, add, remove, use, eject, template and targets. `astryx theme` and the
549
+ * copies under `astryx experimental theme` share these actions and their API
550
+ * calls; `docs` and `words` give each copy its own names.
551
+ * @param {import('commander').Command} theme the group to register under
552
+ * @param {import('commander').Command} program the root program
553
+ * @param {ThemeCommandDocs} docs
554
+ * @param {ThemeCommandWords} words
555
+ */
556
+ export function registerThemeSubcommands(theme, program, docs, words) {
557
+ const palette = defineCommand(theme, docs.palette, {
491
558
  action: (
492
559
  /** @type {unknown} */ options,
493
560
  /** @type {import('commander').Command} */ cmd,
@@ -499,7 +566,7 @@ export function registerTheme(program) {
499
566
  reason: 'available subcommand',
500
567
  }));
501
568
  return cliError(
502
- `unknown subcommand 'theme palette ${String(extras[0])}'`,
569
+ `unknown subcommand '${words.group} palette ${String(extras[0])}'`,
503
570
  {
504
571
  suggestions,
505
572
  code: ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND,
@@ -511,7 +578,7 @@ export function registerTheme(program) {
511
578
  },
512
579
  });
513
580
 
514
- defineCommand(palette, themePaletteGenerateCommand, {
581
+ defineCommand(palette, docs.paletteGenerate, {
515
582
  fn: themePaletteGenerateFn,
516
583
  action: (
517
584
  /** @type {string} */ configPath,
@@ -576,7 +643,7 @@ export function registerTheme(program) {
576
643
  },
577
644
  });
578
645
 
579
- defineCommand(theme, themeBuildCommand, {
646
+ defineCommand(theme, docs.build, {
580
647
  fn: themeBuildFn,
581
648
  action: async (
582
649
  /** @type {string[]} */ files,
@@ -605,7 +672,7 @@ export function registerTheme(program) {
605
672
  suggestions: looksGlobby
606
673
  ? [
607
674
  {
608
- name: `astryx theme build ${entry.file.replace(/['"]/g, '')}`,
675
+ name: `astryx ${words.group} ${words.build} ${entry.file.replace(/['"]/g, '')}`,
609
676
  reason:
610
677
  'globs are expanded by your shell; pass the pattern unquoted, or list the files',
611
678
  },
@@ -665,7 +732,7 @@ export function registerTheme(program) {
665
732
  code: ERROR_CODES.ERR_THEME_INVALID,
666
733
  });
667
734
  }
668
- await runThemeBuildWatch(entries, {...options, detail});
735
+ await runThemeBuildWatch(entries, {...options, detail}, words);
669
736
  return NO_RESULT_SET;
670
737
  }
671
738
 
@@ -817,7 +884,7 @@ export function registerTheme(program) {
817
884
  },
818
885
  });
819
886
 
820
- defineCommand(theme, themeListCommand, {
887
+ defineCommand(theme, docs.list, {
821
888
  fn: themeListFn,
822
889
  action: async (/** @type {{package?: string}} */ options) => {
823
890
  const json = program.opts().json || false;
@@ -847,12 +914,12 @@ export function registerTheme(program) {
847
914
  return answered;
848
915
  }
849
916
 
850
- printThemeList(result.data, result.meta?.unmigratedCopies);
917
+ printThemeList(result.data, result.meta?.unmigratedCopies, words);
851
918
  return answered;
852
919
  },
853
920
  });
854
921
 
855
- const themeAddCli = defineCommand(theme, themeAddCommand, {
922
+ const themeAddCli = defineCommand(theme, docs.add, {
856
923
  fn: themeAddFn,
857
924
  action: async (
858
925
  /** @type {string | undefined} */ slug,
@@ -893,7 +960,7 @@ export function registerTheme(program) {
893
960
  return answered;
894
961
  }
895
962
  if (result.type === 'theme.list') {
896
- printThemeAddList(result.data);
963
+ printThemeAddList(result.data, words);
897
964
  return answered;
898
965
  }
899
966
  printThemeApp(result);
@@ -903,7 +970,7 @@ export function registerTheme(program) {
903
970
  // Reject the removed target-path argument in Commander's standard parse path.
904
971
  themeAddCli.allowExcessArguments(false);
905
972
 
906
- defineCommand(theme, themeRemoveCommand, {
973
+ defineCommand(theme, docs.remove, {
907
974
  fn: themeRemoveFn,
908
975
  action: async (/** @type {string} */ slug) => {
909
976
  const json = program.opts().json || false;
@@ -926,7 +993,7 @@ export function registerTheme(program) {
926
993
  },
927
994
  });
928
995
 
929
- defineCommand(theme, themeUseCommand, {
996
+ defineCommand(theme, docs.use, {
930
997
  fn: themeUseFn,
931
998
  action: async (/** @type {string} */ slug) => {
932
999
  const json = program.opts().json || false;
@@ -949,7 +1016,7 @@ export function registerTheme(program) {
949
1016
  },
950
1017
  });
951
1018
 
952
- defineCommand(theme, themeEjectCommand, {
1019
+ defineCommand(theme, docs.eject, {
953
1020
  fn: themeEjectFn,
954
1021
  action: async (
955
1022
  /** @type {string} */ slug,
@@ -976,12 +1043,12 @@ export function registerTheme(program) {
976
1043
  }
977
1044
  await warnOnThemeIntegrationIssues(json);
978
1045
  if (json) jsonOut(result);
979
- else printThemeEject(result);
1046
+ else printThemeEject(result, words);
980
1047
  return NO_RESULT_SET;
981
1048
  },
982
1049
  });
983
1050
 
984
- defineCommand(theme, themeTemplateCommand, {
1051
+ defineCommand(theme, docs.template, {
985
1052
  fn: themeTemplateFn,
986
1053
  action: (
987
1054
  /** @type {string | undefined} */ targetPath,
@@ -1026,13 +1093,13 @@ export function registerTheme(program) {
1026
1093
  'It documents every defineTheme field, the token families, and the component override syntax. ' +
1027
1094
  'Copy what you need into your own theme file, then delete it.',
1028
1095
  ),
1029
- code(`${invocation} theme build ${result.data.path}`),
1096
+ code(`${invocation} ${words.group} ${words.build} ${result.data.path}`),
1030
1097
  );
1031
1098
  return NO_RESULT_SET;
1032
1099
  },
1033
1100
  });
1034
1101
 
1035
- defineCommand(theme, themeTargetsCommand, {
1102
+ defineCommand(theme, docs.targets, {
1036
1103
  fn: themeTargetsFn,
1037
1104
  action: async (/** @type {string | undefined} */ filter) => {
1038
1105
  const json = program.opts().json || false;
@@ -106,6 +106,22 @@ export const JSON_SUPPORTED = new Set([
106
106
  'experimental icon new-set',
107
107
  'experimental icon new-definition',
108
108
  'experimental render',
109
+ 'experimental theme new',
110
+ 'experimental theme set',
111
+ 'experimental theme reset',
112
+ 'experimental theme show',
113
+ 'experimental theme undo',
114
+ 'experimental theme preview',
115
+ 'experimental theme explain',
116
+ 'experimental theme compile',
117
+ 'experimental theme list',
118
+ 'experimental theme add',
119
+ 'experimental theme remove',
120
+ 'experimental theme use',
121
+ 'experimental theme eject',
122
+ 'experimental theme template',
123
+ 'experimental theme targets',
124
+ 'experimental theme palette generate',
109
125
  'build',
110
126
  'swizzle',
111
127
  'gap-report',
@@ -137,6 +137,9 @@ export function defineCommand(parent, doc, {fn, action, hidden} = {}) {
137
137
  const base = cmd.description() || '';
138
138
  cmd.description(`${base} [DEPRECATED: ${doc.deprecated}]`);
139
139
  }
140
+ if (doc.replaces?.length) {
141
+ cmd.addHelpText('before', `Will replace: ${doc.replaces.map(name => `astryx ${name}`).join(', ')}\n`);
142
+ }
140
143
 
141
144
  const paramDesc = (/** @type {string | undefined} */ name) =>
142
145
  (fn?.params ?? []).find(p => p.name === name)?.description ?? '';
@@ -32,6 +32,10 @@ export function iconSetIssues(packageDir: string, loaded: {
32
32
  * {@link suggestedIcons} gives, if any
33
33
  * @property {IconSetUnchecked[]} unchecked what the checks could not judge:
34
34
  * never counted, never failing, even under `--strict`
35
+ * @property {{unmapped: import('./template-icon-meanings.mjs').TemplateMeaning[]}} [templateMeanings]
36
+ * the icon definitions the bundled templates use that the set's `map` does
37
+ * not name, most used first: a copied template renders a placeholder for
38
+ * each. Never counted, never failing
35
39
  */
36
40
  /**
37
41
  * Which icon definitions each valid set under a package's
@@ -40,12 +44,15 @@ export function iconSetIssues(packageDir: string, loaded: {
40
44
  * @param {{name: string, iconSets?: string}} loaded
41
45
  * @param {Map<string, IconSetUnchecked[]>} [unchecked] what
42
46
  * {@link iconSetIssues} could not judge, by set name
47
+ * @param {import('./template-icon-meanings.mjs').TemplateMeaning[]} [templateMeanings]
48
+ * the definitions the bundled templates use; each set lists the ones it
49
+ * leaves unmapped
43
50
  * @returns {IconSetCoverage[]}
44
51
  */
45
52
  export function iconSetCoverage(loaded: {
46
53
  name: string;
47
54
  iconSets?: string;
48
- }, unchecked?: Map<string, IconSetUnchecked[]>): IconSetCoverage[];
55
+ }, unchecked?: Map<string, IconSetUnchecked[]>, templateMeanings?: import("./template-icon-meanings.mjs").TemplateMeaning[]): IconSetCoverage[];
49
56
  /**
50
57
  * The best icon {@link suggestedIcons} gives for a definition, or null when
51
58
  * it gives none.
@@ -171,6 +178,14 @@ export type IconSetCoverage = {
171
178
  * never counted, never failing, even under `--strict`
172
179
  */
173
180
  unchecked: IconSetUnchecked[];
181
+ /**
182
+ * the icon definitions the bundled templates use that the set's `map` does
183
+ * not name, most used first: a copied template renders a placeholder for
184
+ * each. Never counted, never failing
185
+ */
186
+ templateMeanings?: {
187
+ unmapped: import("./template-icon-meanings.mjs").TemplateMeaning[];
188
+ } | undefined;
174
189
  };
175
190
  export type Issue = import("../integrations/issue").AstryxIntegrationIssue;
176
191
  export type DiscoveredIconSet = import("./icon-set-discovery.mjs").DiscoveredIconSet;
@@ -69,6 +69,7 @@ import {
69
69
  } from './module-exports.mjs';
70
70
  import {astryxIconDefinitions} from './icon-definition-discovery.mjs';
71
71
  import {rankIcons} from './icon-ranking.mjs';
72
+ import {unmappedTemplateMeanings} from './template-icon-meanings.mjs';
72
73
  import {shellArg} from '../text/shell-arg.mjs';
73
74
  import {
74
75
  issueError,
@@ -405,6 +406,10 @@ function checkDefinitions(set) {
405
406
  * {@link suggestedIcons} gives, if any
406
407
  * @property {IconSetUnchecked[]} unchecked what the checks could not judge:
407
408
  * never counted, never failing, even under `--strict`
409
+ * @property {{unmapped: import('./template-icon-meanings.mjs').TemplateMeaning[]}} [templateMeanings]
410
+ * the icon definitions the bundled templates use that the set's `map` does
411
+ * not name, most used first: a copied template renders a placeholder for
412
+ * each. Never counted, never failing
408
413
  */
409
414
 
410
415
  /**
@@ -414,9 +419,16 @@ function checkDefinitions(set) {
414
419
  * @param {{name: string, iconSets?: string}} loaded
415
420
  * @param {Map<string, IconSetUnchecked[]>} [unchecked] what
416
421
  * {@link iconSetIssues} could not judge, by set name
422
+ * @param {import('./template-icon-meanings.mjs').TemplateMeaning[]} [templateMeanings]
423
+ * the definitions the bundled templates use; each set lists the ones it
424
+ * leaves unmapped
417
425
  * @returns {IconSetCoverage[]}
418
426
  */
419
- export function iconSetCoverage(loaded, unchecked = new Map()) {
427
+ export function iconSetCoverage(
428
+ loaded,
429
+ unchecked = new Map(),
430
+ templateMeanings,
431
+ ) {
420
432
  if (!loaded.iconSets) return [];
421
433
  const found = discoverIconSetDirectory(loaded.iconSets, loaded.name);
422
434
  const astryx = astryxIconDefinitions().definitions.map(each => each.doc);
@@ -445,6 +457,16 @@ export function iconSetCoverage(loaded, unchecked = new Map()) {
445
457
  : [];
446
458
  }),
447
459
  unchecked: unchecked.get(set.name) ?? [],
460
+ ...(templateMeanings
461
+ ? {
462
+ templateMeanings: {
463
+ unmapped: unmappedTemplateMeanings(
464
+ templateMeanings,
465
+ set.data.map,
466
+ ),
467
+ },
468
+ }
469
+ : {}),
448
470
  };
449
471
  });
450
472
  }
@@ -592,27 +614,47 @@ export function suggestedIcons(set, doc) {
592
614
  }
593
615
  // 3. Ids that start with the name as written (`video` → `video-camera`),
594
616
  // never a negated form. A plural is not the same start: `users` is not
595
- // `user-plus`, and `apps` is not `app-window`.
617
+ // `user-plus`, and `apps` is not `app-window`. Only an id whose other
618
+ // words are the definition's words, or a size, shape, or number, comes
619
+ // here; one whose other words name something else (`delete-left`, a
620
+ // key) comes after the icons the definition's words name.
596
621
  const nameRaw = nameId.split('-');
597
- ranked(
622
+ const startsWithName = ranked(
598
623
  icons.filter(
599
624
  icon =>
600
625
  icon.raw.length > nameRaw.length &&
601
626
  nameRaw.every((word, index) => icon.raw[index] === word) &&
602
627
  !negated(icon.raw.slice(nameRaw.length)),
603
628
  ),
604
- ).forEach(icon => add(icon.id, nameId));
629
+ );
630
+ const onlyMeaning = (/** @type {{raw: string[]}} */ icon) =>
631
+ icon.raw
632
+ .slice(nameRaw.length)
633
+ .every(word => meaning.has(stem(word)) || QUALIFIER_RE.test(word));
634
+ startsWithName.filter(onlyMeaning).forEach(icon => add(icon.id, nameId));
635
+ // A word another Astryx definition also has (`store` for save and for a
636
+ // shopping bag) does not say which one an icon draws: the words only this
637
+ // definition has come first.
638
+ const shared = sharedWords(doc.name);
639
+ const wordOrder = [
640
+ ...[...wordIds.keys()].filter(index => !shared.has(wordIds[index])),
641
+ ...[...wordIds.keys()].filter(index => shared.has(wordIds[index])),
642
+ ];
605
643
  // 4. An icon whose whole id is one of the definition's words.
606
- for (const id of wordIds) {
644
+ for (const index of wordOrder) {
645
+ const id = wordIds[index];
607
646
  if (icons.some(icon => icon.id === id)) add(id, id.replace(/-/gu, ' '));
608
647
  }
609
648
  // 5. Another name the library gives an icon that is one of the
610
649
  // definition's words (Lucide's `smile` on `face-slightly-smiling`).
611
- for (const [index, id] of wordIds.entries()) {
650
+ for (const index of wordOrder) {
612
651
  for (const icon of icons) {
613
- if (icon.other.includes(id)) add(icon.id, doc.words[index]);
652
+ if (icon.other.includes(wordIds[index])) add(icon.id, doc.words[index]);
614
653
  }
615
654
  }
655
+ startsWithName
656
+ .filter(icon => !onlyMeaning(icon))
657
+ .forEach(icon => add(icon.id, nameId));
616
658
  // 6. Last, two-word ids that are a one-word word with only a size, shape,
617
659
  // or number after it (`columns` → `columns-3`, `plus` → `plus-circle`,
618
660
  // `grid` → `grid-2x2`), best fit first. Any other second word names
@@ -634,6 +676,25 @@ export function suggestedIcons(set, doc) {
634
676
  return found.slice(0, SUGGESTIONS_PER_DEFINITION);
635
677
  }
636
678
 
679
+ /**
680
+ * The words, written as ids, that another Astryx definition than `name` also
681
+ * has as its name or one of its words.
682
+ * @param {string} name
683
+ * @returns {Set<string>}
684
+ */
685
+ function sharedWords(name) {
686
+ /** @type {Set<string>} */
687
+ const shared = new Set();
688
+ for (const {doc} of astryxIconDefinitions().definitions) {
689
+ if (doc.name === name) continue;
690
+ shared.add(doc.name.replace(/([a-z0-9])([A-Z])/gu, '$1-$2').toLowerCase());
691
+ for (const word of doc.words) {
692
+ shared.add(word.trim().toLowerCase().replace(/\s+/gu, '-'));
693
+ }
694
+ }
695
+ return shared;
696
+ }
697
+
637
698
  /**
638
699
  * Each icon as the suggestion rules read it: its id's words as written and
639
700
  * in singular form, and the library's other names for it (the same ones
@@ -143,14 +143,29 @@ export function iconSetList(configured: string | readonly string[] | undefined):
143
143
  /**
144
144
  * Installed sets the project's list leaves out: the problem, and the fix that
145
145
  * adds them as backups after the list's own. Doctor and `experimental icon
146
- * use` print the same words.
147
- * @param {number} installed how many sets are installed
148
- * @param {string} main the main set as the list writes it
149
- * @param {string[]} backups the list's backups, in order
150
- * @param {string[]} unlisted the installed sets the list leaves out
146
+ * use` print the same words. Every set is named the same way: by its name
147
+ * when no other installed set has that name, else as `<package>/<set>`.
148
+ * @param {Array<{package: string, name: string}>} installed every installed set
149
+ * @param {{package: string, name: string}} main the list's main set
150
+ * @param {Array<{package: string, name: string}>} backups the list's
151
+ * backups, in order
152
+ * @param {Array<{package: string, name: string}>} unlisted the installed
153
+ * sets the list leaves out
151
154
  * @returns {{problem: string, command: string, fix: string}}
152
155
  */
153
- export function unlistedIconSets(installed: number, main: string, backups: string[], unlisted: string[]): {
156
+ export function unlistedIconSets(installed: Array<{
157
+ package: string;
158
+ name: string;
159
+ }>, main: {
160
+ package: string;
161
+ name: string;
162
+ }, backups: Array<{
163
+ package: string;
164
+ name: string;
165
+ }>, unlisted: Array<{
166
+ package: string;
167
+ name: string;
168
+ }>): {
154
169
  problem: string;
155
170
  command: string;
156
171
  fix: string;
@@ -476,18 +476,27 @@ export const ICON_USE_ORDER_COMMAND =
476
476
  /**
477
477
  * Installed sets the project's list leaves out: the problem, and the fix that
478
478
  * adds them as backups after the list's own. Doctor and `experimental icon
479
- * use` print the same words.
480
- * @param {number} installed how many sets are installed
481
- * @param {string} main the main set as the list writes it
482
- * @param {string[]} backups the list's backups, in order
483
- * @param {string[]} unlisted the installed sets the list leaves out
479
+ * use` print the same words. Every set is named the same way: by its name
480
+ * when no other installed set has that name, else as `<package>/<set>`.
481
+ * @param {Array<{package: string, name: string}>} installed every installed set
482
+ * @param {{package: string, name: string}} main the list's main set
483
+ * @param {Array<{package: string, name: string}>} backups the list's
484
+ * backups, in order
485
+ * @param {Array<{package: string, name: string}>} unlisted the installed
486
+ * sets the list leaves out
484
487
  * @returns {{problem: string, command: string, fix: string}}
485
488
  */
486
489
  export function unlistedIconSets(installed, main, backups, unlisted) {
487
- const them = unlisted.length === 1 ? 'it' : 'them';
488
- const command = `astryx experimental icon use ${main}${[...backups, ...unlisted].map(each => ` --backup ${each}`).join('')}`;
490
+ /** @param {{package: string, name: string}} set */
491
+ const named = set =>
492
+ installed.filter(each => each.name === set.name).length > 1
493
+ ? iconSetKey(set)
494
+ : set.name;
495
+ const left = unlisted.map(named);
496
+ const them = left.length === 1 ? 'it' : 'them';
497
+ const command = `astryx experimental icon use ${named(main)}${[...backups.map(named), ...left].map(each => ` --backup ${each}`).join('')}`;
489
498
  return {
490
- problem: `${installed} icon sets are installed and ${unlisted.join(', ')} ${unlisted.length === 1 ? 'is' : 'are'} not in your list`,
499
+ problem: `${installed.length} icon sets are installed and ${left.join(', ')} ${left.length === 1 ? 'is' : 'are'} not in your list`,
491
500
  command,
492
501
  fix: `Add ${them} as backup with \`${command}\`, or uninstall ${them}.`,
493
502
  };
@@ -0,0 +1,39 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Count the definitions some templates declare in `icons`, most used first,
6
+ * then by name.
7
+ * @param {Array<{icons?: Record<string, unknown>}>} templates
8
+ * @param {Set<string> | Map<string, unknown>} known the definitions that count
9
+ * @returns {TemplateMeaning[]}
10
+ */
11
+ export function countTemplateMeanings(templates: Array<{
12
+ icons?: Record<string, unknown>;
13
+ }>, known: Set<string> | Map<string, unknown>): TemplateMeaning[];
14
+ /**
15
+ * Every Astryx icon definition the bundled templates use, with how many
16
+ * templates use it, most used first. Read once per process.
17
+ * @returns {Promise<TemplateMeaning[]>}
18
+ */
19
+ export function templateIconMeanings(): Promise<TemplateMeaning[]>;
20
+ /**
21
+ * The template meanings a set's `map` does not name, most used first.
22
+ * @param {TemplateMeaning[]} meanings
23
+ * @param {Record<string, string> | undefined} map
24
+ * @returns {TemplateMeaning[]}
25
+ */
26
+ export function unmappedTemplateMeanings(meanings: TemplateMeaning[], map: Record<string, string> | undefined): TemplateMeaning[];
27
+ /**
28
+ * One icon definition templates use.
29
+ */
30
+ export type TemplateMeaning = {
31
+ /**
32
+ * the definition's name
33
+ */
34
+ definition: string;
35
+ /**
36
+ * how many bundled templates use it
37
+ */
38
+ templates: number;
39
+ };