@astryxdesign/cli 0.7.4 → 0.7.5-canary.1093026

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 (208) hide show
  1. package/README.md +18 -18
  2. package/api/discover/_adapter.d.mts +1 -1
  3. package/api/experimental.d.mts +5 -0
  4. package/api/experimental.mjs +15 -0
  5. package/api/hook/list/list.d.mts +1 -1
  6. package/api/icon/_adapter.d.mts +3 -2
  7. package/api/icon/_adapter.mjs +16 -3
  8. package/api/icon/_authoring.d.mts +5 -1
  9. package/api/icon/_authoring.mjs +478 -63
  10. package/api/icon/_options.d.mts +11 -0
  11. package/api/icon/_options.mjs +39 -4
  12. package/api/icon/_records.d.mts +19 -0
  13. package/api/icon/_records.mjs +25 -0
  14. package/api/icon/add/add.d.mts +3 -3
  15. package/api/icon/add/add.mjs +227 -14
  16. package/api/icon/all-or-nothing.test.mjs +283 -0
  17. package/api/icon/detail/detail.mjs +2 -13
  18. package/api/icon/error-codes.test.mjs +14 -7
  19. package/api/icon/icon.d.mts +2 -2
  20. package/api/icon/icon.doc.mjs +30 -2
  21. package/api/icon/icon.mjs +57 -8
  22. package/api/icon/icon.test.mjs +133 -1
  23. package/api/icon/icon.type.d.mts +126 -1
  24. package/api/icon/icon.type.mjs +67 -3
  25. package/api/icon/iconAdd.doc.mjs +22 -6
  26. package/api/icon/iconMap.doc.mjs +24 -8
  27. package/api/icon/iconNewDefinition.doc.mjs +2 -2
  28. package/api/icon/iconNewSet.doc.mjs +30 -2
  29. package/api/icon/iconUse.doc.mjs +4 -1
  30. package/api/icon/map/map.d.mts +4 -4
  31. package/api/icon/map/map.mjs +134 -9
  32. package/api/icon/new-definition/new-definition.mjs +6 -2
  33. package/api/icon/new-set/new-set.mjs +2 -2
  34. package/api/icon/new-set/new-set.test.mjs +60 -10
  35. package/api/icon/option-pairs.test.mjs +368 -0
  36. package/api/icon/search/search.d.mts +10 -0
  37. package/api/icon/search/search.mjs +55 -14
  38. package/api/icon/use/use.mjs +2 -13
  39. package/api/integration/add-helpers.d.mts +15 -1
  40. package/api/integration/add-helpers.mjs +1 -1
  41. package/api/integration/validate-integration.type.d.mts +3 -2
  42. package/api/integration/validate-integration.type.mjs +3 -2
  43. package/api/render/_adapter.d.mts +28 -0
  44. package/api/render/_adapter.mjs +540 -0
  45. package/api/render/render.d.mts +15 -0
  46. package/api/render/render.doc.d.mts +9 -0
  47. package/api/render/render.doc.mjs +112 -0
  48. package/api/render/render.mjs +113 -0
  49. package/api/render/render.test.mjs +1155 -0
  50. package/api/render/render.type.d.mts +74 -0
  51. package/api/render/render.type.mjs +64 -0
  52. package/api/search/_result.d.mts +5 -5
  53. package/api/search/search.d.mts +1 -1
  54. package/api/template/template.type.d.mts +2 -1
  55. package/api/template/template.type.mjs +1 -1
  56. package/assets/discover/official-packages.json +4 -0
  57. package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
  58. package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
  59. package/assets/docs/tree/icon-sets.doc.mjs +50 -20
  60. package/assets/docs/tree/render-pages.doc.mjs +94 -0
  61. package/assets/icons/definitions/activity.doc.mjs +1 -1
  62. package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
  63. package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
  64. package/assets/icons/definitions/alignStart.doc.mjs +10 -0
  65. package/assets/icons/definitions/archive.doc.mjs +1 -1
  66. package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
  67. package/assets/icons/definitions/attach.doc.mjs +1 -1
  68. package/assets/icons/definitions/audio.doc.mjs +1 -1
  69. package/assets/icons/definitions/cart.doc.mjs +1 -1
  70. package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
  71. package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
  72. package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
  73. package/assets/icons/definitions/close.doc.mjs +1 -1
  74. package/assets/icons/definitions/collapse.doc.mjs +1 -1
  75. package/assets/icons/definitions/compose.doc.mjs +1 -1
  76. package/assets/icons/definitions/conversation.doc.mjs +1 -1
  77. package/assets/icons/definitions/copy.doc.mjs +1 -1
  78. package/assets/icons/definitions/cpu.doc.mjs +9 -0
  79. package/assets/icons/definitions/database.doc.mjs +1 -1
  80. package/assets/icons/definitions/desktop.doc.mjs +1 -1
  81. package/assets/icons/definitions/discount.doc.mjs +1 -1
  82. package/assets/icons/definitions/download.doc.mjs +1 -1
  83. package/assets/icons/definitions/emoji.doc.mjs +1 -1
  84. package/assets/icons/definitions/error.doc.mjs +1 -1
  85. package/assets/icons/definitions/expand.doc.mjs +1 -1
  86. package/assets/icons/definitions/experiment.doc.mjs +1 -1
  87. package/assets/icons/definitions/externalLink.doc.mjs +7 -1
  88. package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
  89. package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
  90. package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
  91. package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
  92. package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
  93. package/assets/icons/definitions/gitFork.doc.mjs +9 -0
  94. package/assets/icons/definitions/info.doc.mjs +1 -1
  95. package/assets/icons/definitions/location.doc.mjs +1 -1
  96. package/assets/icons/definitions/mention.doc.mjs +1 -1
  97. package/assets/icons/definitions/menu.doc.mjs +1 -1
  98. package/assets/icons/definitions/microphone.doc.mjs +1 -1
  99. package/assets/icons/definitions/mobile.doc.mjs +1 -1
  100. package/assets/icons/definitions/money.doc.mjs +1 -1
  101. package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
  102. package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
  103. package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
  104. package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
  105. package/assets/icons/definitions/panelRight.doc.mjs +10 -0
  106. package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
  107. package/assets/icons/definitions/redo.doc.mjs +1 -1
  108. package/assets/icons/definitions/refresh.doc.mjs +1 -1
  109. package/assets/icons/definitions/rotate.doc.mjs +9 -0
  110. package/assets/icons/definitions/scale.doc.mjs +10 -0
  111. package/assets/icons/definitions/search.doc.mjs +1 -1
  112. package/assets/icons/definitions/send.doc.mjs +1 -1
  113. package/assets/icons/definitions/settings.doc.mjs +1 -1
  114. package/assets/icons/definitions/star.doc.mjs +1 -1
  115. package/assets/icons/definitions/stop.doc.mjs +1 -1
  116. package/assets/icons/definitions/success.doc.mjs +1 -1
  117. package/assets/icons/definitions/textCase.doc.mjs +9 -0
  118. package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
  119. package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
  120. package/assets/icons/definitions/trendDown.doc.mjs +7 -1
  121. package/assets/icons/definitions/trendUp.doc.mjs +1 -1
  122. package/assets/icons/definitions/undo.doc.mjs +1 -1
  123. package/assets/icons/definitions/upload.doc.mjs +1 -1
  124. package/assets/icons/definitions/userAdd.doc.mjs +1 -1
  125. package/assets/icons/definitions/warning.doc.mjs +1 -1
  126. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
  127. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
  128. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
  129. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
  130. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
  131. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
  132. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
  133. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
  134. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
  135. package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
  136. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  137. package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
  138. package/authoring/debug/parse.d.mts +2 -2
  139. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
  140. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
  141. package/authoring/doctypes/icon-set/parse.d.mts +1 -0
  142. package/authoring/doctypes/icon-set/parse.mjs +1 -0
  143. package/authoring/doctypes/icon-set/type.ts +5 -0
  144. package/authoring/doctypes/template/template.doc.mjs +1 -1
  145. package/authoring/doctypes/template/type.ts +2 -1
  146. package/clients/cli/commands/doctor.mjs +16 -17
  147. package/clients/cli/commands/experimental/icon.mjs +167 -35
  148. package/clients/cli/commands/experimental/index.mjs +2 -0
  149. package/clients/cli/commands/experimental/render.mjs +113 -0
  150. package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
  151. package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
  152. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
  153. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
  154. package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
  155. package/clients/cli/commands/experimental-render.doc.mjs +60 -0
  156. package/clients/cli/commands/experimental.doc.mjs +4 -2
  157. package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
  158. package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
  159. package/clients/cli/commands/icon.test.mjs +1 -1
  160. package/clients/cli/commands/template.mjs +4 -1
  161. package/clients/cli/commands/text-json-parity.test.mjs +46 -0
  162. package/clients/cli/index.mjs +1 -0
  163. package/foundation/discovery/component-discovery.d.mts +2 -1
  164. package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
  165. package/foundation/discovery/component-discovery.mjs +13 -7
  166. package/foundation/discovery/icon-set-checks.d.mts +43 -9
  167. package/foundation/discovery/icon-set-checks.mjs +296 -21
  168. package/foundation/discovery/icon-set-checks.test.mjs +125 -12
  169. package/foundation/discovery/icon-set-writer.d.mts +192 -3
  170. package/foundation/discovery/icon-set-writer.mjs +608 -34
  171. package/foundation/discovery/icon-set-writer.test.mjs +26 -0
  172. package/foundation/discovery/module-exports.mjs +82 -25
  173. package/foundation/discovery/module-exports.test.mjs +38 -1
  174. package/foundation/discovery/package-exports.d.mts +13 -0
  175. package/foundation/discovery/package-exports.mjs +40 -1
  176. package/foundation/discovery/template-icons.d.mts +6 -0
  177. package/foundation/discovery/template-icons.mjs +98 -10
  178. package/foundation/discovery/template-icons.test.mjs +103 -0
  179. package/foundation/doc-compiler/doc-loads.test.mjs +15 -0
  180. package/foundation/doc-compiler/tree.mjs +3 -1
  181. package/foundation/render/assets.d.mts +31 -0
  182. package/foundation/render/assets.mjs +102 -0
  183. package/foundation/render/component-map.d.mts +52 -0
  184. package/foundation/render/component-map.mjs +141 -0
  185. package/foundation/render/css-cut.d.mts +29 -0
  186. package/foundation/render/css-cut.mjs +144 -0
  187. package/foundation/render/embedded-files.d.mts +28 -0
  188. package/foundation/render/embedded-files.mjs +108 -0
  189. package/foundation/render/embedded-imports.d.mts +61 -0
  190. package/foundation/render/embedded-imports.mjs +315 -0
  191. package/foundation/render/html-reader.d.mts +37 -0
  192. package/foundation/render/html-reader.mjs +121 -0
  193. package/foundation/render/page-worker.d.mts +7 -0
  194. package/foundation/render/page-worker.mjs +519 -0
  195. package/foundation/render/rebuild.d.mts +19 -0
  196. package/foundation/render/rebuild.mjs +269 -0
  197. package/foundation/render/render-page.d.mts +85 -0
  198. package/foundation/render/render-page.mjs +612 -0
  199. package/foundation/render/render.test.mjs +117 -0
  200. package/foundation/render/source-block.d.mts +52 -0
  201. package/foundation/render/source-block.mjs +106 -0
  202. package/foundation/response/error-codes.d.mts +10 -1
  203. package/foundation/response/error-codes.doc.mjs +56 -0
  204. package/foundation/response/error-codes.mjs +61 -0
  205. package/foundation/response/response-types.doc.mjs +38 -1
  206. package/foundation/text/string-utils.mjs +33 -0
  207. package/foundation/text/string-utils.test.mjs +17 -0
  208. package/package.json +14 -9
