@ohos-ports/shadcn 4.21.0-beta.1

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.
@@ -0,0 +1,2 @@
1
+ var e={lucide:{name:"lucide",title:"Lucide",packages:["lucide-react"],import:"import { ICON } from 'lucide-react'",usage:"<ICON />",export:"lucide-react"},tabler:{name:"tabler",title:"Tabler Icons",packages:["@tabler/icons-react"],import:"import { ICON } from '@tabler/icons-react'",usage:"<ICON />",export:"@tabler/icons-react"},hugeicons:{name:"hugeicons",title:"HugeIcons",packages:["@hugeicons/react","@hugeicons/core-free-icons"],import:`import { HugeiconsIcon } from '@hugeicons/react'
2
+ import { ICON } from '@hugeicons/core-free-icons';`,usage:"<HugeiconsIcon icon={ICON} strokeWidth={2} />",export:"@hugeicons/core-free-icons"},phosphor:{name:"phosphor",title:"Phosphor Icons",packages:["@phosphor-icons/react"],import:"import { ICON } from '@phosphor-icons/react'",usage:"<ICON strokeWidth={2} />",export:"@phosphor-icons/react"},remixicon:{name:"remixicon",title:"Remix Icon",packages:["@remixicon/react"],import:"import { ICON } from '@remixicon/react'",usage:"<ICON />",export:"@remixicon/react"}};export{e as a};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-CHWMSXYA.js';import {SyntaxKind,Project,ScriptKind}from'ts-morph';import {promises}from'fs';import {twMerge}from'cn';var ot=async({sourceFile:r,config:n})=>{let e=n.iconLibrary;if(!e||!(e in a))return r;let t=e,i=a[t],o=[];for(let a$1 of r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)){if(a$1.getTagNameNode()?.getText()!=="IconPlaceholder")continue;let f=a$1.getAttributes().find(g=>g.getKind()!==SyntaxKind.JsxAttribute?false:g.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()===t);if(!f)continue;let s=f.asKindOrThrow(SyntaxKind.JsxAttribute),l=s.getInitializer()?.getText().replace(/^["']|["']$/g,"");if(!l)continue;o.includes(l)||o.push(l);let u=i.usage.match(/<(\w+)([^>]*)\s*\/>/);s.remove();for(let g of a$1.getAttributes()){if(g.getKind()!==SyntaxKind.JsxAttribute)continue;let x=g.asKindOrThrow(SyntaxKind.JsxAttribute);x.getNameNode().getText()in a&&x.remove();}if(!u){a$1.getTagNameNode()?.replaceWithText(l);continue}let[,b,K]=u;if(b==="ICON"){let g=a$1.getAttributes().filter(x=>x.getKind()!==SyntaxKind.JsxAttribute?true:!(x.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(x=>x.getText()).join(" ");g.trim()?a$1.replaceWithText(`<${l} ${g} />`):a$1.getTagNameNode()?.replaceWithText(l);}else {let g=new Set(a$1.getAttributes().filter(m=>m.getKind()===SyntaxKind.JsxAttribute).map(m=>m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText())),A=K.replace(/\{ICON\}/g,`{${l}}`).trim().split(/\s+(?=\w+=)/).filter(m=>m).map(m=>{let E=m.split("=")[0];return E&&!g.has(E)?m:null}).filter(Boolean),y=a$1.getAttributes().filter(m=>m.getKind()!==SyntaxKind.JsxAttribute?true:!(m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(m=>m.getText()).join(" "),M=[...A,y].filter(Boolean).join(" ");a$1.replaceWithText(`<${b} ${M} />`);}}for(let a of r.getImportDeclarations()??[])if(a.getModuleSpecifier()?.getText()?.includes("icon-placeholder")){let l=(a.getNamedImports()??[]).find(d=>d.getName()==="IconPlaceholder");l&&l.remove(),a.getNamedImports()?.length===0&&a.remove();}if(o.length>0){let a=i.import.split(`
2
+ `),f=[];for(let s of a){let l=s.match(/import\s+{([^}]+)}\s+from\s+['"]([^'"]+)['"]/);if(!l)continue;let[,d,u]=l,b=d.split(",").map(g=>g.trim()).map(g=>g==="ICON"?o.map(x=>({name:x})):{name:g}).flat(),K=r.addImportDeclaration({moduleSpecifier:u,namedImports:b});f.push(K);}if(!z(r))for(let s of f)s.replaceWithText(s.getText().replace(";",""));}return r};function z(r){return r.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}var ft=async({sourceFile:r,config:n,baseColor:e})=>(n.tailwind?.cssVariables||!e?.inlineColors||r.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(t=>{let i=t.getLiteralText(),o=J(i,e.inlineColors).trim();o!==i&&t.setLiteralValue(o);}),r);function L(r){if(!r.includes("/")&&!r.includes(":"))return [null,r,null];let n=-1,e=0;for(let s=r.length-1;s>=0;s--){let l=r[s];if(l==="]")e++;else if(l==="[")e--;else if(l===":"&&e===0){n=s;break}}let t=null,i;n===-1?i=r:(t=r.slice(0,n),i=r.slice(n+1));let o=i.lastIndexOf("/");if(o===-1)return [t,i,null];let a=i.slice(0,o),f=i.slice(o+1);return [t,a,f]}var k=["bg-","text-","border-","ring-offset-","ring-"];function J(r,n){r.includes(" border ")&&(r=r.replace(" border "," border border-border "));let e=r.split(" "),t=new Set,i=new Set;for(let o of e){let[a,f,s]=L(o),l=k.find(u=>f?.startsWith(u));if(!l){t.has(o)||t.add(o);continue}let d=f?.replace(l,"");if(d&&d in n.light){t.add([a,`${l}${n.light[d]}`].filter(Boolean).join(":")+(s?`/${s}`:"")),i.add(["dark",a,`${l}${n.dark[d]}`].filter(Boolean).join(":")+(s?`/${s}`:""));continue}t.has(o)||t.add(o);}return [...Array.from(t),...Array.from(i)].join(" ").trim()}var W=[["-ml-","-ms-"],["-mr-","-me-"],["ml-","ms-"],["mr-","me-"],["pl-","ps-"],["pr-","pe-"],["-left-","-start-"],["-right-","-end-"],["left-","start-"],["right-","end-"],["inset-l-","inset-inline-start-"],["inset-r-","inset-inline-end-"],["rounded-tl-","rounded-ss-"],["rounded-tr-","rounded-se-"],["rounded-bl-","rounded-es-"],["rounded-br-","rounded-ee-"],["rounded-l-","rounded-s-"],["rounded-r-","rounded-e-"],["border-l-","border-s-"],["border-r-","border-e-"],["border-l","border-s"],["border-r","border-e"],["text-left","text-start"],["text-right","text-end"],["scroll-ml-","scroll-ms-"],["scroll-mr-","scroll-me-"],["scroll-pl-","scroll-ps-"],["scroll-pr-","scroll-pe-"],["float-left","float-start"],["float-right","float-end"],["clear-left","clear-start"],["clear-right","clear-end"],["origin-top-left","origin-top-start"],["origin-top-right","origin-top-end"],["origin-bottom-left","origin-bottom-start"],["origin-bottom-right","origin-bottom-end"],["origin-left","origin-start"],["origin-right","origin-end"]],B=[["-translate-x-","translate-x-"],["translate-x-","-translate-x-"]],G=[["space-x-","space-x-reverse"],["divide-x-","divide-x-reverse"]],X=[["cursor-w-resize","cursor-e-resize"],["cursor-e-resize","cursor-w-resize"]],F=[["data-[side=inline-start]","slide-in-from-right","slide-in-from-end"],["data-[side=inline-start]","slide-out-to-right","slide-out-to-end"],["data-[side=inline-end]","slide-in-from-left","slide-in-from-start"],["data-[side=inline-end]","slide-out-to-left","slide-out-to-start"]],Q="cn-rtl-flip",$=["ContextMenuContent","ContextMenuSubContent","DropdownMenuSubContent"],P={right:"inline-end",left:"inline-start"},U=["-left-","-right-","left-","right-"],pt=async({sourceFile:r,config:n})=>(n.rtl&&O(r),r);async function xt(r,n){if(!n)return r;let t=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",r,{scriptKind:ScriptKind.TSX,overwrite:true});return O(t),t.getText()}function C(r){return r.replace(/^["']|["']$/g,"")}function h(r){let n=r.getLiteralText();r.setLiteralValue(q(n));}function q(r){return r.split(" ").flatMap(n=>{if(n.startsWith("rtl:")||n.startsWith("ltr:"))return [n];if(n===Q)return ["rtl:rotate-180"];let[e,t,i]=L(n);if(!t)return [n];for(let[s,l]of B)if(t.startsWith(s)){let d=t.replace(s,l),u=e?`rtl:${e}:${d}${i?`/${i}`:""}`:`rtl:${d}${i?`/${i}`:""}`;return [n,u]}for(let[s,l]of G)if(t.startsWith(s)){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l]of X)if(t===s){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l,d]of F)if(e?.includes(s)&&t.startsWith(l)){let u=t.replace(l,d);return [i?`${e}:${u}/${i}`:`${e}:${u}`]}let o=e?.includes("data-[side=left]")||e?.includes("data-[side=right]"),a=t;for(let[s,l]of W)if(!(o&&U.some(d=>s.startsWith(d)))&&t.startsWith(s)){if(!s.endsWith("-")&&t!==s)continue;a=t.replace(s,l);break}let f;return e?f=i?`${e}:${a}/${i}`:`${e}:${a}`:f=i?`${a}/${i}`:a,[f]}).join(" ")}function O(r){r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="cva").forEach(n=>{let e=n.getArguments()[0];e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&n.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(t=>t.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(t=>{t.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{let o=i.getInitializerIfKind(SyntaxKind.StringLiteral);o&&h(o);});});}),r.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(n=>{if(n.getNameNode().getText()==="className"){let e=n.getInitializer();if(e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let t=n.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(i=>i.getExpression().getText()==="cn");t&&t.getArguments().forEach(i=>{(i.isKind(SyntaxKind.ConditionalExpression)||i.isKind(SyntaxKind.BinaryExpression))&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),i.isKind(SyntaxKind.StringLiteral)&&h(i);});}}n.getNameNode().getText()==="classNames"&&n.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&n.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(e=>{if(e.getInitializer()?.isKind(SyntaxKind.CallExpression)){let i=e.getInitializerIfKind(SyntaxKind.CallExpression);i&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.ConditionalExpression)&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),o.isKind(SyntaxKind.StringLiteral)&&h(o);});}let t=e.getInitializer();t?.isKind(SyntaxKind.StringLiteral)&&e.getNameNode().getText()!=="variant"&&h(t);});}),r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="mergeProps").forEach(n=>{let e=n.getArguments()[0];if(e?.isKind(SyntaxKind.ObjectLiteralExpression)){let t=e.getProperties().find(i=>i.isKind(SyntaxKind.PropertyAssignment)&&i.getName()==="className");if(t?.isKind(SyntaxKind.PropertyAssignment)){let i=t.getInitializer();i?.isKind(SyntaxKind.CallExpression)&&i.getExpression().getText()==="cn"&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.StringLiteral)&&h(o),(o.isKind(SyntaxKind.ConditionalExpression)||o.isKind(SyntaxKind.BinaryExpression))&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h);}),i?.isKind(SyntaxKind.StringLiteral)&&h(i);}}}),[...r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),...r.getDescendantsOfKind(SyntaxKind.JsxOpeningElement)].forEach(n=>{let e=n.getTagNameNode().getText();if(!$.includes(e))return;let t=n.getAttributes().find(f=>f.isKind(SyntaxKind.JsxAttribute)&&f.getNameNode().getText()==="side");if(!t?.isKind(SyntaxKind.JsxAttribute))return;let i=t.getInitializer();if(!i?.isKind(SyntaxKind.StringLiteral))return;let o=C(i.getText()??""),a=P[o];a&&i.replaceWithText(`"${a}"`);}),r.getDescendantsOfKind(SyntaxKind.BindingElement).forEach(n=>{if(n.getNameNode().getText()!=="side")return;let i=n.getFirstAncestorByKind(SyntaxKind.FunctionDeclaration)?.getName();if(!i||!$.includes(i))return;let o=n.getInitializer();if(!o?.isKind(SyntaxKind.StringLiteral))return;let a=C(o.getText()??""),f=P[a];f&&o.replaceWithText(`"${f}"`);});}var D=[{marker:"cn-font-heading",utility:"font-heading",supportToken:"--font-heading:"}],w=/\bcn-font-heading\b/,v=new Map;async function Y(r,n=[]){let e=new Set(n);if(!r)return e;let t=v.get(r);return t||(t=promises.readFile(r,"utf8").then(i=>{let o=new Set;for(let a of D)i.includes(a.supportToken)&&o.add(a.marker);return o}).catch(()=>new Set),v.set(r,t)),(await t).forEach(i=>{e.add(i);}),e}function R(r,n){let e=r;for(let t of D)e.includes(t.marker)&&(e=e.replace(new RegExp(`\\b${t.marker}\\b`,"g"),n.has(t.marker)?t.utility:""));return e.replace(/\s+/g," ").trim()}function N(r,n){let e=r.getLiteralValue();if(!w.test(e))return;let t=R(e,n);t!==e&&r.setLiteralValue(t);}function I(r,n){for(let e of r.getDescendantsOfKind(SyntaxKind.StringLiteral))N(e,n);for(let e of r.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral))N(e,n);}var At=async({sourceFile:r,config:n,supportedFontMarkers:e})=>{let t=await Y(n.resolvedPaths.tailwindCss,e),i=[];for(let o of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){let a=o.getNameNode().getText();if(a!=="className"&&a!=="classNames")continue;let f=o.getInitializer();if(f?.isKind(SyntaxKind.StringLiteral)){let s=f.getLiteralValue();if(w.test(s)){let l=R(s,t);l===""?i.push(o):l!==s&&f.setLiteralValue(l);}}f?.isKind(SyntaxKind.JsxExpression)&&I(f,t);}for(let o of i)o.remove();for(let o of r.getDescendantsOfKind(SyntaxKind.CallExpression)){if(o.getExpression().getText()==="cva"){for(let a of o.getArguments()){if(a.isKind(SyntaxKind.StringLiteral)){N(a,t);continue}if(a.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)){N(a,t);continue}I(a,t);}continue}o.getExpression().getText()==="mergeProps"&&I(o,t);}return r};var et="animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!",yt=async({sourceFile:r,config:n})=>{let e=n.menuColor,t=e==="default-translucent"||e==="inverted-translucent";for(let i of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(i.getNameNode().getText()!=="className")continue;let a=i.getInitializer();if(!a)continue;let f=a.getText();if(!f.includes("cn-menu-target")&&!f.includes("cn-menu-translucent"))continue;let s=f,l=false;e==="inverted"||e==="inverted-translucent"?s=s.replace(/cn-menu-target/g,"dark"):(s=s.replace(/cn-menu-target/g,""),l=true),t?s=s.replace(/"([^"]*cn-menu-translucent[^"]*)"/g,(d,u)=>`"${twMerge(u,et).replace(/\s*\bcn-menu-translucent\b\s*/g," ").trim()}"`):s.includes("cn-menu-translucent")&&(s=s.replace(/cn-menu-translucent/g,""),l=true),l&&(s=s.replace(/\s{2,}/g," "),s=s.replace(/"\s+/g,'"'),s=s.replace(/\s+"/g,'"'),s=s.replace(/,\s*""\s*,/g,","),s=s.replace(/\(\s*""\s*,/g,"("),s=s.replace(/,\s*""\s*\)/g,")")),i.setInitializer(s);}return r};export{ft as a,L as b,ot as c,pt as d,xt as e,At as f,yt as g};
@@ -0,0 +1,75 @@
1
+ import {$a,R as R$1,Za,_a,ma,m as m$1,ia,oa,ab}from'./chunk-B2MD6U5O.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import m from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';var A="shadcn@latest";async function u(n){return `${await ia(process.cwd())} ${A} ${n}`}async function l(n=process.cwd()){return {registries:(await oa(n,{useCache:false})).registries}}function _(n,t){let{query:r,registries:i}=t||{},o=n.items.map(c=>{let g=[`- ${c.name}`];return c.type&&g.push(`(${c.type})`),c.description&&g.push(`- ${c.description}`),c.registry&&g.push(`[${c.registry}]`),g.push(`
2
+ Add command: \`${u(`add ${c.addCommandArgument}`)}\``),g.join(" ")}),a=`Found ${n.pagination.total} items`;r&&(a+=` matching "${r}"`),i&&i.length>0&&(a+=` in registries ${i.join(", ")}`),a+=":";let s=`Showing items ${n.pagination.offset+1}-${Math.min(n.pagination.offset+n.pagination.limit,n.pagination.total)} of ${n.pagination.total}:`,p=`${a}
3
+
4
+ ${s}
5
+
6
+ ${o.join(`
7
+
8
+ `)}`;return n.pagination.hasMore&&(p+=`
9
+
10
+ More items available. Use offset: ${n.pagination.offset+n.pagination.limit} to see the next page.`),p}function w(n){if(!n?.length)return null;let t=ab(n);return t.length===0?null:`Unknown type${t.length===1?"":"s"}: ${t.join(", ")}. Valid types: ${$a.join(", ")}.`}function $(n){if(!n.errors?.length)return "";let t=n.errors.map(r=>`- ${r.registry}: ${r.message}`);return `
11
+
12
+ Skipped ${n.errors.length} registr${n.errors.length===1?"y":"ies"} that failed to load:
13
+ ${t.join(`
14
+ `)}`}function E(n){return n.map(t=>[`## ${t.name}`,t.description?`
15
+ ${t.description}
16
+ `:"",t.type?`**Type:** ${t.type}`:"",t.files&&t.files.length>0?`**Files:** ${t.files.length} file(s)`:"",t.dependencies&&t.dependencies.length>0?`**Dependencies:** ${t.dependencies.join(", ")}`:"",t.devDependencies&&t.devDependencies.length>0?`**Dev Dependencies:** ${t.devDependencies.join(", ")}`:""].filter(Boolean).join(`
17
+ `))}function R(n,t){let r=n.map(o=>{let a=[`## Example: ${o.name}`,o.description?`
18
+ ${o.description}
19
+ `:""];return o.files?.length&&o.files.forEach(s=>{s.content&&(a.push(`### Code (${s.path}):
20
+ `),a.push("```tsx"),a.push(s.content),a.push("```"));}),a.filter(Boolean).join(`
21
+ `)});return `# Usage Examples
22
+
23
+ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
24
+ `+r.join(`
25
+
26
+ ---
27
+
28
+ `)}var j=new Server({name:"shadcn",version:"1.0.0"},{capabilities:{logging:{},resources:{},tools:{}}});async function N(n){try{await j.sendLoggingMessage({level:"info",data:n});}catch{console.error(n);}}j.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"get_project_registries",description:"Get configured registry names from components.json - Returns error if no components.json exists (use init_project to create one)",inputSchema:zodToJsonSchema(z.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to list (e.g., ['@shadcn', '@acme']). Omit to list from every registry configured in components.json."),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${$a.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"search_items_in_registries",description:"Search for components in registries using fuzzy matching (requires components.json). After finding an item, use get_item_examples_from_registries to see usage examples.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("Search query string for fuzzy matching against item names and descriptions"),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${$a.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"view_items_in_registries",description:"View detailed information about specific registry items including the name, description, type and files content. For usage examples, use get_item_examples_from_registries instead.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of item names with registry prefix (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_item_examples_from_registries",description:"Find usage examples and demos with their complete code. Search for patterns like 'accordion-demo', 'button example', 'card-demo', etc. Returns full implementation code with dependencies.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("Search query for examples (e.g., 'accordion-demo', 'button demo', 'card example', 'tooltip-demo', 'example-booking-form', 'example-hero'). Common patterns: '{item-name}-demo', '{item-name} example', 'example {item-name}'")}))},{name:"get_add_command_for_items",description:"Get the shadcn CLI add command for specific items in a registry. This is useful for adding one or more components to your project.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of items to get the add command for prefixed with the registry name (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_audit_checklist",description:"After creating new components or generating new code files, use this tool for a quick checklist to verify that everything is working as expected. Make sure to run the tool after all required steps have been completed.",inputSchema:zodToJsonSchema(z.object({}))}]}));j.setRequestHandler(CallToolRequestSchema,async n=>R$1(()=>I(n),{onGitHubAuthNotice:N}));async function I(n){try{if(!n.params.arguments)throw new Error("No tool arguments provided.");switch(n.params.name){case "get_project_registries":{let t=await l(process.cwd());return t?.registries?{content:[{type:"text",text:m`The following registries are configured in the current project:
29
+
30
+ ${Object.keys(t.registries).map(r=>`- ${r}`).join(`
31
+ `)}
32
+
33
+ You can view the items in a registry by running:
34
+ \`${await u("view @name-of-registry")}\`
35
+
36
+ For example: \`${await u("view @shadcn")}\` or \`${await u("view @shadcn @acme")}\` to view multiple registries.
37
+ `}]}:{content:[{type:"text",text:m`No components.json found or no registries configured.
38
+
39
+ To fix this:
40
+ 1. Use the \`init\` command to create a components.json file
41
+ 2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let r=z.object({registries:z.array(z.string()).optional(),query:z.string(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional()}).parse(n.params.arguments),i=w(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await l(process.cwd()),a=!r.registries?.length,s=Za(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await _a(s,{query:r.query,types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),c=$(p);return p.items.length===0?{content:[{type:"text",text:m`No items found matching "${r.query}" in registries ${s.join(", ")}, Try searching with a different query or registry.${c}`}]}:{content:[{type:"text",text:_(p,{query:r.query,registries:s})+c}]}}case "list_items_in_registries":{let r=z.object({registries:z.array(z.string()).optional(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional(),cwd:z.string().optional()}).parse(n.params.arguments),i=w(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await l(process.cwd()),a=!r.registries?.length,s=Za(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await _a(s,{types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),c=$(p);return p.items.length===0?{content:[{type:"text",text:m`No items found in registries ${s.join(", ")}.${c}`}]}:{content:[{type:"text",text:_(p,{registries:s})+c}]}}case "view_items_in_registries":{let r=z.object({items:z.array(z.string())}).parse(n.params.arguments),i=await ma(r.items,{config:await l(process.cwd()),useCache:!1});if(i?.length===0)return {content:[{type:"text",text:m`No items found for: ${r.items.join(", ")}
42
+
43
+ Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let o=E(i);return {content:[{type:"text",text:m`Item Details:
44
+
45
+ ${o.join(`
46
+
47
+ ---
48
+
49
+ `)}`}]}}case "get_item_examples_from_registries":{let r=z.object({query:z.string(),registries:z.array(z.string()).optional()}).parse(n.params.arguments),i=await l(),o=!r.registries?.length,a=Za(r.registries??[],i);if(a.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let s=await _a(a,{query:r.query,config:i,useCache:!1,continueOnError:o});if(s.items.length===0)return {content:[{type:"text",text:m`No examples found for query "${r.query}".
50
+
51
+ Try searching with patterns like:
52
+ - "accordion-demo" for accordion examples
53
+ - "button demo" or "button example"
54
+ - Component name followed by "-demo" or "example"
55
+
56
+ You can also:
57
+ 1. Use search_items_in_registries to find all items matching your query
58
+ 2. View the main component with view_items_in_registries for inline usage documentation`}]};let p=s.items.map(g=>g.addCommandArgument),c=await ma(p,{config:i,useCache:!1});return {content:[{type:"text",text:R(c,r.query)}]}}case "get_add_command_for_items":{let t=z.object({items:z.array(z.string())}).parse(n.params.arguments);return {content:[{type:"text",text:await u(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:m`## Component Audit Checklist
59
+
60
+ After adding or generating components, check the following common issues:
61
+
62
+ - [ ] Ensure imports are correct i.e named vs default imports
63
+ - [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.
64
+ - [ ] Ensure all dependencies are installed.
65
+ - [ ] Check for linting errors or warnings
66
+ - [ ] Check for TypeScript errors
67
+ - [ ] Use the Playwright MCP if available.
68
+ `}]};default:throw new Error(`Tool ${n.params.name} not found`)}}catch(t){if(t instanceof z.ZodError)return {content:[{type:"text",text:m`Invalid input parameters:
69
+ ${t.errors.map(i=>`- ${i.path.join(".")}: ${i.message}`).join(`
70
+ `)}
71
+ `}],isError:true};if(t instanceof m$1){let i=t.message;return t.suggestion&&(i+=`
72
+
73
+ \u{1F4A1} ${t.suggestion}`),t.context&&(i+=`
74
+
75
+ Context: ${JSON.stringify(t.context,null,2)}`),{content:[{type:"text",text:m`Error (${t.code}): ${i}`}],isError:true}}let r=t instanceof Error?t.message:String(t);return {content:[{type:"text",text:m`Error: ${r}`}],isError:true}}}export{j as a};
@@ -0,0 +1,6 @@
1
+ import { configSchema } from './schema/index.js';
2
+ import { z } from 'zod';
3
+
4
+ type Config = z.infer<typeof configSchema>;
5
+
6
+ export type { Config as C };
@@ -0,0 +1,60 @@
1
+ declare const iconLibraries: {
2
+ readonly lucide: {
3
+ readonly name: "lucide";
4
+ readonly title: "Lucide";
5
+ readonly packages: readonly ["lucide-react"];
6
+ readonly import: "import { ICON } from 'lucide-react'";
7
+ readonly usage: "<ICON />";
8
+ readonly export: "lucide-react";
9
+ };
10
+ readonly tabler: {
11
+ readonly name: "tabler";
12
+ readonly title: "Tabler Icons";
13
+ readonly packages: readonly ["@tabler/icons-react"];
14
+ readonly import: "import { ICON } from '@tabler/icons-react'";
15
+ readonly usage: "<ICON />";
16
+ readonly export: "@tabler/icons-react";
17
+ };
18
+ readonly hugeicons: {
19
+ readonly name: "hugeicons";
20
+ readonly title: "HugeIcons";
21
+ readonly packages: readonly ["@hugeicons/react", "@hugeicons/core-free-icons"];
22
+ readonly import: "import { HugeiconsIcon } from '@hugeicons/react'\nimport { ICON } from '@hugeicons/core-free-icons';";
23
+ readonly usage: "<HugeiconsIcon icon={ICON} strokeWidth={2} />";
24
+ readonly export: "@hugeicons/core-free-icons";
25
+ };
26
+ readonly phosphor: {
27
+ readonly name: "phosphor";
28
+ readonly title: "Phosphor Icons";
29
+ readonly packages: readonly ["@phosphor-icons/react"];
30
+ readonly import: "import { ICON } from '@phosphor-icons/react'";
31
+ readonly usage: "<ICON strokeWidth={2} />";
32
+ readonly export: "@phosphor-icons/react";
33
+ };
34
+ readonly remixicon: {
35
+ readonly name: "remixicon";
36
+ readonly title: "Remix Icon";
37
+ readonly packages: readonly ["@remixicon/react"];
38
+ readonly import: "import { ICON } from '@remixicon/react'";
39
+ readonly usage: "<ICON />";
40
+ readonly export: "@remixicon/react";
41
+ };
42
+ };
43
+ type IconLibraries = typeof iconLibraries;
44
+ type IconLibrary = IconLibraries[keyof IconLibraries];
45
+ type IconLibraryName = keyof IconLibraries;
46
+
47
+ interface ParsedImport {
48
+ moduleSpecifier: string;
49
+ namedImports: string[];
50
+ }
51
+ interface ParsedUsage {
52
+ componentName: string;
53
+ iconAttribute?: string;
54
+ attributes: Record<string, string>;
55
+ }
56
+ declare function parseImportTemplate(template: string): ParsedImport[];
57
+ declare function getIconModuleSpecifier(template: string): string | undefined;
58
+ declare function parseUsageTemplate(usage: string): ParsedUsage;
59
+
60
+ export { type IconLibraries, type IconLibrary, type IconLibraryName, type ParsedImport, type ParsedUsage, getIconModuleSpecifier, iconLibraries, parseImportTemplate, parseUsageTemplate };
@@ -0,0 +1 @@
1
+ export{b as getIconModuleSpecifier,a as parseImportTemplate,c as parseUsageTemplate}from'../chunk-3W6BGJGE.js';export{a as iconLibraries}from'../chunk-CHWMSXYA.js';