@astryxdesign/cli 0.1.4-canary.fd7ab46 → 0.1.4

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 (73) hide show
  1. package/CHANGELOG.md +1 -2
  2. package/docs/getting-started.doc.mjs +0 -4
  3. package/docs/migration.doc.mjs +0 -134
  4. package/docs/styling.doc.mjs +0 -53
  5. package/docs/working-with-ai.doc.mjs +1 -1
  6. package/package.json +10 -15
  7. package/src/api/component.mjs +1 -2
  8. package/src/api/doctor.mjs +2 -13
  9. package/src/api/template.mjs +3 -14
  10. package/src/codemods/__tests__/registry.test.mjs +0 -1
  11. package/src/codemods/__tests__/runner.test.mjs +0 -38
  12. package/src/codemods/registry.mjs +0 -1
  13. package/src/codemods/runner.mjs +0 -2
  14. package/src/commands/agent-docs.mjs +6 -9
  15. package/src/commands/agent-docs.test.mjs +0 -33
  16. package/src/commands/build-theme.mjs +14 -118
  17. package/src/commands/component-resolution.test.mjs +4 -4
  18. package/src/commands/doctor.test.mjs +0 -34
  19. package/src/commands/init.mjs +1 -1
  20. package/src/commands/swizzle.mjs +0 -34
  21. package/src/commands/swizzle.routing.test.mjs +0 -67
  22. package/src/lib/component-discovery.mjs +4 -8
  23. package/templates/blocks/components/AspectRatio/AspectRatioCircleImage.tsx +6 -1
  24. package/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +7 -2
  25. package/templates/blocks/components/AspectRatio/AspectRatioShowcase.tsx +5 -2
  26. package/templates/blocks/components/AspectRatio/AspectRatioSquareImage.tsx +6 -1
  27. package/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +6 -1
  28. package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
  29. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +48 -27
  30. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +54 -31
  31. package/templates/pages/classic-gallery/page.tsx +1 -1
  32. package/templates/pages/dashboard/page.tsx +1 -1
  33. package/templates/pages/documentation/page.tsx +1 -1
  34. package/templates/pages/kanban-board/page.tsx +13 -37
  35. package/templates/pages/mixed-gallery/page.tsx +1 -1
  36. package/templates/pages/payment-form/page.tsx +6 -2
  37. package/templates/pages/product-detail/page.tsx +11 -3
  38. package/templates/pages/product-gallery/page.tsx +1 -1
  39. package/templates/pages/settings/page.tsx +1 -1
  40. package/templates/pages/side-gallery/page.tsx +1 -1
  41. package/templates/pages/table-page/page.tsx +1 -1
  42. package/templates/pages/table-page-chart/page.tsx +14 -4
  43. package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
  44. package/templates/pages/table-page-shoe-store-heatmap/page.tsx +19 -5
  45. package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  46. package/src/codemods/transforms/v0.1.5/index.mjs +0 -19
  47. package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +0 -140
  48. package/src/commands/build-theme.color-scheme.test.mjs +0 -153
  49. package/src/commands/build-theme.variants.test.mjs +0 -193
  50. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +0 -14
  51. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +0 -58
  52. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +0 -14
  53. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +0 -24
  54. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +0 -13
  55. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +0 -33
  56. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +0 -15
  57. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +0 -39
  58. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +0 -15
  59. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +0 -39
  60. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +0 -15
  61. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +0 -27
  62. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +0 -15
  63. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +0 -38
  64. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +0 -14
  65. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +0 -44
  66. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +0 -15
  67. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +0 -107
  68. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +0 -15
  69. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +0 -47
  70. package/templates/pages/incident-console/page.tsx +0 -580
  71. package/templates/pages/incident-console/template.doc.mjs +0 -12
  72. package/templates/pages/messaging-shell/page.tsx +0 -676
  73. package/templates/pages/messaging-shell/template.doc.mjs +0 -12
@@ -175,85 +175,14 @@ async function getKnownValues(componentName) {
175
175
  return _knownValuesCache.get(componentName);
176
176
  }
177
177
 