@@ -11,10 +11,14 @@ import * as path from 'node:path';
11
11
  import {afterEach, beforeEach, describe, expect, it} from 'vitest';
12
12
  import {icon} from './icon.mjs';
13
13
  import {iconUse} from './use/use.mjs';
14
+ import {iconMap} from './map/map.mjs';
15
+ import {iconAdd} from './add/add.mjs';
16
+ import {iconNewDefinition} from './new-definition/new-definition.mjs';
14
17
  import {ICON_NAMES} from '../../authoring/doctypes/icon-set/icon-names.mjs';
15
18
  import {rankIcons, scoreIcon} from './_records.mjs';
16
19
  import {
17
20
  glyphsData,
21
+ writeIconPackage,
18
22
  writeIconSetProject,
19
23
  } from '../../test-utils/icon-set-fixture.mjs';
20
24
 
@@ -331,9 +335,18 @@ describe('icon.list', () => {
331
335
  expect(set.coverage.own).toEqual([]);
332
336
  });
333
337
 
338
+ it('refuses --set and --limit with one icon, which they would not change', async () => {
339
+ for (const options of [{set: 'glyphs'}, {limit: 2}]) {
340
+ await expect(
341
+ icon('glyphs/trash', {cwd, ...options}),
342
+ ).rejects.toMatchObject({code: 'ERR_INVALID_OPTION'});
343
+ }
344
+ });
345
+
334
346
  it('refuses a query with --list and no query without it', async () => {
335
347
  await expect(icon('x', {cwd, list: true})).rejects.toMatchObject({
336
- code: 'ERR_INVALID_ARGUMENT',
348
+ code: 'ERR_INVALID_OPTION',
349
+ message: '--list and a query cannot be used together',
337
350
  });
338
351
  await expect(icon('', {cwd})).rejects.toMatchObject({
339
352
  code: 'ERR_MISSING_ARGUMENT',
@@ -372,3 +385,122 @@ describe('a withdrawn set, named', () => {
372
385
  });
373
386
  });
374
387
  });
