@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16-canary.gfef050d

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 (111) hide show
  1. package/README.md +1 -1
  2. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  3. package/api/doctor/_adapter.d.mts +3 -2
  4. package/api/doctor/_adapter.mjs +7 -1
  5. package/api/doctor/doctor.d.mts +8 -0
  6. package/api/doctor/doctor.mjs +53 -8
  7. package/api/doctor/theme-checks.mjs +157 -8
  8. package/api/icon/_adapter.d.mts +7 -3
  9. package/api/icon/_adapter.mjs +12 -3
  10. package/api/icon/icon.type.d.mts +15 -0
  11. package/api/icon/icon.type.mjs +10 -3
  12. package/api/icon/iconUse.doc.mjs +19 -5
  13. package/api/icon/list/list.mjs +7 -1
  14. package/api/icon/use/use.d.mts +8 -5
  15. package/api/icon/use/use.mjs +95 -13
  16. package/api/init/run/run.mjs +1 -0
  17. package/api/template/template.type.d.mts +6 -2
  18. package/api/template/template.type.mjs +2 -1
  19. package/api/theme/_adapter.mjs +16 -2
  20. package/api/theme/build/build.d.mts +10 -6
  21. package/api/theme/build/build.mjs +42 -29
  22. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  23. package/api/theme/palette/generate/generator.mjs +141 -2
  24. package/api/theme/theme.type.d.mts +39 -0
  25. package/api/theme/theme.type.mjs +21 -0
  26. package/api/theme/themeBuild.doc.mjs +1 -1
  27. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  28. package/api/theme-edit/_adapter.d.mts +1 -0
  29. package/api/theme-edit/_adapter.mjs +79 -21
  30. package/api/theme-edit/_check.d.mts +25 -2
  31. package/api/theme-edit/_check.mjs +251 -61
  32. package/api/theme-edit/_context.d.mts +2 -1
  33. package/api/theme-edit/_context.mjs +19 -1
  34. package/api/theme-edit/_edit.d.mts +16 -0
  35. package/api/theme-edit/_edit.mjs +360 -59
  36. package/api/theme-edit/_how-question.d.mts +8 -0
  37. package/api/theme-edit/_how-question.mjs +169 -22
  38. package/api/theme-edit/_marks.d.mts +13 -0
  39. package/api/theme-edit/_marks.mjs +15 -0
  40. package/api/theme-edit/_palette.d.mts +27 -0
  41. package/api/theme-edit/_palette.mjs +112 -8
  42. package/api/theme-edit/_preview-app.d.mts +46 -1
  43. package/api/theme-edit/_preview-app.mjs +367 -36
  44. package/api/theme-edit/_preview.d.mts +55 -0
  45. package/api/theme-edit/_preview.mjs +231 -6
  46. package/api/theme-edit/_project.d.mts +4 -0
  47. package/api/theme-edit/_project.mjs +27 -6
  48. package/api/theme-edit/_settings.d.mts +61 -2
  49. package/api/theme-edit/_settings.mjs +317 -115
  50. package/api/theme-edit/_tables.mjs +1 -1
  51. package/api/theme-edit/theme-edit.type.d.mts +30 -2
  52. package/api/theme-edit/theme-edit.type.mjs +10 -2
  53. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  54. package/assets/docs/author-a-theme.doc.mjs +1 -1
  55. package/assets/docs/theme.doc.dense.mjs +1 -1
  56. package/assets/docs/theme.doc.mjs +1 -1
  57. package/assets/docs/theme.doc.zh.mjs +4 -3
  58. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  59. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  60. package/assets/docs.generated.json +2 -2
  61. package/assets/self-audit.generated.json +1 -1
  62. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  63. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  64. package/assets/templates/components.generated.json +1 -1
  65. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  66. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  67. package/authoring/config/config.doc.mjs +8 -0
  68. package/authoring/config/parse.d.mts +1 -0
  69. package/authoring/config/parse.mjs +12 -0
  70. package/authoring/config/type.ts +8 -0
  71. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  72. package/clients/cli/build-id.generated.json +1 -1
  73. package/clients/cli/commands/experimental/icon.mjs +61 -6
  74. package/clients/cli/commands/experimental/theme.mjs +9 -2
  75. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  76. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  77. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  78. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  79. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  80. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  81. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  82. package/clients/cli/commands/theme.doc.mjs +7 -2
  83. package/clients/cli/commands/theme.mjs +41 -18
  84. package/clients/cli/commands.generated.json +1 -1
  85. package/clients/cli/index.mjs +25 -5
  86. package/clients/cli/manifest.generated.json +1 -1
  87. package/foundation/agent-docs/agent-docs.mjs +1 -1
  88. package/foundation/config/config-writer.d.mts +23 -0
  89. package/foundation/config/config-writer.mjs +150 -56
  90. package/foundation/config/project.mjs +43 -2
  91. package/foundation/discovery/component-discovery.mjs +6 -5
  92. package/foundation/discovery/icon-set-checks.mjs +164 -48
  93. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  94. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  95. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  96. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  97. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  98. package/foundation/discovery/icon-set-writer.mjs +57 -16
  99. package/foundation/discovery/template-icons.d.mts +27 -10
  100. package/foundation/discovery/template-icons.mjs +142 -26
  101. package/foundation/discovery/theme-discovery.d.mts +25 -0
  102. package/foundation/discovery/theme-discovery.mjs +48 -7
  103. package/foundation/fs/gather-cache.mjs +6 -2
  104. package/foundation/integrations/autolink.d.mts +4 -2
  105. package/foundation/integrations/autolink.mjs +4 -2
  106. package/foundation/integrations/cli-requirement.d.mts +16 -5
  107. package/foundation/integrations/cli-requirement.mjs +27 -6
  108. package/foundation/integrations/may-have-integrations.mjs +5 -2
  109. package/foundation/integrations/missing-dependency.d.mts +9 -0
  110. package/foundation/integrations/missing-dependency.mjs +100 -0
  111. package/package.json +6 -6
