@astryxdesign/cli 0.6.5-canary.cc06b18 → 0.6.5-canary.cc101b9

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.
@@ -4,9 +4,7 @@
4
4
  /**
5
5
  * Collect the effective handler set in delivery order: project config first,
6
6
  * then integrations in config order. Valid handlers dedupe by handle identity;
7
- * malformed integration exports and integrations that failed to load retain
8
- * their position as failed deliveries. An unloadable integration may export a
9
- * handler, so it never counts as an empty set that enables the fallback.
7
+ * malformed integration exports retain their position as failed deliveries.
10
8
  *
11
9
  * @param {Project} project
12
10
  * @returns {HandlerEntry[]}
@@ -189,9 +189,7 @@ async function selectTarget(project, component, packageName) {
189
189
  /**
190
190
  * Collect the effective handler set in delivery order: project config first,
191
191
  * then integrations in config order. Valid handlers dedupe by handle identity;
192
- * malformed integration exports and integrations that failed to load retain
193
- * their position as failed deliveries. An unloadable integration may export a
194
- * handler, so it never counts as an empty set that enables the fallback.
192
+ * malformed integration exports retain their position as failed deliveries.
195
193
  *
196
194
  * @param {Project} project
197
195
  * @returns {HandlerEntry[]}
@@ -216,15 +214,7 @@ export function collectGapReportHandlers(project) {
216
214
  }
217
215
 
218
216
  for (const integration of project.loadedIntegrations) {
219
- if (integration.__loadError) {
220
- entries.push({
221
- kind: 'malformed',
222
- handlerType: 'integration',
223
- handlerName: integration.name,
224
- error: `Integration failed to load, so it could not receive this report: ${integration.__loadError}. Fix the package or remove it from integrations in astryx.config, then rerun.`,
225
- });
226
- continue;
227
- }
217
+ if (integration.__loadError) continue;
228
218
  if (integration.__gapReportError) {
229
219
  entries.push({
230
220
  kind: 'malformed',
@@ -105,45 +105,6 @@ function addIntegration({
105
105
  return {dir};
106
106
  }
107
107
 
108
- /**
109
- * Add an integration whose module throws on import, so it never loads.
110
- * @param {string} name
111
- */
112
- function addBrokenIntegration(name) {
113
- const dir = packageDir(name);
114
- fs.mkdirSync(dir, {recursive: true});
115
- fs.writeFileSync(
116
- path.join(dir, 'package.json'),
117
- JSON.stringify({name, version: '1.0.0', type: 'module'}),
118
- );
119
- fs.writeFileSync(
120
- path.join(dir, 'astryx.integration.mjs'),
121
- "throw new Error('intentional integration load failure');\n",
122
- );
123
- }
124
-
125
- /**
126
- * Put a fake `gh` first on PATH that records its arguments if it is called.
127
- * @returns {string} the file the fake writes when invoked
128
- */
129
- function stubGh() {
130
- const binDir = path.join(projectDir, 'bin');
131
- const argsFile = path.join(projectDir, 'gh-args.json');
132
- fs.mkdirSync(binDir, {recursive: true});
133
- fs.writeFileSync(
134
- path.join(binDir, 'gh'),
135
- `#!/usr/bin/env node
136
- import fs from 'node:fs';
137
- fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
138
- console.log('https://github.com/acme/core/issues/42');
139
- `,
140
- {mode: 0o755},
141
- );
142
- fs.chmodSync(path.join(binDir, 'gh'), 0o755);
143
- vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
144
- return argsFile;
145
- }
146
-
147
108
  const reportOptions = {
148
109
  category: 'missing_variant',
149
110
  reason: 'Need a compact size',
@@ -720,73 +681,6 @@ describe('gapReport handler isolation', () => {
720
681
  });
721
682
  });
722
683
 