388
+
389
+ describe('every entry point that names a set reports it the same way (FR17)', () => {
390
+ /** @type {string} */
391
+ let app;
392
+ /** @type {string} */
393
+ let authored;
394
+ beforeEach(() => {
395
+ app = writeIconSetProject(path.join(tmp, 'entry-app'), {
396
+ packages: [{}, {name: '@acme/lines', data: '{nope'}],
397
+ });
398
+ // A package being authored with one valid set and one withdrawn one.
399
+ authored = path.join(tmp, 'entry-pkg', 'glyphs');
400
+ writeIconPackage(authored);
401
+ const broken = path.join(authored, 'icon-sets', 'lines');
402
+ fs.mkdirSync(broken, {recursive: true});
403
+ fs.copyFileSync(
404
+ path.join(authored, 'icon-sets', 'glyphs', 'glyphs.doc.mjs'),
405
+ path.join(broken, 'lines.doc.mjs'),
406
+ );
407
+ fs.writeFileSync(
408
+ path.join(broken, 'lines.doc.mjs'),
409
+ fs
410
+ .readFileSync(path.join(broken, 'lines.doc.mjs'), 'utf8')
411
+ .replace('"name": "glyphs"', '"name": "lines"'),
412
+ );
413
+ fs.writeFileSync(path.join(broken, 'lines.icons.json'), '{nope');
414
+ });
415
+
416
+ /** @type {Array<[string, 'installed' | 'authored', (cwd: string, set: string) => Promise<unknown>]>} */
417
+ const ENTRY_POINTS = [
418
+ [
419
+ 'a query with --set',
420
+ 'installed',
421
+ (dir, set) => icon('close', {cwd: dir, set}),
422
+ ],
423
+ [
424
+ '--set with --all-icons',
425
+ 'installed',
426
+ (dir, set) => icon(undefined, {cwd: dir, set, allIcons: true}),
427
+ ],
428
+ ['<set>/<id>', 'installed', (dir, set) => icon(`${set}/x`, {cwd: dir})],
429
+ ['use', 'installed', (dir, set) => iconUse(set, {cwd: dir})],
430
+ [
431
+ 'map --set',
432
+ 'authored',
433
+ (dir, set) => iconMap('close', 'x', {cwd: dir, set}),
434
+ ],
435
+ [
436
+ 'add --set',
437
+ 'authored',
438
+ (dir, set) =>
439
+ iconAdd('XIcon', {
440
+ cwd: dir,
441
+ set,
442
+ from: './icons/x.js',
443
+ definition: 'close',
444
+ }),
445
+ ],
446
+ [
447
+ 'new-definition --set',
448
+ 'authored',
449
+ (dir, set) =>
450
+ iconNewDefinition('binIt', {
451
+ cwd: dir,
452
+ set,
453
+ description: 'Put something in the bin.',
454
+ words: ['bin'],
455
+ }),
456
+ ],
457
+ ];
458
+
459
+ it.each(ENTRY_POINTS)('%s: a missing set', async (_label, kind, run) => {
460
+ await expect(
461
+ run(kind === 'installed' ? app : authored, 'nope'),
462
+ ).rejects.toMatchObject({
463
+ code: 'ERR_NOT_FOUND',
464
+ message:
465
+ kind === 'installed'
466
+ ? 'No installed icon set named "nope"'
467
+ : 'No icon set named "nope" in this package',
468
+ });
469
+ });
470
+
471
+ it.each(ENTRY_POINTS)('%s: a withdrawn set', async (_label, kind, run) => {
472
+ await expect(
473
+ run(kind === 'installed' ? app : authored, 'lines'),
474
+ ).rejects.toMatchObject({
475
+ code: 'ERR_NOT_FOUND',
476
+ message: expect.stringMatching(
477
+ kind === 'installed'
478
+ ? /^Icon set "lines" is installed but withdrawn: .*not valid JSON/u
479
+ : /^Icon set "lines" is in this package but withdrawn: .*not valid JSON/u,
480
+ ),
481
+ });
482
+ });
483
+ });
484
+
485
+ describe('partial matches answer only when nothing better does (FR6)', () => {
486
+ /** @param {string} query */
487
+ const ids = async query => {
488
+ const result = await icon(query, {cwd, set: 'glyphs'});
489
+ if (result.type !== 'icon.search') throw new Error(result.type);
490
+ return result.data.matches.map(match => [match.id, match.score]);
491
+ };
492
+
493
+ it('leaves out a partial match when a word starts with the query', async () => {
494
+ // `se` starts `search`, and is only inside `house` (home).
495
+ const found = await ids('se');
496
+ expect(found.map(([id]) => id)).toContain('search');
497
+ expect(found.map(([id]) => id)).not.toContain('home');
498
+ expect(found.every(([, score]) => Number(score) >= 60)).toBe(true);
499
+ });
500
+
501
+ it('answers with partial matches when nothing scores 60 or more', async () => {
502
+ // `ouse` starts no word; it is inside `house`.
503
+ const found = await ids('ouse');
504
+ expect(found).toEqual([['home', 40]]);
505
+ });
506
+ });
@@ -202,6 +202,29 @@ export type IconMapOptions = {
202
202
  * - Remove the definition's entry instead.
203
203
  */
204
204
  remove?: boolean | undefined;
205
+ /**
206
+ * - Many entries at once, as `<definition>=<icon>` pairs separated by commas or spaces; then no definition or icon is passed. All are checked before any is written.
207
+ */
208
+ pairs?: string | string[] | undefined;
209
+ };
210
+ /**
211
+ * `astryx --json experimental icon map --pairs <definition>=<icon>,...`.
212
+ */
213
+ export type IconMapManyResponse = {
214
+ type: "icon.mapMany";
215
+ data: {
216
+ set: string;
217
+ package: string;
218
+ file: string;
219
+ entries: Array<{
220
+ definition: string;
221
+ icon: string;
222
+ previous: string | null;
223
+ changed: boolean;
224
+ }>;
225
+ changed: boolean;
226
+ files?: string[] | undefined;
227
+ };
205
228
  };