178
- /**
179
- * Resolve `@astryxdesign/core`'s package root relative to the CLI package. Core
180
- * and the CLI ship as siblings (`@astryxdesign/core`, `@astryxdesign/cli`), so
181
- * `../../../core` from `src/commands/` reaches core whether installed from npm
182
- * or run inside the monorepo. Returns null if it can't be found.
183
- */
184
- function resolveCoreRoot() {
185
- const cliDir = path.dirname(fileURLToPath(import.meta.url));
186
- const coreRoot = path.resolve(cliDir, '../../../core');
187
- return fs.existsSync(coreRoot) ? coreRoot : null;
188
- }
189
-
190
- /**
191
- * Read the type declarations `@astryxdesign/core/<Component>` exposes so we can
192
- * check whether a given augmentation-target interface actually exists before
193
- * generating a module augmentation against it.
194
- *
195
- * Reads the shipped `dist/<Component>/index.d.ts` (what a consumer's TypeScript
196
- * actually sees), falling back to the `src/<Component>/index.ts` in the
197
- * monorepo. Returns the file contents, or '' if nothing is found.
198
- */
199
- const _componentDeclCache = new Map();
200
- function readComponentDeclarations(pascalName) {
201
- if (_componentDeclCache.has(pascalName)) {
202
- return _componentDeclCache.get(pascalName);
203
- }
204
- let contents = '';
205
- const coreRoot = resolveCoreRoot();
206
- if (coreRoot) {
207
- const candidates = [
208
- path.join(coreRoot, 'dist', pascalName, 'index.d.ts'),
209
- path.join(coreRoot, 'src', pascalName, 'index.ts'),
210
- ];
211
- for (const file of candidates) {
212
- try {
213
- if (fs.existsSync(file)) {
214
- contents = fs.readFileSync(file, 'utf-8');
215
- break;
216
- }
217
- } catch {
218
- // ignore and try the next candidate
219
- }
220
- }
221
- }
222
- _componentDeclCache.set(pascalName, contents);
223
- return contents;
224
- }
225
-
226
- /**
227
- * Determine whether `@astryxdesign/core/<Component>` exports an interface named
228
- * `interfaceName` that can be augmented via module augmentation.
229
- *
230
- * Only interfaces are extension points — closed literal-union types (e.g.
231
- * `HeadingType`, `ButtonSize`) are NOT augmentable, so a generated augmentation
232
- * against them is dead code. We check that the name is exported (directly or
233
- * re-exported) as a type/interface.
234
- */
235
- function componentHasAugmentableInterface(pascalName, interfaceName) {
236
- const decl = readComponentDeclarations(pascalName);
237
- if (!decl) return false;
238
- // Word-boundary match so `ButtonVariantMap` doesn't match `XButtonVariantMap`.
239
- const re = new RegExp(`\\b${interfaceName}\\b`);
240
- return re.test(decl);
241
- }
242
-
243
178
  /**
244
179
  * Generate TypeScript declaration content with module augmentation for custom
245
180
  * component prop values found in the theme's `components` keys. Reads known
246
181
  * values from doc files to filter out base prop values.
247
182
  *
248
- * Interface naming convention: PascalCase(component) + PascalCase(prop) + Map
249
- * banner + status → BannerStatusMap
250
- * button + variant → ButtonVariantMap
251
- *
252
- * An augmentation is only emitted when `@astryxdesign/core/<Component>` actually
253
- * exports a matching interface. Props backed by closed literal-union types
254
- * (e.g. Button `size`, Heading `type`/`level`) have no augmentation point, so
255
- * generating a `declare module` block for them would be dead code — those are
256
- * skipped.
183
+ * Interface naming convention: Astryx + PascalCase(component) + PascalCase(prop) + Map
184
+ * banner + status → XDSBannerStatusMap
185
+ * button + variant → XDSButtonVariantMap
257
186
  *
258
187
  * @param {object} themeDef - Theme definition (resolved by defineTheme)
259
188
  * @returns {Promise<string|null>} TypeScript declaration content, or null if no augmentations needed
@@ -305,14 +234,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
305
234
  const pascal = toPascalCase(component);
306
235
  const propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
307
236
  const modulePath = `@astryxdesign/core/${pascal}`;
308
- const interfaceName = `${pascal}${propPascal}Map`;
309
-
310
- // Only augment interfaces that actually exist as an extension point in
311
- // core. Props backed by closed literal-union types (e.g. Button `size`,
312
- // Heading `type`/`level`) have no `*Map` interface — a `declare module`
313
- // block against a non-existent interface just creates a new, unused
314
- // interface and never extends the component's prop union, so skip it.
315
- if (!componentHasAugmentableInterface(pascal, interfaceName)) continue;
237
+ const interfaceName = `XDS${pascal}${propPascal}Map`;
316
238
 
317
239
  sections.push(`declare module '${modulePath}' {`);
318
240
  sections.push(` interface ${interfaceName} {`);
@@ -325,13 +247,6 @@ async function generateVariantDeclarationsAsync(themeDef) {
325
247
  }
326
248
  }
327
249
 
328
- // If every custom value targeted a non-augmentable prop, there's nothing to
329
- // emit beyond the header — return null so no `.variants.d.ts` is written.
330
- const hasEmittedAugmentation = sections.some(line =>
331
- line.startsWith('declare module'),
332
- );
333
- if (!hasEmittedAugmentation) return null;
334
-
335
250
  return sections.join('\n');
336
251
  }
337
252
 
@@ -518,21 +433,13 @@ ${iconReExport}`;
518
433
  /**
519
434
  * Generate TypeScript declarations for a built theme module.
520
435
  */