723
- it('an integration that fails to load is a failed delivery, not a missing handler', async () => {
724
- addBrokenIntegration('@test/broken');
725
- configure(['@test/broken'], {
726
- issuesUrl: 'https://github.com/acme/core/issues/new',
727
- });
728
-
729
- const result = await gapReport('General', {
730
- ...reportOptions,
731
- cwd: projectDir,
732
- });
733
-
734
- expect(result.data.status).toBe('failed');
735
- expect(result.data.deliveries).toEqual([
736
- {
737
- handlerType: 'integration',
738
- handler: '@test/broken',
739
- audience: null,
740
- status: 'failed',
741
- url: null,
742
- message: expect.stringContaining(
743
- 'intentional integration load failure',
744
- ),
745
- },
746
- ]);
747
- });
748
-
749
- it('an integration that fails to load keeps the public fallback off, even with consent', async () => {
750
- addBrokenIntegration('@test/broken');
751
- configure(['@test/broken'], {
752
- issuesUrl: 'https://github.com/acme/core/issues/new',
753
- });
754
- const argsFile = stubGh();
755
-
756
- const result = await gapReport('General', {
757
- ...reportOptions,
758
- confirmPublic: true,
759
- cwd: projectDir,
760
- });
761
-
762
- expect(result.data.status).toBe('failed');
763
- expect(result.data.deliveries.map(d => d.handlerType)).toEqual([
764
- 'integration',
765
- ]);
766
- expect(fs.existsSync(argsFile)).toBe(false);
767
- });
768
-
769
- it('an integration that fails to load keeps its place beside working handlers', async () => {
770
- addBrokenIntegration('@test/broken');
771
- addIntegration({
772
- name: '@test/valid',
773
- audience: 'internal',
774
- handleBody: "return {status: 'filed', message: 'ok'};",
775
- });
776
- configure(['@test/broken', '@test/valid']);
777
-
778
- const result = await gapReport('General', {
779
- ...reportOptions,
780
- cwd: projectDir,
781
- });
782
-
783
- expect(result.data.status).toBe('partial');
784
- expect(result.data.deliveries.map(d => [d.handler, d.status])).toEqual([
785
- ['@test/broken', 'failed'],
786
- ['@test/valid', 'filed'],
787
- ]);
788
- });
789
-
790
684
  it('invalid handler receipt is recorded as failed delivery', async () => {
791
685
  addIntegration({
792
686
  name: '@test/bad-receipt',
@@ -2,9 +2,6 @@
2
2
 
3
3
  /**
4
4
  * @file theme build API — compile standalone themes or one selected family.
5
- * @input JS/TS theme modules, build/check options, and the installed Core.
6
- * @output Generated artifacts preserving imported and inherited icon registries.
7
- * @position CLI theme compiler; standalone icon provenance is icon-imports.mjs.
8
5
  *
9
6
  * `themeBuild` and `themeBuildFamily` share the same loader, compiler,
10
7
  * serializers, check, and writer. They read defineTheme() sources and, via
@@ -15,14 +12,11 @@
15
12
  * - A .d.ts (plus an optional .variants.d.ts for custom prop values)
16
13
  *
17
14
  * It performs the writes and returns a `theme.build` receipt — its `warnings`
18
- * carry override problems and every declaration core's generator dropped
19
- * because its value could not stay one CSS declaration; `notices` carry fonts
20
- * the theme names but does not load (font-warning.mjs) — or `null` when the
21
- * theme produced no CSS (nothing to build). Standalone icon imports come from
22
- * the selected theme's parsed bindings and inheritance, never from comment or
23
- * string contents. A registry that cannot be preserved fails before output
24
- * generation, including in check mode. Errors throw AstryxError (with a stable
25
- * code). Human progress is emitted through the shared `logger`
15
+ * carry override problems, every declaration core's generator dropped because
16
+ * its value could not stay one CSS declaration, and any fonts the theme names
17
+ * but does not load (font-warning.mjs) — or `null` when the theme produced no
18
+ * CSS (nothing to build). Errors throw AstryxError (with
19
+ * a stable code). Human progress is emitted through the shared `logger`
26
20
  * (silent by default), so the CLI keeps its exact output while a programmatic
27
21
  * caller stays quiet.
28
22
  *
@@ -73,7 +67,6 @@ import {
73
67
  import {collectUnloadedFonts, formatFontLoadingHelp} from './font-warning.mjs';
74
68
  import {interceptCore} from './core-interception.mjs';
75
69
  import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
76
- import {resolveIconImports} from './icon-imports.mjs';
77
70
 
78
71
  // Import shared theme processing from core. `astryx theme build` MUST produce the
79
72
  // exact same CSS as the `<Theme>` runtime, so it has exactly one generation
@@ -1513,19 +1506,6 @@ async function validateRegistryGraphs(/** @type {Array<{specifier: string, expor
1513
1506
  if (!(root.exportName in exports)) throw registryGraphError(`Family registry ${root.file} does not export "${root.exportName}".`);
1514
1507
  }
1515
1508
  }
1516
- /**
1517
- * Resolve inherited source with exactly the loader's extension precedence.
1518
- * This reads module locations only; icon discovery never executes a second load.
1519
- * @param {string} specifier
1520
- * @param {string} fromFile
1521
- * @returns {string}
1522
- */
1523
- function resolveThemeModule(specifier, fromFile) {
1524
- return createJiti(fromFile, {extensions: THEME_MODULE_EXTENSIONS}).resolve(
1525
- specifier,
1526
- );
1527
- }
1528
-
1529
1509
  /**
1530
1510
  * Errors that mean "the synchronous loader cannot evaluate this module", as
1531
1511
  * opposed to "this module is broken". Only the former may fall back to the
@@ -1573,7 +1553,7 @@ function isSyncLoaderLimitation(error) {
1573
1553
  *
1574
1554
  * @param {string} filePath
1575
1555
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
1576
- * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1556
+ * @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1577
1557
  */
1578
1558
  // prettier-ignore
1579
1559
  async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -1623,14 +1603,12 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
1623
1603
  mod = await jiti.import(filePath, {default: true});
1624
1604
  }
1625
1605
 
1626
- if (isThemeObject(mod)) return {theme: mod, exportName: 'default', degraded};
1606
+ if (isThemeObject(mod)) return {theme: mod, degraded};
1627
1607
 
1628
1608
  if (mod && typeof mod === 'object') {
1629
- if (isThemeObject(mod.default)) {
1630
- return {theme: mod.default, exportName: 'default', degraded};
1631
- }
1632
- for (const [exportName, value] of Object.entries(mod)) {
1633
- if (isThemeObject(value)) return {theme: value, exportName, degraded};
1609
+ if (isThemeObject(mod.default)) return {theme: mod.default, degraded};
1610
+ for (const value of Object.values(mod)) {
1611
+ if (isThemeObject(value)) return {theme: value, degraded};
1634
1612
  }
1635
1613
  }
1636
1614
 
@@ -1664,7 +1642,7 @@ function isThemeObject(value) {
1664
1642
  *
1665
1643
  * @param {string} filePath
1666
1644
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
1667
- * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1645
+ * @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1668
1646
  */
1669
1647
  // prettier-ignore
1670
1648
  async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -1689,8 +1667,6 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
1689
1667
  /**
1690
1668
  * Fallback extraction via regex + eval.
1691
1669
  * Only works for plain object literals — can't follow imports or variables.
1692
- * Never erase icon references: an unresolved registry must preserve the loader
1693
- * error instead of turning an incomplete theme into a successful build.
1694
1670
  * @param {string} filePath
1695
1671
  * @returns {any}
1696
1672
  */
@@ -1712,6 +1688,10 @@ function extractThemeDefinitionLegacy(filePath) {
1712
1688
 
1713
1689
  let objStr = defineMatch[1];
1714
1690
  objStr = objStr.replace(/\s+as\s+const/g, '');
1691
+ objStr = objStr.replace(
1692
+ /icons:\s*[a-zA-Z_][a-zA-Z0-9_]*/g,
1693
+ 'icons: undefined',
1694
+ );
1715
1695
 
1716
1696
  try {
1717
1697
  return eval(`(${objStr})`);
@@ -1726,19 +1706,30 @@ function extractThemeDefinitionLegacy(filePath) {
1726
1706
  }
1727
1707
 
1728
1708
  /**
1729
- * Extract a family member's named registry import from its source file.
1730
- * Returns { importPath, exportName } or null when the theme names none.
1731
- * Standalone builds resolve icons through `resolveIconImports` instead.
1709
+ * Extract icon import info from a theme source file.
1710
+ * Returns { importPath, exportName } or null if no icons.
1732
1711
  *
1733
1712
  * Looks for patterns like:
1734
1713
  * import { defaultIconRegistry } from './icons';
1735
1714
  * icons: defaultIconRegistry,
1736
1715
  * @param {string} filePath
1737
- * @param {'icons' | 'indicators'} field
1738
1716
  * @returns {{exportName: string, importPath: string} | null}
1739
1717
  */
1740
- function extractRegistryInfo(filePath, field) {
1718
+ function extractRegistryInfo(filePath, field = 'icons', familyMode = false) {
1741
1719
  const content = fs.readFileSync(filePath, 'utf8');
1720
+ if (!familyMode) {
1721
+ const fieldMatch = content.match(
1722
+ new RegExp(`${field}:\\s*([a-zA-Z_][a-zA-Z0-9_]*)`),
1723
+ );
1724
+ if (!fieldMatch) return null;
1725
+ const varName = fieldMatch[1];
1726
+ const match = content.match(
1727
+ new RegExp(
1728
+ `import\\s*{[^}]*\\b${varName}\\b[^}]*}\\s*from\\s*['"]([^'"]+)['"]`,
1729
+ ),
1730
+ );
1731
+ return match ? {exportName: varName, importPath: match[1]} : null;
1732
+ }
1742
1733
  const defineIndex = content.indexOf('defineTheme(');
1743
1734
  if (defineIndex < 0) return null;
1744
1735
  const themeSource = content.slice(defineIndex);
@@ -1778,18 +1769,17 @@ function extractRegistryInfo(filePath, field) {
1778
1769
  * override it had.
1779
1770
  *
1780
1771
  * The icon registry is imported rather than inlined because it holds React
1781
- * elements, which cannot be serialized. `resolveIconImports` reads actual
1782
- * imports from the selected theme's source, where extensionless `./icons` uses
1772
+ * elements, which cannot be serialized. `extractIconInfo` lifts the specifier
1773
+ * out of the TypeScript source, where an extensionless `./icons` is resolved by
1783
1774
  * the TypeScript resolver — but the artifact here is ESM JavaScript, which
1784
1775
  * requires a fully specified path. Only the caller knows what its own build
1785
1776
  * will emit and under what name, so `iconsSpecifier` lets it say. When it is
1786
- * not given, direct registry specifiers are preserved, and inherited relative
1787
- * imports are rebased from the base module to the theme entry's directory.
1777
+ * not given, the scraped specifier is emitted unchanged.
1788
1778
  *
1789
1779
  * @param {any} themeDef
1790
- * @param {import('./icon-imports.mjs').IconImports | null} iconInfo
1791
- * @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
1792
- * @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
1780
+ * @param {{exportName: string, importPath: string} | null} iconInfo
1781
+ * @param {string} [iconsSpecifier] - Overrides the scraped icon import specifier.
1782
+ * @param {{themeBinding?: string, iconBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
1793
1783
  * @returns {string}
1794
1784
  */
1795
1785
  function generateBuiltModule(
@@ -1800,46 +1790,29 @@ function generateBuiltModule(
1800
1790
  ) {
1801
1791
  const themeBinding =
1802
1792
  moduleOptions.themeBinding ?? `${toIdentifier(themeDef.name)}Theme`;
1793
+ const iconBinding = moduleOptions.iconBinding ?? iconInfo?.exportName;
1803
1794
  const artifactBaseName = moduleOptions.artifactBaseName ?? themeDef.name;
1804
1795
  const exportIcons = moduleOptions.exportIcons ?? true;
1805
- // Keep ordinary direct named imports byte-compatible, while encoding paths
1806
- // with quotes/escapes and retaining default, namespace, and aliased bindings.
1807
- const iconImport = (iconInfo?.imports ?? [])
1808
- .map(({importPath, importedName, localName}) => {
1809
- const overridden =
1810
- iconsSpecifier !== undefined &&
1811
- importPath === iconInfo?.iconsSpecifierImportPath &&
1812
- localName === iconInfo?.iconsSpecifierLocalName;
1813
- const specifier = overridden
1814
- ? JSON.stringify(iconsSpecifier)
1815
- : /['\\\r\n]/u.test(importPath)
1816
- ? JSON.stringify(importPath)
1817
- : `'${importPath}'`;
1818
- const imported = /^[$\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(
1819
- importedName,
1820
- )
1821
- ? importedName
1822
- : JSON.stringify(importedName);
1823
- const binding =
1824
- importedName === 'default'
1825
- ? localName
1826
- : importedName === '*'
1827
- ? `* as ${localName}`
1828
- : `{ ${imported}${importedName === localName ? '' : ` as ${localName}`} }`;
1829
- return `import ${binding} from ${specifier};\n`;
1830
- })
1831
- .join('');
1832
- const iconDeclaration =
1833
- iconInfo && iconInfo.expression !== iconInfo.exportName
1834
- ? `const ${iconInfo.exportName} = ${iconInfo.expression};\n`
1835
- : '';
1836
- const iconsExpression = moduleOptions.iconsExpression ?? iconInfo?.exportName;
1796
+ // Preserve the historical generated bytes when no override is supplied.
1797
+ // User-provided specifiers need string-literal encoding so quotes and
1798
+ // backslashes cannot produce invalid JavaScript.
1799
+ const renderedSpecifier =
1800
+ iconsSpecifier === undefined
1801
+ ? `'${iconInfo?.importPath}'`
1802
+ : JSON.stringify(iconsSpecifier);
1803
+ const iconImport = iconInfo
1804
+ ? `import { ${iconInfo.exportName}${iconBinding === iconInfo.exportName ? '' : ` as ${iconBinding}`} } from ${renderedSpecifier};\n`
1805
+ : '';
1806
+ const iconsExpression =
1807
+ moduleOptions.iconsExpression ?? (iconInfo ? iconBinding : undefined);
1837
1808
  const iconsField = iconsExpression ? ` icons: ${iconsExpression},` : '';
1838
1809
  const indicatorsField = moduleOptions.indicatorsExpression
1839
1810
  ? `\n indicators: ${moduleOptions.indicatorsExpression},`
1840
1811
  : '';
1841
1812
  const iconReExport =
1842
- iconInfo && exportIcons ? `\nexport { ${iconInfo.exportName} };\n` : '';
1813
+ iconInfo && exportIcons
1814
+ ? `\nexport { ${iconBinding}${iconBinding === iconInfo.exportName ? '' : ` as ${iconInfo.exportName}`} };\n`
1815
+ : '';
1843
1816
 
1844
1817
  // Resolve token values — tuples become light-dark() strings
1845
1818
  /** @type {Record<string, unknown>} */
@@ -1898,7 +1871,7 @@ function generateBuiltModule(
1898
1871
  serializeField('__adaptations', themeDef.__adaptations) +
1899
1872
  serializeField('__axes', themeDef.__axes ?? {}, true);
1900
1873
 
1901
- return `${iconImport}${iconDeclaration}/**
1874
+ return `${iconImport}/**
1902
1875
  * ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
1903
1876
  * Import the CSS file alongside this module:
1904
1877
  *
@@ -1917,7 +1890,7 @@ ${iconReExport}`;
1917
1890
  /**
1918
1891
  * Generate TypeScript declarations for a built theme module.
1919
1892
  * @param {any} themeDef
1920
- * @param {{exportName: string} | null} iconInfo - The re-exported registry, if any.
1893
+ * @param {{exportName: string, importPath: string} | null} iconInfo
1921
1894
  * @param {string | null} variantsFileName
1922
1895
  * @param {{themeBinding?: string, includeIconExport?: boolean, includeThemeImport?: boolean}} [typeOptions]
1923
1896
  * @returns {string}
@@ -2343,7 +2316,7 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
2343
2316
  * `out` overrides the output CSS path; `check` compares against on-disk outputs
2344
2317
  * instead of writing. `iconsSpecifier` overrides the icon registry import
2345
2318
  * specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
2346
- * direct registry specifiers from the theme source are emitted unchanged.
2319
+ * specifier scraped from the theme source is emitted unchanged.
2347
2320
  * @param {{cwd?: string}} [ctx]
2348
2321
  * @returns {Promise<any>}
2349
2322
  */
@@ -2378,8 +2351,6 @@ async function themeBuildInternal(
2378
2351
 
2379
2352
  // Extract theme definition
2380
2353
  let themeDef;
2381
- /** The export actually selected by the loader, not the first AST match. */
2382
- let themeExportName;
2383
2354
  /** Paths through the load that interception could not fully observe. */
2384
2355
  let loadDegradation;
2385
2356
  try {
@@ -2389,7 +2360,6 @@ async function themeBuildInternal(
2389
2360
  options.__familyLoader,
2390
2361
  );
2391
2362
  themeDef = loaded.theme;
2392
- themeExportName = loaded.exportName;
2393
2363
  loadDegradation = loaded.degraded;
2394
2364
  } catch (e) {
2395
2365
  const err = /** @type {Error} */ (e);
@@ -2455,25 +2425,6 @@ async function themeBuildInternal(
2455
2425
  throw err;
2456
2426
  }
2457
2427
 
2458
- // A generated module must preserve the registry through an import: it may
2459
- // contain React elements, which cannot be serialized. Validate before CSS
2460
- // generation so neither the no-CSS return nor --check can bypass the error.
2461
- // Family preparation keeps its own named-import registry contract, which
2462
- // themeBuildFamily checks against the selected members' graph.
2463
- const standaloneIcons = !options.__prepareFamily;
2464
- const iconResolution = {
2465
- readSource: (/** @type {string} */ file) => fs.readFileSync(file, 'utf8'),
2466
- resolveModule: resolveThemeModule,
2467
- reservedNames: [`${toIdentifier(themeDef.name)}Theme`],
2468
- rawInput: 'extends' in themeDef,
2469
- hasIcons:
2470
- Object.keys(themeDef.icons ?? {}).length > 0 ||
2471
- Object.keys(themeDef.extends?.icons ?? {}).length > 0,
2472
- };
2473
- let iconInfo = standaloneIcons
2474
- ? await resolveIconImports(filePath, themeExportName, iconResolution)
2475
- : null;
2476
-
2477
2428
  // Validate component overrides
2478
2429
  const warnings = await validateComponentOverrides(themeDef);
2479
2430
  const warningMessages = [];
@@ -2580,40 +2531,6 @@ async function themeBuildInternal(
2580
2531
  resolvedTheme = themeDef;
2581
2532
  }
2582
2533
 
2583
- // Raw object exports can acquire icons only when Core resolves `extends`.
2584
- // Recheck an unresolved provenance result before any generator runs.
2585
- if (
2586
- standaloneIcons &&
2587
- !iconInfo &&
2588
- Object.keys(resolvedTheme.icons ?? {}).length > 0
2589
- ) {
2590
- iconInfo = await resolveIconImports(filePath, themeExportName, {
2591
- ...iconResolution,
2592
- hasIcons: true,
2593
- });
2594
- }
2595
- // An opaque package base can legitimately have no icons. Its .icons
2596
- // reference is unnecessary; direct empty registry imports remain intact.
2597
- if (
2598
- iconInfo &&
2599
- iconInfo.iconsSpecifierLocalName === undefined &&
2600
- Object.keys(resolvedTheme.icons ?? {}).length === 0
2601
- ) {
2602
- iconInfo = null;
2603
- }
2604
- if (
2605
- iconInfo &&
2606
- options.iconsSpecifier !== undefined &&
2607
- iconInfo.iconsSpecifierImportPath === undefined
2608
- ) {
2609
- throw new AstryxError(
2610
- 'The icon registry is inherited through a theme import. ' +
2611
- 'To use --icons-specifier, import the registry directly and set icons to that binding.',
2612
- undefined,
2613
- ERROR_CODES.ERR_THEME_INVALID,
2614
- );
2615
- }
2616
-
2617
2534
  // Cores that predate adaptations can still resolve typography, color,
2618
2535
  // radius, and motion into root tokens, but they do not retain the raw axis
2619
2536
  // inputs. Keep the effective metadata captured from the same defineTheme
@@ -2839,6 +2756,15 @@ async function themeBuildInternal(
2839
2756
  const jsPath = path.join(outDir, `${baseName}.js`);
2840
2757
  const dtsPath = path.join(outDir, `${baseName}.d.ts`);
2841
2758
 
2759
+ const iconInfo = extractRegistryInfo(
2760
+ filePath,
2761
+ 'icons',
2762
+ options.__prepareFamily,
2763
+ );
2764
+ const indicatorInfo = options.__prepareFamily
2765
+ ? extractRegistryInfo(filePath, 'indicators', true)
2766
+ : null;
2767
+
2842
2768
  // Type augmentation .d.ts if theme has custom prop values. Computed
2843
2769
  // before the main .d.ts so the latter can reference it (see below).
2844
2770
  const augmentationSource = resolvedTheme || themeDef;
@@ -2886,8 +2812,8 @@ async function themeBuildInternal(
2886
2812
  theme: displayTheme,
2887
2813
  sourceTheme: themeDef,
2888
2814
  sourceParent,
2889
- iconInfo: extractRegistryInfo(filePath, 'icons'),
2890
- indicatorInfo: extractRegistryInfo(filePath, 'indicators'),
2815
+ iconInfo,
2816
+ indicatorInfo,
2891
2817
  variantDecl,
2892
2818
  css: cssPlan,
2893
2819
  versions,
@@ -3231,14 +3157,11 @@ export async function themeBuildFamily(
3231
3157
  const indicatorImport = indicator.info
3232
3158
  ? `import { ${indicator.info.exportName} as ${ownIndicators} } from ${JSON.stringify(indicator.specifier ?? indicator.info.importPath)};\n`
3233
3159
  : '';
3234
- // The member's own registry import, bound to its family-unique name; a
3235
- // rebased or overridden specifier replaces the scraped one.
3236
- // prettier-ignore
3237
- const iconImports = icon.info && ownIcons ? {imports: [{importPath: icon.info.importPath, importedName: icon.info.exportName, localName: ownIcons}], expression: ownIcons, exportName: ownIcons, iconsSpecifierImportPath: icon.info.importPath, iconsSpecifierLocalName: ownIcons} : null;
3238
3160
  return (
3239
3161
  indicatorImport +
3240
- generateBuiltModule(member.theme, iconImports, icon.specifier, {
3162
+ generateBuiltModule(member.theme, icon.info, icon.specifier, {
3241
3163
  themeBinding,
3164
+ iconBinding: ownIcons ?? undefined,
3242
3165
  iconsExpression: expression(ownIcons, inheritedIcons),
3243
3166
  indicatorsExpression: expression(ownIndicators, inheritedIndicators),
3244
3167
  artifactBaseName: baseName,