206
229
  /**
207
230
  * `astryx --json experimental icon map <definition> <icon>`.
@@ -260,6 +283,27 @@ export type IconAddOptions = {
260
283
  * - The icon's id, instead of the one its name gives.
261
284
  */
262
285
  id?: string | undefined;
286
+ /**
287
+ * - With `variant` and `from`, and no export name: add that variant for every icon whose id an export of `from` has.
288
+ */
289
+ all?: boolean | undefined;
290
+ };
291
+ /**
292
+ * `astryx --json experimental icon add --variant <name> --from <module> --all`.
293
+ */
294
+ export type IconAddVariantsResponse = {
295
+ type: "icon.addVariants";
296
+ data: {
297
+ set: string;
298
+ package: string;
299
+ variant: string;
300
+ from: string;
301
+ added: number;
302
+ already: number;
303
+ missing: string[];
304
+ files: string[];
305
+ changed: boolean;
306
+ };
263
307
  };
264
308
  /**
265
309
  * `astryx --json experimental icon add <Export> --from <module> --definition <name>`.
@@ -329,6 +373,45 @@ export type IconOptions = {
329
373
  * - Max matches (default 10).
330
374
  */
331
375
  limit?: number | undefined;
376
+ /**
377
+ * - With `set` and no query: every icon of that set.
378
+ */
379
+ allIcons?: boolean | undefined;
380
+ /**
381
+ * - Every Astryx icon definition, and nothing else.
382
+ */
383
+ definitions?: boolean | undefined;
384
+ };
385
+ /**
386
+ * `astryx --json experimental icon --definitions`.
387
+ */
388
+ export type IconDefinitionsResponse = {
389
+ type: "icon.definitions";
390
+ data: {
391
+ definitions: Array<{
392
+ name: string;
393
+ builtIn: boolean;
394
+ description: string;
395
+ words: string[];
396
+ }>;
397
+ };
398
+ };
399
+ /**
400
+ * `astryx --json experimental icon --set <name> --all-icons`.
401
+ */
402
+ export type IconSetIconsResponse = {
403
+ type: "icon.setIcons";
404
+ data: {
405
+ set: string;
406
+ package: string;
407
+ iconCount: number;
408
+ icons: Array<{
409
+ id: string;
410
+ export: string;
411
+ words: string[];
412
+ definitions: string[];
413
+ }>;
414
+ };
332
415
  };
333
416
  /**
334
417
  * Options for `iconNewSet()`.
@@ -350,6 +433,22 @@ export type IconNewSetOptions = {
350
433
  * - With `from`: export names that are not icons; a string is split on commas.
351
434
  */
352
435
  exclude?: string | string[] | undefined;
436
+ /**
437
+ * - The variants the set supplies, such as `outline,solid`; a string is split on commas.
438
+ */
439
+ variants?: string | string[] | undefined;
440
+ /**
441
+ * - With `variants`: the variant each icon's own export draws; the first variant when absent.
442
+ */
443
+ defaultVariant?: string | undefined;
444
+ /**
445
+ * - The descriptor's display name; the set name in title case when absent.
446
+ */
447
+ displayName?: string | undefined;
448
+ /**
449
+ * - The descriptor's one-line description; `<Display name> icons.` when absent.
450
+ */
451
+ description?: string | undefined;
353
452
  };