package/README.md CHANGED
@@ -112,7 +112,7 @@ Each command declares what it does in a folder outside any project, and `astryx
112
112
  | `search` | Search components, hooks, docs, templates, and themes in one ranked list | `same` |
113
113
  | `swizzle` | Copy component source for customization | `refuse` |
114
114
  | `template` | List, show, or scaffold page and block templates | `same` |
115
- | `theme` | Add, switch, build, and author themes | by subcommand |
115
+ | `theme` | Add, switch, build, and author themes (to make or change one, use experimental theme editor) | by subcommand |
116
116
  | `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components | `own` |
117
117
 
118
118
  <!-- END GENERATED: commands -->
@@ -277,7 +277,7 @@ useMenuDrillIn useMenuDrillIn DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/use
277
277
  useMenuHover useMenuHover hooks/useAnimatedLayout.doc.mjs hooks/useMenuHover.ts
278
278
  useMenuOverflow useMenuOverflow DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/useMenuOverflow.ts
279
279
  useMobileKeyboard ERR_UNKNOWN_COMPONENT - keyboard/useMobileKeyboard.ts
280
- useOutlineFromDOM useOutlineFromDOM Outline/Outline.doc.mjs Outline/useOutlineFromDOM.ts
280
+ useOutlineFromDOM useOutlineFromDOM Outline/useOutlineFromDOM.doc.mjs Outline/useOutlineFromDOM.ts
281
281
  useOverlay useOverlay Overlay/useOverlay.doc.mjs Overlay/useOverlay.tsx
282
282
  useOwnScrollGesture useOwnScrollGesture DateInput/DateInput.doc.mjs DateInput/useOwnScrollGesture.ts
283
283
  usePager usePager hooks/useAnimatedLayout.doc.mjs hooks/usePager.ts
