@astryxdesign/cli 0.7.12 → 0.7.13-canary.802938b

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 (89) hide show
  1. package/api/component/__fixtures__/resolutions/modules.txt +2 -2
  2. package/api/doctor/_adapter.d.mts +17 -0
  3. package/api/doctor/_adapter.mjs +40 -0
  4. package/api/doctor/doctor.d.mts +34 -4
  5. package/api/doctor/doctor.mjs +108 -21
  6. package/api/icon/_adapter.d.mts +6 -3
  7. package/api/icon/_adapter.mjs +11 -3
  8. package/api/icon/icon.type.d.mts +22 -1
  9. package/api/icon/icon.type.mjs +12 -4
  10. package/api/icon/iconUse.doc.mjs +27 -7
  11. package/api/icon/list/list.mjs +29 -3
  12. package/api/icon/use/use.d.mts +7 -3
  13. package/api/icon/use/use.mjs +68 -18
  14. package/api/integration/validate-integration.d.mts +4 -0
  15. package/api/integration/validate-integration.mjs +32 -2
  16. package/api/integration/validate-integration.type.d.mts +15 -0
  17. package/api/integration/validate-integration.type.mjs +6 -1
  18. package/api/template/copy/copy.mjs +4 -2
  19. package/api/template/template.type.d.mts +42 -4
  20. package/api/template/template.type.mjs +9 -6
  21. package/assets/discover/official-packages.json +4 -0
  22. package/assets/docs/tree/icon-sets.doc.mjs +91 -7
  23. package/assets/icons/definitions/alignBottom.doc.mjs +9 -0
  24. package/assets/icons/definitions/alignJustify.doc.mjs +9 -0
  25. package/assets/icons/definitions/alignMiddle.doc.mjs +9 -0
  26. package/assets/icons/definitions/alignTop.doc.mjs +9 -0
  27. package/assets/icons/definitions/angle.doc.mjs +9 -0
  28. package/assets/icons/definitions/cloud.doc.mjs +9 -0
  29. package/assets/icons/definitions/collection.doc.mjs +9 -0
  30. package/assets/icons/definitions/contrast.doc.mjs +9 -0
  31. package/assets/icons/definitions/cornerRadius.doc.mjs +9 -0
  32. package/assets/icons/definitions/cut.doc.mjs +9 -0
  33. package/assets/icons/definitions/fingerprint.doc.mjs +9 -0
  34. package/assets/icons/definitions/fire.doc.mjs +9 -0
  35. package/assets/icons/definitions/frame.doc.mjs +9 -0
  36. package/assets/icons/definitions/gift.doc.mjs +9 -0
  37. package/assets/icons/definitions/group.doc.mjs +9 -0
  38. package/assets/icons/definitions/integration.doc.mjs +9 -0
  39. package/assets/icons/definitions/lowercase.doc.mjs +9 -0
  40. package/assets/icons/definitions/paddingHorizontal.doc.mjs +9 -0
  41. package/assets/icons/definitions/paddingPerSide.doc.mjs +9 -0
  42. package/assets/icons/definitions/paddingVertical.doc.mjs +9 -0
  43. package/assets/icons/definitions/panelBottom.doc.mjs +9 -0
  44. package/assets/icons/definitions/photoEffect.doc.mjs +9 -0
  45. package/assets/icons/definitions/radiusPerCorner.doc.mjs +9 -0
  46. package/assets/icons/definitions/rotateCounterclockwise.doc.mjs +9 -0
  47. package/assets/icons/definitions/tablet.doc.mjs +9 -0
  48. package/assets/icons/definitions/text.doc.mjs +9 -0
  49. package/assets/icons/definitions/textRegular.doc.mjs +9 -0
  50. package/assets/icons/definitions/transfer.doc.mjs +9 -0
  51. package/assets/icons/definitions/uppercase.doc.mjs +9 -0
  52. package/assets/icons/definitions/userRemove.doc.mjs +9 -0
  53. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadMenu.doc.mjs +23 -0
  54. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadMenu.tsx +199 -0
  55. package/assets/templates/blocks/components/ButtonGroup/ButtonGroupShowcase.doc.mjs +1 -0
  56. package/assets/templates/blocks/components/ChatSystemMessage/ChatSystemMessageStatusUpdates.doc.mjs +7 -2
  57. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +21 -0
  58. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.tsx +46 -0
  59. package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.doc.mjs +18 -0
  60. package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +101 -0
  61. package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
  62. package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
  63. package/assets/templates/pages/canvas-editor/template.doc.mjs +20 -0
  64. package/assets/templates/pages/editor/template.doc.mjs +1 -0
  65. package/assets/templates/pages/form-wizard-vertical/template.doc.mjs +1 -0
  66. package/assets/templates/pages/settings-dialog/template.doc.mjs +4 -0
  67. package/assets/templates/pages/shell-top-nav/template.doc.mjs +3 -0
  68. package/assets/templates/pages/table-collapsible/template.doc.mjs +1 -0
  69. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  70. package/authoring/config/config.doc.mjs +4 -4
  71. package/authoring/config/parse.d.mts +1 -1
  72. package/authoring/config/parse.mjs +3 -1
  73. package/authoring/config/type.ts +7 -5
  74. package/authoring/doctypes/template/template.doc.mjs +1 -1
  75. package/authoring/doctypes/template/type.ts +5 -3
  76. package/clients/cli/commands/experimental/icon.mjs +38 -9
  77. package/clients/cli/commands/experimental-icon-use.doc.mjs +9 -4
  78. package/clients/cli/commands/template.mjs +12 -3
  79. package/foundation/config/config-writer.d.mts +14 -0
  80. package/foundation/config/config-writer.mjs +73 -17
  81. package/foundation/discovery/icon-set-discovery.d.mts +77 -7
  82. package/foundation/discovery/icon-set-discovery.mjs +128 -42
  83. package/foundation/discovery/template-icon-notes.d.mts +46 -0
  84. package/foundation/discovery/template-icon-notes.mjs +94 -16
  85. package/foundation/discovery/template-icons.d.mts +247 -0
  86. package/foundation/discovery/template-icons.mjs +591 -37
  87. package/foundation/integrations/cli-requirement.d.mts +13 -4
  88. package/foundation/integrations/cli-requirement.mjs +18 -6
  89. package/package.json +14 -14