354
453
  /**
355
454
  * Options for `iconNewDefinition()`.
@@ -409,7 +508,33 @@ export type IconNewData = {
409
508
  */
410
509
  icons?: number | undefined;
411
510
  /**
412
- * - What the author does next.
511
+ * - With `from` on an existing set: the set was refreshed, not created.
512
+ */
513
+ refreshed?: boolean | undefined;
514
+ /**
515
+ * - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
516
+ */
517
+ renamed?: {
518
+ from: string;
519
+ to: string;
520
+ }[] | undefined;
521
+ /**
522
+ * - With `from`: the `map` entries an icon with the definition's exact name gives (on a refresh, every such entry, kept or new); check each.
523
+ */
524
+ mapped?: {
525
+ definition: string;
526
+ icon: string;
527
+ }[] | undefined;
528
+ /**
529
+ * - With `from`: for each unmapped Astryx definition, up to three icons it might map to, best first: the definition's name in another spelling or as another name of an icon, ids that start with it, an id or another name that is one of its words, then two-word ids that are a one-word word sized, shaped, or numbered (`grid-2x2`); never a negated form, the opposite direction, or an icon already mapped. `word` is the name or word that matched. Never written.
530
+ */
531
+ suggestions?: {
532
+ definition: string;
533
+ icon: string;
534
+ word: string;
535
+ }[] | undefined;
536
+ /**
537
+ * - What the author does next, including each change the package needs that the CLI never makes itself (its entry, peers, scripts), as text to copy.
413
538
  */
414
539
  notes?: string[] | undefined;
415
540
  };
@@ -142,6 +142,21 @@
142
142
  * @property {string} [cwd]
143
143
  * @property {string} [set] - The set to edit, when the package ships several.
144
144
  * @property {boolean} [remove] - Remove the definition's entry instead.
145
+ * @property {string | string[]} [pairs] - Many entries at once, as `<definition>=<icon>` pairs separated by commas or spaces; then no definition or icon is passed. All are checked before any is written.
146
+ */
147
+
148
+ /**
149
+ * `astryx --json experimental icon map --pairs <definition>=<icon>,...`.
150
+ * @experimental May change or be removed in a patch release.
151
+ * @typedef {object} IconMapManyResponse
152
+ * @property {'icon.mapMany'} type
153
+ * @property {object} data
154
+ * @property {string} data.set
155
+ * @property {string} data.package
156
+ * @property {string} data.file - The data file, relative to the package.
157
+ * @property {Array<{definition: string, icon: string, previous: string | null, changed: boolean}>} data.entries - Each pair, in order, and what it replaced.
158
+ * @property {boolean} data.changed - Whether the file was written.
159
+ * @property {string[]} [data.files] - The generated module and its types, when its theme map was rewritten.
145
160
  */
146
161
 
147
162
  /**
@@ -154,7 +169,7 @@
154
169
  * @property {string} data.package
155
170
  * @property {string} data.file - The data file, relative to the package.
156
171
  * @property {string} data.definition
157
- * @property {string | null} data.icon - The icon id now mapped; null after `remove`.
172
+ * @property {string | null} data.icon - The id of the icon now mapped (the icon may be named by any name `map` accepts); null after `remove`.
158
173
  * @property {string | null} data.previous - The icon id it replaced.
159
174
  * @property {boolean} data.changed - Whether the file was written.
160
175
  * @property {string[]} [data.files] - The generated module and its types, when its theme map was rewritten.
@@ -174,6 +189,24 @@
174
189
  * @property {boolean} [useDefault] - The module's default export is the icon.
175
190
  * @property {string} [variant] - Add the export as this declared variant of an existing icon.
176
191
  * @property {string} [id] - The icon's id, instead of the one its name gives.
192
+ * @property {boolean} [all] - With `variant` and `from`, and no export name: add that variant for every icon whose id an export of `from` has.
193
+ */
194
+
195
+ /**
196
+ * `astryx --json experimental icon add --variant <name> --from <module> --all`.
197
+ * @experimental May change or be removed in a patch release.
198
+ * @typedef {object} IconAddVariantsResponse
199
+ * @property {'icon.addVariants'} type
200
+ * @property {object} data
201
+ * @property {string} data.set
202
+ * @property {string} data.package
203
+ * @property {string} data.variant
204
+ * @property {string} data.from - The module the variant exports are read from.
205
+ * @property {number} data.added - Icons that gained the variant.
206
+ * @property {number} data.already - Icons that already had it.
207
+ * @property {string[]} data.missing - Ids of icons `from` has no export for; they keep no such variant.
208
+ * @property {string[]} data.files - Files written, relative to the package.
209
+ * @property {boolean} data.changed
177
210
  */
178
211
 
179
212
  /**
@@ -190,7 +223,7 @@
190
223
  * @property {string} [data.newDefinition] - The set's own definition the command wrote.
191
224
  * @property {string[]} data.files - Files written, relative to the package.
192
225
  * @property {boolean} data.changed - Whether anything was written.
193
- * @property {string} [data.note] - What the set's module still needs to export the icon.
226
+ * @property {string} [data.note] - What the package still needs, as text to copy: the entry line that exports the icon from the set's module, and the package.json `files` that publishes a `./` source.
194
227
  */
195
228
 