@@ -282,7 +282,6 @@ export function readBuiltPath(target: string, { fileLimit }?: {
282
282
  */
283
283
  export function builtIntegrationPackages(target: string, cwd: string): string[];
284
284
  export { placeholderFixes } from "../../foundation/discovery/template-icons.mjs";
285
- export { unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
286
285
  export { installCommandFor as packageInstallCommand } from "../../foundation/discovery/template-needs.mjs";
287
286
  export { resolveRecordedTheme } from "../theme/theme.mjs";
288
287
  export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
@@ -298,6 +297,8 @@ import { lastNoticeSkip } from '../../foundation/release/notices.mjs';
298
297
  import { lastCheckFailure } from '../../foundation/release/global-state.mjs';
299
298
  import { stateLockHolder } from '../../foundation/release/global-state.mjs';
300
299
  import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
300
+ export { iconUseCommand, unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
301
301
  export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
302
- export { missingThemePackage, themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
302
+ export { GENERATED_MARKER, isPrivateVarRefusal, missingThemePackage, themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
303
+ export { APP_COPY_MARK, EDITOR_GENERATED_MARK } from "../theme-edit/_marks.mjs";
303
304
  export { AUTHORING_AUDIT, authoringAudit, authoringAuditData } from "./_authoring-audit.mjs";
@@ -41,7 +41,10 @@ import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs'
41
41
  import * as fs from 'node:fs';
42
42
  import {placeholderUses} from '../../foundation/discovery/template-icons.mjs';
43
43
  export {placeholderFixes} from '../../foundation/discovery/template-icons.mjs';
44
- export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mjs';
44
+ export {
45
+ iconUseCommand,
46
+ unlistedIconSets,
47
+ } from '../../foundation/discovery/icon-set-discovery.mjs';
45
48
  import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
46
49
  import {cssImports} from '../../foundation/render/embedded-imports.mjs';
47
50
  import {satisfiesRange} from '../../foundation/env/semver.mjs';
@@ -73,10 +76,13 @@ export {
73
76
  resolveThemeModule,
74
77
  } from '../../foundation/config/theme-state.mjs';
75
78
  export {
79
+ GENERATED_MARKER,
80
+ isPrivateVarRefusal,
76
81
  missingThemePackage,
77
82
  themeBuild,
78
83
  validateThemePrivateInputs,
79
84
  } from '../theme/build/build.mjs';
85
+ export {APP_COPY_MARK, EDITOR_GENERATED_MARK} from '../theme-edit/_marks.mjs';
80
86
  export {installCommandFor as packageInstallCommand} from '../../foundation/discovery/template-needs.mjs';
81
87
  export {resolveRecordedTheme} from '../theme/theme.mjs';
82
88
  export {collectUnloadedFonts} from '../theme/build/font-warning.mjs';
@@ -482,6 +482,14 @@ export type DoctorContext = {
482
482
  status: "selected" | "none" | "ambiguous" | "missing" | "withdrawn";
483
483
  reason: string;
484
484
  configured?: string;
485
+ set?: {
486
+ name: string;
487
+ package: string;
488
+ data: {
489
+ variants?: string[];
490
+ };
491
+ };
492
+ variant?: string;
485
493
  backups?: Array<{
486
494
  selector: string;
487
495
  status: "selected" | "ambiguous" | "missing" | "withdrawn";
@@ -110,6 +110,7 @@ import {
110
110
  projectHasOwnCli,
111
111
  computerIntegrationsOutside,
112
112
  findIconPlaceholders,
113
+ iconUseCommand,
113
114
  placeholderFixes,
114
115
  unlistedIconSets,
115
116
  computerIntegrationsToAdd,
@@ -168,7 +169,7 @@ import {checkBuilt} from './built-checks.mjs';
168
169
  * Combined project-level integration issues, including cross-package template replacement warnings.
169
170
  * @property {Error|null} [configError] - Error thrown while resolving the config
170
171
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
171
- * @property {{sets: Array<{name: string, package: string}>, withdrawn: Array<{name: string, package: string, reason: string}>, choice: {status: 'selected'|'none'|'ambiguous'|'missing'|'withdrawn', reason: string, configured?: string, backups?: Array<{selector: string, status: 'selected'|'ambiguous'|'missing'|'withdrawn', reason: string}>, order?: Array<{name: string, package: string}>}}|null} [iconSets]
172
+ * @property {{sets: Array<{name: string, package: string}>, withdrawn: Array<{name: string, package: string, reason: string}>, choice: {status: 'selected'|'none'|'ambiguous'|'missing'|'withdrawn', reason: string, configured?: string, set?: {name: string, package: string, data: {variants?: string[]}}, variant?: string, backups?: Array<{selector: string, status: 'selected'|'ambiguous'|'missing'|'withdrawn', reason: string}>, order?: Array<{name: string, package: string}>}}|null} [iconSets]
172
173
  * The project's icon sets (AST-084 FR17), or null when they could not be read.
173
174
  * Experimental: may change or be removed in a patch release.
174
175
  * @property {Array<{file: string, local: string, meanings: string[] | null, uses: number}>|null} [iconPlaceholders]
@@ -652,9 +653,11 @@ export function checkImplicitIntegrations(ctx) {
652
653
 
653
654
  /**
654
655
  * The sentence `implicit-integrations` adds for dependencies whose manifest
655
- * could not be loaded, or '' when there are none. Still informational: the
656
- * package is a dependency's own bug, which `doctor integration validate`
657
- * diagnoses, but doctor must not report it as absent.
656
+ * could not be loaded, or '' when there are none. Still informational: a
657
+ * broken install (a package the dependency requires is missing) is also that
658
+ * package's integration issue (INV14), and anything else is the dependency's
659
+ * own bug, which `doctor integration validate` diagnoses; either way doctor
660
+ * must not report it as absent.
658
661
  * @param {Array<{spec: string, error: string}>} failures
659
662
  * @returns {string}
660
663
  */
@@ -1145,11 +1148,34 @@ export function checkIconSets(ctx) {
1145
1148
  fix: 'Write each name in experimental.iconSet as "<package>/<set>" (`astryx experimental icon --list` names them).',
1146
1149
  };
1147
1150
  }
1151
+ // The look a project picks is one of its main set's variants.
1152
+ const declared = choice.set?.data.variants ?? [];
1153
+ if (choice.set && choice.variant && !declared.includes(choice.variant)) {
1154
+ return {
1155
+ id,
1156
+ label,
1157
+ status: 'fail',
1158
+ message:
1159
+ declared.length === 0
1160
+ ? `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured} declares no variants: it draws one look.`
1161
+ : `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured} declares no such variant. Its variants: ${declared.join(', ')}.`,
1162
+ fix:
1163
+ declared.length === 0
1164
+ ? `Remove experimental.iconVariant: run \`${iconUseCommandOf(choice)}\`.`
1165
+ : `Pick one of its variants: \`${iconUseCommandOf(choice, '<variant>')}\`.`,
1166
+ };
1167
+ }
1148
1168
  const order = choice.order ?? [];
1149
1169
  const unlisted = sets.filter(set => !order.includes(set));
1150
1170
  if (sets.length > 1 && unlisted.length > 0 && order.length > 0) {
1151
1171
  const [main, ...backups] = order;
1152
- const {problem, fix} = unlistedIconSets(sets, main, backups, unlisted);
1172
+ const {problem, fix} = unlistedIconSets(
1173
+ sets,
1174
+ main,
1175
+ backups,
1176
+ unlisted,
1177
+ choice.variant,
1178
+ );
1153
1179
  return {
1154
1180
  id,
1155
1181
  label,
@@ -1171,10 +1197,24 @@ export function checkIconSets(ctx) {
1171
1197
  id,
1172
1198
  label,
1173
1199
  status: 'pass',
1174
- message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}`,
1200
+ message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}${choice.variant ? ` Each icon draws its "${choice.variant}" look where its set has one.` : ''}`,
1175
1201
  };
1176
1202
  }
1177
1203
 
1204
+ /**
1205
+ * The `experimental icon use` command that writes the project's list again,
1206
+ * as astryx.config names it, with a variant when one is given.
1207
+ * @param {NonNullable<DoctorContext['iconSets']>['choice']} choice
1208
+ * @param {string} [variant]
1209
+ */
1210
+ function iconUseCommandOf(choice, variant) {
1211
+ return iconUseCommand(
1212
+ /** @type {string} */ (choice.configured),
1213
+ (choice.backups ?? []).map(each => each.selector),
1214
+ variant,
1215
+ );
1216
+ }
1217
+
1178
1218
  /**
1179
1219
  * The placeholder component for a missing icon, still in the project's own
1180
1220
  * source (AST-084): each file and the meanings it stands for, with the commands that give each a
@@ -1207,7 +1247,12 @@ export function checkIconPlaceholders(ctx) {
1207
1247
  )
1208
1248
  .join(', ');
1209
1249
  const uses = found.reduce((total, each) => total + each.uses, 0);
1210
- const [mapFix, backupFix] = placeholderFixes(meanings, main);
1250
+ const [mapFix, backupFix] = placeholderFixes(
1251
+ meanings,
1252
+ main,
1253
+ (choice.backups ?? []).map(each => each.selector),
1254
+ choice.variant,
1255
+ );
1211
1256
  return {
1212
1257
  id,
1213
1258
  label,
@@ -2277,7 +2322,7 @@ export function checkGatherCache() {
2277
2322
  id: 'gather-cache',
2278
2323
  label: 'Kept catalog cache',
2279
2324
  status: 'info',
2280
- message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, integrations' theme records, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2325
+ message: `search, build, component, template, theme, discover, docs and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, integrations' theme records, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2281
2326
  };
2282
2327
  }
2283
2328
 
@@ -32,11 +32,15 @@ import {
32
32
  resolveRecordedTheme,
33
33
  resolveThemeModule,
34
34
  SOURCE_EXTENSIONS,
35
+ isPrivateVarRefusal,
35
36
  missingThemePackage,
36
37
  packageInstallCommand,
37
38
  themeBuild,
38
39
  themeRecordOwner,
39
40
  validateThemePrivateInputs,
41
+ GENERATED_MARKER,
42
+ APP_COPY_MARK,
43
+ EDITOR_GENERATED_MARK,
40
44
  } from './_adapter.mjs';
41
45
  import {
42
46
  getCliInvocation,
@@ -215,6 +219,123 @@ function sourceImportEvidence(root, generatedModule) {
215
219
  return {found: false, parseFailures};
216
220
  }
217
221
 
222
+ /**
223
+ * Whether the file's leading comment says the CLI generated it: a theme
224
+ * build, or a file of the theme editor (its settings module, its app copy).
225
+ * @param {string} source
226
+ */
227
+ function generatedThemeFile(source) {
228
+ const leading =
229
+ /^\s*(?:\/\*[\s\S]*?\*\/|(?:\/\/[^\n]*(?:\n|$)\s*)+)/.exec(source)?.[0] ??
230
+ '';
231
+ return [GENERATED_MARKER, EDITOR_GENERATED_MARK, APP_COPY_MARK].some(m =>
232
+ leading.includes(m),
233
+ );
234
+ }
235
+
236
+ /**
237
+ * The specifiers a file imports only to extend a theme: every binding of
238
+ * the import is used solely as the `extends` value of a `defineTheme({...})`
239
+ * call. Any other use of a binding (a switcher, a render, a re-export) keeps
240
+ * the import, and so does a second import of the same specifier.
241
+ * @param {any} ast
242
+ * @returns {Set<string>}
243
+ */
244
+ function extendOnlySpecifiers(ast) {
245
+ /** @type {Map<string, string>} binding -> specifier */
246
+ const bindings = new Map();
247
+ /** @type {Map<string, number>} */
248
+ const importsOf = new Map();
249
+ for (const node of ast.program?.body ?? []) {
250
+ if (node.type !== 'ImportDeclaration' || node.importKind === 'type')
251
+ continue;
252
+ const from = node.source.value;
253
+ importsOf.set(from, (importsOf.get(from) ?? 0) + 1);
254
+ for (const s of node.specifiers ?? []) bindings.set(s.local.name, from);
255
+ }
256
+ /** @type {Map<string, {extends: number, other: number}>} */
257
+ const uses = new Map();
258
+ /**
259
+ * @param {any} node
260
+ * @param {any} parent
261
+ * @param {any} grand
262
+ * @param {any} great
263
+ */
264
+ const visit = (node, parent, grand, great) => {
265
+ if (node == null || typeof node !== 'object') return;
266
+ if (Array.isArray(node)) {
267
+ for (const n of node) visit(n, parent, grand, great);
268
+ return;
269
+ }
270
+ if (
271
+ node.type === 'Identifier' &&
272
+ bindings.has(node.name) &&
273
+ ![
274
+ 'ImportSpecifier',
275
+ 'ImportDefaultSpecifier',
276
+ 'ImportNamespaceSpecifier',
277
+ ].includes(parent?.type) &&
278
+ !(
279
+ parent?.type === 'ObjectProperty' &&
280
+ parent.key === node &&
281
+ !parent.computed &&
282
+ parent.value !== node
283
+ )
284
+ ) {
285
+ const u = uses.get(node.name) ?? {extends: 0, other: 0};
286
+ // The `extends` of a `defineTheme({...})` call, as the check reads a
287
+ // theme's base everywhere else.
288
+ const asExtends = definedThemeBase(great) === node;
289
+ if (asExtends) u.extends++;
290
+ else u.other++;
291
+ uses.set(node.name, u);
292
+ }
293
+ if (typeof node.type !== 'string') return;
294
+ for (const [key, child] of Object.entries(node)) {
295
+ if (['loc', 'start', 'end', 'extra'].includes(key)) continue;
296
+ visit(child, node, parent, grand);
297
+ }
298
+ };
299
+ visit(ast.program, null, null, null);
300
+ // Every other way the file loads a module (`import()`, `require()`,
301
+ // `export … from`): a specifier loaded so is not only extended.
302
+ /** @type {Set<string>} */
303
+ const loadedOtherwise = new Set();
304
+ walkAst(ast.program, node => {
305
+ if (
306
+ ['ExportNamedDeclaration', 'ExportAllDeclaration'].includes(node.type) &&
307
+ typeof node.source?.value === 'string'
308
+ )
309
+ loadedOtherwise.add(node.source.value);
310
+ if (
311
+ node.type === 'ImportExpression' &&
312
+ typeof node.source?.value === 'string'
313
+ )
314
+ loadedOtherwise.add(node.source.value);
315
+ if (
316
+ node.type === 'CallExpression' &&
317
+ (node.callee?.type === 'Import' || node.callee?.name === 'require') &&
318
+ typeof node.arguments?.[0]?.value === 'string'
319
+ )
320
+ loadedOtherwise.add(node.arguments[0].value);
321
+ });
322
+ /** @type {Map<string, boolean>} */
323
+ const only = new Map();
324
+ for (const [name, from] of bindings) {
325
+ const u = uses.get(name) ?? {extends: 0, other: 0};
326
+ const ok = u.extends > 0 && u.other === 0;
327
+ only.set(from, (only.get(from) ?? true) && ok);
328
+ }
329
+ return new Set(
330
+ [...only]
331
+ .filter(
332
+ ([from, ok]) =>
333
+ ok && importsOf.get(from) === 1 && !loadedOtherwise.has(from),
334
+ )
335
+ .map(([from]) => from),
336
+ );
337
+ }
338
+
218
339
  /**
219
340
  * Find a source file that imports one added built module without its paired CSS.
220
341
  * @param {string} root
@@ -235,6 +356,10 @@ function themeImportPairEvidence(root, generatedModule, themes) {
235
356
  } catch {
236
357
  continue;
237
358
  }
359
+ // A file the CLI generates (a theme build, the editor's files) only
360
+ // extends another theme's module, never renders it. The app's theme
361
+ // module stays checked.
362
+ if (file !== generatedModule && generatedThemeFile(source)) continue;
238
363
  const candidates = themes.filter(theme =>
239
364
  source.includes(
240
365
  theme.source === 'local'
@@ -246,6 +371,11 @@ function themeImportPairEvidence(root, generatedModule, themes) {
246
371
  let specifiers;
247
372
  try {
248
373
  specifiers = moduleSpecifiers(source);
374
+ // An import used only as a theme's `extends` (a theme source) does not
375
+ // render that theme: its stylesheet is not asked for.
376
+ if (file !== generatedModule)
377
+ for (const from of extendOnlySpecifiers(parseModule(source)))
378
+ specifiers.delete(from);
249
379
  } catch {
250
380
  unproven.push(relative(root, file));
251
381
  continue;
@@ -1085,6 +1215,9 @@ export async function checkAppThemes(cwd) {
1085
1215
  });
1086
1216
  } else {
1087
1217
  const stale = [];
1218
+ /** Local themes the build refused for a private var: not checked. */
1219
+ /** @type {string[]} */
1220
+ const refused = [];
1088
1221
  /** @type {Map<string, string[]>} theme slugs by the package they import and the app lacks */
1089
1222
  const missingPackages = new Map();
1090
1223
  const previousSilent = logger.silent;
@@ -1111,6 +1244,12 @@ export async function checkAppThemes(cwd) {
1111
1244
  stale.push(theme.slug);
1112
1245
  }
1113
1246
  } catch (error) {
1247
+ // A theme that sets a private var is the "Private theme
1248
+ // variables" check's to report, not a stale output.
1249
+ if (isPrivateVarRefusal(error)) {
1250
+ refused.push(theme.slug);
1251
+ continue;
1252
+ }
1114
1253
  const missing = missingThemePackage(error);
1115
1254
  if (missing) {
1116
1255
  missingPackages.set(missing, [
@@ -1151,7 +1290,7 @@ export async function checkAppThemes(cwd) {
1151
1290
  .map(([pkg, slugs]) => `${pkg} (${slugs.join(', ')})`)
1152
1291
  .join(
1153
1292
  '; ',
1154
- )}.${stale.length > 0 ? ` Local theme outputs are also missing or stale: ${stale.join(', ')}.` : ''}`,
1293
+ )}.${stale.length > 0 ? ` Local theme outputs are also missing or stale: ${stale.join(', ')}.` : ''}${refused.length > 0 ? ` Not checked (a private theme variable; see theme-private-variables): ${refused.join(', ')}.` : ''}`,
1155
1294
  fix: [
1156
1295
  install?.installCommand ??
1157
1296
  install?.noCommandReason ??
@@ -1164,15 +1303,25 @@ export async function checkAppThemes(cwd) {
1164
1303
  id: 'theme-local-builds',
1165
1304
  label: 'Local theme build freshness',
1166
1305
  status: 'fail',
1167
- message: `Local theme outputs are missing or stale: ${stale.join(', ')}.`,
1306
+ message: `Local theme outputs are missing or stale: ${stale.join(', ')}.${refused.length > 0 ? ` Not checked (a private theme variable; see theme-private-variables): ${refused.join(', ')}.` : ''}`,
1168
1307
  fix: refresh.join(' '),
1169
1308
  }
1170
- : {
1171
- id: 'theme-local-builds',
1172
- label: 'Local theme build freshness',
1173
- status: 'pass',
1174
- message: 'Every added local theme output matches its source.',
1175
- },
1309
+ : refused.length > 0
1310
+ ? {
1311
+ // Not a pass: the build refused these, so their outputs
1312
+ // were never compared with their sources.
1313
+ id: 'theme-local-builds',
1314
+ label: 'Local theme build freshness',
1315
+ status: 'info',
1316
+ message: `Not checked: ${refused.join(', ')} ${refused.length === 1 ? 'sets' : 'set'} a private theme variable, so the build refuses ${refused.length === 1 ? 'it' : 'them'} and ${refused.length === 1 ? 'its' : 'their'} outputs were not compared with ${refused.length === 1 ? 'its source' : 'their sources'}.`,
1317
+ fix: 'Follow the fix on the theme-private-variables check, then run doctor again.',
1318
+ }
1319
+ : {
1320
+ id: 'theme-local-builds',
1321
+ label: 'Local theme build freshness',
1322
+ status: 'pass',
1323
+ message: 'Every added local theme output matches its source.',
1324
+ },
1176
1325
  );
1177
1326
  }
1178
1327
 
@@ -37,17 +37,20 @@ export function loadIconProject(cwd: string): Promise<{
37
37
  projectDir: string;
38
38
  sets: import("../../foundation/discovery/icon-set-discovery.mjs").DiscoveredIconSet[];
39
39
  withdrawn: import("../../foundation/discovery/icon-set-discovery.mjs").WithdrawnIconSet[];
40
+ variant: string | null;
40
41
  }>;
41
42
  /**
42
43
  * Why a CLI the project may run would refuse its astryx.config once it sets
43
44
  * `experimental.iconSet`, read from the project's package.json; null when
44
45
  * nothing says so.
45
46
  * @param {string} projectDir
46
- * @param {{list?: boolean}} [options] `list`: the value written is a list
47
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value
48
+ * written is a list; `variant`: `experimental.iconVariant` is written too
47
49
  * @returns {string | null}
48
50
  */
49
51
  export function iconSetConfigCliWarning(projectDir: string, options?: {
50
52
  list?: boolean;
53
+ variant?: boolean;
51
54
  }): string | null;
52
55
  /**
53
56
  * The icon definitions the bundled templates use that a set of the local
@@ -59,11 +62,12 @@ export function iconSetConfigCliWarning(projectDir: string, options?: {
59
62
  */
60
63
  export function templateMeaningsOf(cwd: string, selector: string | undefined): Promise<import("./icon.type.mjs").IconTemplateMeanings | null>;
61
64
  export { astryxIconDefinitions } from "../../foundation/discovery/icon-definition-discovery.mjs";
65
+ export { lookThemeMap } from "../../foundation/discovery/icon-set-theme-maps.mjs";
62
66
  export { exportValueKind } from "../../foundation/discovery/module-exports.mjs";
63
67
  export { templateIconMeanings } from "../../foundation/discovery/template-icon-meanings.mjs";
64
68
  export { iconRecord, importLine, leadingReading, matchIcon, answeringMatches, rankIcons, scoreIcon } from "../../foundation/discovery/icon-ranking.mjs";
65
- export { iconSetKey, ICON_USE_ORDER_COMMAND, unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
66
- export { setConfigString, setConfigValue } from "../../foundation/config/config-writer.mjs";
69
+ export { iconSetKey, ICON_USE_ORDER_COMMAND, iconSetLook, iconUseCommand, unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
70
+ export { setConfigString, setConfigValues } from "../../foundation/config/config-writer.mjs";
67
71
  export { assertIconExport, checkNewDefinition, definitionNameFromInput, definitionFile, findLocalIconSet, writeDefinitionFile, iconIdOf, closestNames, libraryIcons, mappableDefinitions, resolveIconSource, generatedModulePath, generatedNamesOf, generatedOrigins, iconModulePackage, sameIconModule, iconExportName, iconNaming, modulePrefix, moduleNaming, iconNamingWithoutLook, splitLook, setModuleNote, variantExportName, writeGeneratedIcons, writeIconSetData, definitionNameOf, iconIdIn, iconsWithWord, localSourceNote, THEME_MAP_NAME } from "../../foundation/discovery/icon-set-writer.mjs";
68
72
  export { addIconDefinition, addIconSet } from "./_authoring.mjs";
69
73
  export { checkVariantLook, drawnLooks } from "./_default-look.mjs";
@@ -41,10 +41,13 @@ export {astryxIconDefinitions} from '../../foundation/discovery/icon-definition-
41
41
  export {iconSetKey} from '../../foundation/discovery/icon-set-discovery.mjs';
42
42
  export {
43
43
  setConfigString,
44
- setConfigValue,
44
+ setConfigValues,
45
45
  } from '../../foundation/config/config-writer.mjs';
46
+ export {lookThemeMap} from '../../foundation/discovery/icon-set-theme-maps.mjs';
46
47
  export {
47
48
  ICON_USE_ORDER_COMMAND,
49
+ iconSetLook,
50
+ iconUseCommand,
48
51
  unlistedIconSets,
49
52
  } from '../../foundation/discovery/icon-set-discovery.mjs';
50
53
  export {
@@ -167,7 +170,12 @@ export async function loadIconSets(cwd) {
167
170
  export async function loadIconProject(cwd) {
168
171
  const project = await Project.load(cwd);
169
172
  const {sets, withdrawn} = await project.iconSets({experimental: true});
170
- return {projectDir: findProjectDir(cwd), sets, withdrawn};
173
+ return {
174
+ projectDir: findProjectDir(cwd),
175
+ sets,
176
+ withdrawn,
177
+ variant: project.config.experimental?.iconVariant ?? null,
178
+ };
171
179
  }
172
180
 
173
181
  /**
@@ -190,7 +198,8 @@ function findProjectDir(cwd) {
190
198
  * `experimental.iconSet`, read from the project's package.json; null when
191
199
  * nothing says so.
192
200
  * @param {string} projectDir
193
- * @param {{list?: boolean}} [options] `list`: the value written is a list
201
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value
202
+ * written is a list; `variant`: `experimental.iconVariant` is written too
194
203
  * @returns {string | null}
195
204
  */
196
205
  export function iconSetConfigCliWarning(projectDir, options = {}) {
@@ -136,6 +136,10 @@ export type IconSetEntry = {
136
136
  * - The set's position in the list, the main set at 1; null when it is not listed.
137
137
  */
138
138
  rank: number | null;
139
+ /**
140
+ * - Present when the project names a variant: the look this set's icons draw, the variant when the set declares it, else its default look; null when the list leaves the set out or it declares no variants.
141
+ */
142
+ look?: string | null | undefined;
139
143
  };
140
144
  /**
141
145
  * Which icon definitions one set's `map` covers.
@@ -179,6 +183,7 @@ export type IconListResponse = {
179
183
  projectSet: string | null;
180
184
  reason: string;
181
185
  order: string[];
186
+ variant: string | null;
182
187
  backups: Array<{
183
188
  iconSet: string;
184
189
  status: "selected" | "ambiguous" | "missing" | "withdrawn";
@@ -201,11 +206,21 @@ export type IconUseResponse = {
201
206
  iconSet: string;
202
207
  set: string;
203
208
  }>;
209
+ variant: string | null;
204
210
  config: string;
205
211
  created: boolean;
206
212
  previous: string | string[] | null;
213
+ previousVariant: string | null;
207
214
  changed: boolean;
208
215
  unlisted: string[];
216
+ looks?: {
217
+ set: string;
218
+ variant: string | null;
219
+ }[] | undefined;
220
+ themeMap?: {
221
+ module: string;
222
+ export: string;
223
+ } | undefined;
209
224
  next?: string | undefined;
210
225
  warning?: string | undefined;
211
226
  };
@@ -86,6 +86,7 @@
86
86
  * @property {boolean} project - Whether this is the project's icon set.
87
87
  * @property {'main' | 'backup' | null} role - The set's place in the project's list: its main set, a backup, or not listed.
88
88
  * @property {number | null} rank - The set's position in the list, the main set at 1; null when it is not listed.
89
+ * @property {string | null} [look] - Present when the project names a variant: the look this set's icons draw, the variant when the set declares it, else its default look; null when the list leaves the set out or it declares no variants.
89
90
  */
90
91
 
91
92
  /**
@@ -116,6 +117,7 @@
116
117
  * @property {string | null} data.projectSet - The project's set, as `<package>/<set>`, when selected.
117
118
  * @property {string} data.reason - Why the project has that set, or none.
118
119
  * @property {string[]} data.order - The project's list as `<package>/<set>`: the main set, then each backup that resolves; empty when no main set is selected.
120
+ * @property {string | null} data.variant - The look the project's icons draw, as `experimental.iconVariant` names it; null when it names none.
119
121
  * @property {Array<{iconSet: string, status: 'selected' | 'ambiguous' | 'missing' | 'withdrawn', reason: string}>} data.backups - Each backup the list names, and whether it resolves.
120
122
  * @property {string} [data.next] - Present when two or more sets are installed and none is the main set: the command that chooses the order.
121
123
  * @property {IconSetEntry[]} data.sets - Installed sets in list order: the main set, its backups, then the rest.
@@ -131,16 +133,21 @@
131
133
  * @property {string} data.iconSet - The main set, as written to `experimental.iconSet` (alone, or first in the list).
132
134
  * @property {string} data.set - The main set it names, as `<package>/<set>`.
133
135
  * @property {Array<{iconSet: string, set: string}>} data.backups - The backup sets, in order, as written and as `<package>/<set>`; empty when there are none.
136
+ * @property {string | null} data.variant - The look every icon draws, as written to `experimental.iconVariant`; null when none is named, and the key is removed, so each set draws its default look.
134
137
  * @property {string} data.config - The config file, relative to the project.
135
138
  * @property {boolean} data.created - Whether the config file was created.
136
139
  * @property {string | string[] | null} data.previous - The `experimental.iconSet` value it replaced.
140
+ * @property {string | null} data.previousVariant - The `experimental.iconVariant` value it replaced.
137
141
  * @property {boolean} data.changed - Whether anything was written.
138
142
  * @property {string[]} data.unlisted - Installed sets the list leaves out, as `<package>/<set>`. Doctor fails a project that installs more than one set and leaves one out.
143
+ * @property {Array<{set: string, variant: string | null}>} [data.looks] - Present when a variant is named: each set in the list, main set first, as `<package>/<set>`, with the look its icons draw: the variant, or the set's default look when it declares no variant of that name (null when it declares no variants).
144
+ * @property {{module: string, export: string}} [data.themeMap] - Present when a variant is named and the main set has a theme map for that look: the export a theme sets as `icons` to draw the built-in icons in it (`themeIconsFilled`), and the module it is imported from.
139
145
  * @property {string} [data.next] - Present when `unlisted` is not empty: the command that adds them as backups.
140
146
  * @property {string} [data.warning] - Present when the project's
141
- * `@astryxdesign/cli` range admits a release before 0.7.4, which refuses
142
- * an astryx.config that sets `experimental.iconSet`: what fails, and the
143
- * range to require.
147
+ * `@astryxdesign/cli` range admits a release that refuses the config
148
+ * written: before 0.7.4 for `experimental.iconSet`, before 0.7.12 for it
149
+ * as a list, and before 0.7.16 for `experimental.iconVariant`. It says
150
+ * what fails, and the range to require.
144
151
  */
145
152
 
146
153
  /**