shadcn 3.6.0 → 3.6.2
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.
- package/LICENSE.md +21 -0
- package/README.md +11 -3
- package/dist/{chunk-6SDOGUEN.js → chunk-BFNVF2P5.js} +2 -2
- package/dist/chunk-BFNVF2P5.js.map +1 -0
- package/dist/chunk-I3JXSMK6.js +34 -0
- package/dist/chunk-I3JXSMK6.js.map +1 -0
- package/dist/chunk-PMFK2ZSQ.js +3 -0
- package/dist/chunk-PMFK2ZSQ.js.map +1 -0
- package/dist/{chunk-KAJFNXHN.js → chunk-SSXFFJQN.js} +7 -7
- package/dist/{chunk-KAJFNXHN.js.map → chunk-SSXFFJQN.js.map} +1 -1
- package/dist/icons/index.d.ts +8 -0
- package/dist/icons/index.js +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +21 -21
- package/dist/chunk-6SDOGUEN.js.map +0 -1
- package/dist/chunk-UHRSOZGS.js +0 -18
- package/dist/chunk-UHRSOZGS.js.map +0 -1
- package/dist/chunk-YPHLD64H.js +0 -19
- package/dist/chunk-YPHLD64H.js.map +0 -1
package/dist/chunk-YPHLD64H.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-6SDOGUEN.js';import {z}from'zod';import {SyntaxKind}from'ts-morph';var g={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},u=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(i,e={}){super(i),this.name="RegistryError",this.code=e.code||g.UNKNOWN_ERROR,this.statusCode=e.statusCode,this.cause=e.cause,this.context=e.context,this.suggestion=e.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,context:this.context,suggestion:this.suggestion,timestamp:this.timestamp,stack:this.stack}}},E=class extends u{constructor(e,t){let n=`The item at ${e} was not found. It may not exist at the registry.`;super(n,{code:g.NOT_FOUND,statusCode:404,cause:t,context:{url:e},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=e;this.name="RegistryNotFoundError";}},$=class extends u{constructor(e,t){let n=`You are not authorized to access the item at ${e}. If this is a remote registry, you may need to authenticate.`;super(n,{code:g.UNAUTHORIZED,statusCode:401,cause:t,context:{url:e},suggestion:"Check your authentication credentials and environment variables."});this.url=e;this.name="RegistryUnauthorizedError";}},_=class extends u{constructor(e,t){let n=`You are not authorized to access the item at ${e}. If this is a remote registry, you may need to authenticate.`;super(n,{code:g.FORBIDDEN,statusCode:403,cause:t,context:{url:e},suggestion:"Check your authentication credentials and environment variables."});this.url=e;this.name="RegistryForbiddenError";}},C=class extends u{constructor(e,t,n,a){let o=t?`Failed to fetch from registry (${t}): ${e}`:`Failed to fetch from registry: ${e}`,p=typeof a=="string"&&a?`${o} - ${a}`:o,r="Check your network connection and try again.";t===404?r="The requested resource was not found. Check the URL or item name.":t===500?r="The registry server encountered an error. Try again later.":t&&t>=400&&t<500&&(r="There was a client error. Check your request parameters.");super(p,{code:g.FETCH_ERROR,statusCode:t,cause:a,context:{url:e,responseBody:n},suggestion:r});this.url=e;this.responseBody=n;this.name="RegistryFetchError";}},k=class extends u{constructor(e){let t=e?`Unknown registry "${e}". Make sure it is defined in components.json as follows:
|
|
2
|
-
{
|
|
3
|
-
"registries": {
|
|
4
|
-
"${e}": "[URL_TO_REGISTRY]"
|
|
5
|
-
}
|
|
6
|
-
}`:'Unknown registry. Make sure it is defined in components.json under "registries".';super(t,{code:g.NOT_CONFIGURED,context:{registryName:e},suggestion:"Add the registry configuration to your components.json file. Consult the registry documentation for the correct format."});this.registryName=e;this.name="RegistryNotConfiguredError";}},w=class extends u{constructor(e,t){super(`Failed to read local registry file: ${e}`,{code:g.LOCAL_FILE_ERROR,cause:t,context:{filePath:e},suggestion:"Check if the file exists and you have read permissions."});this.filePath=e;this.name="RegistryLocalFileError";}},j=class extends u{constructor(e,t){let n=`Failed to parse registry item: ${e}`;t instanceof z.ZodError&&(n=`Failed to parse registry item: ${e}
|
|
7
|
-
${t.errors.map(a=>` - ${a.path.join(".")}: ${a.message}`).join(`
|
|
8
|
-
`)}`);super(n,{code:g.PARSE_ERROR,cause:t,context:{item:e},suggestion:"The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See https://ui.shadcn.com/schema/registry-item.json."});this.item=e;this.parseError=t,this.name="RegistryParseError";}parseError},S=class extends u{constructor(e,t){let n=`Registry "${e}" requires the following environment variables:
|
|
9
|
-
|
|
10
|
-
`+t.map(a=>` \u2022 ${a}`).join(`
|
|
11
|
-
`);super(n,{code:g.MISSING_ENV_VARS,context:{registryName:e,missingVars:t},suggestion:"Set the required environment variables to your .env or .env.local file."});this.registryName=e;this.missingVars=t;this.name="RegistryMissingEnvironmentVariablesError";}},v=class extends u{constructor(e){let t=`Invalid registry namespace: "${e}". Registry names must start with @ (e.g., @shadcn, @v0).`;super(t,{code:g.VALIDATION_ERROR,context:{name:e},suggestion:"Use a valid registry name starting with @ or provide a direct URL to the registry."});this.name=e;this.name="RegistryInvalidNamespaceError";}};var D=class extends u{constructor(e,t){let n=`Invalid components.json configuration in ${e}.`;t instanceof z.ZodError&&(n=`Invalid components.json configuration in ${e}:
|
|
12
|
-
${t.errors.map(a=>` - ${a.path.join(".")}: ${a.message}`).join(`
|
|
13
|
-
`)}`);super(n,{code:g.INVALID_CONFIG,cause:t,context:{cwd:e},suggestion:"Check your components.json file for syntax errors or invalid configuration. Run 'npx shadcn@latest init' to regenerate a valid configuration."});this.cwd=e;this.name="ConfigParseError";}},L=class extends u{parseError;constructor(i){let e="Failed to parse registries index";if(i instanceof z.ZodError){let t=i.errors.filter(n=>n.path.length>0).map(n=>`"${n.path[0]}"`).filter((n,a,o)=>o.indexOf(n)===a);t.length>0?e=`Failed to parse registries index. Invalid registry namespace(s): ${t.join(", ")}
|
|
14
|
-
${i.errors.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
15
|
-
`)}`:e=`Failed to parse registries index:
|
|
16
|
-
${i.errors.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
17
|
-
`)}`;}super(e,{code:g.PARSE_ERROR,cause:i,context:{parseError:i},suggestion:"The registries index may be corrupted or have invalid registry namespace format. Registry names must start with @ (e.g., @shadcn, @example)."}),this.parseError=i,this.name="RegistriesIndexParseError";}},N=class extends u{constructor(e,t){let n=`Invalid icon library "${e}". Valid options are: ${t.join(", ")}`;super(n,{code:g.INVALID_CONFIG,context:{iconLibrary:e,validOptions:t},suggestion:`Update the "iconLibrary" field in your components.json to one of: ${t.join(", ")}`});this.iconLibrary=e;this.validOptions=t;this.name="InvalidConfigIconLibraryError";}};var H=async({sourceFile:s,config:i})=>{let e=i.iconLibrary;if(!e)return s;if(!(e in a))throw new N(e,Object.keys(a));let t=e,n=a[t],a$1=[];for(let o of s.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)){if(o.getTagNameNode()?.getText()!=="IconPlaceholder")continue;let p=o.getAttributes().find(c=>c.getKind()!==SyntaxKind.JsxAttribute?false:c.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()===t);if(!p)continue;let r=p.asKindOrThrow(SyntaxKind.JsxAttribute),m=r.getInitializer()?.getText().replace(/^["']|["']$/g,"");if(!m)continue;a$1.includes(m)||a$1.push(m);let R=n.usage.match(/<(\w+)([^>]*)\s*\/>/);r.remove();for(let c of o.getAttributes()){if(c.getKind()!==SyntaxKind.JsxAttribute)continue;let f=c.asKindOrThrow(SyntaxKind.JsxAttribute);f.getNameNode().getText()in a&&f.remove();}if(!R){o.getTagNameNode()?.replaceWithText(m);continue}let[,y,I]=R;if(y==="ICON"){let c=o.getAttributes().filter(f=>f.getKind()!==SyntaxKind.JsxAttribute?true:!(f.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(f=>f.getText()).join(" ");c.trim()?o.replaceWithText(`<${m} ${c} />`):o.getTagNameNode()?.replaceWithText(m);}else {let c=new Set(o.getAttributes().filter(l=>l.getKind()===SyntaxKind.JsxAttribute).map(l=>l.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText())),O=I.replace(/\{ICON\}/g,`{${m}}`).trim().split(/\s+(?=\w+=)/).filter(l=>l).map(l=>{let b=l.split("=")[0];return b&&!c.has(b)?l:null}).filter(Boolean),A=o.getAttributes().filter(l=>l.getKind()!==SyntaxKind.JsxAttribute?true:!(l.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(l=>l.getText()).join(" "),F=[...O,A].filter(Boolean).join(" ");o.replaceWithText(`<${y} ${F} />`);}}for(let o of s.getImportDeclarations()??[])if(o.getModuleSpecifier()?.getText()?.includes("icon-placeholder")){let m=(o.getNamedImports()??[]).find(x=>x.getName()==="IconPlaceholder");m&&m.remove(),o.getNamedImports()?.length===0&&o.remove();}if(a$1.length>0){let o=n.import.split(`
|
|
18
|
-
`),p=[];for(let r of o){let m=r.match(/import\s+{([^}]+)}\s+from\s+['"]([^'"]+)['"]/);if(!m)continue;let[,x,R]=m,y=x.split(",").map(c=>c.trim()).map(c=>c==="ICON"?a$1.map(f=>({name:f})):{name:c}).flat(),I=s.addImportDeclaration({moduleSpecifier:R,namedImports:y});p.push(I);}if(!U(s))for(let r of p)r.replaceWithText(r.getText().replace(";",""));}return s};function U(s){return s.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}var q=async({sourceFile:s,config:i})=>{let t=i.menuColor==="inverted"?"dark":"";for(let n of s.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(n.getNameNode().getText()!=="className")continue;let o=n.getInitializer();if(!o)continue;let p=o.getText();if(!p.includes("cn-menu-target"))continue;let r=p.replace(/cn-menu-target/g,t);t||(r=r.replace(/\s{2,}/g," "),r=r.replace(/"\s+/g,'"'),r=r.replace(/\s+"/g,'"'),r=r.replace(/,\s*""\s*,/g,","),r=r.replace(/\(\s*""\s*,/g,"("),r=r.replace(/,\s*""\s*\)/g,")")),n.setInitializer(r);}return s};export{u as a,E as b,$ as c,_ as d,C as e,k as f,w as g,j as h,S as i,v as j,D as k,L as l,H as m,q as n};//# sourceMappingURL=chunk-YPHLD64H.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-YPHLD64H.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/errors.ts","../src/utils/transformers/transform-icons.ts","../src/utils/transformers/transform-menu.ts"],"names":["RegistryErrorCode","RegistryError","message","options","RegistryNotFoundError","url","cause","RegistryUnauthorizedError","RegistryForbiddenError","RegistryFetchError","statusCode","responseBody","baseMessage","suggestion","RegistryNotConfiguredError","registryName","RegistryLocalFileError","filePath","RegistryParseError","item","parseError","z","e","RegistryMissingEnvironmentVariablesError","missingVars","v","RegistryInvalidNamespaceError","name","ConfigParseError","cwd","RegistriesIndexParseError","invalidNamespaces","i","arr","InvalidConfigIconLibraryError","iconLibrary","validOptions","transformIcons","sourceFile","config","iconLibraries","targetLibrary","libraryConfig","transformedIcons","element","SyntaxKind","libraryPropAttr","attr","jsxIconAttr","targetIconName","usageMatch","jsxAttr","componentName","defaultPropsStr","userAttributes","existingPropNames","defaultPropsToAdd","prop","propName","allProps","importDeclaration","iconPlaceholderImport","specifier","importStatements","addedImports","importStmt","importMatch","importedNames","modulePath","namedImports","icon","newImport","_useSemicolon","importDecl","transformMenu","replacement","initializer","text","newText"],"mappings":"0FAGO,IAAMA,CAAAA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CACT","file":"chunk-YPHLD64H.js","sourcesContent":["import { z } from \"zod\"\n\n// Error codes for programmatic error handling\nexport const RegistryErrorCode = {\n // Network errors\n NETWORK_ERROR: \"NETWORK_ERROR\",\n NOT_FOUND: \"NOT_FOUND\",\n UNAUTHORIZED: \"UNAUTHORIZED\",\n FORBIDDEN: \"FORBIDDEN\",\n FETCH_ERROR: \"FETCH_ERROR\",\n\n // Configuration errors\n NOT_CONFIGURED: \"NOT_CONFIGURED\",\n INVALID_CONFIG: \"INVALID_CONFIG\",\n MISSING_ENV_VARS: \"MISSING_ENV_VARS\",\n\n // File system errors\n LOCAL_FILE_ERROR: \"LOCAL_FILE_ERROR\",\n\n // Parsing errors\n PARSE_ERROR: \"PARSE_ERROR\",\n VALIDATION_ERROR: \"VALIDATION_ERROR\",\n\n // Generic errors\n UNKNOWN_ERROR: \"UNKNOWN_ERROR\",\n} as const\n\nexport type RegistryErrorCode =\n (typeof RegistryErrorCode)[keyof typeof RegistryErrorCode]\n\nexport class RegistryError extends Error {\n public readonly code: RegistryErrorCode\n public readonly statusCode?: number\n public readonly context?: Record<string, unknown>\n public readonly suggestion?: string\n public readonly timestamp: Date\n public readonly cause?: unknown\n\n constructor(\n message: string,\n options: {\n code?: RegistryErrorCode\n statusCode?: number\n cause?: unknown\n context?: Record<string, unknown>\n suggestion?: string\n } = {}\n ) {\n super(message)\n this.name = \"RegistryError\"\n this.code = options.code || RegistryErrorCode.UNKNOWN_ERROR\n this.statusCode = options.statusCode\n this.cause = options.cause\n this.context = options.context\n this.suggestion = options.suggestion\n this.timestamp = new Date()\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor)\n }\n }\n\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n statusCode: this.statusCode,\n context: this.context,\n suggestion: this.suggestion,\n timestamp: this.timestamp,\n stack: this.stack,\n }\n }\n}\n\nexport class RegistryNotFoundError extends RegistryError {\n constructor(public readonly url: string, cause?: unknown) {\n const message = `The item at ${url} was not found. It may not exist at the registry.`\n\n super(message, {\n code: RegistryErrorCode.NOT_FOUND,\n statusCode: 404,\n cause,\n context: { url },\n suggestion:\n \"Check if the item name is correct and the registry URL is accessible.\",\n })\n this.name = \"RegistryNotFoundError\"\n }\n}\n\nexport class RegistryUnauthorizedError extends RegistryError {\n constructor(public readonly url: string, cause?: unknown) {\n const message = `You are not authorized to access the item at ${url}. If this is a remote registry, you may need to authenticate.`\n\n super(message, {\n code: RegistryErrorCode.UNAUTHORIZED,\n statusCode: 401,\n cause,\n context: { url },\n suggestion:\n \"Check your authentication credentials and environment variables.\",\n })\n this.name = \"RegistryUnauthorizedError\"\n }\n}\n\nexport class RegistryForbiddenError extends RegistryError {\n constructor(public readonly url: string, cause?: unknown) {\n const message = `You are not authorized to access the item at ${url}. If this is a remote registry, you may need to authenticate.`\n\n super(message, {\n code: RegistryErrorCode.FORBIDDEN,\n statusCode: 403,\n cause,\n context: { url },\n suggestion:\n \"Check your authentication credentials and environment variables.\",\n })\n this.name = \"RegistryForbiddenError\"\n }\n}\n\nexport class RegistryFetchError extends RegistryError {\n constructor(\n public readonly url: string,\n statusCode?: number,\n public readonly responseBody?: string,\n cause?: unknown\n ) {\n // Use the error detail from the server if available\n const baseMessage = statusCode\n ? `Failed to fetch from registry (${statusCode}): ${url}`\n : `Failed to fetch from registry: ${url}`\n\n const message =\n typeof cause === \"string\" && cause\n ? `${baseMessage} - ${cause}`\n : baseMessage\n\n let suggestion = \"Check your network connection and try again.\"\n if (statusCode === 404) {\n suggestion =\n \"The requested resource was not found. Check the URL or item name.\"\n } else if (statusCode === 500) {\n suggestion = \"The registry server encountered an error. Try again later.\"\n } else if (statusCode && statusCode >= 400 && statusCode < 500) {\n suggestion = \"There was a client error. Check your request parameters.\"\n }\n\n super(message, {\n code: RegistryErrorCode.FETCH_ERROR,\n statusCode,\n cause,\n context: { url, responseBody },\n suggestion,\n })\n this.name = \"RegistryFetchError\"\n }\n}\n\nexport class RegistryNotConfiguredError extends RegistryError {\n constructor(public readonly registryName: string | null) {\n const message = registryName\n ? `Unknown registry \"${registryName}\". Make sure it is defined in components.json as follows:\n{\n \"registries\": {\n \"${registryName}\": \"[URL_TO_REGISTRY]\"\n }\n}`\n : `Unknown registry. Make sure it is defined in components.json under \"registries\".`\n\n super(message, {\n code: RegistryErrorCode.NOT_CONFIGURED,\n context: { registryName },\n suggestion:\n \"Add the registry configuration to your components.json file. Consult the registry documentation for the correct format.\",\n })\n this.name = \"RegistryNotConfiguredError\"\n }\n}\n\nexport class RegistryLocalFileError extends RegistryError {\n constructor(public readonly filePath: string, cause?: unknown) {\n super(`Failed to read local registry file: ${filePath}`, {\n code: RegistryErrorCode.LOCAL_FILE_ERROR,\n cause,\n context: { filePath },\n suggestion: \"Check if the file exists and you have read permissions.\",\n })\n this.name = \"RegistryLocalFileError\"\n }\n}\n\nexport class RegistryParseError extends RegistryError {\n public readonly parseError: unknown\n\n constructor(public readonly item: string, parseError: unknown) {\n let message = `Failed to parse registry item: ${item}`\n\n if (parseError instanceof z.ZodError) {\n message = `Failed to parse registry item: ${item}\\n${parseError.errors\n .map((e) => ` - ${e.path.join(\".\")}: ${e.message}`)\n .join(\"\\n\")}`\n }\n\n super(message, {\n code: RegistryErrorCode.PARSE_ERROR,\n cause: parseError,\n context: { item },\n suggestion:\n \"The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See https://ui.shadcn.com/schema/registry-item.json.\",\n })\n\n this.parseError = parseError\n this.name = \"RegistryParseError\"\n }\n}\n\nexport class RegistryMissingEnvironmentVariablesError extends RegistryError {\n constructor(\n public readonly registryName: string,\n public readonly missingVars: string[]\n ) {\n const message =\n `Registry \"${registryName}\" requires the following environment variables:\\n\\n` +\n missingVars.map((v) => ` • ${v}`).join(\"\\n\")\n\n super(message, {\n code: RegistryErrorCode.MISSING_ENV_VARS,\n context: { registryName, missingVars },\n suggestion:\n \"Set the required environment variables to your .env or .env.local file.\",\n })\n this.name = \"RegistryMissingEnvironmentVariablesError\"\n }\n}\n\nexport class RegistryInvalidNamespaceError extends RegistryError {\n constructor(public readonly name: string) {\n const message = `Invalid registry namespace: \"${name}\". Registry names must start with @ (e.g., @shadcn, @v0).`\n\n super(message, {\n code: RegistryErrorCode.VALIDATION_ERROR,\n context: { name },\n suggestion:\n \"Use a valid registry name starting with @ or provide a direct URL to the registry.\",\n })\n this.name = \"RegistryInvalidNamespaceError\"\n }\n}\n\nexport class ConfigMissingError extends RegistryError {\n constructor(public readonly cwd: string) {\n const message = `No components.json found in ${cwd} or parent directories.`\n\n super(message, {\n code: RegistryErrorCode.NOT_CONFIGURED,\n context: { cwd },\n suggestion:\n \"Run 'npx shadcn@latest init' to create a components.json file, or check that you're in the correct directory.\",\n })\n this.name = \"ConfigMissingError\"\n }\n}\n\nexport class ConfigParseError extends RegistryError {\n constructor(public readonly cwd: string, parseError: unknown) {\n let message = `Invalid components.json configuration in ${cwd}.`\n\n if (parseError instanceof z.ZodError) {\n message = `Invalid components.json configuration in ${cwd}:\\n${parseError.errors\n .map((e) => ` - ${e.path.join(\".\")}: ${e.message}`)\n .join(\"\\n\")}`\n }\n\n super(message, {\n code: RegistryErrorCode.INVALID_CONFIG,\n cause: parseError,\n context: { cwd },\n suggestion:\n \"Check your components.json file for syntax errors or invalid configuration. Run 'npx shadcn@latest init' to regenerate a valid configuration.\",\n })\n this.name = \"ConfigParseError\"\n }\n}\n\nexport class RegistriesIndexParseError extends RegistryError {\n public readonly parseError: unknown\n\n constructor(parseError: unknown) {\n let message = \"Failed to parse registries index\"\n\n if (parseError instanceof z.ZodError) {\n const invalidNamespaces = parseError.errors\n .filter((e) => e.path.length > 0)\n .map((e) => `\"${e.path[0]}\"`)\n .filter((v, i, arr) => arr.indexOf(v) === i) // remove duplicates\n\n if (invalidNamespaces.length > 0) {\n message = `Failed to parse registries index. Invalid registry namespace(s): ${invalidNamespaces.join(\n \", \"\n )}\\n${parseError.errors\n .map((e) => ` - ${e.path.join(\".\")}: ${e.message}`)\n .join(\"\\n\")}`\n } else {\n message = `Failed to parse registries index:\\n${parseError.errors\n .map((e) => ` - ${e.path.join(\".\")}: ${e.message}`)\n .join(\"\\n\")}`\n }\n }\n\n super(message, {\n code: RegistryErrorCode.PARSE_ERROR,\n cause: parseError,\n context: { parseError },\n suggestion:\n \"The registries index may be corrupted or have invalid registry namespace format. Registry names must start with @ (e.g., @shadcn, @example).\",\n })\n\n this.parseError = parseError\n this.name = \"RegistriesIndexParseError\"\n }\n}\n\nexport class InvalidConfigIconLibraryError extends RegistryError {\n constructor(\n public readonly iconLibrary: string,\n public readonly validOptions: string[]\n ) {\n const message = `Invalid icon library \"${iconLibrary}\". Valid options are: ${validOptions.join(\n \", \"\n )}`\n\n super(message, {\n code: RegistryErrorCode.INVALID_CONFIG,\n context: { iconLibrary, validOptions },\n suggestion: `Update the \"iconLibrary\" field in your components.json to one of: ${validOptions.join(\n \", \"\n )}`,\n })\n this.name = \"InvalidConfigIconLibraryError\"\n }\n}\n","import { iconLibraries, type IconLibraryName } from \"@/src/icons/libraries\"\nimport { InvalidConfigIconLibraryError } from \"@/src/registry/errors\"\nimport { Transformer } from \"@/src/utils/transformers\"\nimport { SourceFile, SyntaxKind } from \"ts-morph\"\n\nexport const transformIcons: Transformer = async ({ sourceFile, config }) => {\n const iconLibrary = config.iconLibrary\n if (!iconLibrary) {\n return sourceFile\n }\n\n if (!(iconLibrary in iconLibraries)) {\n throw new InvalidConfigIconLibraryError(\n iconLibrary,\n Object.keys(iconLibraries)\n )\n }\n\n const targetLibrary = iconLibrary as IconLibraryName\n const libraryConfig = iconLibraries[targetLibrary]\n let transformedIcons: string[] = []\n\n for (const element of sourceFile.getDescendantsOfKind(\n SyntaxKind.JsxSelfClosingElement\n )) {\n if (element.getTagNameNode()?.getText() !== \"IconPlaceholder\") {\n continue\n }\n\n // Find the library-specific prop (e.g., \"lucide\", \"tabler\", \"hugeicons\")\n const libraryPropAttr = element.getAttributes().find((attr) => {\n if (attr.getKind() !== SyntaxKind.JsxAttribute) {\n return false\n }\n const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute)\n return jsxAttr.getNameNode().getText() === targetLibrary\n })\n\n if (!libraryPropAttr) {\n continue // No icon specified for this library\n }\n\n const jsxIconAttr = libraryPropAttr.asKindOrThrow(SyntaxKind.JsxAttribute)\n const targetIconName = jsxIconAttr\n .getInitializer()\n ?.getText()\n .replace(/^[\"']|[\"']$/g, \"\")\n\n if (!targetIconName) {\n continue\n }\n\n if (!transformedIcons.includes(targetIconName)) {\n transformedIcons.push(targetIconName)\n }\n\n const usage = libraryConfig.usage\n const usageMatch = usage.match(/<(\\w+)([^>]*)\\s*\\/>/)\n\n // Remove the library-specific prop\n jsxIconAttr.remove()\n\n // Remove all other library-specific props\n for (const attr of element.getAttributes()) {\n if (attr.getKind() !== SyntaxKind.JsxAttribute) {\n continue\n }\n const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute)\n const attrName = jsxAttr.getNameNode().getText()\n // Filter out library-specific props (lucide, tabler, hugeicons, etc.)\n if (attrName in iconLibraries) {\n jsxAttr.remove()\n }\n }\n\n if (!usageMatch) {\n element.getTagNameNode()?.replaceWithText(targetIconName)\n continue\n }\n\n const [, componentName, defaultPropsStr] = usageMatch\n\n if (componentName === \"ICON\") {\n // Get remaining user attributes (non-library props)\n const userAttributes = element\n .getAttributes()\n .filter((attr) => {\n if (attr.getKind() !== SyntaxKind.JsxAttribute) {\n return true\n }\n const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute)\n const attrName = jsxAttr.getNameNode().getText()\n // Filter out library-specific props (lucide, tabler, hugeicons, etc.)\n return !(attrName in iconLibraries)\n })\n .map((attr) => attr.getText())\n .join(\" \")\n\n if (userAttributes.trim()) {\n element.replaceWithText(`<${targetIconName} ${userAttributes} />`)\n } else {\n element.getTagNameNode()?.replaceWithText(targetIconName)\n }\n } else {\n const existingPropNames = new Set(\n element\n .getAttributes()\n .filter((attr) => attr.getKind() === SyntaxKind.JsxAttribute)\n .map((attr) =>\n attr.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()\n )\n )\n\n // Replace ICON placeholder in defaultPropsStr with actual icon name\n const defaultPropsWithIcon = defaultPropsStr.replace(\n /\\{ICON\\}/g,\n `{${targetIconName}}`\n )\n\n const defaultPropsToAdd = defaultPropsWithIcon\n .trim()\n .split(/\\s+(?=\\w+=)/)\n .filter((prop) => prop)\n .map((prop) => {\n const propName = prop.split(\"=\")[0]\n return propName && !existingPropNames.has(propName) ? prop : null\n })\n .filter(Boolean)\n\n const userAttributes = element\n .getAttributes()\n .filter((attr) => {\n if (attr.getKind() !== SyntaxKind.JsxAttribute) {\n return true\n }\n const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute)\n const attrName = jsxAttr.getNameNode().getText()\n // Filter out library-specific props (lucide, tabler, hugeicons, etc.)\n return !(attrName in iconLibraries)\n })\n .map((attr) => attr.getText())\n .join(\" \")\n\n const allProps = [...defaultPropsToAdd, userAttributes]\n .filter(Boolean)\n .join(\" \")\n\n element.replaceWithText(`<${componentName} ${allProps} />`)\n }\n }\n\n for (const importDeclaration of sourceFile.getImportDeclarations() ?? []) {\n const moduleSpecifier = importDeclaration.getModuleSpecifier()?.getText()\n if (moduleSpecifier?.includes(\"icon-placeholder\")) {\n const namedImports = importDeclaration.getNamedImports() ?? []\n const iconPlaceholderImport = namedImports.find(\n (specifier) => specifier.getName() === \"IconPlaceholder\"\n )\n\n if (iconPlaceholderImport) {\n iconPlaceholderImport.remove()\n }\n\n if (importDeclaration.getNamedImports()?.length === 0) {\n importDeclaration.remove()\n }\n }\n }\n\n if (transformedIcons.length > 0) {\n const importStatements = libraryConfig.import.split(\"\\n\")\n const addedImports = []\n\n for (const importStmt of importStatements) {\n const importMatch = importStmt.match(\n /import\\s+{([^}]+)}\\s+from\\s+['\"]([^'\"]+)['\"]/\n )\n\n if (!importMatch) continue\n\n const [, importedNames, modulePath] = importMatch\n const namedImports = importedNames\n .split(\",\")\n .map((name) => name.trim())\n .map((name) => {\n if (name === \"ICON\") {\n return transformedIcons.map((icon) => ({ name: icon }))\n }\n return { name }\n })\n .flat()\n\n const newImport = sourceFile.addImportDeclaration({\n moduleSpecifier: modulePath,\n namedImports,\n })\n\n addedImports.push(newImport)\n }\n\n if (!_useSemicolon(sourceFile)) {\n for (const importDecl of addedImports) {\n importDecl.replaceWithText(importDecl.getText().replace(\";\", \"\"))\n }\n }\n }\n\n return sourceFile\n}\n\nfunction _useSemicolon(sourceFile: SourceFile) {\n return (\n sourceFile.getImportDeclarations()?.[0]?.getText().endsWith(\";\") ?? false\n )\n}\n","import { Transformer } from \"@/src/utils/transformers\"\nimport { SyntaxKind } from \"ts-morph\"\n\n// Transforms cn-menu-target class based on config.menuColor.\n// If menuColor is \"inverted\", replaces cn-menu-target with \"dark\".\n// Otherwise, removes cn-menu-target entirely.\nexport const transformMenu: Transformer = async ({ sourceFile, config }) => {\n const menuColor = config.menuColor\n\n // If menuColor is not set or is \"default\", we remove the placeholder.\n const replacement = menuColor === \"inverted\" ? \"dark\" : \"\"\n\n for (const attr of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {\n const attrName = attr.getNameNode().getText()\n if (attrName !== \"className\") {\n continue\n }\n\n const initializer = attr.getInitializer()\n if (!initializer) {\n continue\n }\n\n const text = initializer.getText()\n if (!text.includes(\"cn-menu-target\")) {\n continue\n }\n\n // Replace cn-menu-target with the replacement value.\n let newText = text.replace(/cn-menu-target/g, replacement)\n\n // Clean up extra spaces if we removed the class.\n if (!replacement) {\n // Remove double spaces.\n newText = newText.replace(/\\s{2,}/g, \" \")\n // Clean up leading/trailing spaces in strings.\n newText = newText.replace(/\"\\s+/g, '\"')\n newText = newText.replace(/\\s+\"/g, '\"')\n // Clean up empty strings in cn() calls.\n newText = newText.replace(/,\\s*\"\"\\s*,/g, \",\")\n newText = newText.replace(/\\(\\s*\"\"\\s*,/g, \"(\")\n newText = newText.replace(/,\\s*\"\"\\s*\\)/g, \")\")\n }\n\n attr.setInitializer(newText)\n }\n\n return sourceFile\n}\n"]}
|