196
229
  /**
@@ -226,6 +259,29 @@
226
259
  * @property {boolean} [list] - List the installed sets.
227
260
  * @property {string} [set] - Keep one set, by name or `<package>/<set>`.
228
261
  * @property {number} [limit] - Max matches (default 10).
262
+ * @property {boolean} [allIcons] - With `set` and no query: every icon of that set.
263
+ * @property {boolean} [definitions] - Every Astryx icon definition, and nothing else.
264
+ */
265
+
266
+ /**
267
+ * `astryx --json experimental icon --definitions`.
268
+ * @experimental May change or be removed in a patch release.
269
+ * @typedef {object} IconDefinitionsResponse
270
+ * @property {'icon.definitions'} type
271
+ * @property {object} data
272
+ * @property {Array<{name: string, builtIn: boolean, description: string, words: string[]}>} data.definitions - Every Astryx icon definition, by name; `builtIn` ones every set maps.
273
+ */
274
+
275
+ /**
276
+ * `astryx --json experimental icon --set <name> --all-icons`.
277
+ * @experimental May change or be removed in a patch release.
278
+ * @typedef {object} IconSetIconsResponse
279
+ * @property {'icon.setIcons'} type
280
+ * @property {object} data
281
+ * @property {string} data.set
282
+ * @property {string} data.package
283
+ * @property {number} data.iconCount
284
+ * @property {Array<{id: string, export: string, words: string[], definitions: string[]}>} data.icons - Every icon, by id, with the definitions `map` names it for.
229
285
  */
230
286
 
231
287
  /**
@@ -236,6 +292,10 @@
236
292
  * @property {boolean} [dryRun] - Return the receipt without writing.
237
293
  * @property {string} [from] - A module whose every icon component the set wraps: a package, a package subpath, or a ./ path in the package.
238
294
  * @property {string[] | string} [exclude] - With `from`: export names that are not icons; a string is split on commas.
295
+ * @property {string[] | string} [variants] - The variants the set supplies, such as `outline,solid`; a string is split on commas.
296
+ * @property {string} [defaultVariant] - With `variants`: the variant each icon's own export draws; the first variant when absent.
297
+ * @property {string} [displayName] - The descriptor's display name; the set name in title case when absent.
298
+ * @property {string} [description] - The descriptor's one-line description; `<Display name> icons.` when absent.
239
299
  */
240
300
 
241
301
  /**
@@ -263,7 +323,11 @@
263
323
  * @property {boolean} dryRun
264
324
  * @property {string} [from]
265
325
  * @property {number} [icons] - With `from`: how many icons it wrote.
266
- * @property {string[]} [notes] - What the author does next.
326
+ * @property {boolean} [refreshed] - With `from` on an existing set: the set was refreshed, not created.
327
+ * @property {Array<{from: string, to: string}>} [renamed] - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
328
+ * @property {Array<{definition: string, icon: string}>} [mapped] - With `from`: the `map` entries an icon with the definition's exact name gives (on a refresh, every such entry, kept or new); check each.
329
+ * @property {Array<{definition: string, icon: string, word: string}>} [suggestions] - With `from`: for each unmapped Astryx definition, up to three icons it might map to, best first: the definition's name in another spelling or as another name of an icon, ids that start with it, an id or another name that is one of its words, then two-word ids that are a one-word word sized, shaped, or numbered (`grid-2x2`); never a negated form, the opposite direction, or an icon already mapped. `word` is the name or word that matched. Never written.
330
+ * @property {string[]} [notes] - What the author does next, including each change the package needs that the CLI never makes itself (its entry, peers, scripts), as text to copy.
267
331
  */
268
332
 