521
- function generateBuiltTypes(themeDef, iconInfo, variantsFileName) {
436
+ function generateBuiltTypes(themeDef, iconInfo) {
522
437
  const iconType = iconInfo
523
438
  ? `import type { IconRegistry } from '@astryxdesign/core/Icon';
524
439
  export declare const ${iconInfo.exportName}: IconRegistry;
525
440
  `
526
441
  : '';
527
- // Pull in the generated custom-variant augmentations so that importing the
528
- // theme's types also loads the module augmentations (otherwise the
529
- // `.variants.d.ts` is emitted but never referenced, and the custom variants
530
- // never widen the component prop unions for consumers).
531
- const variantsRef = variantsFileName
532
- ? `/// <reference path="./${variantsFileName}" />
533
- `
534
- : '';
535
- return `${variantsRef}import type { DefinedTheme } from '@astryxdesign/core/theme';
442
+ return `import type { DefinedTheme } from '@astryxdesign/core/theme';
536
443
  ${iconType}export declare const ${toIdentifier(themeDef.name)}Theme: DefinedTheme;
537
444
  `;
538
445
  }
@@ -939,15 +846,8 @@ export function registerTheme(program) {
939
846
  if (component.length > 0) {
940
847
  const componentInner = component.join('\n\n');
941
848
  const componentScope = `@scope (${scopeSelector}) to (${scopeTo}) {\n${componentInner}\n}`;
942
- // light-dark() needs a color-scheme declaration in this bundle, but a
943
- // bare `:root { color-scheme: light dark }` outranks reset.css's
944
- // `html[data-theme]` mapping (astryx-theme layer comes after reset),
945
- // silently defeating `<Theme mode>` forcing on <html>. Mirror the
946
- // attribute-keyed mapping so the declaration follows the active mode.
947
849
  const colorSchemeDecl = componentScope.includes('light-dark(')
948
- ? ' :root { color-scheme: light dark; }\n' +
949
- ' html[data-theme="light"] { color-scheme: light; }\n' +
950
- ' html[data-theme="dark"] { color-scheme: dark; }\n\n'
850
+ ? ' :root { color-scheme: light dark; }\n\n'
951
851
  : '';
952
852
  cssParts.push(
953
853
  `@layer astryx-theme {\n${colorSchemeDecl}${componentScope}\n}`,
@@ -994,23 +894,19 @@ export function registerTheme(program) {
994
894
 
995
895
  const iconInfo = extractIconInfo(filePath);
996
896
 
997
- // Type augmentation .d.ts if theme has custom prop values. Computed
998
- // before the main .d.ts so the latter can reference it (see below).
897
+ // Generate all file contents in memory first.
898
+ const cssContent = generatedHeader(sourceRelative, 'css', buildCommand) + css;
899
+ const jsContent = generatedHeader(sourceRelative, 'js', buildCommand) + generateBuiltModule(resolvedTheme || themeDef, iconInfo);
900
+ const dtsContent = generatedHeader(sourceRelative, 'ts', buildCommand) + generateBuiltTypes(themeDef, iconInfo);
901
+
902
+ // Type augmentation .d.ts if theme has custom prop values
999
903
  const augmentationSource = resolvedTheme || themeDef;
1000
904
  const variantDecl = await generateVariantDeclarationsAsync(augmentationSource);
1001
- const variantsFileName = variantDecl ? `${baseName}.variants.d.ts` : null;
1002
- const variantDtsPath = variantDecl ? path.join(outDir, variantsFileName) : null;
905
+ const variantDtsPath = variantDecl ? path.join(outDir, `${baseName}.variants.d.ts`) : null;
1003
906
  const variantContent = variantDecl
1004
907
  ? generatedHeader(sourceRelative, 'ts', buildCommand) + variantDecl
1005
908
  : null;
1006
909
 
1007
- // Generate all file contents in memory first. The main .d.ts references
1008
- // the variants file (when present) via a triple-slash directive so
1009
- // importing the theme also loads the custom-variant augmentations.
1010
- const cssContent = generatedHeader(sourceRelative, 'css', buildCommand) + css;
1011
- const jsContent = generatedHeader(sourceRelative, 'js', buildCommand) + generateBuiltModule(resolvedTheme || themeDef, iconInfo);
1012
- const dtsContent = generatedHeader(sourceRelative, 'ts', buildCommand) + generateBuiltTypes(themeDef, iconInfo, variantsFileName);
1013
-
1014
910
  // Atomic-ish write: stage every file as `<dest>.tmp`, then rename
1015
911
  // each into place. If any stage step fails we clean up partials and
1016
912
  // exit; if a rename fails mid-way we still have the originals (or
@@ -78,13 +78,13 @@ describe('findShowcase() priority', () => {
78
78
  it('Badge resolves to Badge dir, not a sibling that uses Badge', async () => {
79
79
  const result = await findShowcase('Badge');
80
80
  expect(result).not.toBeNull();
81
- expect(result.filePath).toMatch(/[/\\]Badge[/\\]/);
81
+ expect(result.filePath).toMatch(/\/Badge\//);
82
82
  });
83
83
 
84
84
  it('Avatar resolves to Avatar dir, not AvatarStatusDot', async () => {
85
85
  const result = await findShowcase('Avatar');
86
86
  expect(result).not.toBeNull();
87
- expect(result.filePath).toMatch(/[/\\]Avatar[/\\]/);
87
+ expect(result.filePath).toMatch(/\/Avatar\//);
88
88
  expect(result.filePath).not.toMatch(/AvatarStatusDot/);
89
89
  });
90
90
 
@@ -92,7 +92,7 @@ describe('findShowcase() priority', () => {
92
92
  const result = await findShowcase('ClickableCard');
93
93
  expect(result).not.toBeNull();
94
94
  expect(result.name).toBe('ClickableCard');
95
- expect(result.filePath).toMatch(/[/\\]Card[/\\]/);
95
+ expect(result.filePath).toMatch(/\/Card\//);
96
96
  });
97
97
 
98
98
  it('SelectableCard resolves via componentsUsed in Card/', async () => {
@@ -104,7 +104,7 @@ describe('findShowcase() priority', () => {
104
104
  it('Stack resolves to Stack dir despite componentsUsed elsewhere', async () => {
105
105
  const result = await findShowcase('Stack');
106
106
  expect(result).not.toBeNull();
107
- expect(result.filePath).toMatch(/[/\\]Stack[/\\]/);
107
+ expect(result.filePath).toMatch(/\/Stack\//);
108
108
  });
109
109
 
110
110
  it('returns null for nonexistent component', async () => {
@@ -63,33 +63,6 @@ function installPkg(name, version = '1.0.0') {
63
63
  return dir;
64
64
  }
65
65
 
66
- /**
67
- * Mirror pnpm's layout: the real package lives under node_modules/.pnpm and
68
- * the entry in the scope directory is a symlink to it.
69
- */
70
- function installPkgPnpmStyle(name, version = '1.0.0') {
71
- const realDir = path.join(
72
- tmpDir,
73
- 'node_modules',
74
- '.pnpm',
75
- `${name.replace('/', '+')}@${version}`,
76
- 'node_modules',
77
- ...name.split('/'),
78
- );
79
- fs.mkdirSync(realDir, {recursive: true});
80
- fs.writeFileSync(
81
- path.join(realDir, 'package.json'),
82
- JSON.stringify({name, version, main: 'index.js'}),
83
- );
84
- fs.writeFileSync(path.join(realDir, 'index.js'), 'module.exports = {};');
85
- const linkPath = path.join(tmpDir, 'node_modules', ...name.split('/'));
86
- fs.mkdirSync(path.dirname(linkPath), {recursive: true});
87
- // 'junction' keeps this working on Windows without elevated permissions;
88
- // it is ignored on posix.
89
- fs.symlinkSync(realDir, linkPath, 'junction');
90
- return linkPath;
91
- }
92
-
93
66
  function find(checks, id) {
94
67
  return checks.find(c => c.id === id);
95
68
  }
@@ -146,13 +119,6 @@ describe('doctor — individual checks', () => {
146
119
  expect(res.status).toBe('pass');
147
120
  });
148
121
 
149
- it('themes: detects pnpm-style symlinked theme packages (#3530)', () => {
150
- installPkgPnpmStyle('@astryxdesign/theme-neutral', '0.1.2');
151
- const res = checkThemes({cwd: tmpDir, configTheme: 'default'});
152
- expect(res.status).toBe('pass');
153
- expect(res.message).toContain('@astryxdesign/theme-neutral');
154
- });
155
-
156
122
  it('config: INFO when no astryx.config.mjs', async () => {
157
123
  const res = await checkConfig({cwd: tmpDir, configPath: null});
158
124
  expect(res.status).toBe('info');
@@ -198,7 +198,7 @@ export function registerInit(program) {
198
198
  .option('--features <list>', 'Comma-separated features to install (agents, theme, template)')
199
199
  .option('--all', 'Install all features, no prompts')
200
200
  .option('--remove-agents', 'Remove AI agent docs from all agent doc files')
201
- .option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, hermes, all')
201
+ .option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, all')
202
202
  .option('--agent-docs-path <path...>', 'Explicit file path(s) for agent docs')
203
203
  .action(async (options) => {
204
204
  const targetDir = process.cwd();
@@ -26,7 +26,6 @@ import {jsonOut, humanLog} from '../lib/json.mjs';
26
26
  import {cliError} from '../lib/cli-error.mjs';
27
27
  import {ERROR_CODES} from '../lib/error-codes.mjs';
28
28
  import {checkGhCli} from '../utils/github.mjs';
29
- import {getRunPrefix} from '../utils/package-manager.mjs';
30
29
  import {Project} from '../lib/project.mjs';
31
30
  import {
32
31
  CORE_PACKAGE,
@@ -340,10 +339,6 @@ export function registerSwizzle(program) {
340
339
  // Copy all non-test, non-doc, non-README files
341
340
  const files = fs.readdirSync(componentDir);
342
341
  let copied = 0;
343
- // Track whether any copied source uses StyleX. Swizzled StyleX source
344
- // needs a build-time StyleX compiler in the consumer's app or it renders
345
- // unstyled with no error — so we surface a setup note after copying.
346
- let usesStyleX = false;
347
342
 
348
343
  for (const file of files) {
349
344
  // Skip test files, doc files, and README
@@ -360,13 +355,6 @@ export function registerSwizzle(program) {
360
355
  content = rewriteImports(content, owner.ownerPackage);
361
356
  }
362
357
 
363
- if (
364
- (file.endsWith('.ts') || file.endsWith('.tsx')) &&
365
- content.includes('@stylexjs/stylex')
366
- ) {
367
- usesStyleX = true;
368
- }
369
-
370
358
  fs.writeFileSync(path.join(outputDir, file), content);
371
359
  copied++;
372
360
  }
@@ -388,7 +376,6 @@ export function registerSwizzle(program) {
388
376
  outputDir: relOutput,
389
377
  filesCopied: copied,
390
378
  files: copiedFiles.map(f => f),
391
- usesStyleX,
392
379
  };
393
380
  if (feedback) payload.feedback = feedback;
394
381
  return jsonOut('swizzle.copy', payload);
@@ -400,27 +387,6 @@ export function registerSwizzle(program) {
400
387
  );
401
388
  humanLog('You can now customize the component source freely.\n');
402
389
 
403
- // StyleX build requirement. Swizzled components ship raw StyleX source,
404
- // which needs a build-time StyleX compiler in the consumer's app to
405
- // produce atomic CSS. Without it the component compiles but renders
406
- // unstyled, with no error — a confusing silent failure, so call it out.
407
- if (usesStyleX) {
408
- humanLog(
409
- '⚠ These components use StyleX and require a StyleX compiler in your build.',
410
- );
411
- humanLog(
412
- ' Without one they render unstyled (no error). See setup per framework:',
413
- );
414
- humanLog(` ${getRunPrefix()} astryx docs styling`);
415
- humanLog(
416
- ' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —',
417
- );
418
- humanLog(
419
- ' use an SWC-based StyleX transform instead (covered in the guide).',
420
- );
421
- humanLog('');
422
- }
423
-
424
390
  // Maintainer feedback note. If we couldn't swizzle cleanly, the team
425
391
  // wants to know — point users at the issue tracker. Skipped when the
426
392
  // owning package ships no issues URL.
@@ -277,70 +277,3 @@ describe('swizzle — ambiguous ownership', () => {
277
277
  expect(out).toContain(`from '@astryxdesign/core/theme'`);
278
278
  });
279
279
  });
280
-
281
- /**
282
- * Build a fake @astryxdesign/core with a component that imports StyleX directly
283
- * (so the swizzle StyleX-build note should fire) and one that doesn't.
284
- */
285
- function buildStyleXCore(project) {
286
- const core = path.join(project, 'node_modules', '@astryxdesign', 'core');
287
- // StyleX component.
288
- const styledDir = path.join(core, 'src', 'Styled');
289
- fs.mkdirSync(styledDir, {recursive: true});
290
- fs.writeFileSync(
291
- path.join(core, 'package.json'),
292
- '{"name":"@astryxdesign/core","version":"0.0.13"}',
293
- );
294
- fs.writeFileSync(
295
- path.join(styledDir, 'Styled.tsx'),
296
- [
297
- `import * as stylex from '@stylexjs/stylex';`,
298
- `const styles = stylex.create({base: {color: 'red'}});`,
299
- `export const Styled = () => null;`,
300
- '',
301
- ].join('\n'),
302
- );
303
- // Plain component (no StyleX).
304
- const plainDir = path.join(core, 'src', 'Plain');
305
- fs.mkdirSync(plainDir, {recursive: true});
306
- fs.writeFileSync(
307
- path.join(plainDir, 'Plain.tsx'),
308
- `export const Plain = () => null;\n`,
309
- );
310
- return core;
311
- }
312
-
313
- describe('swizzle — StyleX build setup note (#3373)', () => {
314
- it('reports usesStyleX and prints a setup note for StyleX components', () => {
315
- buildStyleXCore(project);
316
- writeProjectPackageJson(project);
317
-
318
- // JSON payload carries the machine-readable flag.
319
- const jsonResult = runCli(['--json', 'swizzle', 'Styled', '-f'], project);
320
- expect(jsonResult.code).toBe(0);
321
- const env = JSON.parse(jsonResult.stdout);
322
- expect(env.data.usesStyleX).toBe(true);
323
-
324
- // Human output surfaces the compiler requirement + Next.js caveat.
325
- const humanResult = runCli(['swizzle', 'Styled', '-f'], project);
326
- expect(humanResult.code).toBe(0);
327
- expect(humanResult.stdout).toMatch(/StyleX compiler/i);
328
- expect(humanResult.stdout).toMatch(/unstyled/i);
329
- expect(humanResult.stdout).toMatch(/next\/font/i);
330
- expect(humanResult.stdout).toMatch(/astryx docs styling/);
331
- });
332
-
333
- it('does not print the StyleX note for components without StyleX', () => {
334
- buildStyleXCore(project);
335
- writeProjectPackageJson(project);
336
-
337
- const jsonResult = runCli(['--json', 'swizzle', 'Plain', '-f'], project);
338
- expect(jsonResult.code).toBe(0);
339
- const env = JSON.parse(jsonResult.stdout);
340
- expect(env.data.usesStyleX).toBe(false);
341
-
342
- const humanResult = runCli(['swizzle', 'Plain', '-f'], project);
343
- expect(humanResult.code).toBe(0);
344
- expect(humanResult.stdout).not.toMatch(/StyleX compiler/i);
345
- });
346
- });
@@ -335,13 +335,10 @@ export function resolveImportPath(coreDir, componentName) {
335
335
  ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
336
336
  : null;
337
337
 
338
- const exportKeys = Object.keys(pkg?.exports || {});
339
-
340
338
  // Priority 1: exact subpath export matching the component name (e.g. ./Heading)
341
339
  // This allows convenience re-export directories to win over the source directory.
342
- const exactMatch = exportKeys.find(k => k.toLowerCase() === `./${componentName}`.toLowerCase());
343
- if (exactMatch) {
344
- return `@astryxdesign/core/${exactMatch.slice(2)}`;
340
+ if (pkg?.exports?.[`./${componentName}`]) {
341
+ return `@astryxdesign/core/${componentName}`;
345
342
  }
346
343
 
347
344
  const sourcePath = findComponentSource(coreDir, componentName);
@@ -351,9 +348,8 @@ export function resolveImportPath(coreDir, componentName) {
351
348
  const relToSrc = path.relative(srcDir, sourcePath);
352
349
  const topDir = relToSrc.split(path.sep)[0];
353
350
 
354
- const topMatch = exportKeys.find(k => k.toLowerCase() === `./${topDir}`.toLowerCase());
355
- if (topMatch) {
356
- return `@astryxdesign/core/${topMatch.slice(2)}`;
351
+ if (pkg?.exports?.[`./${topDir}`]) {
352
+ return `@astryxdesign/core/${topDir}`;
357
353
  }
358
354
 
359
355
  return '@astryxdesign/core';
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
8
8
  export default function AspectRatioCircleImage() {
9
9
  return (
10
10
  <Center width={300}>
11
- <AspectRatio ratio={1} shape="ellipse" fit="cover">
11
+ <AspectRatio ratio={1} shape="ellipse">
12
12
  <img
13
13
  src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
14
14
  alt="Circular image"
15
+ style={{
16
+ width: '100%',
17
+ height: '100%',
18
+ objectFit: 'cover',
19
+ }}
15
20
  />
16
21
  </AspectRatio>
17
22
  </Center>
@@ -25,11 +25,16 @@ export default function AspectRatioImageGallery() {
25
25
  <Center width={600}>
26
26
  <Grid columns={3} gap={4} width="100%">
27
27
  {images.map(({id, alt}) => (
28
- <AspectRatio key={id} ratio={4 / 3} fit="cover">
28
+ <AspectRatio key={id} ratio={4 / 3}>
29
29
  <img
30
30
  src="https://lookaside.facebook.com/assets/astryx/illustrative-horizontal-1.png"
31
31
  alt={alt}
32
- style={{borderRadius: 8}}
32
+ style={{
33
+ width: '100%',
34
+ height: '100%',
35
+ objectFit: 'cover',
36
+ borderRadius: 8,
37
+ }}
33
38
  />
34
39
  </AspectRatio>
35
40
  ))}
@@ -34,13 +34,16 @@ export default function AspectRatioShowcase() {
34
34
  <VStack key={label} gap={2} hAlign="center">
35
35
  <AspectRatio
36
36
  ratio={ratio}
37
- fit="cover"
38
37
  style={{
39
38
  height: 120,
40
39
  width: 'auto',
41
40
  borderRadius: 'var(--radius-container)',
42
41
  }}>
43
- <img src={src} alt={alt} />
42
+ <img
43
+ src={src}
44
+ alt={alt}
45
+ style={{width: '100%', height: '100%', objectFit: 'cover'}}
46
+ />
44
47
  </AspectRatio>
45
48
  <Text type="supporting" color="secondary">
46
49
  {label}
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
8
8
  export default function AspectRatioSquareImage() {
9
9
  return (
10
10
  <Center width={300}>
11
- <AspectRatio ratio={1} fit="cover">
11
+ <AspectRatio ratio={1}>
12
12
  <img
13
13
  src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
14
14
  alt="1:1 square"
15
+ style={{
16
+ width: '100%',
17
+ height: '100%',
18
+ objectFit: 'cover',
19
+ }}
15
20
  />
16
21
  </AspectRatio>
17
22
  </Center>
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
8
8
  export default function AspectRatioWidescreen() {
9
9
  return (
10
10
  <Center width={600}>
11
- <AspectRatio ratio={16 / 9} fit="cover">
11
+ <AspectRatio ratio={16 / 9}>
12
12
  <img
13
13
  src="https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png"
14
14
  alt="16:9 widescreen"
15
+ style={{
16
+ width: '100%',
17
+ height: '100%',
18
+ objectFit: 'cover',
19
+ }}
15
20
  />
16
21
  </AspectRatio>
17
22
  </Center>
@@ -2,36 +2,34 @@
2
2
 
3
3
  'use client';
4
4
 
5
- import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
5
+ import {Collapsible} from '@astryxdesign/core/Collapsible';
6
6
  import {Divider} from '@astryxdesign/core/Divider';
7
7
  import {Text} from '@astryxdesign/core/Text';
8
8
  import {VStack} from '@astryxdesign/core/Layout';
9
9
 
10
10
  export default function CollapsibleWithoutCard() {
11
11
  return (
12
- <CollapsibleGroup type="single" defaultValue="deployment">
13
- <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
14
- <Collapsible trigger="Deployment Details" value="deployment">
15
- <Text type="body">
16
- Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
17
- duration was 2m 14s with zero warnings.
18
- </Text>
19
- </Collapsible>
20
- <Divider />
21
- <Collapsible trigger="Environment Variables" value="environment">
22
- <Text type="body">
23
- 12 variables configured. Last updated March 30, 2026. All secrets
24
- are encrypted at rest with AES-256.
25
- </Text>
26
- </Collapsible>
27
- <Divider />
28
- <Collapsible trigger="Build Logs" value="logs">
29
- <Text type="body">
30
- Build completed successfully. 847 modules compiled, 0 errors, 0
31
- warnings. Bundle size: 142 KB gzipped.
32
- </Text>
33
- </Collapsible>
34
- </VStack>
35
- </CollapsibleGroup>
12
+ <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
13
+ <Collapsible trigger="Deployment Details">
14
+ <Text type="body">
15
+ Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
16
+ duration was 2m 14s with zero warnings.
17
+ </Text>
18
+ </Collapsible>
19
+ <Divider />
20
+ <Collapsible trigger="Environment Variables" defaultIsOpen={false}>
21
+ <Text type="body">
22
+ 12 variables configured. Last updated March 30, 2026. All secrets are
23
+ encrypted at rest with AES-256.
24
+ </Text>
25
+ </Collapsible>
26
+ <Divider />
27
+ <Collapsible trigger="Build Logs" defaultIsOpen={false}>
28
+ <Text type="body">
29
+ Build completed successfully. 847 modules compiled, 0 errors, 0
30
+ warnings. Bundle size: 142 KB gzipped.
31
+ </Text>
32
+ </Collapsible>
33
+ </VStack>
36
34
  );
37
35
  }