@@ -0,0 +1,101 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useEffect, useRef, useState} from 'react';
6
+ import {InternationalizationProvider, useDirection} from '@astryxdesign/core';
7
+ import {VStack} from '@astryxdesign/core/Layout';
8
+ import {
9
+ SegmentedControl,
10
+ SegmentedControlItem,
11
+ } from '@astryxdesign/core/SegmentedControl';
12
+
13
+ const DATA_POINTS = [10, 25, 18, 40, 32, 60, 48, 75];
14
+
15
+ function Sparkline() {
16
+ const direction = useDirection();
17
+ const canvasRef = useRef<HTMLCanvasElement | null>(null);
18
+
19
+ useEffect(() => {
20
+ const canvas = canvasRef.current;
21
+ if (!canvas) {
22
+ return;
23
+ }
24
+ const ctx = canvas.getContext('2d');
25
+ if (!ctx) {
26
+ return;
27
+ }
28
+
29
+ const width = canvas.width;
30
+ const height = canvas.height;
31
+ ctx.clearRect(0, 0, width, height);
32
+
33
+ const step = width / (DATA_POINTS.length - 1);
34
+ const maxVal = Math.max(...DATA_POINTS);
35
+ const minVal = Math.min(...DATA_POINTS);
36
+ const range = maxVal - minVal || 1;
37
+
38
+ ctx.beginPath();
39
+ ctx.strokeStyle = '#0064e0';
40
+ ctx.lineWidth = 2;
41
+
42
+ DATA_POINTS.forEach((val, i) => {
43
+ // In LTR: oldest data starts at 0 (left), newest at right.
44
+ // In RTL: oldest data starts at right (width), newest at left.
45
+ const x = direction === 'rtl' ? width - i * step : i * step;
46
+ const y = height - ((val - minVal) / range) * (height - 10) - 5;
47
+ if (i === 0) {
48
+ ctx.moveTo(x, y);
49
+ } else {
50
+ ctx.lineTo(x, y);
51
+ }
52
+ });
53
+ ctx.stroke();
54
+
55
+ // Draw point at latest value
56
+ const lastIndex = DATA_POINTS.length - 1;
57
+ const lastX = direction === 'rtl' ? 0 : width;
58
+ const lastY =
59
+ height - ((DATA_POINTS[lastIndex] - minVal) / range) * (height - 10) - 5;
60
+ ctx.beginPath();
61
+ ctx.arc(lastX, lastY, 4, 0, Math.PI * 2);
62
+ ctx.fillStyle = '#0064e0';
63
+ ctx.fill();
64
+ }, [direction]);
65
+
66
+ return (
67
+ <canvas
68
+ ref={canvasRef}
69
+ width={200}
70
+ height={60}
71
+ data-testid="sparkline-canvas"
72
+ data-direction={direction}
73
+ style={{border: '1px solid #e1e4e8', borderRadius: 4}}
74
+ />
75
+ );
76
+ }
77
+
78
+ export default function UseDirectionHookUsage() {
79
+ const [lang, setLang] = useState<'en' | 'ar'>('en');
80
+ const isRtl = lang === 'ar';
81
+
82
+ return (
83
+ <InternationalizationProvider locale={lang} dir={isRtl ? 'rtl' : 'ltr'}>
84
+ <VStack
85
+ gap={4}
86
+ hAlign="center"
87
+ dir={isRtl ? 'rtl' : 'ltr'}
88
+ style={{width: '100%'}}>
89
+ <SegmentedControl
90
+ label="Locale"
91
+ value={lang}
92
+ onChange={next => setLang(next as 'en' | 'ar')}
93
+ size="sm">
94
+ <SegmentedControlItem value="en" label="English (LTR)" />
95
+ <SegmentedControlItem value="ar" label="العربية (RTL)" />
96
+ </SegmentedControl>
97
+ <Sparkline />
98
+ </VStack>
99
+ </InternationalizationProvider>
100
+ );
101
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTruncation',
7
+ name: 'useTruncation — Tooltip on Cut-Off Text',
8
+ displayName: 'useTruncation — Tooltip on Cut-Off Text',
9
+ description:
10
+ 'A narrow table column shows the full path in a Tooltip only where useTruncation reports the text is cut off; the short path shows none. One cell clamped to two lines shows the multi-line case.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Table', 'Tooltip'],
14
+ };
@@ -0,0 +1,112 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useTruncation} from '@astryxdesign/core/Text';
6
+ import {Tooltip} from '@astryxdesign/core/Tooltip';
7
+ import {
8
+ Table,
9
+ TableBody,
10
+ TableCell,
11
+ TableHeader,
12
+ TableHeaderCell,
13
+ TableRow,
14
+ } from '@astryxdesign/core/Table';
15
+
16
+ interface FileAsset {
17
+ name: string;
18
+ path: string;
19
+ mode: 'single' | 'clamped' | 'short';
20
+ }
21
+
22
+ const FILES: FileAsset[] = [
23
+ {
24
+ name: 'build',
25
+ path: 'artifacts/release/build-20261103-120344/index.html',
26
+ mode: 'single',
27
+ },
28
+ {
29
+ name: 'bundle',
30
+ path: 'reports/coverage/packages/core/src/components/Calendar/index.html',
31
+ mode: 'clamped',
32
+ },
33
+ {
34
+ name: 'readme',
35
+ path: 'README.md',
36
+ mode: 'short',
37
+ },
38
+ ];
39
+
40
+ function TruncatedCell({children}: {children: string}) {
41
+ const truncation = useTruncation({maxLines: 1});
42
+ return (
43
+ <Tooltip
44
+ content={truncation.fullText}
45
+ placement="above"
46
+ isEnabled={truncation.isTruncated}>
47
+ <span
48
+ ref={truncation.ref}
49
+ tabIndex={truncation.isTruncated ? 0 : undefined}
50
+ style={{
51
+ display: 'block',
52
+ maxWidth: 120,
53
+ overflow: 'hidden',
54
+ textOverflow: 'ellipsis',
55
+ whiteSpace: 'nowrap',
56
+ }}>
57
+ {children}
58
+ </span>
59
+ </Tooltip>
60
+ );
61
+ }
62
+
63
+ function ClampedCell({children}: {children: string}) {
64
+ const truncation = useTruncation({maxLines: 2});
65
+ return (
66
+ <Tooltip
67
+ content={truncation.fullText}
68
+ placement="above"
69
+ isEnabled={truncation.isTruncated}>
70
+ <span
71
+ ref={truncation.ref}
72
+ tabIndex={truncation.isTruncated ? 0 : undefined}
73
+ style={{
74
+ display: '-webkit-box',
75
+ WebkitLineClamp: 2,
76
+ WebkitBoxOrient: 'vertical',
77
+ overflow: 'hidden',
78
+ maxWidth: 120,
79
+ wordBreak: 'break-all',
80
+ }}>
81
+ {children}
82
+ </span>
83
+ </Tooltip>
84
+ );
85
+ }
86
+
87
+ export default function UseTruncationHookUsage() {
88
+ return (
89
+ <Table>
90
+ <TableHeader>
91
+ <TableRow>
92
+ <TableHeaderCell>Asset</TableHeaderCell>
93
+ <TableHeaderCell>Path</TableHeaderCell>
94
+ </TableRow>
95
+ </TableHeader>
96
+ <TableBody>
97
+ {FILES.map(file => (
98
+ <TableRow key={file.name}>
99
+ <TableCell>{file.name}</TableCell>
100
+ <TableCell>
101
+ {file.mode === 'clamped' ? (
102
+ <ClampedCell>{file.path}</ClampedCell>
103
+ ) : (
104
+ <TruncatedCell>{file.path}</TruncatedCell>
105
+ )}
106
+ </TableCell>
107
+ </TableRow>
108
+ ))}
109
+ </TableBody>
110
+ </Table>
111
+ );
112
+ }
@@ -18,27 +18,47 @@ export const doc = {
18
18
  isReady: true,
19
19
  category: 'Tools - Canvas Editor',
20
20
  icons: {
21
+ Aperture: 'photoEffect',
22
+ ArrowDownToLine: 'alignBottom',
23
+ ArrowUpToLine: 'alignTop',
24
+ Baseline: 'textRegular',
25
+ CaseLower: 'lowercase',
21
26
  CaseSensitive: 'textCase',
27
+ CaseUpper: 'uppercase',
28
+ Contrast: 'contrast',
22
29
  Download: 'download',
23
30
  File: 'file',
24
31
  FlipHorizontal2: 'flipHorizontal',
25
32
  FlipVertical2: 'flipVertical',
33
+ FoldVertical: 'alignMiddle',
34
+ Frame: 'frame',
26
35
  Grip: 'drag',
36
+ Group: 'group',
27
37
  Image: 'image',
28
38
  Italic: 'italic',
29
39
  Lock: 'lock',
30
40
  LockOpen: 'unlock',
31
41
  Menu: 'menu',
32
42
  Minus: 'remove',
43
+ PanelBottom: 'panelBottom',
33
44
  PanelLeft: 'panelLeft',
45
+ PanelLeftRightDashed: 'paddingHorizontal',
34
46
  PanelRight: 'panelRight',
47
+ PanelTopBottomDashed: 'paddingVertical',
35
48
  Plus: 'add',
36
49
  Redo2: 'redo',
50
+ RotateCcw: 'rotateCounterclockwise',
37
51
  RotateCw: 'rotate',
52
+ Scan: 'cornerRadius',
53
+ SquareRoundCorner: 'radiusPerCorner',
54
+ SquareSquare: 'paddingPerSide',
38
55
  Strikethrough: 'strikethrough',
39
56
  TextAlignCenter: 'alignCenter',
40
57
  TextAlignEnd: 'alignEnd',
58
+ TextAlignJustify: 'alignJustify',
41
59
  TextAlignStart: 'alignStart',
60
+ TriangleRight: 'angle',
61
+ Type: 'text',
42
62
  Underline: 'underline',
43
63
  Undo2: 'undo',
44
64
  X: 'close',
@@ -25,6 +25,7 @@ export const doc = {
25
25
  ComputerDesktopIcon: 'desktop',
26
26
  CursorArrowRaysIcon: 'click',
27
27
  DevicePhoneMobileIcon: 'mobile',
28
+ DeviceTabletIcon: 'tablet',
28
29
  DocumentTextIcon: 'document',
29
30
  EllipsisHorizontalIcon: 'moreHorizontal',
30
31
  EyeIcon: 'eye',
@@ -18,6 +18,7 @@ export const doc = {
18
18
  ExclamationTriangleIcon: 'warning',
19
19
  GlobeAltIcon: 'globe',
20
20
  LanguageIcon: 'language',
21
+ RectangleStackIcon: 'collection',
21
22
  TagIcon: 'tag',
22
23
  UserIcon: 'user',
23
24
  },
@@ -21,6 +21,7 @@ export const doc = {
21
21
  ArrowDownTrayIcon: 'download',
22
22
  ArrowUturnLeftIcon: 'undo',
23
23
  AtSymbolIcon: 'mention',
24
+ Bars3BottomLeftIcon: 'panelLeft',
24
25
  Bars3Icon: 'menu',
25
26
  BeakerIcon: 'experiment',
26
27
  BellIcon: 'notification',
@@ -40,6 +41,7 @@ export const doc = {
40
41
  DocumentTextIcon: 'document',
41
42
  EnvelopeIcon: 'mail',
42
43
  EyeIcon: 'eye',
44
+ FingerPrintIcon: 'fingerprint',
43
45
  FolderIcon: 'folder',
44
46
  GlobeAltIcon: 'globe',
45
47
  HandRaisedIcon: 'raiseHand',
@@ -50,7 +52,9 @@ export const doc = {
50
52
  MagnifyingGlassIcon: 'search',
51
53
  MapPinIcon: 'location',
52
54
  MoonIcon: 'moon',
55
+ PaintBrushIcon: 'swatch',
53
56
  PencilSquareIcon: 'compose',
57
+ PuzzlePieceIcon: 'integration',
54
58
  QuestionMarkCircleIcon: 'info',
55
59
  ReceiptPercentIcon: 'discount',
56
60
  ShieldCheckIcon: 'shield',
@@ -20,7 +20,10 @@ export const doc = {
20
20
  category: 'Shell - Top Nav',
21
21
  icons: {
22
22
  BoltIcon: 'bolt',
23
+ CloudIcon: 'cloud',
23
24
  FaceSmileIcon: 'emoji',
25
+ FireIcon: 'fire',
26
+ GiftIcon: 'gift',
24
27
  GlobeAltIcon: 'globe',
25
28
  HomeModernIcon: 'home',
26
29
  MagnifyingGlassIcon: 'search',
@@ -10,6 +10,7 @@ export const doc = {
10
10
  isReady: true,
11
11
  category: 'Table - Grouped',
12
12
  icons: {
13
+ ArrowsRightLeftIcon: 'transfer',
13
14
  BuildingLibraryIcon: 'bank',
14
15
  CreditCardIcon: 'creditCard',
15
16
  PresentationChartLineIcon: 'activity',
@@ -19,6 +19,7 @@ export const doc = {
19
19
  Image: 'image',
20
20
  Plus: 'add',
21
21
  Sparkles: 'sparkles',
22
+ Type: 'text',
22
23
  Video: 'video',
23
24
  Zap: 'bolt',
24
25
  },
@@ -68,7 +68,7 @@ export const doc = {
68
68
  description:
69
69
  'Tell `{@command discover}` which integrations this project could add: an async function that returns a catalog. An integration can provide one too, as a `discover` named export from its manifest. Discover calls every source, yours first, and one that fails never hides the others. Discover only reads; your package manager installs.',
70
70
  example:
71
- "async ({signal, package: name, version}) => fetchCatalog({signal, name, version})",
71
+ 'async ({signal, package: name, version}) => fetchCatalog({signal, name, version})',
72
72
  },
73
73
  {
74
74
  name: 'experimental',
@@ -77,11 +77,11 @@ export const doc = {
77
77
  fields: [
78
78
  {
79
79
  name: 'experimental.iconSet',
80
- type: 'string',
80
+ type: 'string | string[]',
81
81
  stability: 'experimental',
82
82
  description:
83
- "Experimental: may change or be removed in a patch release. The project's icon set, by set name or as `<package>/<set>`. It is the opt-in: copied templates use its icons, and `astryx discover` and `astryx doctor` report icon sets, only when it is set. `astryx experimental icon` ranks its icons first; without it, the only installed set is the project's there. `astryx search` never returns icons.",
84
- example: "'@acme/outline-icons/outline'",
83
+ "Experimental: may change or be removed in a patch release. The project's main icon set, by set name or as `<package>/<set>`; or a list of them, the main set first and then backup sets in order. A copied template takes each icon from the first set in the list that has its meaning, and draws a placeholder the copied file declares when none has it. It is the opt-in: copied templates use these icons, and `astryx discover` and `astryx doctor` report icon sets, only when it is set. `astryx experimental icon use <main> --backup <set>` writes it. `astryx experimental icon` ranks the main set's icons first; without it, the only installed set is the project's there. `astryx search` never returns icons.",
84
+ example: "['@acme/outline-icons/outline', '@acme/brand-icons/brand']",
85
85
  },
86
86
  {
87
87
  name: 'experimental.xle.components',
@@ -58,7 +58,7 @@ declare const configSchema: z.ZodObject<{
58
58
  default: z.ZodOptional<z.ZodBoolean>;
59
59
  }, z.core.$strict>>>;
60
60
  }, z.core.$strict>>;
61
- iconSet: z.ZodOptional<z.ZodString>;
61
+ iconSet: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
62
62
  }, z.core.$strict>>;
63
63
  }, z.core.$strict>;
64
64
  export {};
@@ -103,7 +103,9 @@ const configSchema = z
103
103
  })
104
104
  .strict()
105
105
  .optional(),
106
- iconSet: z.string().min(1).optional(),
106
+ iconSet: z
107
+ .union([z.string().min(1), z.array(z.string().min(1)).min(1)])
108
+ .optional(),
107
109
  })
108
110
  .strict()
109
111
  .optional(),
@@ -123,12 +123,14 @@ export interface AstryxConfig {
123
123
  components?: Record<string, XleComponent>;
124
124
  };
125
125
  /**
126
- * Experimental icon sets (spec:AST-084): the project's icon set, a set
127
- * name (`"outline"`) or `"<package>/<set>"`, and the opt-in. Copied
128
- * templates use its icons, and discover and Doctor report icon sets, only
129
- * when it is set.
126
+ * Experimental icon sets (spec:AST-084): the project's main icon set, a
127
+ * set name (`"outline"`) or `"<package>/<set>"`, and the opt-in. A list
128
+ * (`["outline", "@acme/icons/brand"]`) names the main set first, then
129
+ * backup sets in order: a copied template takes each icon from the first
130
+ * set that has its meaning. Copied templates use these icons, and
131
+ * discover and Doctor report icon sets, only when it is set.
130
132
  * @experimental May change or be removed in a patch release.
131
133
  */
132
- iconSet?: string;
134
+ iconSet?: string | string[];
133
135
  };
134
136
  }
@@ -69,7 +69,7 @@ export const doc = {
69
69
  type: 'Record<string, string>',
70
70
  stability: 'experimental',
71
71
  description:
72
- "The icon definition each icon the source imports draws, such as `{TrashIcon: 'delete'}`: a named import is keyed by the name it imports (`{Trash as TrashIcon}` is `Trash`), a default import by its local name (`import DeleteIcon from …` is `DeleteIcon`). When the project sets `experimental.iconSet`, `astryx template` (shown or copied) replaces each declared icon with the set's icon for that definition (`astryx docs cli/experimental/icon-definitions`) and reports every key as mapped or kept; an undeclared import is left alone. A name imported from two modules (`TrashIcon` from an outline and a solid module) needs one key, and each import keeps its variant when its module belongs to an installed set.",
72
+ "The icon definition each icon the source imports draws, such as `{TrashIcon: 'delete'}`: a named import is keyed by the name it imports (`{Trash as TrashIcon}` is `Trash`), a default import by its local name (`import DeleteIcon from …` is `DeleteIcon`). When the project sets `experimental.iconSet`, `astryx template` (shown or copied) replaces each declared icon with the icon for that definition (`astryx docs cli/experimental/icon-definitions`) from the first set in the project's list that maps it, or with a placeholder the copied file declares when no set does, and reports every key as mapped, a placeholder, or kept; an undeclared import is left alone, and `astryx integration check` notes it (`template_icon_undeclared`, failing `--strict --next`) in a package whose templates declare `icons`. A name imported from two modules (`TrashIcon` from an outline and a solid module) needs one key, and each import keeps its variant when its module belongs to an installed set.",
73
73
  },
74
74
  {
75
75
  name: 'isReady',
@@ -55,9 +55,11 @@ export interface BaseTemplateDoc extends AuthoredDocGraphFields {
55
55
  * (`{TrashIcon: 'delete'}`), keyed by the name a named import reads
56
56
  * (`{Trash as TrashIcon}` is `Trash`) or a default import's local name
57
57
  * (`import DeleteIcon from …` is `DeleteIcon`). When the project has an
58
- * icon set, each declared icon is replaced by the set's icon for that
59
- * definition (`astryx docs cli/experimental/icon-definitions`), and every
60
- * key is reported as mapped or kept. A name imported from two modules
58
+ * icon set, each declared icon is replaced by the icon for that
59
+ * definition (`astryx docs cli/experimental/icon-definitions`) from the
60
+ * first set in the project's list that maps it, or by a placeholder the
61
+ * copied file declares when no set does, and every key is reported as mapped, a
62
+ * placeholder, or kept. A name imported from two modules
61
63
  * (`TrashIcon` from an outline and a solid module) needs one key.
62
64
  * @experimental May change or be removed in a patch release. */
63
65
  icons?: Record<string, string>;
@@ -256,10 +256,17 @@ export function registerExperimentalIcon(group, program) {
256
256
  return answered;
257
257
  }
258
258
 
259
- const {status, projectSet, reason, sets, withdrawn} = result.data;
259
+ const {status, projectSet, reason, sets, withdrawn, order, next} =
260
+ result.data;
260
261
  emit(
261
262
  section('Icon sets'),
262
- record({status, projectSet, reason}),
263
+ record({
264
+ status,
265
+ projectSet,
266
+ ...(order.length > 1 ? {order: order.join(' > ')} : {}),
267
+ reason,
268
+ }),
269
+ ...(next ? [text(`[warn] ${next}`)] : []),
263
270
  ...(sets.length > 0
264
271
  ? [
265
272
  records(
@@ -283,6 +290,7 @@ export function registerExperimentalIcon(group, program) {
283
290
  'definitions',
284
291
  'own',
285
292
  'missing',
293
+ 'role',
286
294
  'project',
287
295
  'description',
288
296
  ],
@@ -346,21 +354,42 @@ export function registerExperimentalIcon(group, program) {
346
354
 
347
355
  defineCommand(iconCli, iconUseCommand, {
348
356
  fn: iconUseFn,
349
- action: (/** @type {string} */ set) =>
357
+ action: (
358
+ /** @type {string} */ set,
359
+ /** @type {{backup?: string[]}} */ options,
360
+ ) =>
350
361
  run(
351
- () => iconUse(set, {cwd: process.cwd()}),
352
- ({data}) =>
362
+ () => iconUse(set, {cwd: process.cwd(), backups: options.backup ?? []}),
363
+ ({data}) => {
364
+ /** @type {Array<{iconSet: string, set: string}>} */
365
+ const backups = data.backups;
366
+ const shown = (/** @type {string | string[]} */ value) =>
367
+ Array.isArray(value) ? JSON.stringify(value) : `"${value}"`;
368
+ const main = `"${data.iconSet}" (${data.set})`;
369
+ const order =
370
+ backups.length > 0
371
+ ? `main set ${main}, then ${backups.map(each => `"${each.iconSet}" (${each.set})`).join(', then ')}`
372
+ : main;
353
373
  emit(
354
374
  text(
355
375
  data.changed
356
- ? `[ok] experimental.iconSet is now "${data.iconSet}" (${data.set}) in ${data.config}${data.created ? ', created' : ''}.`
357
- : `[ok] experimental.iconSet already names "${data.iconSet}" in ${data.config}.`,
376
+ ? `[ok] experimental.iconSet is now ${order} in ${data.config}${data.created ? ', created' : ''}.`
377
+ : `[ok] experimental.iconSet already names ${order} in ${data.config}.`,
358
378
  ),
379
+ ...(backups.length > 0
380
+ ? [
381
+ text(
382
+ 'A copied template takes each icon from the first set in this order that has its meaning.',
383
+ ),
384
+ ]
385
+ : []),
359
386
  ...(data.previous && data.changed
360
- ? [text(`It was "${data.previous}".`)]
387
+ ? [text(`It was ${shown(data.previous)}.`)]
361
388
  : []),
389
+ ...(data.next ? [text(`[warn] ${data.next}`)] : []),
362
390
  ...(data.warning ? [text(`[warn] ${data.warning}`)] : []),
363
- ),
391
+ );
392
+ },
364
393
  ),
365
394
  });
366
395
 
@@ -9,13 +9,18 @@ export const doc = {
9
9
  displayName: 'astryx experimental icon use',
10
10
  namespace: 'cli/commands',
11
11
  stability: 'experimental',
12
- summary: "Choose the project's icon set",
12
+ summary: "Choose the project's main icon set and backups",
13
13
  description:
14
- "Writes `experimental.iconSet` in astryx.config, so copied templates and blocks use that set's icons. The set must be installed. Experimental: it may change or be removed in a patch release.",
14
+ "Writes `experimental.iconSet` in astryx.config, so copied templates and blocks use that set's icons. With `--backup`, it writes a list: the main set first, then each backup in the order given. A copied template takes each icon from the first set in the list that has its meaning. Every set must be installed. Experimental: it may change or be removed in a patch release.",
15
15
  fn: 'iconUse',
16
16
  args: [{name: 'set', param: 'set', required: true}],
17
+ options: [{flag: '--backup <set...>', param: 'options.backups'}],
17
18
  examples: [
18
19
  {label: 'Use a set', cli: 'astryx experimental icon use outline'},
20
+ {
21
+ label: 'Use a main set with a backup',
22
+ cli: 'astryx experimental icon use outline --backup @acme/brand-icons/brand',
23
+ },
19
24
  {
20
25
  label: 'Name its package',
21
26
  cli: 'astryx experimental icon use @acme/icons/outline',
@@ -25,11 +30,11 @@ export const doc = {
25
30
  exitCodes: [
26
31
  {
27
32
  code: 0,
28
- when: 'experimental.iconSet is written, or already names the set',
33
+ when: 'experimental.iconSet is written, or already names the sets',
29
34
  },
30
35
  {
31
36
  code: 1,
32
- when: 'the set is not installed, two packages ship it, the config cannot be updated (not a static object literal, or it spreads another object, which you then edit by hand), or the config is protected (a symbolic link, or marked generated, vendored, or ignored: `ERR_CODEMOD_PROTECTED`, naming the declaration)',
37
+ when: 'a set is not installed, two packages ship it, a set is named twice, the config cannot be updated (not a static object literal, or it spreads another object, which you then edit by hand), or the config is protected (a symbolic link, or marked generated, vendored, or ignored: `ERR_CODEMOD_PROTECTED`, naming the declaration)',
33
38
  },
34
39
  ],
35
40
  related: ['experimental icon', 'template'],
@@ -57,9 +57,10 @@ function demoContentNote(count, file) {
57
57
  }
58
58
 
59
59
  /**
60
- * The icon report as text lines (AST-084 FR10): one line per mapped or kept
61
- * icon, or one line saying why nothing was mapped. Nothing when the project
62
- * has no icon set at all (no report: icon sets are experimental).
60
+ * The icon report as text lines (AST-084 FR10): one line per mapped,
61
+ * placeholder, or kept icon, or one line saying why nothing was mapped.
62
+ * Nothing when the project has no icon set at all (no report: icon sets are
63
+ * experimental). A placeholder line names its meaning and both fixes.
63
64
  * @param {import('../../../api/template/template.type.mjs').TemplateIconsReport | undefined} icons
64
65
  * @returns {string[]}
65
66
  */
@@ -74,10 +75,18 @@ function iconLines(icons) {
74
75
  ...icons.mapped.map(
75
76
  each =>
76
77
  `icons: mapped ${each.source.export} (${each.source.module}) -> ${each.target.export} (${each.target.module}) by ${each.by}` +
78
+ (icons.order ? ` from ${each.target.package}/${each.target.set}` : '') +
79
+ (each.variant
80
+ ? `; ${each.variant.asked} look not in the set, drew ${each.variant.used ?? 'its default look'}`
81
+ : '') +
77
82
  (each.dropped && each.dropped.length > 0
78
83
  ? `; dropped ${each.dropped.join(', ')} (size comes from CSS)`
79
84
  : ''),
80
85
  ),
86
+ ...(icons.placeholder ?? []).map(
87
+ each =>
88
+ `icons: placeholder ${each.source.export} (${each.source.module}) -> ${each.target.local}: no set in your list has "${each.definitions.join('", "')}", so the file draws a placeholder it declares. Fix: add a backup set that has it, \`${each.fixes[1]}\`; or, if you author your main set, map it there, \`${each.fixes[0]}\`.`,
89
+ ),
81
90
  ...icons.kept.map(
82
91
  each =>
83
92
  `icons: kept ${each.export}${each.module == null ? '' : ` (${each.module})`}: ${each.reason}` +
@@ -14,6 +14,20 @@ export function setConfigString(projectDir: string, key: string, value: string):
14
14
  previous: string | null;
15
15
  changed: boolean;
16
16
  };
17
+ /**
18
+ * Set `key` to `value`, a string or a list of strings, in the project's
19
+ * astryx.config.
20
+ * @param {string} projectDir
21
+ * @param {string} key a top-level key, or a dotted path (`experimental.iconSet`)
22
+ * @param {string | readonly string[]} value
23
+ * @returns {{file: string, created: boolean, previous: string | string[] | null, changed: boolean}}
24
+ */
25
+ export function setConfigValue(projectDir: string, key: string, value: string | readonly string[]): {
26
+ file: string;
27
+ created: boolean;
28
+ previous: string | string[] | null;
29
+ changed: boolean;
30
+ };
17
31
  /** A protected astryx.config the writer refused to touch. */
18
32
  export class ConfigProtectedError extends Error {
19
33
  /**