269
333
  /**
@@ -13,10 +13,10 @@ export const doc = {
13
13
  summary:
14
14
  'Register one icon you chose from a library in the set being authored.',
15
15
  description:
16
- "Run inside an icon-set package. The caller picks the export; the CLI never searches the library. It proves the export is a runtime component of `from` (a package, a package subpath, or a relative path this package exports), read without running it. With no definition it answers the icon definitions that fit the export, Astryx's and the set's own, and writes nothing. With `definition` it adds the icon (id from its name, `module` the source unless the set's own module already exports it, words from its name and the definition) and maps the definition to it. With `newDefinition` it first writes the set's own definition file. A `variant` adds the export as that declared variant of an existing icon. Running it again changes nothing. Experimental: it may change or be removed in a patch release.",
16
+ "Run inside an icon-set package. The caller picks the export; the CLI never searches the library. It proves the export is a runtime component of `from` (a package, a package subpath, or a ./ path to a file inside this package), read without running it. With no definition it answers the icon definitions that fit the export, Astryx's and the set's own, and writes nothing. With `definition` it adds the icon (id from its name, `module` the source unless the set's own module already exports it, words from its name and the definition) and maps the definition to it. With `newDefinition` it first writes the set's own definition file. A `variant` adds the export as that declared variant of an existing icon. With `variant`, `from`, and `all` and no export name, it adds that variant for every icon of the set whose id an export of `from` has, in one write. Running it again changes nothing. Experimental: it may change or be removed in a patch release.",
17
17
  importPath: '@astryxdesign/cli/api',
18
18
  signature:
19
- 'iconAdd(exportName: string, options: IconAddOptions): Promise<IconAddResponse | IconDefinitionMatchesResponse>',
19
+ 'iconAdd(exportName: string | undefined, options: IconAddOptions): Promise<IconAddResponse | IconDefinitionMatchesResponse | IconAddVariantsResponse>',
20
20
  keywords: [
21
21
  'icon',
22
22
  'icon set',
@@ -28,10 +28,10 @@ export const doc = {
28
28
  params: [
29
29
  {
30
30
  name: 'exportName',
31
- type: 'string',
31
+ type: 'string | undefined',
32
32
  description:
33
- 'The export the set exposes the icon as, such as `Bin`; the set exports it as `<Name>Icon`.',
34
- required: true,
33
+ 'The export the set exposes the icon as, such as `Bin`; the set exports it as `<Name>Icon`. Omitted with `options.all`.',
34
+ required: false,
35
35
  },
36
36
  {
37
37
  name: 'options.from',
@@ -82,6 +82,13 @@ export const doc = {
82
82
  type: 'string',
83
83
  description: "The icon's id, instead of the one its name gives.",
84
84
  },
85
+ {
86
+ name: 'options.all',
87
+ type: 'boolean',
88
+ description:
89
+ 'With `variant` and `from`, and no export name: add that variant for every icon of the set whose id an export of `from` has (`TrashIcon` in a solid module becomes the solid variant of `trash`).',
90
+ default: 'false',
91
+ },
85
92
  {
86
93
  name: 'options.cwd',
87
94
  type: 'string',
@@ -94,6 +101,11 @@ export const doc = {
94
101
  description:
95
102
  'The icon registered, the definition mapped, and the files written.',
96
103
  },
104
+ {
105
+ type: 'icon.addVariants',
106
+ description:
107
+ 'With all: how many icons gained the variant, how many had it, the ids the module has no export for, and the files written.',
108
+ },
97
109
  {
98
110
  type: 'icon.definitionMatches',
99
111
  description:
@@ -103,13 +115,17 @@ export const doc = {
103
115
  throws: [
104
116
  {
105
117
  code: 'ERR_NOT_FOUND',
106
- when: 'the module does not export the name, or the definition is unknown',
118
+ when: 'the module does not export the name, the definition is unknown, or `set` names no set in the package or one that is withdrawn (with why)',
107
119
  },
108
120
  {
109
121
  code: 'ERR_INVALID_ARGUMENT',
110
122
  when: 'the export is data rather than a component, a new definition is named like an Astryx one, or the variant is not one the set declares',
111
123
  },
112
124
  {code: 'ERR_FILE_EXISTS', when: 'another icon already has the id'},
125
+ {
126
+ code: 'ERR_INVALID_OPTION',
127
+ when: 'an option is given that the call would ignore: `all` with an export name, `definition`, `newDefinition`, `description`, `words`, `useDefault`, or `id`; `definition` with `newDefinition`; or `description` or `words` without `newDefinition`',
128
+ },
113
129
  {
114
130
  code: 'ERR_PROJECT_REQUIRED',
115
131
  when: 'the folder is outside any project and has no package.json at or above it',
@@ -13,22 +13,23 @@ export const doc = {
13
13
  summary:
14
14
  'Register which icon of the set being authored draws an icon definition.',
15
15
  description:
16
- "Run inside an icon-set package. Sets `map[definition] = icon` in the set's data file, or removes the entry. The definition must be Astryx's or one the set declares, and the icon an id in the file. The file is written in one fixed shape, `map` keys sorted. `integration check` suggests these commands for definitions the set has a fitting icon for. Experimental: it may change or be removed in a patch release.",
16
+ "Run inside an icon-set package. Sets `map[definition] = icon` in the set's data file, or removes the entry. The definition must be Astryx's or one the set declares, named by its name or kebab id. The icon must be in the set, named by its id, its export name in any case, or another name its library exports it as (`trash-2` or `Trash2`), never by one word of its id; the entry records its id. The file is written in one fixed shape, `map` keys sorted. `integration check` suggests these commands for definitions the set has a fitting icon for. Experimental: it may change or be removed in a patch release.",
17
17
  importPath: '@astryxdesign/cli/api',
18
18
  signature:
19
- 'iconMap(definition: string, icon?: string, options?: IconMapOptions): Promise<IconMapResponse>',
19
+ 'iconMap(definition: string | undefined, icon?: string, options?: IconMapOptions): Promise<IconMapResponse | IconMapManyResponse>',
20
20
  keywords: ['icon', 'icon set', 'map', 'icon definition', 'register'],
21
21
  params: [
22
22
  {
23
23
  name: 'definition',
24
- type: 'string',
25
- description: 'The icon definition.',
26
- required: true,
24
+ type: 'string | undefined',
25
+ description: 'The icon definition. Omit with `options.pairs`.',
26
+ required: false,
27
27
  },
28
28
  {
29
29
  name: 'icon',
30
30
  type: 'string',
31
- description: 'An icon id in the set. Omit with `remove`.',
31
+ description:
32
+ 'An icon in the set, named by its id, its export name in any case (`TrashIcon`, `trashicon`), or another name its library exports it as, as an id or as the library spells it (`trash-2`, `Trash2`); never one word of its id. Omit with `remove`.',
32
33
  },
33
34
  {
34
35
  name: 'options.cwd',
@@ -46,8 +47,19 @@ export const doc = {
46
47
  description: "Remove the definition's entry.",
47
48
  default: 'false',
48
49
  },
50
+ {
51
+ name: 'options.pairs',
52
+ type: 'string | string[]',
53
+ description:
54
+ 'Many entries at once: `<definition>=<icon>` pairs separated by commas or spaces, with no definition or icon argument; each icon is named as the icon argument is. Every pair is checked before any is written.',
55
+ },
49
56
  ],
50
57
  returns: [
58
+ {
59
+ type: 'icon.mapMany',
60
+ description:
61
+ 'With pairs: the set, the data file, each entry with the icon it replaced, and whether the file changed.',
62
+ },
51
63
  {
52
64
  type: 'icon.map',
53
65
  description:
@@ -57,19 +69,23 @@ export const doc = {
57
69
  throws: [
58
70
  {
59
71
  code: 'ERR_NOT_FOUND',
60
- when: 'the definition is unknown, or the set has no such icon',
72
+ when: 'the definition is unknown, the set has no such icon, or `set` names no set in the package or one that is withdrawn (with why)',
61
73
  },
62
74
  {
63
75
  code: 'ERR_INVALID_ARGUMENT',
64
76
  when: 'the package ships several sets and none is named',
65
77
  },
78
+ {
79
+ code: 'ERR_INVALID_OPTION',
80
+ when: '`pairs` is given with a definition, an icon, or `remove`, or `remove` with an icon',
81
+ },
66
82
  {
67
83
  code: 'ERR_PROJECT_REQUIRED',
68
84
  when: 'the folder is outside any project and has no package.json at or above it',
69
85
  },
70
86
  {
71
87
  code: 'ERR_MISSING_ARGUMENT',
72
- when: 'the definition is missing, or the icon id without `remove`',
88
+ when: 'the definition is missing, or the icon without `remove`',
73
89
  },
74
90
  {
75
91
  code: 'ERR_PATH_TRAVERSAL',
@@ -75,7 +75,7 @@ export const doc = {
75
75
  {code: 'ERR_FILE_EXISTS', when: 'the definition file already exists'},
76
76
  {
77
77
  code: 'ERR_NOT_FOUND',
78
- when: 'the package ships no icon set, or the set has no such icon',
78
+ when: 'the package ships no icon set, `set` names no set in it or one that is withdrawn (with why), or the set has no such icon',
79
79
  },
80
80
  {
81
81
  code: 'ERR_PROJECT_REQUIRED',
@@ -93,7 +93,7 @@ export const doc = {
93
93
  examples: [
94
94
  {
95
95
  label: 'Add and map a definition',
96
- code: "await iconNewDefinition('rotate', {description: 'Rotate an image or shape.', words: ['turn', 'spin'], icon: 'rotate-cw'});",
96
+ code: "await iconNewDefinition('random', {description: 'Pick something at random.', words: ['dice', 'shuffle', 'chance'], icon: 'dice-5'});",
97
97
  },
98
98
  ],
99
99
  command: 'experimental icon new-definition',
@@ -10,7 +10,7 @@ export const doc = {
10
10
  displayName: 'iconNewSet()',
11
11
  summary: 'Add an icon set to an integration package.',
12
12
  description:
13
- "Creates an integration manifest when the package has none, writes the set directory with its strongly typed same-stem IconSetDoc and a starter data file (schemaVersion 1, module set to the package name, no icons and an empty map yet), and the set's generated module with its declaration file and an empty themeIcons theme map; with from, it wraps a library's icons into them. It declares the manifest's `experimental.iconSets` root on first use, and includes the manifest and root in package.json files when the package already uses an allowlist. Every path is confined to the package and existing files are never overwritten. Experimental: it may change or be removed in a patch release.",
13
+ "Creates an integration manifest when the package has none, writes the set directory with its strongly typed same-stem IconSetDoc and a starter data file (schemaVersion 1, module set to the package name, no icons and an empty map yet), and the set's generated module with its declaration file and an empty themeIcons theme map; with from, it wraps a library's icons into them, records the installed library and version as the data file's source, copies the library's license notices into the set, uses the library's license, maps each Astryx definition whose name is an icon id, and returns up to three likely icons for each other definition as suggestions (by its name, its words, and the other names the library gives an icon; never a part of a word, a negated form, or the opposite direction), never written. It declares the manifest's `experimental.iconSets` root on first use, and includes the manifest and root in package.json files when the package already uses an allowlist. It never writes the package's entry, exports, main, types, files list, peers, or scripts: its notes name each change the package needs as text to copy. Every path is confined to the package and existing files are never overwritten. Experimental: it may change or be removed in a patch release.",
14
14
  importPath: '@astryxdesign/cli/api',
15
15
  signature:
16
16
  'iconNewSet(name: string, options?: IconNewSetOptions): Promise<IconNewSetResponse>',
@@ -46,6 +46,30 @@ export const doc = {
46
46
  description:
47
47
  'With from: export names that are not icons; a string is split on commas. SCREAMING_CASE names and number or boolean exports are always left out.',
48
48
  },
49
+ {
50
+ name: 'options.variants',
51
+ type: 'string[] | string',
52
+ description:
53
+ "The variants the set supplies, lower-kebab names such as outline and solid; a string is split on commas. Written to the data file's variants.",
54
+ },
55
+ {
56
+ name: 'options.defaultVariant',
57
+ type: 'string',
58
+ description:
59
+ "With variants: the variant each icon's own export draws, written to the data file's default; the first variant when absent.",
60
+ },
61
+ {
62
+ name: 'options.displayName',
63
+ type: 'string',
64
+ description:
65
+ "The descriptor's display name; the set name in title case when absent.",
66
+ },
67
+ {
68
+ name: 'options.description',
69
+ type: 'string',
70
+ description:
71
+ "The descriptor's one-line description; '<Display name> icons.' when absent.",
72
+ },
49
73
  ],
50
74
  returns: [
51
75
  {
@@ -57,7 +81,11 @@ export const doc = {
57
81
  throws: [
58
82
  {
59
83
  code: 'ERR_INVALID_ARGUMENT',
60
- when: 'the name is not lowercase kebab-case, or package.json has no name',
84
+ when: 'the name is not lowercase kebab-case, package.json has no name, or a variant name or the default variant is invalid',
85
+ },
86
+ {
87
+ code: 'ERR_INVALID_OPTION',
88
+ when: '`exclude` is given without `from`, or `defaultVariant` without `variants`',
61
89
  },
62
90
  {
63
91
  code: 'ERR_FILE_EXISTS',
@@ -38,7 +38,10 @@ export const doc = {
38
38
  },
39
39
  ],
40
40
  throws: [
41
- {code: 'ERR_NOT_FOUND', when: 'no installed set has the name'},
41
+ {
42
+ code: 'ERR_NOT_FOUND',
43
+ when: 'no installed set has the name, or the set it names is withdrawn (the message says which, and why)',
44
+ },
42
45
  {
43
46
  code: 'ERR_INVALID_ARGUMENT',
44
47
  when: 'two installed packages ship a set with the name',