An open source design system that's fully customizable and agent ready
TypeScript
fix(shadcn): preserve JavaScript composition upgrades (#6246)
Joey32ef5231d734
diff --git a/.changeset/shadcn-js-receipts.md b/.changeset/shadcn-js-receipts.mdnew file mode 100644index 0000000000..3800a1b6eb--- /dev/null+++ b/.changeset/shadcn-js-receipts.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] Keep ShadCN composition upgrades safe in JavaScript projects and publish precompiled JSX with strict TypeScript declarations.++@josephfarinadiff --git a/.github/scripts/shadcn-registry-ci.test.mjs b/.github/scripts/shadcn-registry-ci.test.mjsindex 1864f6ef79..b8292f361e 100644--- a/.github/scripts/shadcn-registry-ci.test.mjs+++ b/.github/scripts/shadcn-registry-ci.test.mjs@@ -81,6 +81,19 @@ describe('ShadCN registry CI contract', () => {expect(preview.run).toContain('generate-data.mjs');});+ it('keeps the soak rollout out of public CLI discovery', () => {+ const docsDirectory = path.join(root, 'packages/cli/assets/docs');+ expect(fs.readdirSync(docsDirectory)).not.toContain(+ 'shadcn-compatibility.doc.mjs',+ );+ expect(fs.readdirSync(docsDirectory)).toContain(+ 'shadcn-compatibility.doc.draft.mjs',+ );+ expect(read('packages/cli/api/upgrade/upgrade.doc.mjs')).not.toMatch(+ /shadcn/i,+ );+ });+it('builds every workspace package before exercising local package exports', () => {expect(step('Build registry package exports').run).toBe('pnpm build');});@@ -96,12 +109,16 @@ describe('ShadCN registry CI contract', () => {for (const invariant of ["'add', ...itemPaths","'--silent'",- 'installed different bytes',+ 'expectedInstalledFile(file, tsx)',+ 'for (const tsx of [true, false])','did not install declared dependency','alias route','duplicate item name',- 'must contain exactly one source and one receipt',+ 'must contain one source, one receipt, and a declaration only for precompiled JavaScript',+ 'lacks its exact JavaScript install variant',+ 'precompiled declaration type-check exited','parseRegistryReceipt',+ 'verifyPrecompiledTypeDeclarations(project, catalog.items)','compileSources(project, sources)',]) {expect(verifier).toContain(invariant);diff --git a/apps/docsite/scripts/generate-shadcn-registry.mjs b/apps/docsite/scripts/generate-shadcn-registry.mjsindex e3f32ca8f5..ec69261e1d 100644--- a/apps/docsite/scripts/generate-shadcn-registry.mjs+++ b/apps/docsite/scripts/generate-shadcn-registry.mjs@@ -20,6 +20,12 @@ import stylexPlugin from '@stylexjs/babel-plugin';import ts from 'typescript';import {registryItemSchema, registrySchema} from 'shadcn/schema';import {stripCopyrightHeader} from '../../../packages/cli/foundation/text/copyright-header.mjs';+import {+ createShadcnPrecompiledDeclaration,+ shadcnJavaScriptTarget,+ shadcnPrecompiledDeclarationTarget,+ transformShadcnJavaScriptSource,+} from '../../../packages/cli/authoring/shadcn/source-variants.mjs';import {createRegistryReceipt,registryReceiptTarget,@@ -131,8 +137,13 @@ function precompileStylexSource(source, fileName) {if (result.code.includes('stylex.create')) {throw new Error(`Uncompiled stylex.create remains in ${fileName}`);}+ const precompiled = `${result.code}\n`;return {- source: `${result.code}\n`,+ // Normalize once through the pinned client's JavaScript printer. That+ // transform is idempotent, so tsx=true and tsx=false write identical JSX.+ source: transformShadcnJavaScriptSource(precompiled),+ // Babel strips the source's types while precompiling StyleX, so publish the+ // result honestly as JSX and add a narrow declaration beside the catalog.extension: 'jsx',precompiledStylex: true,};@@ -264,9 +275,30 @@ function componentItem(};}+function precompiledDeclarationFile(itemName, sourceTarget) {+ const target = shadcnPrecompiledDeclarationTarget(sourceTarget);+ return {+ path: `registry/${itemName}/astryx-types.d.mts`,+ type: 'registry:file',+ target,+ content: createShadcnPrecompiledDeclaration(sourceTarget),+ };+}+function withCompositionReceipt(item, identity, sourceVersion) {- const sourceFile = item.files[0];+ const [sourceFile, ...supportFiles] = item.files;const receiptTarget = registryReceiptTarget(sourceFile.target, item.name);+ const javascriptTarget = shadcnJavaScriptTarget(sourceFile.target);+ const variants =+ javascriptTarget === sourceFile.target+ ? []+ : [+ {+ format: 'javascript',+ target: javascriptTarget,+ content: transformShadcnJavaScriptSource(sourceFile.content),+ },+ ];const receipt = createRegistryReceipt({item: {name: item.name,@@ -282,7 +314,15 @@ function withCompositionReceipt(item, identity, sourceVersion) {target: sourceFile.target,registryPath: sourceFile.path,content: sourceFile.content,+ variants,},+ ...supportFiles.map(file => ({+ id: 'types',+ target: file.target,+ registryPath: file.path,+ content: file.content,+ variants: [],+ })),],});@@ -290,6 +330,7 @@ function withCompositionReceipt(item, identity, sourceVersion) {...item,files: [sourceFile,+ ...supportFiles,{path: `registry/${item.name}/astryx-receipt.json`,type: 'registry:file',@@ -334,6 +375,7 @@ function blockItem(stripCopyrightHeader(block.source),fileName,);+ const sourceTarget = `components/astryx/${kind === 'block' ? 'blocks' : `${kind}s`}/${block.dirName}.${compiled.extension}`;return withCompositionReceipt({$schema: REGISTRY_ITEM_SCHEMA,@@ -353,9 +395,12 @@ function blockItem({path: `registry/${itemName}/${block.dirName}.${compiled.extension}`,type: 'registry:block',- target: `components/astryx/${kind === 'block' ? 'blocks' : `${kind}s`}/${block.dirName}.${compiled.extension}`,+ target: sourceTarget,content: compiled.source,},+ ...(compiled.precompiledStylex+ ? [precompiledDeclarationFile(itemName, sourceTarget)]+ : []),],astryx: {kind,@@ -393,6 +438,7 @@ function pageItem(stripCopyrightHeader(template.source),fileName,);+ const sourceTarget = `app/astryx/${template.slug}/page.${compiled.extension}`;return withCompositionReceipt({$schema: REGISTRY_ITEM_SCHEMA,@@ -414,9 +460,12 @@ function pageItem(// shadcn 4.19.0 silently skips files typed registry:page. The item// remains registry:page while its source file uses the working type.type: 'registry:block',- target: `app/astryx/${template.slug}/page.${compiled.extension}`,+ target: sourceTarget,content: compiled.source,},+ ...(compiled.precompiledStylex+ ? [precompiledDeclarationFile(itemName, sourceTarget)]+ : []),],astryx: {kind: 'page',diff --git a/apps/docsite/src/content/blog/posts/meet-astryx-from-shadcn.md b/apps/docsite/src/content/blog/posts/meet-astryx-from-shadcn.mdindex 59a9ed1fb1..0d187108e5 100644--- a/apps/docsite/src/content/blog/posts/meet-astryx-from-shadcn.md+++ b/apps/docsite/src/content/blog/posts/meet-astryx-from-shadcn.md@@ -30,7 +30,7 @@ shadcn has a [Registry protocol](https://ui.shadcn.com/docs/registry). A registrAstryx can do the same thing.```bash-npx shadcn@latest add <registry-origin>/templates/dashboard.json+npx [email protected] add <registry-origin>/templates/dashboard.json```The important bit is what happens after that command. Astryx does not become a pile of copied component source. The command installs the real `@astryxdesign/core` package. The dashboard code it copies imports `Card`, `Table`, `Button`, `ProgressBar`, and everything else from that package.@@ -68,7 +68,7 @@ The two paths can sit next to each other:```bash# I know the exact item and already use shadcn-npx shadcn@latest add <registry-origin>/examples/button/variants.json+npx [email protected] add <registry-origin>/examples/button/variants.json# I need help finding and maintaining the right piecesastryx build "analytics dashboard with filters"diff --git a/apps/docsite/src/lib/shadcnRegistry.mjs b/apps/docsite/src/lib/shadcnRegistry.mjsindex 219b191534..5fcfd6671d 100644--- a/apps/docsite/src/lib/shadcnRegistry.mjs+++ b/apps/docsite/src/lib/shadcnRegistry.mjs@@ -13,6 +13,10 @@ const RELATIVE_PATH_PATTERN =/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/;const REGISTRY_IDENTITY_KEYS = new Set(['slug', 'aliases']);+// SYNC: apps/docsite/package.json. Receipt JavaScript variants mirror this+// client's transform, so generated install commands must pin the tested client.+export const SHADCN_CLI_VERSION = '4.19.0';+export function resolveShadcnRegistryOrigin(env = process.env) {const explicitOrigin = env.NEXT_PUBLIC_ASTRYX_REGISTRY_ORIGIN;if (explicitOrigin) {@@ -264,5 +268,5 @@ export function shadcnInstallCommand(itemPath,registryOrigin = SHADCN_REGISTRY_ORIGIN,) {- return `npx shadcn@latest add ${registryOrigin}/${itemPath}.json`;+ return `npx shadcn@${SHADCN_CLI_VERSION} add ${registryOrigin}/${itemPath}.json`;}diff --git a/internal/shadcn-registry/generate-shadcn-registry.test.mjs b/internal/shadcn-registry/generate-shadcn-registry.test.mjsindex d372d3d17d..8fbc5aa50f 100644--- a/internal/shadcn-registry/generate-shadcn-registry.test.mjs+++ b/internal/shadcn-registry/generate-shadcn-registry.test.mjs@@ -22,6 +22,10 @@ import path from 'node:path';import {promisify} from 'node:util';import {describe, expect, it} from 'vitest';import {reconcileRegistryCompositions} from '../../packages/cli/api/upgrade/registry/registry.mjs';+import {+ createShadcnPrecompiledDeclaration,+ shadcnPrecompiledDeclarationTarget,+} from '../../packages/cli/authoring/shadcn/source-variants.mjs';import {parseRegistryReceipt,registryContentHash,@@ -32,10 +36,12 @@ import {generateShadcnRegistryForTarget,} from '../../apps/docsite/scripts/generate-shadcn-registry.mjs';import {+ SHADCN_CLI_VERSION,blockRegistryIdentity,componentRegistryIdentity,pageRegistryIdentity,resolveShadcnRegistryOrigin,+ shadcnInstallCommand,} from '../../apps/docsite/src/lib/shadcnRegistry.mjs';const execFileAsync = promisify(execFile);@@ -95,7 +101,7 @@ function fixture(overrides = {}) {};}-function writeConsumerProject(project) {+function writeConsumerProject(project, {tsx = true} = {}) {mkdirSync(path.join(project, 'src'), {recursive: true});writeFileSync(path.join(project, 'package.json'),@@ -111,7 +117,7 @@ function writeConsumerProject(project) {$schema: 'https://ui.shadcn.com/schema.json',style: 'nova',rsc: false,- tsx: true,+ tsx,tailwind: {config: '',css: 'src/index.css',@@ -130,10 +136,9 @@ function writeConsumerProject(project) {}),);writeFileSync(- path.join(project, 'tsconfig.json'),+ path.join(project, tsx ? 'tsconfig.json' : 'jsconfig.json'),JSON.stringify({compilerOptions: {- baseUrl: '.',paths: {'@/*': ['./src/*']},},}),@@ -158,6 +163,18 @@ describe('resolveShadcnRegistryOrigin', () => {}),).toBe('https://astryx-git-example.vercel.app/shadcn');});++ it('pins install commands to the client used for receipt variants', () => {+ const manifest = JSON.parse(+ readFileSync('apps/docsite/package.json', 'utf8'),+ );+ expect(SHADCN_CLI_VERSION).toBe(manifest.devDependencies.shadcn);+ expect(+ shadcnInstallCommand('components/button', 'https://registry.example'),+ ).toBe(+ `npx shadcn@${SHADCN_CLI_VERSION} add https://registry.example/components/button.json`,+ );+ });});describe('registry identities', () => {@@ -353,7 +370,7 @@ describe('buildShadcnRegistry', () => {});const receipt = parseRegistryReceipt(JSON.parse(receiptFile.content));expect(receipt).toMatchObject({- schemaVersion: 1,+ schemaVersion: 2,item: {name: item.name,path: item.astryx.path,@@ -368,7 +385,16 @@ describe('buildShadcnRegistry', () => {registryPath: sourceFile.path,sha256: registryContentHash(sourceFile.content),content: sourceFile.content,+ variants: [+ expect.objectContaining({+ format: 'javascript',+ registryTarget: sourceFile.target.replace(/\.tsx$/, '.jsx'),+ }),+ ],});+ expect(receipt.files[0].variants[0].sha256).toBe(+ registryContentHash(receipt.files[0].variants[0].content),+ );}});@@ -465,6 +491,80 @@ describe('buildShadcnRegistry', () => {}});+ it('records the exact JavaScript bytes written by stock ShadCN', async () => {+ const project = mkdtempSync(path.join(tmpdir(), 'astryx-shadcn-js-'));+ try {+ writeConsumerProject(project, {tsx: false});+ const base = fixture();+ const {items} = buildShadcnRegistry(+ fixture({+ blocks: [+ {+ ...base.blocks[0],+ source:+ "'use client';\n\n" ++ "import type {ReactNode} from 'react';\n" ++ "import {Button} from '@astryxdesign/core/Button';\n" ++ 'const label: ReactNode = "Save";\n' ++ 'export default function ButtonShowcase() { return <Button label={label} isDisabled={false} onPress={() => {}} />; }\n',+ },+ ],+ }),+ );+ const block = items.find(+ item => item.name === 'showcase-button-variants',+ );+ const itemPath = path.join(project, 'block.json');+ writeFileSync(itemPath, JSON.stringify(block));++ await execFileAsync(+ path.resolve('node_modules/.bin/shadcn'),+ ['add', itemPath, '--yes'],+ {cwd: project, timeout: 30_000},+ );++ const sourcePath = path.join(+ project,+ 'src',+ 'components',+ 'astryx',+ 'showcases',+ 'ButtonShowcase.jsx',+ );+ const receipt = parseRegistryReceipt(+ JSON.parse(+ readFileSync(+ path.join(+ project,+ 'src',+ 'components',+ 'astryx',+ 'showcases',+ '.astryx',+ 'showcase-button-variants.json',+ ),+ 'utf8',+ ),+ ),+ );+ const javascript = receipt.files[0].variants.find(+ variant => variant.format === 'javascript',+ );+ const installed = readFileSync(sourcePath, 'utf8');++ expect(existsSync(sourcePath.replace(/\.jsx$/, '.tsx'))).toBe(false);+ expect(javascript).toMatchObject({+ target: '../ButtonShowcase.jsx',+ registryTarget: 'components/astryx/showcases/ButtonShowcase.jsx',+ content: installed,+ sha256: registryContentHash(installed),+ });+ expect(installed).not.toContain('ReactNode');+ } finally {+ rmSync(project, {recursive: true, force: true});+ }+ });+it('upgrades a stock-ShadCN install from its adjacent receipt', async () => {const project = mkdtempSync(path.join(tmpdir(), 'astryx-shadcn-upgrade-'));const oldInput = fixture();@@ -812,6 +912,21 @@ describe('buildShadcnRegistry', () => {expect(block.files[0].content).toContain('stylex-inject');expect(block.files[0].content).not.toContain('stylex.create');expect(block.files[0].target).toMatch(/\.jsx$/);+ expect(block.files[0].content).not.toMatch(/:\s*[A-Z][A-Za-z]+/);+ expect(block.files).toHaveLength(3);+ expect(block.files[1]).toMatchObject({+ type: 'registry:file',+ target: shadcnPrecompiledDeclarationTarget(block.files[0].target),+ content: createShadcnPrecompiledDeclaration(block.files[0].target),+ });+ const receipt = parseRegistryReceipt(JSON.parse(block.files[2].content));+ expect(receipt.files[0].variants).toEqual([]);+ expect(receipt.files[1]).toMatchObject({+ id: 'types',+ registryTarget: block.files[1].target,+ content: block.files[1].content,+ variants: [],+ });expect(block.dependencies).toContain('@stylexjs/[email protected]');});diff --git a/internal/shadcn-registry/verify-full-catalog.mjs b/internal/shadcn-registry/verify-full-catalog.mjsindex 663c0f91b9..a37d7c46a1 100644--- a/internal/shadcn-registry/verify-full-catalog.mjs+++ b/internal/shadcn-registry/verify-full-catalog.mjs@@ -4,8 +4,9 @@/*** @file verify-full-catalog.mjs* @description Installs every generated Astryx registry item through the pinned- * ShadCN client, verifies exact written bytes and dependencies, then compiles- * every installed source file against the current Astryx package exports.+ * ShadCN client in TypeScript and JavaScript modes, verifies exact written+ * bytes and dependencies, then compiles every installed source file against+ * the current Astryx package exports.* @input A generated canary registry under apps/docsite/public/shadcn.* @output A clean-consumer proof for every canonical item and alias route.* @position Required CI contract for the public ShadCN compatibility surface.@@ -20,7 +21,16 @@ import {fileURLToPath} from 'node:url';import {build} from 'esbuild';-import {parseRegistryReceipt} from '../../packages/cli/authoring/shadcn/receipt.mjs';+import {+ createShadcnPrecompiledDeclaration,+ shadcnJavaScriptTarget,+ shadcnPrecompiledDeclarationTarget,+ transformShadcnJavaScriptSource,+} from '../../packages/cli/authoring/shadcn/source-variants.mjs';+import {+ parseRegistryReceipt,+ registryContentHash,+} from '../../packages/cli/authoring/shadcn/receipt.mjs';import {expandWorkspaceDirs} from '../../scripts/lib/workspace-globs.mjs';const __dirname = path.dirname(fileURLToPath(import.meta.url));@@ -36,6 +46,7 @@ const docsiteRequire = createRequire(path.join(REPO_ROOT, 'apps', 'docsite', 'package.json'),);const SHADCN_BIN = docsiteRequire.resolve('shadcn');+const TYPESCRIPT_BIN = docsiteRequire.resolve('typescript/bin/tsc');const KEEP_TEMP = process.env.ASTRYX_KEEP_SHADCN_MATRIX === '1';const MAX_COMMAND_OUTPUT = 16 * 1024 * 1024;const COPIED_KINDS = new Set(['showcase', 'example', 'block', 'page']);@@ -88,21 +99,50 @@ function localPackageDirs() {function verifyItemFileShape(item) {const receipts = item.files.filter(- file => file.type === 'registry:file' && file.target.includes('/.astryx/'),+ file =>+ file.type === 'registry:file' &&+ file.target.includes('/.astryx/') &&+ file.target.endsWith('.json'),+ );+ const declarations = item.files.filter(+ file =>+ file.type === 'registry:file' && file.target.endsWith('.astryx.d.mts'),+ );+ const sources = item.files.filter(+ file => !receipts.includes(file) && !declarations.includes(file),);- const sources = item.files.filter(file => !receipts.includes(file));const kind = item.astryx?.kind;if (COPIED_KINDS.has(kind)) {+ const precompiled = item.astryx?.precompiledStylex === true;if (sources.length !== 1 ||receipts.length !== 1 ||- item.files.length !== 2+ declarations.length !== (precompiled ? 1 : 0) ||+ item.files.length !== (precompiled ? 3 : 2)) {- fail(`${item.name} must contain exactly one source and one receipt`);+ fail(+ `${item.name} must contain one source, one receipt, and a declaration only for precompiled JavaScript`,+ );}const source = sources[0];const receiptFile = receipts[0];+ if (precompiled) {+ if (!/\.jsx?$/.test(source.target)) {+ fail(`${item.name} precompiled source must be JavaScript`);+ }+ const declaration = declarations[0];+ if (+ declaration.target !==+ shadcnPrecompiledDeclarationTarget(source.target) ||+ declaration.content !==+ createShadcnPrecompiledDeclaration(source.target)+ ) {+ fail(`${item.name} has an invalid precompiled-source declaration`);+ }+ } else if (!/\.tsx?$/.test(source.target)) {+ fail(`${item.name} canonical copied source must remain TypeScript`);+ }const expectedReceiptTarget = path.posix.join(path.posix.dirname(source.target),'.astryx',@@ -122,13 +162,49 @@ function verifyItemFileShape(item) {receipt.item.name !== item.name ||receipt.item.path !== item.astryx.path ||receipt.item.kind !== kind ||- receipt.files.length !== 1 ||+ receipt.files.length !== (precompiled ? 2 : 1) ||receipt.files[0].registryPath !== source.path ||receipt.files[0].registryTarget !== source.target ||receipt.files[0].content !== source.content) {fail(`${item.name} receipt does not describe its installed source`);}+ if (precompiled) {+ const declaration = declarations[0];+ const declarationReceipt = receipt.files[1];+ if (+ declarationReceipt.id !== 'types' ||+ declarationReceipt.registryPath !== declaration.path ||+ declarationReceipt.registryTarget !== declaration.target ||+ declarationReceipt.content !== declaration.content ||+ declarationReceipt.variants?.length !== 0+ ) {+ fail(+ `${item.name} receipt does not describe its TypeScript declaration`,+ );+ }+ }+ if (receipt.schemaVersion !== 2) {+ fail(`${item.name} receipt is not schema version 2`);+ }+ const expectedJavaScriptTarget = shadcnJavaScriptTarget(source.target);+ const javascript = receipt.files[0].variants.find(+ variant => variant.format === 'javascript',+ );+ if (expectedJavaScriptTarget === source.target) {+ if (receipt.files[0].variants.length !== 0) {+ fail(+ `${item.name} JavaScript source must not duplicate itself as a variant`,+ );+ }+ } else if (+ receipt.files[0].variants.length !== 1 ||+ javascript?.registryTarget !== expectedJavaScriptTarget ||+ javascript?.content !== transformShadcnJavaScriptSource(source.content) ||+ javascript?.sha256 !== registryContentHash(javascript?.content ?? '')+ ) {+ fail(`${item.name} receipt lacks its exact JavaScript install variant`);+ }return;}@@ -136,6 +212,7 @@ function verifyItemFileShape(item) {(kind === 'component' || kind === 'hook') &&sources.length === 1 &&receipts.length === 0 &&+ declarations.length === 0 &&item.files.length === 1) {return;@@ -231,7 +308,7 @@ function loadCatalog() {return {items, routeCount: routes.size, targetCount: targets.size};}-function writeConsumer(project, items, packageDirs) {+function writeConsumer(project, items, packageDirs, {tsx}) {const rootManifest = readJSON(path.join(REPO_ROOT, 'package.json'));const itemDirectory = path.join(project, 'items');fs.mkdirSync(path.join(project, 'src'), {recursive: true});@@ -246,6 +323,8 @@ function writeConsumer(project, items, packageDirs) {version: '0.0.0',packageManager: rootManifest.packageManager,dependencies: {+ '@types/react': rootManifest.devDependencies['@types/react'],+ '@types/react-dom': rootManifest.devDependencies['@types/react-dom'],react: rootManifest.devDependencies.react,'react-dom': rootManifest.devDependencies['react-dom'],},@@ -265,7 +344,6 @@ function writeConsumer(project, items, packageDirs) {`${JSON.stringify({compilerOptions: {- baseUrl: '.',jsx: 'react-jsx',module: 'ESNext',moduleResolution: 'Bundler',@@ -285,7 +363,7 @@ function writeConsumer(project, items, packageDirs) {$schema: 'https://ui.shadcn.com/schema.json',style: 'nova',rsc: false,- tsx: true,+ tsx,tailwind: {config: '',css: 'src/index.css',@@ -359,28 +437,44 @@ function runShadcn(project, itemPaths) {}}-function verifyInstall(project, items, dependencyNames) {+function expectedInstalledFile(file, tsx) {+ if (tsx) return {target: file.target, content: file.content};+ const target = shadcnJavaScriptTarget(file.target);+ return {+ target,+ content:+ target === file.target+ ? file.content+ : transformShadcnJavaScriptSource(file.content),+ };+}++function verifyInstall(project, items, dependencyNames, {tsx}) {const sources = [];let installedFiles = 0;for (const item of items) {for (const file of item.files) {+ const expected = expectedInstalledFile(file, tsx);const installed = resolveInside(path.join(project, 'src'),- file.target,+ expected.target,`${item.name} installed target`,);if (!fs.existsSync(installed)) {- fail(`${item.name} did not install ${file.target}`);+ fail(`${item.name} did not install ${expected.target}`);}const actual = fs.readFileSync(installed, 'utf8');- if (actual !== file.content) {+ if (actual !== expected.content) {fail(- `${item.name} installed different bytes at ${file.target}; generated content must match stock ShadCN output`,+ `${item.name} installed different ${tsx ? 'TypeScript' : 'JavaScript'} bytes at ${expected.target}`,);}installedFiles += 1;- if (!file.target.includes('/.astryx/')) {+ if (+ /\.[cm]?[jt]sx?$/.test(expected.target) &&+ !/\.d\.[cm]?ts$/.test(expected.target)+ ) {sources.push(installed);}}@@ -410,6 +504,76 @@ function verifyInstall(project, items, dependencyNames) {return {installedFiles, sources};}+function verifyPrecompiledTypeDeclarations(project, items) {+ const precompiled = items.filter(+ item => item.astryx?.precompiledStylex === true,+ );+ if (precompiled.length === 0) return;++ const imports = [];+ const identifiers = [];+ const declarationFiles = [];+ for (const [index, item] of precompiled.entries()) {+ const source = item.files.find(file => /\.jsx?$/.test(file.target));+ const declaration = item.files.find(file =>+ file.target.endsWith('.astryx.d.mts'),+ );+ if (source == null || declaration == null) {+ fail(`${item.name} is missing its precompiled source or declaration`);+ }+ const identifier = `Composition${index}`;+ const specifier = `./${source.target.replace(/\.jsx?$/, '')}`;+ imports.push(`import ${identifier} from ${JSON.stringify(specifier)};`);+ identifiers.push(identifier);+ declarationFiles.push(`src/${declaration.target}`);+ }++ const harness = 'src/__astryx-precompiled-typecheck.ts';+ fs.writeFileSync(+ path.join(project, harness),+ `${imports.join('\n')}\n\nconst compositions: Array<import('react').ComponentType> = [${identifiers.join(', ')}];\nvoid compositions;\n`,+ );+ const configPath = path.join(project, 'tsconfig.precompiled.json');+ fs.writeFileSync(+ configPath,+ `${JSON.stringify(+ {+ compilerOptions: {+ strict: true,+ noEmit: true,+ module: 'ESNext',+ moduleResolution: 'Bundler',+ skipLibCheck: true,+ target: 'ES2022',+ },+ files: [harness, ...declarationFiles],+ },+ null,+ 2,+ )}\n`,+ );+ const result = spawnSync(+ process.execPath,+ [TYPESCRIPT_BIN, '--project', configPath],+ {+ cwd: project,+ encoding: 'utf8',+ maxBuffer: MAX_COMMAND_OUTPUT,+ timeout: 2 * 60_000,+ },+ );+ if (result.error != null) {+ fail(+ `could not type-check precompiled declarations: ${result.error.message}`,+ );+ }+ if (result.status !== 0) {+ process.stderr.write(result.stdout ?? '');+ process.stderr.write(result.stderr ?? '');+ fail(`precompiled declaration type-check exited ${result.status}`);+ }+}+async function compileSources(project, sources) {await build({absWorkingDir: project,@@ -429,36 +593,44 @@ async function main() {const startedAt = Date.now();const catalog = loadCatalog();const packageDirs = localPackageDirs();- const project = fs.mkdtempSync(- path.join(os.tmpdir(), 'astryx-shadcn-registry-ci-'),- );-- try {- const {dependencyNames, itemPaths} = writeConsumer(- project,- catalog.items,- packageDirs,- );- runShadcn(project, itemPaths);- const {installedFiles, sources} = verifyInstall(- project,- catalog.items,- dependencyNames,- );- await compileSources(project, sources);+ const results = [];- const seconds = ((Date.now() - startedAt) / 1000).toFixed(1);- console.log(- `Verified ${catalog.items.length} items, ${catalog.routeCount} routes, ` +- `${installedFiles} installed files, and ${sources.length} compiled sources in ${seconds}s.`,+ for (const tsx of [true, false]) {+ const mode = tsx ? 'TypeScript' : 'JavaScript';+ const project = fs.mkdtempSync(+ path.join(os.tmpdir(), `astryx-shadcn-registry-${tsx ? 'tsx' : 'jsx'}-`),);- } finally {- if (KEEP_TEMP) {- console.log(`Kept clean consumer at ${project}`);- } else {- fs.rmSync(project, {recursive: true, force: true});+ try {+ const {dependencyNames, itemPaths} = writeConsumer(+ project,+ catalog.items,+ packageDirs,+ {tsx},+ );+ runShadcn(project, itemPaths);+ const {installedFiles, sources} = verifyInstall(+ project,+ catalog.items,+ dependencyNames,+ {tsx},+ );+ if (tsx) verifyPrecompiledTypeDeclarations(project, catalog.items);+ await compileSources(project, sources);+ results.push({mode, installedFiles, sources: sources.length});+ } finally {+ if (KEEP_TEMP) {+ console.log(`Kept ${mode} consumer at ${project}`);+ } else {+ fs.rmSync(project, {recursive: true, force: true});+ }}}++ const seconds = ((Date.now() - startedAt) / 1000).toFixed(1);+ console.log(+ `Verified ${catalog.items.length} items and ${catalog.routeCount} routes in ` ++ `${results.map(result => `${result.mode}: ${result.installedFiles} files, ${result.sources} compiled sources`).join('; ')} (${seconds}s).`,+ );}main().catch(error => {diff --git a/packages/cli/api/upgrade/registry/registry.mjs b/packages/cli/api/upgrade/registry/registry.mjsindex 8eb124ca5f..31b3215cf5 100644--- a/packages/cli/api/upgrade/registry/registry.mjs+++ b/packages/cli/api/upgrade/registry/registry.mjs@@ -11,6 +11,13 @@ import * as fs from 'node:fs';import * as path from 'node:path';import {randomUUID} from 'node:crypto';import {mergeDiff3} from 'node-diff3';+import {+ createShadcnPrecompiledDeclaration,+ shadcnJavaScriptTarget,+ shadcnPrecompiledDeclarationTarget,+ shadcnJavaScriptSourcesEquivalent,+ transformShadcnJavaScriptSource,+} from '../../../authoring/shadcn/source-variants.mjs';import {PUBLIC_SHADCN_REGISTRY_ORIGIN,parseRegistryReceipt,@@ -201,6 +208,55 @@ function sourceVersionMatches(sourceVersion, expectedVersion) {);}+/**+ * Flatten the canonical receipt file and each format-specific install variant.+ * Version 1 receipts did not carry variants; derive the stock-ShadCN JavaScript+ * form so early canary installs can repair themselves on their first upgrade.+ * @param {ReturnType<typeof parseRegistryReceipt>} receipt+ * @param {any} file+ */+function receiptFileCandidates(receipt, file) {+ const canonical = {...file, format: 'typescript'};+ /** @type {Array<{format: 'javascript', target: string, registryTarget: string, sha256: string, content: string}>} */+ let variants = receipt.schemaVersion === 2 ? file.variants : [];+ if (receipt.schemaVersion === 1) {+ const target = shadcnJavaScriptTarget(file.target);+ const registryTarget = shadcnJavaScriptTarget(file.registryTarget);+ if (target !== file.target || registryTarget !== file.registryTarget) {+ try {+ const content = transformShadcnJavaScriptSource(file.content);+ variants = [+ {+ format: 'javascript',+ target,+ registryTarget,+ sha256: registryContentHash(content),+ content,+ },+ ];+ } catch {+ // A version 1 receipt may describe a non-code file. Its canonical form+ // remains valid; it simply has no derivable JavaScript variant.+ }+ }+ }+ return [+ canonical,+ ...variants.map(variant => ({+ ...variant,+ id: file.id,+ registryPath: file.registryPath,+ })),+ ];+}++/** @param {ReturnType<typeof parseRegistryReceipt>} receipt @param {any} file @param {string} format */+function receiptFileForFormat(receipt, file, format) {+ return receiptFileCandidates(receipt, file).find(+ candidate => candidate.format === format,+ );+}+/*** @param {string} itemPath* @param {{fetchImpl: typeof fetch, registryOrigin: string, expectedVersion?: string}} options@@ -288,6 +344,38 @@ async function fetchLatestReceipt();}+ const primaryFile = receipt.files.find(file => file.id === 'primary');+ const typesFile = receipt.files.find(file => file.id === 'types');+ const typesVariants =+ receipt.schemaVersion === 2+ ? receipt.files.find(file => file.id === 'types')?.variants+ : undefined;+ if (typesFile) {+ let expectedTypesTarget;+ let expectedTypesContent;+ try {+ expectedTypesTarget = shadcnPrecompiledDeclarationTarget(+ primaryFile?.registryTarget ?? '',+ );+ expectedTypesContent = createShadcnPrecompiledDeclaration(+ primaryFile?.registryTarget ?? '',+ );+ } catch {+ expectedTypesTarget = null;+ expectedTypesContent = null;+ }+ if (+ primaryFile == null ||+ typesFile.registryTarget !== expectedTypesTarget ||+ typesFile.content !== expectedTypesContent ||+ typesVariants?.length !== 0+ ) {+ throw new Error(+ `Registry item ${url} has an invalid TypeScript declaration`,+ );+ }+ }+for (const file of receipt.files) {const source = parsed.files.find(candidate => candidate.path === file.registryPath,@@ -306,6 +394,19 @@ async function fetchLatestReceipt(`Registry item ${url} receipt has a corrupt hash for ${file.registryPath}`,);}+ for (const variant of receiptFileCandidates(receipt, file).slice(1)) {+ if (+ variant.target !== shadcnJavaScriptTarget(file.target) ||+ variant.registryTarget !==+ shadcnJavaScriptTarget(file.registryTarget) ||+ variant.content !== transformShadcnJavaScriptSource(file.content) ||+ registryContentHash(variant.content) !== variant.sha256+ ) {+ throw new Error(+ `Registry item ${url} has an invalid ${variant.format} variant for ${file.registryPath}`,+ );+ }+ }}return receipt;}@@ -341,28 +442,39 @@ function loadInstalledReceipt(receiptPath, root) {}const files = receipt.files.map(file => {- if (registryContentHash(file.content) !== file.sha256) {- throw new Error(- `Invalid receipt ${relativePath(receiptPath, root)}: stored hash does not match ${file.registryPath}`,- );- }- let sourcePath;- try {- sourcePath = assertWithin(- path.resolve(path.dirname(receiptPath), file.target),- root,- {allowAbsolute: true, label: 'registry composition source'},- );- } catch (error) {- if (error instanceof PathSafetyError) {+ const candidates = receiptFileCandidates(receipt, file).map(candidate => {+ if (registryContentHash(candidate.content) !== candidate.sha256) {throw new Error(- `Invalid receipt ${relativePath(receiptPath, root)}: ${error.message}`,- {cause: error},+ `Invalid receipt ${relativePath(receiptPath, root)}: stored hash does not match ${file.registryPath} (${candidate.format})`,);}- throw error;+ let sourcePath;+ try {+ sourcePath = assertWithin(+ path.resolve(path.dirname(receiptPath), candidate.target),+ root,+ {allowAbsolute: true, label: 'registry composition source'},+ );+ } catch (error) {+ if (error instanceof PathSafetyError) {+ throw new Error(+ `Invalid receipt ${relativePath(receiptPath, root)}: ${error.message}`,+ {cause: error},+ );+ }+ throw error;+ }+ return {...candidate, sourcePath};+ });+ const existing = candidates.filter(candidate =>+ fs.existsSync(candidate.sourcePath),+ );+ if (existing.length > 1) {+ throw new Error(+ `Invalid receipt ${relativePath(receiptPath, root)}: multiple install variants exist for ${file.registryPath}`,+ );}- return {...file, sourcePath};+ return existing[0] ?? candidates[0];});return {receipt, files, receiptText};@@ -422,7 +534,19 @@ async function planReceipt(receiptPath, root, options) {}const oldIds = oldReceipt.files.map(file => file.id).sort();const newIds = newReceipt.files.map(file => file.id).sort();- if (JSON.stringify(oldIds) !== JSON.stringify(newIds)) {+ const removedIds = oldIds.filter(id => !newIds.includes(id));+ const addedIds = newIds.filter(id => !oldIds.includes(id));+ const addsOnlyGeneratedTypes =+ removedIds.length === 0 &&+ addedIds.length === 1 &&+ addedIds[0] === 'types' &&+ oldReceipt.files.some(+ file => file.id === 'primary' && /\.jsx?$/.test(file.registryTarget),+ );+ if (+ JSON.stringify(oldIds) !== JSON.stringify(newIds) &&+ !addsOnlyGeneratedTypes+ ) {return {receiptPath,item: oldReceipt.item.name,@@ -436,10 +560,84 @@ async function planReceipt(receiptPath, root, options) {}const plannedFiles = [];+ if (addsOnlyGeneratedTypes) {+ const newReceiptFile = newReceipt.files.find(file => file.id === 'types');+ const newFile = newReceiptFile+ ? receiptFileCandidates(newReceipt, newReceiptFile)[0]+ : null;+ if (newFile) {+ let sourcePath;+ try {+ sourcePath = assertWithin(+ path.resolve(path.dirname(receiptPath), newFile.target),+ root,+ {allowAbsolute: true, label: 'registry composition declaration'},+ );+ } catch (error) {+ return {+ receiptPath,+ item: oldReceipt.item.name,+ itemPath: oldReceipt.item.path,+ action: 'invalid',+ message: error instanceof Error ? error.message : String(error),+ files: [],+ oldReceiptText,+ };+ }+ const displayPath = relativePath(sourcePath, root);+ try {+ if (!fs.existsSync(sourcePath)) {+ plannedFiles.push({+ id: newFile.id,+ path: displayPath,+ sourcePath,+ action: 'create',+ content: newFile.content,+ });+ } else if (fs.lstatSync(sourcePath).isSymbolicLink()) {+ plannedFiles.push({+ id: newFile.id,+ path: displayPath,+ sourcePath,+ action: 'invalid',+ message:+ 'Generated declaration is a symbolic link; it will not be replaced',+ });+ } else {+ const current = fs.readFileSync(sourcePath, 'utf8');+ const currentHash = registryContentHash(current);+ plannedFiles.push({+ id: newFile.id,+ path: displayPath,+ sourcePath,+ currentContent: current,+ action: currentHash === newFile.sha256 ? 'current' : 'conflict',+ message:+ currentHash === newFile.sha256+ ? undefined+ : 'Generated declaration already exists with different content',+ });+ }+ } catch (error) {+ plannedFiles.push({+ id: newFile.id,+ path: displayPath,+ sourcePath,+ action: 'invalid',+ message: error instanceof Error ? error.message : String(error),+ });+ }+ }+ }for (const oldFile of oldFiles) {- const newFile = newReceipt.files.find(file => file.id === oldFile.id);+ const newReceiptFile = newReceipt.files.find(+ file => file.id === oldFile.id,+ );+ const newFile = newReceiptFile+ ? receiptFileForFormat(newReceipt, newReceiptFile, oldFile.format)+ : null;const displayPath = relativePath(oldFile.sourcePath, root);- if (!newFile) {+ if (!newReceiptFile) {plannedFiles.push({id: oldFile.id,path: displayPath,@@ -448,6 +646,15 @@ async function planReceipt(receiptPath, root, options) {});continue;}+ if (!newFile) {+ plannedFiles.push({+ id: oldFile.id,+ path: displayPath,+ action: 'target-changed',+ message: `Latest item removed the ${oldFile.format} install variant`,+ });+ continue;+ }if (newFile.target !== oldFile.target ||newFile.registryTarget !== oldFile.registryTarget ||@@ -501,6 +708,10 @@ async function planReceipt(receiptPath, root, options) {const currentHash = registryContentHash(currentCanonical);const oldHash = registryContentHash(oldCanonical);const newHash = registryContentHash(newCanonical);+ const currentMatchesOld =+ currentHash === oldHash ||+ (/\.jsx?$/.test(oldFile.target) &&+ shadcnJavaScriptSourcesEquivalent(currentCanonical, oldCanonical));if (oldHash === newHash) {plannedFiles.push({id: oldFile.id,@@ -508,11 +719,11 @@ async function planReceipt(receiptPath, root, options) {sourcePath: oldFile.sourcePath,currentContent: current,conflictPath,- action: currentHash === oldHash ? 'current' : 'user-modified',+ action: currentMatchesOld ? 'current' : 'user-modified',});continue;}- if (currentHash === oldHash) {+ if (currentMatchesOld) {plannedFiles.push({id: oldFile.id,path: displayPath,@@ -563,7 +774,9 @@ async function planReceipt(receiptPath, root, options) {action = 'conflict';} else if (plannedFiles.some(file => file.action === 'merge')) {action = 'merge';- } else if (plannedFiles.some(file => file.action === 'update')) {+ } else if (+ plannedFiles.some(file => ['update', 'create'].includes(file.action))+ ) {action = 'update';} else if (plannedFiles.some(file => file.action === 'receipt-only') ||@@ -635,6 +848,7 @@ function emptySummary(apply) {/** @param {string} action @param {boolean} apply */function publicAction(action, apply) {if (action === 'update') return apply ? 'updated' : 'would-update';+ if (action === 'create') return apply ? 'created' : 'would-create';if (action === 'merge') return apply ? 'merged' : 'would-merge';if (action === 'receipt-only') {return apply ? 'receipt-refreshed' : 'would-refresh-receipt';@@ -675,6 +889,9 @@ function applyPlan(plan) {throw new Error('Receipt changed while the upgrade was running');}for (const file of plan.files) {+ if (file.action === 'create' && fs.existsSync(file.sourcePath)) {+ throw new Error(`${file.path} appeared while the upgrade was running`);+ }if (file.sourcePath &&file.currentContent != null &&@@ -699,20 +916,37 @@ function applyPlan(plan) {const writable = plan.files.filter(/** @param {any} file */- file => ['update', 'merge'].includes(file.action),- );- const originals = writable.map(- /** @param {any} file */- file => ({- path: file.sourcePath,- content: fs.readFileSync(file.sourcePath, 'utf8'),- }),+ file => ['update', 'merge', 'create'].includes(file.action),);+ const originals = writable+ .filter(+ /** @param {any} file */+ file => file.action !== 'create',+ )+ .map(+ /** @param {any} file */+ file => ({+ path: file.sourcePath,+ content: fs.readFileSync(file.sourcePath, 'utf8'),+ }),+ );+ /** @type {string[]} */+ const created = [];const oldReceiptText = fs.readFileSync(plan.receiptPath, 'utf8');try {- for (const file of writable) atomicWrite(file.sourcePath, file.content);+ for (const file of writable) {+ atomicWrite(file.sourcePath, file.content);+ if (file.action === 'create') created.push(file.sourcePath);+ }atomicWrite(plan.receiptPath, serializeRegistryReceipt(plan.newReceipt));} catch (error) {+ for (const createdPath of created) {+ try {+ fs.rmSync(createdPath, {force: true});+ } catch {+ // Preserve the first failure.+ }+ }for (const original of originals) {try {atomicWrite(original.path, original.content);@@ -804,7 +1038,10 @@ export async function reconcileRegistryCompositions(applyPlan(plan);if (['update', 'merge'].includes(plan.action)) {for (const file of plan.files) {- if (file.sourcePath && ['update', 'merge'].includes(file.action)) {+ if (+ file.sourcePath &&+ ['update', 'merge', 'create'].includes(file.action)+ ) {writtenFiles.push(file.sourcePath);}}diff --git a/packages/cli/api/upgrade/registry/registry.test.mjs b/packages/cli/api/upgrade/registry/registry.test.mjsindex 6a2ed07f12..2af471a960 100644--- a/packages/cli/api/upgrade/registry/registry.test.mjs+++ b/packages/cli/api/upgrade/registry/registry.test.mjs@@ -4,6 +4,12 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';+import {+ createShadcnPrecompiledDeclaration,+ shadcnJavaScriptTarget,+ shadcnPrecompiledDeclarationTarget,+ transformShadcnJavaScriptSource,+} from '../../../authoring/shadcn/source-variants.mjs';import {createRegistryReceipt,registryReceiptTarget,@@ -23,29 +29,50 @@ const ITEM = {const SOURCE_TARGET = 'components/astryx/examples/ButtonBasic.tsx';const REGISTRY_PATH = 'registry/example-button-basic/ButtonBasic.tsx';const RECEIPT_TARGET = registryReceiptTarget(SOURCE_TARGET, ITEM.name);+const JAVASCRIPT_TARGET = shadcnJavaScriptTarget(SOURCE_TARGET);++function javascriptVariant(content) {+ return {+ format: 'javascript',+ target: JAVASCRIPT_TARGET,+ content: transformShadcnJavaScriptSource(content),+ };+}let project;let root;function receipt(content, overrides = {}) {+ const target = overrides.target ?? SOURCE_TARGET;+ const registryPath = overrides.registryPath ?? REGISTRY_PATH;+ const item = overrides.item ?? ITEM;+ const receiptTarget =+ overrides.receiptTarget ?? registryReceiptTarget(target, item.name);return createRegistryReceipt({- item: overrides.item ?? ITEM,+ item,sourceVersion: overrides.version ?? '0.5.0',- receiptTarget: RECEIPT_TARGET,+ receiptTarget,files: [{id: 'primary',- target: SOURCE_TARGET,- registryPath: REGISTRY_PATH,+ target,+ registryPath,content,+ variants: overrides.variants ?? [],},],});}-function seed({base, current = base, receiptValue = receipt(base)}) {- const sourcePath = path.join(root, SOURCE_TARGET);- const receiptPath = path.join(root, RECEIPT_TARGET);+function seed({+ base,+ current = base,+ receiptValue = receipt(base),+ sourceTarget = SOURCE_TARGET,+ receiptTarget = RECEIPT_TARGET,+}) {+ const sourcePath = path.join(root, sourceTarget);+ const receiptPath = path.join(root, receiptTarget);fs.mkdirSync(path.dirname(sourcePath), {recursive: true});fs.mkdirSync(path.dirname(receiptPath), {recursive: true});if (current !== null) fs.writeFileSync(sourcePath, current, 'utf8');@@ -60,19 +87,24 @@ function seed({base, current = base, receiptValue = receipt(base)}) {}function remote(latest, overrides = {}) {+ const itemIdentity = overrides.item ?? ITEM;+ const target = overrides.target ?? SOURCE_TARGET;+ const registryPath = overrides.registryPath ?? REGISTRY_PATH;+ const receiptBaseTarget = registryReceiptTarget(target, itemIdentity.name);const receiptFiles = [{id: 'primary',- target: SOURCE_TARGET,- registryPath: REGISTRY_PATH,+ target,+ registryPath,content: latest,+ variants: overrides.variants ?? [],},...(overrides.extraFiles ?? []),];const nextReceipt = createRegistryReceipt({- item: overrides.item ?? ITEM,+ item: itemIdentity,sourceVersion: overrides.version ?? '0.6.0',- receiptTarget: RECEIPT_TARGET,+ receiptTarget: receiptBaseTarget,files: receiptFiles,});const item = {@@ -81,7 +113,7 @@ function remote(latest, overrides = {}) {files: [...receiptFiles.map(file => ({path: file.registryPath,- type: 'registry:block',+ type: file.id === 'types' ? 'registry:file' : 'registry:block',target: file.target,content:file.id === 'primary'@@ -89,9 +121,9 @@ function remote(latest, overrides = {}) {: file.content,})),{- path: 'registry/example-button-basic/astryx-receipt.json',+ path: `registry/${itemIdentity.name}/astryx-receipt.json`,type: 'registry:file',- target: overrides.receiptTarget ?? RECEIPT_TARGET,+ target: overrides.receiptTarget ?? receiptBaseTarget,content: serializeRegistryReceipt(nextReceipt),},],@@ -303,6 +335,255 @@ describe('registry composition upgrades', () => {).toBe('0.6.0');});+ it('updates the JavaScript install variant selected by stock ShadCN', async () => {+ const base = "export const value: string = 'old';\n";+ const latest = "export const value: string = 'new';\n";+ const installedReceipt = receipt(base, {+ variants: [javascriptVariant(base)],+ });+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);+ const receiptPath = path.join(root, RECEIPT_TARGET);+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});+ fs.writeFileSync(sourcePath, transformShadcnJavaScriptSource(base), 'utf8');+ fs.writeFileSync(+ receiptPath,+ serializeRegistryReceipt(installedReceipt),+ 'utf8',+ );++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ variants: [javascriptVariant(latest)],+ }),+ },+ );++ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(+ transformShadcnJavaScriptSource(latest),+ );+ expect(fs.existsSync(path.join(root, SOURCE_TARGET))).toBe(false);+ const nextReceipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));+ expect(nextReceipt.schemaVersion).toBe(2);+ expect(nextReceipt.files[0].variants[0].registryTarget).toBe(+ JAVASCRIPT_TARGET,+ );+ });++ it('treats printer-only JavaScript drift as pristine', async () => {+ const base = "export const value: string = 'old';\n";+ const latest = "export const value: string = 'new';\n";+ const installedReceipt = receipt(base, {+ variants: [javascriptVariant(base)],+ });+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);+ const receiptPath = path.join(root, RECEIPT_TARGET);+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});+ fs.writeFileSync(sourcePath, 'export const value = "old";\n', 'utf8');+ fs.writeFileSync(+ receiptPath,+ serializeRegistryReceipt(installedReceipt),+ 'utf8',+ );++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ variants: [javascriptVariant(latest)],+ }),+ },+ );++ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(+ transformShadcnJavaScriptSource(latest),+ );+ });++ it('three-way merges edits in a JavaScript install variant', async () => {+ const base =+ "const title: string = 'title';\n" ++ "const body: string = 'body';\n" ++ "const spacer: string = 'spacer';\n" ++ "const footer: string = 'footer';\n" ++ 'export {title, body, spacer, footer};\n';+ const latest = base.replace("'footer'", "'new footer'");+ const current = transformShadcnJavaScriptSource(base).replace(+ "'title'",+ "'custom title'",+ );+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);+ const receiptPath = path.join(root, RECEIPT_TARGET);+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});+ fs.writeFileSync(sourcePath, current, 'utf8');+ fs.writeFileSync(+ receiptPath,+ serializeRegistryReceipt(+ receipt(base, {variants: [javascriptVariant(base)]}),+ ),+ 'utf8',+ );++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ variants: [javascriptVariant(latest)],+ }),+ },+ );++ expect(result.summary).toMatchObject({merged: 1, conflicts: 0});+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(+ transformShadcnJavaScriptSource(latest).replace(+ "'title'",+ "'custom title'",+ ),+ );+ });++ it('repairs a version 1 JavaScript install on its first upgrade', async () => {+ const base = "export const value: string = 'old';\n";+ const latest = "export const value: string = 'new';\n";+ const currentReceipt = receipt(base);+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];+ const legacyReceipt = {+ ...currentReceipt,+ schemaVersion: 1,+ files: [legacyFile],+ };+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);+ const receiptPath = path.join(root, RECEIPT_TARGET);+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});+ fs.writeFileSync(sourcePath, transformShadcnJavaScriptSource(base), 'utf8');+ fs.writeFileSync(+ receiptPath,+ serializeRegistryReceipt(legacyReceipt),+ 'utf8',+ );++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ variants: [javascriptVariant(latest)],+ }),+ },+ );++ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(+ transformShadcnJavaScriptSource(latest),+ );+ expect(JSON.parse(fs.readFileSync(receiptPath, 'utf8')).schemaVersion).toBe(+ 2,+ );+ });++ it('adds a strict TypeScript declaration while upgrading legacy precompiled JSX', async () => {+ const target = 'components/astryx/examples/CompiledExample.jsx';+ const registryPath = 'registry/example-button-basic/CompiledExample.jsx';+ const receiptTarget = registryReceiptTarget(target, ITEM.name);+ const base =+ "export default function CompiledExample() { return 'old'; }\n";+ const latest =+ "export default function CompiledExample() { return 'new'; }\n";+ const currentReceipt = receipt(base, {target, registryPath, receiptTarget});+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];+ const legacyReceipt = {+ ...currentReceipt,+ schemaVersion: 1,+ files: [legacyFile],+ };+ const {sourcePath, receiptPath} = seed({+ base,+ receiptValue: legacyReceipt,+ sourceTarget: target,+ receiptTarget,+ });+ const typesTarget = shadcnPrecompiledDeclarationTarget(target);+ const typesContent = createShadcnPrecompiledDeclaration(target);++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ target,+ registryPath,+ extraFiles: [+ {+ id: 'types',+ target: typesTarget,+ registryPath: 'registry/example-button-basic/astryx-types.d.mts',+ content: typesContent,+ variants: [],+ },+ ],+ }),+ },+ );++ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(latest);+ expect(fs.readFileSync(path.join(root, typesTarget), 'utf8')).toBe(+ typesContent,+ );+ expect(result.writtenFiles).toContain(path.join(root, typesTarget));+ const nextReceipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));+ expect(nextReceipt.schemaVersion).toBe(2);+ expect(nextReceipt.files.map(file => file.id)).toEqual([+ 'primary',+ 'types',+ ]);+ });++ it('reports an unreadable generated declaration target without aborting the run', async () => {+ const target = 'components/astryx/examples/CompiledExample.jsx';+ const registryPath = 'registry/example-button-basic/CompiledExample.jsx';+ const receiptTarget = registryReceiptTarget(target, ITEM.name);+ const base =+ "export default function CompiledExample() { return 'old'; }\n";+ const currentReceipt = receipt(base, {target, registryPath, receiptTarget});+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];+ seed({+ base,+ receiptValue: {...currentReceipt, schemaVersion: 1, files: [legacyFile]},+ sourceTarget: target,+ receiptTarget,+ });+ const typesTarget = shadcnPrecompiledDeclarationTarget(target);+ fs.mkdirSync(path.join(root, typesTarget), {recursive: true});++ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(base, {+ target,+ registryPath,+ extraFiles: [+ {+ id: 'types',+ target: typesTarget,+ registryPath: 'registry/example-button-basic/astryx-types.d.mts',+ content: createShadcnPrecompiledDeclaration(target),+ variants: [],+ },+ ],+ }),+ },+ );++ expect(result.summary).toMatchObject({invalid: 1, conflicts: 1, failed: 0});+ expect(fs.lstatSync(path.join(root, typesTarget)).isDirectory()).toBe(true);+ });+it('rolls back source when the receipt write fails', async () => {if (process.platform === 'win32') return;const {sourcePath, receiptPath} = seed({base: 'old\n'});@@ -510,6 +791,28 @@ describe('registry composition upgrades', () => {expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');});+ it('rejects a remote JavaScript variant that disagrees with canonical source', async () => {+ const base = "export const value: string = 'old';\n";+ const latest = "export const value: string = 'new';\n";+ const {sourcePath} = seed({base});+ const result = await reconcile(+ {apply: true},+ {+ fetchImpl: remote(latest, {+ variants: [+ javascriptVariant("export const value: string = 'tampered';\n"),+ ],+ }),+ },+ );++ expect(result.summary.failed).toBe(1);+ expect(result.summary.items[0].message).toMatch(+ /invalid javascript variant/,+ );+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(base);+ });+it('rejects a remote receipt that disagrees with shipped source', async () => {const {sourcePath} = seed({base: 'old\n'});const result = await reconcile(diff --git a/packages/cli/api/upgrade/upgrade.doc.mjs b/packages/cli/api/upgrade/upgrade.doc.mjsindex defef00da5..c78f5d12a3 100644--- a/packages/cli/api/upgrade/upgrade.doc.mjs+++ b/packages/cli/api/upgrade/upgrade.doc.mjs@@ -12,7 +12,7 @@ export const doc = {kind: 'api',name: 'upgrade',displayName: 'upgrade()',- summary: 'Run version migrations and reconcile ShadCN-copied compositions.',+ summary: 'Run version migrations and reconcile copied compositions.',description:'Migrates project source from a previous Astryx version to the currently ' +'installed one by running the registered codemods, and compares the fully ' +@@ -21,7 +21,7 @@ export const doc = {'writes the prepared block only after selected codemods and hooks succeed. ' +'Core codemods run before ' +'the config is loaded so a config codemod can repair an otherwise-invalid ' +- 'astryx.config. ShadCN-copied compositions carry adjacent receipts; upgrade ' ++ 'astryx.config. Copied compositions carry adjacent receipts with exact canonical and format-specific install bases; upgrade ' +'compares those installed bases with the matching registry release, updates pristine ' +'files, merges non-overlapping edits, and leaves conflicting originals untouched.',importPath: '@astryxdesign/cli/api',@@ -33,7 +33,6 @@ export const doc = {'codemod','migration','version',- 'shadcn','registry',],params: [@@ -86,7 +85,7 @@ export const doc = {name: 'options.registry',type: 'boolean',description:- 'Reconcile ShadCN-copied compositions from their install receipts without requiring `from`.',+ 'Reconcile copied compositions from their install receipts without requiring `from`.',default: 'false',},{@@ -109,7 +108,7 @@ export const doc = {{type: 'upgrade.registry',description:- 'A dry-run or apply receipt for ShadCN-copied compositions, including safe updates, clean merges, conflicts, missing files, and invalid receipts.',+ 'A dry-run or apply receipt for copied compositions, including safe updates, clean merges, conflicts, missing files, and invalid receipts.',},{type: 'upgrade.status',@@ -153,7 +152,7 @@ export const doc = {},{label: 'Preview (dry-run)', code: "await upgrade({from: '0.0.5'});"},{- label: 'Update ShadCN-copied compositions',+ label: 'Update copied compositions',code: 'await upgrade({registry: true, apply: true});',},{diff --git a/packages/cli/assets/docs/shadcn-compatibility.doc.mjs b/packages/cli/assets/docs/shadcn-compatibility.doc.draft.mjssimilarity index 85%rename from packages/cli/assets/docs/shadcn-compatibility.doc.mjsrename to packages/cli/assets/docs/shadcn-compatibility.doc.draft.mjsindex e8289b252f..fc7a86629a 100644--- a/packages/cli/assets/docs/shadcn-compatibility.doc.mjs+++ b/packages/cli/assets/docs/shadcn-compatibility.doc.draft.mjs@@ -97,19 +97,23 @@ export const docs = {type: 'code',lang: 'bash',label: 'Install the Button package entry',- code: 'npx shadcn@latest add <registry-origin>/components/button.json',+ code: 'npx [email protected] add <registry-origin>/components/button.json',},{type: 'code',lang: 'bash',label: 'Install the editable Button showcase',- code: 'npx shadcn@latest add <registry-origin>/showcases/button/variants.json',+ code: 'npx [email protected] add <registry-origin>/showcases/button/variants.json',},{type: 'code',lang: 'bash',label: 'Install the complete dashboard page',- code: 'npx shadcn@latest add <registry-origin>/templates/dashboard.json',+ code: 'npx [email protected] add <registry-origin>/templates/dashboard.json',+ },+ {+ type: 'prose',+ text: 'Astryx pins the tested shadcn client in these commands. The JavaScript receipt base must match the exact transform that client writes; use the displayed version rather than replacing it with `latest`.',},],},@@ -128,7 +132,7 @@ export const docs = {},{type: 'prose',- text: 'For an example, block, or page, the command writes editable TSX plus a small adjacent `.astryx` receipt. The TSX imports public Astryx package paths. The receipt stores the exact installed base so a later upgrade can preserve your edits; it is not application code and should stay committed with the copied file.',+ text: 'For an example, block, or page, the command writes editable TSX in TypeScript projects or JS/JSX in JavaScript projects, plus a small adjacent `.astryx` receipt. A composition that required StyleX compilation stays honest precompiled JSX in both modes and installs a narrow declaration for strict TypeScript imports. The source imports public Astryx package paths. The receipt stores every distinct install base so a later upgrade can preserve your edits; it is not application code and should stay committed with the copied file.',},],},@@ -163,10 +167,11 @@ astryx upgrade --registry --apply`,'A normal `astryx upgrade` also checks copied-composition receipts. Use `astryx upgrade --registry` to preview only those files; add `--apply` to write safe updates.','Registry source must match the installed Astryx release. The command refuses to copy source from a newer or older release.','An unchanged copied file updates automatically. Non-overlapping edits are three-way merged against the installed base.',+ 'JavaScript formatting or quote changes from a compatible shadcn printer are treated as unchanged only when the parsed syntax tree and attached comments still match.','A conflicting edit leaves your file untouched and writes a separate `.astryx-conflict` file for review.','A deleted or moved copied file is reported but never recreated or overwritten.','The registry excludes unpublished packages because an external package manager cannot install them.',- 'Your project needs a valid components.json and TypeScript configuration for the shadcn CLI to resolve target paths.',+ 'Your project needs a valid components.json and path-alias configuration for the shadcn CLI to resolve target paths.','The compatibility layer is additive. It does not require replacing existing shadcn components or migrating the whole application.',],},diff --git a/packages/cli/authoring/shadcn/receipt.mjs b/packages/cli/authoring/shadcn/receipt.mjsindex 808947ad4e..55512a0621 100644--- a/packages/cli/authoring/shadcn/receipt.mjs+++ b/packages/cli/authoring/shadcn/receipt.mjs@@ -2,7 +2,7 @@/*** @file Shared provenance receipt contract for ShadCN-copied Astryx source.- * @input A stable registry identity and the exact copied source bytes.+ * @input A stable registry identity and exact canonical and format-specific install bytes.* @output Validated, deterministic receipts used by registry generation and upgrade.* @position Protocol boundary between the public ShadCN registry and `astryx upgrade`.*/@@ -11,12 +11,16 @@ import {createHash} from 'node:crypto';import * as path from 'node:path';import {z} from 'zod';-export const REGISTRY_RECEIPT_SCHEMA_VERSION = 1;+export const REGISTRY_RECEIPT_SCHEMA_VERSION = 2;export const PUBLIC_SHADCN_REGISTRY_ORIGIN = 'https://astryx.atmeta.com/shadcn';const receiptTargetSchema = z.string()- .regex(/^\.\.\/[^/\\]+$/, 'must point to one adjacent source file');+ .regex(/^\.\.\/[^/\\]+$/, 'must point to one adjacent source file')+ .refine(+ value => value !== '../.' && value !== '../..',+ 'must point to one adjacent source file',+ );const registryFilePathSchema = z.string()@@ -47,52 +51,101 @@ const sourceVersionSchema = z'must be canary or an exact semantic version',);-export const registryReceiptSchema = z+const receiptItemSchema = z+ .object({+ name: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),+ path: registryPathSchema,+ aliases: z.array(registryPathSchema),+ kind: z.enum(['showcase', 'example', 'block', 'page']),+ })+ .strict();++const receiptSourceSchema = z+ .object({+ package: z.literal('@astryxdesign/cli'),+ version: sourceVersionSchema,+ })+ .strict();++const receiptFileBaseShape = {+ id: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),+ target: receiptTargetSchema,+ registryTarget: registryFilePathSchema,+ registryPath: registryFilePathSchema,+ sha256: z.string().regex(/^[a-f0-9]{64}$/),+ content: z.string(),+};++const receiptVariantSchema = z+ .object({+ format: z.literal('javascript'),+ target: receiptTargetSchema,+ registryTarget: registryFilePathSchema,+ sha256: z.string().regex(/^[a-f0-9]{64}$/),+ content: z.string(),+ })+ .strict();++const receiptFileV1Schema = z.object(receiptFileBaseShape).strict();+const receiptFileV2Schema = z+ .object({+ ...receiptFileBaseShape,+ variants: z.array(receiptVariantSchema),+ })+ .strict();++const receiptV1Schema = z+ .object({+ schemaVersion: z.literal(1),+ item: receiptItemSchema,+ source: receiptSourceSchema,+ files: z.array(receiptFileV1Schema).min(1),+ })+ .strict();++const receiptV2Schema = z.object({schemaVersion: z.literal(REGISTRY_RECEIPT_SCHEMA_VERSION),- item: z- .object({- name: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),- path: registryPathSchema,- aliases: z.array(registryPathSchema),- kind: z.enum(['showcase', 'example', 'block', 'page']),- })- .strict(),- source: z- .object({- package: z.literal('@astryxdesign/cli'),- version: sourceVersionSchema,- })- .strict(),- files: z- .array(- z- .object({- id: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),- target: receiptTargetSchema,- registryTarget: registryFilePathSchema,- registryPath: registryFilePathSchema,- sha256: z.string().regex(/^[a-f0-9]{64}$/),- content: z.string(),- })- .strict(),- )- .min(1),+ item: receiptItemSchema,+ source: receiptSourceSchema,+ files: z.array(receiptFileV2Schema).min(1),})- .strict()+ .strict();++export const registryReceiptSchema = z+ .discriminatedUnion('schemaVersion', [receiptV1Schema, receiptV2Schema]).superRefine((receipt, context) => {const identities = [{label: 'id', values: receipt.files.map(file => file.id)},- {label: 'target', values: receipt.files.map(file => file.target)},- {- label: 'registryTarget',- values: receipt.files.map(file => file.registryTarget),- },{label: 'registryPath',values: receipt.files.map(file => file.registryPath),},];+ const installTargets = [];+ const registryTargets = [];+ for (const file of receipt.files) {+ installTargets.push(file.target);+ registryTargets.push(file.registryTarget);+ if ('variants' in file) {+ const formats = file.variants.map(variant => variant.format);+ if (new Set(formats).size !== formats.length) {+ context.addIssue({+ code: 'custom',+ path: ['files'],+ message: 'receipt file variant formats must be unique',+ });+ }+ installTargets.push(...file.variants.map(variant => variant.target));+ registryTargets.push(+ ...file.variants.map(variant => variant.registryTarget),+ );+ }+ }+ identities.push(+ {label: 'target', values: installTargets},+ {label: 'registryTarget', values: registryTargets},+ );for (const {label, values} of identities) {if (new Set(values).size !== values.length) {context.addIssue({@@ -147,7 +200,13 @@ export function registryReceiptTarget(sourceTarget, itemName) {* item: {name: string, path: string, aliases: string[], kind: 'showcase'|'example'|'block'|'page'},* sourceVersion: string,* receiptTarget: string,- * files: Array<{id: string, target: string, registryPath: string, content: string}>,+ * files: Array<{+ * id: string,+ * target: string,+ * registryPath: string,+ * content: string,+ * variants?: Array<{format: 'javascript', target: string, content: string}>,+ * }>,* }} input*/export function createRegistryReceipt(input) {@@ -166,6 +225,13 @@ export function createRegistryReceipt(input) {registryPath: file.registryPath,sha256: registryContentHash(file.content),content: file.content,+ variants: (file.variants ?? []).map(variant => ({+ format: variant.format,+ target: path.posix.relative(receiptDir, variant.target),+ registryTarget: variant.target,+ sha256: registryContentHash(variant.content),+ content: variant.content,+ })),})),};return registryReceiptSchema.parse(receipt);diff --git a/packages/cli/authoring/shadcn/receipt.test.mjs b/packages/cli/authoring/shadcn/receipt.test.mjsindex e605001c94..6b79c3603d 100644--- a/packages/cli/authoring/shadcn/receipt.test.mjs+++ b/packages/cli/authoring/shadcn/receipt.test.mjs@@ -1,6 +1,10 @@// Copyright (c) Meta Platforms, Inc. and affiliates.import {describe, expect, it} from 'vitest';+import {+ shadcnJavaScriptTarget,+ transformShadcnJavaScriptSource,+} from './source-variants.mjs';import {createRegistryReceipt,parseRegistryReceipt,@@ -26,7 +30,16 @@ function receipt() {id: 'primary',target,registryPath: 'registry/example-button-basic/ButtonExample.tsx',- content: 'export default function Example() { return null; }\n',+ content: 'export default function Example(): null { return null; }\n',+ variants: [+ {+ format: 'javascript',+ target: shadcnJavaScriptTarget(target),+ content: transformShadcnJavaScriptSource(+ 'export default function Example(): null { return null; }\n',+ ),+ },+ ],},],});@@ -44,18 +57,67 @@ describe('ShadCN registry receipts', () => {it('records the installed base bytes and a relative target', () => {const value = receipt();+ expect(value.schemaVersion).toBe(2);expect(value.files[0]).toMatchObject({id: 'primary',target: '../ButtonExample.tsx',registryTarget: 'components/astryx/examples/ButtonExample.tsx',registryPath: 'registry/example-button-basic/ButtonExample.tsx',sha256: registryContentHash(value.files[0].content),+ variants: [+ expect.objectContaining({+ format: 'javascript',+ target: '../ButtonExample.jsx',+ registryTarget: 'components/astryx/examples/ButtonExample.jsx',+ }),+ ],});+ expect(value.files[0].variants[0].sha256).toBe(+ registryContentHash(value.files[0].variants[0].content),+ );expect(parseRegistryReceipt(JSON.parse(serializeRegistryReceipt(value))),).toEqual(value);});+ it('permits a canonical JavaScript base without a duplicate variant', () => {+ const target = 'components/astryx/examples/CompiledExample.jsx';+ const value = createRegistryReceipt({+ item: {+ name: 'example-compiled',+ path: 'examples/compiled',+ aliases: [],+ kind: 'example',+ },+ sourceVersion: '0.6.0',+ receiptTarget: registryReceiptTarget(target, 'example-compiled'),+ files: [+ {+ id: 'primary',+ target,+ registryPath: 'registry/example-compiled/CompiledExample.jsx',+ content:+ 'export default function CompiledExample() { return null; }\n',+ variants: [],+ },+ ],+ });++ expect(parseRegistryReceipt(value).files[0].variants).toEqual([]);+ });++ it('continues to parse version 1 receipts without variants', () => {+ const value = receipt();+ const {variants: _variants, ...legacyFile} = value.files[0];+ expect(+ parseRegistryReceipt({+ ...value,+ schemaVersion: 1,+ files: [legacyFile],+ }),+ ).toMatchObject({schemaVersion: 1, files: [{id: 'primary'}]});+ });+it('rejects duplicate file identities', () => {const value = receipt();expect(() =>@@ -66,6 +128,33 @@ describe('ShadCN registry receipts', () => {).toThrow(/must be unique/);});+ it('rejects duplicate or escaping install variants', () => {+ const value = receipt();+ const variant = value.files[0].variants[0];+ expect(() =>+ parseRegistryReceipt({+ ...value,+ files: [+ {+ ...value.files[0],+ variants: [variant, {...variant}],+ },+ ],+ }),+ ).toThrow(/variant formats must be unique/);+ expect(() =>+ parseRegistryReceipt({+ ...value,+ files: [+ {+ ...value.files[0],+ variants: [{...variant, target: '../../outside.jsx'}],+ },+ ],+ }),+ ).toThrow(/adjacent source file/);+ });+it('rejects traversal and corrupt hashes', () => {const value = receipt();expect(() =>@@ -74,6 +163,14 @@ describe('ShadCN registry receipts', () => {files: [{...value.files[0], target: '../../outside.tsx'}],}),).toThrow(/adjacent source file/);+ for (const target of ['../.', '../..']) {+ expect(() =>+ parseRegistryReceipt({+ ...value,+ files: [{...value.files[0], target}],+ }),+ ).toThrow(/adjacent source file/);+ }expect(() =>parseRegistryReceipt({...value,diff --git a/packages/cli/authoring/shadcn/source-variants.mjs b/packages/cli/authoring/shadcn/source-variants.mjsnew file mode 100644index 0000000000..8859bf61f1--- /dev/null+++ b/packages/cli/authoring/shadcn/source-variants.mjs@@ -0,0 +1,176 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Reproduce the JavaScript transform used by the pinned ShadCN client.+ * @input Registry TypeScript/TSX source and its explicit target path.+ * @output Exact JavaScript/JSX bytes and target used when components.json has tsx=false.+ * @position Shared compatibility boundary for generated receipt variants and upgrades.+ */++import {transformFromAstSync} from '@babel/core';+import {parse} from '@babel/parser';+import {createRequire} from 'node:module';+import * as path from 'node:path';+import * as recast from 'recast';++const require = createRequire(import.meta.url);+/** @type {import('@babel/core').PluginItem} */+const transformTypeScript =+ require('@babel/plugin-transform-typescript').default;++/** @type {import('@babel/parser').ParserOptions} */+const SHADCN_PARSER_OPTIONS = {+ sourceType: 'module',+ allowImportExportEverywhere: true,+ allowReturnOutsideFunction: true,+ startLine: 1,+ tokens: true,+ plugins: [+ 'asyncGenerators',+ 'bigInt',+ 'classPrivateMethods',+ 'classPrivateProperties',+ 'classProperties',+ 'classStaticBlock',+ 'decimal',+ 'decorators-legacy',+ 'doExpressions',+ 'dynamicImport',+ 'exportDefaultFrom',+ 'exportNamespaceFrom',+ 'functionBind',+ 'functionSent',+ 'importAssertions',+ 'importMeta',+ 'nullishCoalescingOperator',+ 'numericSeparator',+ 'objectRestSpread',+ 'optionalCatchBinding',+ 'optionalChaining',+ ['pipelineOperator', {proposal: 'minimal'}],+ ['recordAndTuple', {syntaxType: 'hash'}],+ 'throwExpressions',+ 'topLevelAwait',+ 'v8intrinsic',+ 'typescript',+ 'jsx',+ ],+};++/** @param {string} target */+export function shadcnJavaScriptTarget(target) {+ const extension = path.posix.extname(target);+ if (extension === '.tsx') return `${target.slice(0, -4)}.jsx`;+ if (extension === '.ts') return `${target.slice(0, -3)}.js`;+ return target;+}++/**+ * Give precompiled JavaScript a narrow ambient type instead of labelling the+ * untyped Babel output as TSX. The suffix wildcard covers relative and aliased+ * imports of this exact composition without masking unrelated JavaScript.+ * @param {string} sourceTarget+ */+export function createShadcnPrecompiledDeclaration(sourceTarget) {+ const extension = path.posix.extname(sourceTarget);+ if (extension !== '.jsx' && extension !== '.js') {+ throw new Error(+ `Precompiled declaration source must be JavaScript: ${sourceTarget}`,+ );+ }+ const moduleSuffix = sourceTarget.slice(0, -extension.length);+ return (+ `declare module '*${moduleSuffix}' {\n` ++ ` const Component: import('react').ComponentType;\n` ++ ` export default Component;\n` ++ `}\n`+ );+}++/** @param {string} sourceTarget */+export function shadcnPrecompiledDeclarationTarget(sourceTarget) {+ const extension = path.posix.extname(sourceTarget);+ if (extension !== '.jsx' && extension !== '.js') {+ throw new Error(+ `Precompiled declaration source must be JavaScript: ${sourceTarget}`,+ );+ }+ return `${sourceTarget.slice(0, -extension.length)}.astryx.d.mts`;+}++/**+ * Match shadcn 4.19's tsx=false transform byte-for-byte. Keep this small and+ * covered by a real stock-client install test rather than importing private+ * chunks from the shadcn package.+ * @param {string} source+ */+export function transformShadcnJavaScriptSource(source) {+ const ast = recast.parse(source, {+ parser: {+ /** @param {string} input */+ parse: input => parse(input, SHADCN_PARSER_OPTIONS),+ },+ });+ const transformed = transformFromAstSync(ast, source, {+ cloneInputAst: false,+ code: false,+ ast: true,+ plugins: [transformTypeScript],+ configFile: false,+ });+ if (!transformed?.ast) {+ throw new Error('ShadCN JavaScript transform produced no AST');+ }+ return recast.print(transformed.ast).code;+}++/**+ * Ignore parser metadata and literal raw spelling while preserving the complete+ * JavaScript/JSX syntax tree and attached comment text. AST structure keeps+ * automatic-semicolon-insertion changes distinct from printer-only changes.+ * @param {unknown} value+ * @returns {unknown}+ */+function normalizeJavaScriptAst(value) {+ if (Array.isArray(value)) return value.map(normalizeJavaScriptAst);+ if (value == null || typeof value !== 'object') return value;+ const objectValue = /** @type {Record<string, unknown>} */ (value);+ /** @type {Record<string, unknown>} */+ const normalized = {};+ for (const key of Object.keys(objectValue).sort()) {+ if (+ key === 'start' ||+ key === 'end' ||+ key === 'loc' ||+ key === 'range' ||+ key === 'extra' ||+ key === 'tokens' ||+ key === 'errors'+ ) {+ continue;+ }+ normalized[key] = normalizeJavaScriptAst(objectValue[key]);+ }+ return normalized;+}++/**+ * Recognize printer-only JavaScript differences without hiding code or comment+ * edits. This protects receipts from compatible ShadCN formatter drift.+ * @param {string} left+ * @param {string} right+ */+export function shadcnJavaScriptSourcesEquivalent(left, right) {+ try {+ return (+ JSON.stringify(+ normalizeJavaScriptAst(parse(left, SHADCN_PARSER_OPTIONS)),+ ) ===+ JSON.stringify(+ normalizeJavaScriptAst(parse(right, SHADCN_PARSER_OPTIONS)),+ )+ );+ } catch {+ return false;+ }+}diff --git a/packages/cli/authoring/shadcn/source-variants.test.mjs b/packages/cli/authoring/shadcn/source-variants.test.mjsnew file mode 100644index 0000000000..3bc20ed818--- /dev/null+++ b/packages/cli/authoring/shadcn/source-variants.test.mjs@@ -0,0 +1,120 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {readFileSync} from 'node:fs';+import {describe, expect, it} from 'vitest';+import {+ createShadcnPrecompiledDeclaration,+ shadcnJavaScriptSourcesEquivalent,+ shadcnJavaScriptTarget,+ shadcnPrecompiledDeclarationTarget,+ transformShadcnJavaScriptSource,+} from './source-variants.mjs';++describe('ShadCN JavaScript source variants', () => {+ it('uses the target extension ShadCN writes for tsx=false', () => {+ expect(shadcnJavaScriptTarget('components/Example.tsx')).toBe(+ 'components/Example.jsx',+ );+ expect(shadcnJavaScriptTarget('hooks/useExample.ts')).toBe(+ 'hooks/useExample.js',+ );+ expect(shadcnJavaScriptTarget('components/Example.jsx')).toBe(+ 'components/Example.jsx',+ );+ });++ it('matches the pinned ShadCN TypeScript stripping shape', () => {+ const source =+ "'use client';\n\n" ++ "import type {ReactNode} from 'react';\n" ++ 'const value: ReactNode = null;\n' ++ 'export default function Example() { return value; }\n';++ expect(transformShadcnJavaScriptSource(source)).toBe(+ "'use client';;\n" ++ 'const value = null;\n' ++ 'export default function Example() { return value; }\n',+ );+ });++ it('is idempotent for already-precompiled JSX', () => {+ const source =+ "export default function Example() { return <Component label='A long label' value='A long value' onChange={() => {}} />; }\n";+ const transformed = transformShadcnJavaScriptSource(source);+ expect(transformShadcnJavaScriptSource(transformed)).toBe(transformed);+ });++ it('recognizes printer-only JavaScript differences without hiding edits', () => {+ const compact =+ "// Keep this note\nexport default function Example(){return <Button label='Save'/>;}\n";+ const formatted =+ '// Keep this note\nexport default function Example() {\n return <Button label="Save" />;\n}\n';+ expect(shadcnJavaScriptSourcesEquivalent(compact, formatted)).toBe(true);+ expect(+ shadcnJavaScriptSourcesEquivalent(+ compact,+ formatted.replace('Save', 'Delete'),+ ),+ ).toBe(false);+ expect(+ shadcnJavaScriptSourcesEquivalent(+ compact,+ formatted.replace('Keep this note', 'Changed note'),+ ),+ ).toBe(false);+ expect(shadcnJavaScriptSourcesEquivalent('x++;\ny;\n', 'x\n++y;\n')).toBe(+ false,+ );+ expect(+ shadcnJavaScriptSourcesEquivalent(+ 'function value() { return 42; }\n',+ 'function value() { return\n42; }\n',+ ),+ ).toBe(false);+ expect(shadcnJavaScriptSourcesEquivalent('not valid {', formatted)).toBe(+ false,+ );+ });++ it('pins every load-bearing transform dependency', () => {+ const manifest = JSON.parse(+ readFileSync('packages/cli/package.json', 'utf8'),+ );+ expect(manifest.dependencies).toMatchObject({+ '@babel/core': '7.29.7',+ '@babel/parser': '7.29.8',+ '@babel/plugin-transform-typescript': '7.29.7',+ '@babel/types': '7.29.8',+ 'ast-types': '0.16.3',+ recast: '0.23.21',+ });+ const workspace = readFileSync('pnpm-workspace.yaml', 'utf8');+ expect(workspace).toContain("'[email protected]>@babel/core': 7.29.7");+ expect(workspace).toContain("'[email protected]>@babel/parser': 7.29.8");+ expect(workspace).toContain(+ "'[email protected]>@babel/plugin-transform-typescript': 7.29.7",+ );+ expect(workspace).toContain("'[email protected]>recast': 0.23.21");+ });++ it('emits a narrow declaration for precompiled JavaScript', () => {+ expect(+ createShadcnPrecompiledDeclaration(+ 'components/astryx/examples/Example.jsx',+ ),+ ).toBe(+ "declare module '*components/astryx/examples/Example' {\n" ++ " const Component: import('react').ComponentType;\n" ++ ' export default Component;\n' ++ '}\n',+ );+ expect(+ shadcnPrecompiledDeclarationTarget(+ 'components/astryx/examples/Example.jsx',+ ),+ ).toBe('components/astryx/examples/Example.astryx.d.mts');+ expect(() =>+ createShadcnPrecompiledDeclaration('components/Example.tsx'),+ ).toThrow(/must be JavaScript/);+ });+});diff --git a/packages/cli/clients/cli/commands/docs.test.mjs b/packages/cli/clients/cli/commands/docs.test.mjsindex 543965fbe2..e1574313ab 100644--- a/packages/cli/clients/cli/commands/docs.test.mjs+++ b/packages/cli/clients/cli/commands/docs.test.mjs@@ -35,6 +35,7 @@ describe('registerDocs', () => {const output = console.log.mock.calls.map(c => c[0]).join('\n');expect(output).toContain('principles');expect(output).toContain('tokens');+ expect(output).not.toContain('shadcn-compatibility');});it('errors for unknown topic', async () => {diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 7f0089703d..97425b791c 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -99,12 +99,18 @@"prepack": "pnpm sync:api-types"},"dependencies": {+ "@babel/core": "7.29.7",+ "@babel/parser": "7.29.8",+ "@babel/plugin-transform-typescript": "7.29.7",+ "@babel/types": "7.29.8",+ "ast-types": "0.16.3","commander": "^12.1.0","jiti": "^2.7.0","jscodeshift": "^17.3.0","node-diff3": "3.2.1","postcss": "^8.5.23","postcss-selector-parser": "^7.1.5",+ "recast": "0.23.21","zod": "^4.4.3"},"peerDependencies": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 81b3959002..aa9647b4a3 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -23,6 +23,10 @@ catalogs:version: 8.1.3overrides:+ [email protected]>@babel/core: 7.29.7+ [email protected]>@babel/parser: 7.29.8+ [email protected]>@babel/plugin-transform-typescript: 7.29.7+ [email protected]>recast: 0.23.21postcss: ^8.5.23dompurify: ^3.4.13esbuild: '>=0.28.1'@@ -659,6 +663,21 @@ importers:packages/cli:dependencies:+ '@babel/core':+ specifier: 7.29.7+ version: 7.29.7+ '@babel/parser':+ specifier: 7.29.8+ version: 7.29.8+ '@babel/plugin-transform-typescript':+ specifier: 7.29.7+ version: 7.29.7(@babel/[email protected])+ '@babel/types':+ specifier: 7.29.8+ version: 7.29.8+ ast-types:+ specifier: 0.16.3+ version: 0.16.3commander:specifier: ^12.1.0version: 12.1.0@@ -677,6 +696,9 @@ importers:postcss-selector-parser:specifier: ^7.1.5version: 7.1.5+ recast:+ specifier: 0.23.21+ version: 0.23.21zod:specifier: ^4.4.3version: 4.4.3@@ -1152,6 +1174,11 @@ packages:engines: {node: '>=6.0.0'}hasBin: true+ '@babel/[email protected]':+ resolution: {integrity: sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==}+ engines: {node: '>=6.0.0'}+ hasBin: true+'@babel/[email protected]':resolution: {integrity: sha512-aLxAE+imI9bCcyaPrUDjBv3uSkWieifjLe0kuFOZF0zli0L6GCsTmsePnTr55adbIAgYz2zhN1vnFimCBUYcRQ==}engines: {node: ^22.18.0 || >=24.11.0}@@ -1310,8 +1337,8 @@ packages:resolution: {integrity: sha512-bxTj/W2VclGE6CctlfQOpxg8MPDzXArRqkOBePw8EHfebcjF7fETWSS3BriEECo+UiU/Yblq+xUtSImFu7cTbw==}engines: {node: ^22.18.0 || >=24.11.0}- '@babel/[email protected]':- resolution: {integrity: sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==}+ '@babel/[email protected]':+ resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==}engines: {node: '>=6.9.0'}'@babel/[email protected]':@@ -3956,6 +3983,10 @@ packages:resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==}engines: {node: '>=4'}+ resolution: {integrity: sha512-FvWoWYfSCM6kRxCSH+MGLHIKKGRL6A6AW7Zek2O32REPQRdg131428uRTKMBYAeRd3XXAaHDS60Wpri7CdKDrA==}+ engines: {node: '>=4'}+resolution: {integrity: sha512-0bC0/4bTSrnwdhU3IsZDwEdojvuPrSg59OYZfKsLRtJZ0u8VBx9DebfqqG8bRdCC0I7vjgxmPi41P0lpkhJHtA==}@@ -5901,6 +5932,10 @@ packages:resolution: {integrity: sha512-dEWRjcINDu/F4l2dYx57ugBtD7HV9KXESyxhzw/MqWLeglJrsjJKqACPyUPg+6AF8mIgm+Zi0dZ3ACoIg+QtpA==}engines: {node: '>= 4'}+ resolution: {integrity: sha512-mFAyJq9vUbSTARLZUvAEf1z3YxlvAwswbmxMx2mPA/MSm4KmpwvwvhsH/NIrZhyOuwD60Lzyw2qh83uCbgTPYw==}+ engines: {node: '>= 4'}+resolution: {integrity: sha512-G4fy+Pk46RaXgwWMh+Nzhyo/lbFAVqXo9gtetlyehe6Ehge9CsgDuOTwQDD+i1+llaLktNBiNq4bhnGlDRXFtw==}engines: {node: '>=18'}@@ -6902,10 +6937,10 @@ snapshots:'@babel/helper-compilation-targets': 7.29.7'@babel/helper-module-transforms': 7.29.7(@babel/[email protected])'@babel/helpers': 7.29.7- '@babel/parser': 7.29.7+ '@babel/parser': 7.29.8'@babel/template': 7.29.7'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@jridgewell/remapping': 2.3.5convert-source-map: 2.0.0debug: 4.4.3@@ -6917,8 +6952,8 @@ snapshots:'@babel/[email protected]':dependencies:- '@babel/parser': 7.29.7- '@babel/types': 7.29.7+ '@babel/parser': 7.29.8+ '@babel/types': 7.29.8'@jridgewell/gen-mapping': 0.3.13'@jridgewell/trace-mapping': 0.3.31jsesc: 3.1.0@@ -6934,7 +6969,7 @@ snapshots:'@babel/[email protected]':dependencies:- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@babel/[email protected]':dependencies:@@ -6968,14 +7003,14 @@ snapshots:'@babel/[email protected]':dependencies:'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8transitivePeerDependencies:- supports-color'@babel/[email protected]':dependencies:'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8transitivePeerDependencies:- supports-color@@ -6995,7 +7030,7 @@ snapshots:'@babel/[email protected]':dependencies:- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@babel/[email protected]': {}@@ -7015,7 +7050,7 @@ snapshots:'@babel/[email protected]':dependencies:'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8transitivePeerDependencies:- supports-color@@ -7034,11 +7069,15 @@ snapshots:'@babel/[email protected]':dependencies:'@babel/template': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@babel/[email protected]':dependencies:- '@babel/types': 7.29.7+ '@babel/types': 7.29.8++ '@babel/[email protected]':+ dependencies:+ '@babel/types': 7.29.8'@babel/[email protected]':dependencies:@@ -7203,8 +7242,8 @@ snapshots:'@babel/[email protected]':dependencies:'@babel/code-frame': 7.29.7- '@babel/parser': 7.29.7- '@babel/types': 7.29.7+ '@babel/parser': 7.29.8+ '@babel/types': 7.29.8'@babel/[email protected]':dependencies:@@ -7217,9 +7256,9 @@ snapshots:'@babel/code-frame': 7.29.7'@babel/generator': 7.29.7'@babel/helper-globals': 7.29.7- '@babel/parser': 7.29.7+ '@babel/parser': 7.29.8'@babel/template': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8debug: 4.4.3transitivePeerDependencies:- supports-color@@ -7234,7 +7273,7 @@ snapshots:'@babel/types': 8.0.0obug: 2.1.3- '@babel/[email protected]':+ '@babel/[email protected]':dependencies:'@babel/helper-string-parser': 7.29.7'@babel/helper-validator-identifier': 7.29.7@@ -9193,7 +9232,7 @@ snapshots:'@babel/core': 7.29.7'@babel/helper-module-imports': 7.29.7'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@dual-bundle/import-meta-resolve': 4.2.1'@stylexjs/shared': 0.19.0'@stylexjs/stylex': 0.19.0@@ -9356,23 +9395,23 @@ snapshots:'@types/[email protected]':dependencies:'@babel/parser': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@types/babel__generator': 7.27.0'@types/babel__template': 7.4.4'@types/babel__traverse': 7.28.0'@types/[email protected]':dependencies:- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@types/[email protected]':dependencies:- '@babel/parser': 7.29.7- '@babel/types': 7.29.7+ '@babel/parser': 7.29.8+ '@babel/types': 7.29.8'@types/[email protected]':dependencies:- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@types/[email protected]':dependencies:@@ -9714,6 +9753,10 @@ snapshots:dependencies:tslib: 2.8.1+ dependencies:+ tslib: 2.8.1+dependencies:'@jridgewell/trace-mapping': 0.3.31@@ -10875,7 +10918,7 @@ snapshots:dependencies:'@babel/core': 7.29.7- '@babel/parser': 7.29.7+ '@babel/parser': 7.29.8'@babel/plugin-transform-class-properties': 7.29.7(@babel/[email protected])'@babel/plugin-transform-modules-commonjs': 7.29.7(@babel/[email protected])'@babel/plugin-transform-nullish-coalescing-operator': 7.29.7(@babel/[email protected])@@ -10889,7 +10932,7 @@ snapshots:micromatch: 4.0.8neo-async: 2.6.2picocolors: 1.1.1- recast: 0.23.12+ recast: 0.23.21tmp: 0.2.7write-file-atomic: 5.0.1transitivePeerDependencies:@@ -11105,7 +11148,7 @@ snapshots:dependencies:'@babel/parser': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8source-map-js: 1.2.1@@ -11575,7 +11618,7 @@ snapshots:dependencies:'@babel/core': 7.29.7'@babel/traverse': 7.29.7- '@babel/types': 7.29.7+ '@babel/types': 7.29.8'@types/babel__core': 7.20.5'@types/babel__traverse': 7.28.0'@types/doctrine': 0.0.9@@ -11650,6 +11693,14 @@ snapshots:tiny-invariant: 1.3.3tslib: 2.8.1+ dependencies:+ ast-types: 0.16.3+ esprima: 4.0.1+ source-map: 0.6.1+ tiny-invariant: 1.3.3+ tslib: 2.8.1+[email protected](@types/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]):dependencies:'@reduxjs/toolkit': 2.12.0([email protected](@types/[email protected])([email protected])([email protected]))([email protected])@@ -11830,7 +11881,7 @@ snapshots:dependencies:'@babel/core': 7.29.7- '@babel/parser': 7.29.7+ '@babel/parser': 7.29.8'@babel/plugin-transform-typescript': 7.29.7(@babel/[email protected])'@babel/preset-typescript': 7.29.7(@babel/[email protected])'@dotenvx/dotenvx': 1.75.1@@ -11852,7 +11903,7 @@ snapshots:postcss: 8.5.25postcss-selector-parser: 7.1.5prompts: 2.4.2- recast: 0.23.12+ recast: 0.23.21socks: 2.8.10stringify-object: 5.0.0tailwind-merge: 3.6.0diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex bec90467ac..778b7bf616 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -47,11 +47,20 @@ catalog:# Moved from package.json's "pnpm" field: pnpm 11 no longer reads# pnpm.overrides / pnpm.onlyBuiltDependencies from package.json.-# Every entry is a LIVE security floor, annotated with the dependent that pins-# the vulnerable version and the condition for deleting it. To re-verify one:-# drop the line, run `pnpm install --lockfile-only`, then `pnpm audit`. Entries-# the graph now reaches on its own get pruned — no alignment or dedup forces.+# Compatibility pins and security floors that must not float independently.overrides:+ # Receipt JavaScript bytes mirror shadcn 4.19.0's transform. Keep its floating+ # parser/printer aligned with the exact runtime pins in packages/cli.+ '[email protected]>@babel/core': 7.29.7+ '[email protected]>@babel/parser': 7.29.8+ '[email protected]>@babel/plugin-transform-typescript': 7.29.7+ '[email protected]>recast': 0.23.21++ # Every entry below is a LIVE security floor, annotated with the dependent that+ # pins the vulnerable version and the condition for deleting it. To re-verify+ # one: drop the line, run `pnpm install --lockfile-only`, then `pnpm audit`.+ # Entries the graph now reaches on its own get pruned — no alignment or dedup+ # forces.# next@15 pins postcss 8.4.31. Drop when Next raises its postcss dep.postcss: ^8.5.23# [email protected] pins dompurify 3.2.7. Drop when it catches up.