shadcn 3.0.0 → 3.1.0
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/dist/{chunk-GJTZRXUG.js → chunk-CTA6CCSY.js} +3 -3
- package/dist/{chunk-GJTZRXUG.js.map → chunk-CTA6CCSY.js.map} +1 -1
- package/dist/chunk-TGLVS3JU.js +2 -0
- package/dist/chunk-TGLVS3JU.js.map +1 -0
- package/dist/{chunk-FGQE6PDN.js → chunk-WWWGMODU.js} +3 -3
- package/dist/{chunk-FGQE6PDN.js.map → chunk-WWWGMODU.js.map} +1 -1
- package/dist/{index-J2j472vm.d.ts → index-BLY-Eoaq.d.ts} +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -44
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +1 -1
- package/dist/schema/index.d.ts +15 -15
- package/dist/schema/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-VVOKVGPU.js +0 -2
- package/dist/chunk-VVOKVGPU.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {g,q,p,r,m,h,o,i,j as j$1,k,l,t,b as b$1}from'./chunk-
|
|
1
|
+
import {g,q,p,r,m,h,o,i,j as j$1,k,l,t,b as b$1}from'./chunk-TGLVS3JU.js';import*as y from'path';import y__default,{basename}from'path';import {z}from'zod';import*as B from'fs/promises';import {tmpdir,homedir}from'os';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import Oe from'fast-glob';import je from'fs-extra';import {existsSync,promises}from'fs';import Rr from'ora';import {Project,SyntaxKind,ScriptKind,QuoteKind}from'ts-morph';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Or from'@babel/plugin-transform-typescript';import*as ze from'recast';import Wr from'prompts';import ae from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import ws from'node-fetch';import {createHash}from'crypto';import Ss from'stringify-object';import Us from'fuzzysort';var Je=process.env.REGISTRY_URL??"https://ui.shadcn.com/r",Ie="new-york-v4",yt=[{name:"neutral",label:"Neutral"},{name:"gray",label:"Gray"},{name:"zinc",label:"Zinc"},{name:"stone",label:"Stone"},{name:"slate",label:"Slate"}],K={"@shadcn":`${Je}/styles/{style}/{name}.json`};var Js=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];function ce(e){return e.replace(/\${(\w+)}/g,(t,r)=>process.env[r]||"")}function pe(e){let t=[],r=/\${(\w+)}/g,s;for(;(s=r.exec(e))!==null;)t.push(s[1]);return t}var F={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"},b=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||F.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.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}}},J=class extends b{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:F.NOT_FOUND,statusCode:404,cause:s,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},fe=class extends b{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:F.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},me=class extends b{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:F.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},de=class extends b{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,c="Check your network connection and try again.";s===404?c="The requested resource was not found. Check the URL or item name.":s===500?c="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(c="There was a client error. Check your request parameters.");super(a,{code:F.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:c});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},W=class extends b{constructor(r){let s=r?`Unknown registry "${r}". Make sure it is defined in components.json as follows:
|
|
2
2
|
{
|
|
3
3
|
"registries": {
|
|
4
4
|
"${r}": "[URL_TO_REGISTRY]"
|
|
@@ -26,5 +26,5 @@ Suggestion:`),v.error(e.suggestion)),v.break(),process.exit(1)),e instanceof z.Z
|
|
|
26
26
|
`);});let h={};s.forEach(d=>{h=ae(h,d.envVars??{});});let u=await Dt(s.map(d=>d.files??[]),t),R=m.parse({dependencies:ae.all(s.map(d=>d.dependencies??[])),devDependencies:ae.all(s.map(d=>d.devDependencies??[])),files:u,tailwind:l,cssVars:m$1,css:f,docs:x});return Object.keys(h).length>0&&(R.envVars=h),R}catch(s){return H(s),null}}async function ve(e,t,r={},s=new Set){let n=[],i=[];for(let o of e)if(!s.has(o)){if(s.add(o),N(o)||We(o)){let[a]=await Z([o],t,r);if(a&&(n.push(a),a.registryDependencies)){let c=t?.registries?Ee(a.registryDependencies,t):a.registryDependencies,p=await ve(c,t,r,s);n.push(...p.items),i.push(...p.registryNames);}}else if(o.startsWith("@")&&t?.registries){let{registry:a}=te(o);if(a&&!(a in t.registries))throw new W(a);let[c]=await Z([o],t,r);if(c&&(n.push(c),c.registryDependencies)){let p=t?.registries?Ee(c.registryDependencies,t):c.registryDependencies,l=await ve(p,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}else if(i.push(o),t)try{let[a]=await Z([o],t,r);if(a&&a.registryDependencies){let c=t?.registries?Ee(a.registryDependencies,t):a.registryDependencies,p=await ve(c,t,r,s);n.push(...p.items),i.push(...p.registryNames);}}catch{}}return {items:n,registryNames:i}}async function Fs(e,t,r={}){if(N(e))return [e];let{registryNames:s}=await ve([e],t,r,new Set),n=t.resolvedPaths?.cwd?await wt(t.resolvedPaths.cwd,t.style):t.style,i=s.map(o=>Be(N(o)?o:`styles/${n}/${o}.json`));return Array.from(new Set(i))}async function Ls(e,t){let[r,s]=await Promise.all([Ve(e),$e(t)]);if(!r)return null;let n={name:e,type:"registry:theme",tailwind:{config:{theme:{extend:{borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},colors:{}}}}},cssVars:{theme:{},light:{radius:"0.5rem"},dark:{}}};return t.tailwind.cssVariables&&(n.tailwind.config.theme.extend.colors={...n.tailwind.config.theme.extend.colors,...Yt(r.cssVars.dark??{})},n.cssVars={theme:{...r.cssVars.theme,...n.cssVars.theme},light:{...r.cssVars.light,...n.cssVars.light},dark:{...r.cssVars.dark,...n.cssVars.dark}},s==="v4"&&r.cssVarsV4&&(n.cssVars={theme:{...r.cssVarsV4.theme,...n.cssVars.theme},light:{radius:"0.625rem",...r.cssVarsV4.light},dark:{...r.cssVarsV4.dark}})),n}function G(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function Ns(e){if(N(e)){let s=new URL(e).pathname,n=s.match(/\/([^/]+)\.json$/),i=n?n[1]:y__default.basename(s,".json");return {name:i,hash:G({name:i},e)}}if(We(e)){let r=e.match(/\/([^/]+)\.json$/),s=r?r[1]:y__default.basename(e,".json");return {name:s,hash:G({name:s},e)}}let{item:t}=te(e);return {name:t,hash:G({name:t},e)}}function Ds(e,t){let r=new Map,s=new Map,n=new Map,i=new Map;e.forEach(p=>{let l=t.get(p)||p.name,m=G(p,l);r.set(m,p),s.set(m,p),n.set(m,0),i.set(m,[]);});let o=new Map;e.forEach(p=>{let l=t.get(p)||p.name,m=G(p,l);o.has(p.name)||o.set(p.name,[]),o.get(p.name).push(m),l!==p.name&&(o.has(l)||o.set(l,[]),o.get(l).push(m));}),e.forEach(p=>{let l=t.get(p)||p.name,m=G(p,l);p.registryDependencies&&p.registryDependencies.forEach(f=>{let x,h=o.get(f)||[];if(h.length===1)x=h[0];else if(h.length>1)x=h[0];else {let{name:u}=Ns(f),R=o.get(u)||[];R.length>0&&(x=R[0]);}x&&r.has(x)&&(i.get(x).push(m),n.set(m,n.get(m)+1));});});let a=[],c=[];for(n.forEach((p,l)=>{p===0&&a.push(l);});a.length>0;){let p=a.shift(),l=r.get(p);c.push(l),i.get(p).forEach(m=>{let f=n.get(m)-1;n.set(m,f),f===0&&a.push(m);});}if(c.length!==e.length){console.warn("Circular dependency detected in registry items");let p=new Set(c.map(l=>{let m=t.get(l)||l.name;return G(l,m)}));e.forEach(l=>{let m=t.get(l)||l.name,f=G(l,m);p.has(f)||c.push(l);});}return c}async function ot(e,t){let{config:r,useCache:s}=t||{};if(N(e)){let[a]=await $([e],{useCache:s});try{return h.parse(a)}catch(c){throw new j(e,c)}}if(!e.startsWith("@"))throw new ue(e);let n=e;n.endsWith("/registry")||(n=`${n}/registry`);let i=oe(n,ie(r));if(!i?.url)throw new J(n);i.headers&&Object.keys(i.headers).length>0&&he({[i.url]:i.headers});let[o]=await $([i.url],{useCache:s});try{return h.parse(o)}catch(a){throw new j(n,a)}}async function Ks(e,t){let{config:r,useCache:s=false}=t||{};return ye(),Z(e,ie(r),{useCache:s})}async function Vs(e,t){let{config:r,useCache:s=false}=t||{};return ye(),Xt(e,ie(r),{useCache:s})}async function Ka(e,t){let{useCache:r=true}=t||{};r||Pe.clearCaches();let s=await Pe.search(e);if(!s)return {registries:K};let n=z.object({registries:o.optional()}).safeParse(s.config);if(!n.success)throw new be(e,n.error);return {registries:{...K,...n.data.registries||{}}}}async function er(){try{let[e]=await $(["index.json"]);return i.parse(e)}catch(e){v.error(`
|
|
27
27
|
`),H(e);}}async function Va(){try{let[e]=await $(["styles/index.json"]);return j$1.parse(e)}catch(e){return v.error(`
|
|
28
28
|
`),H(e),[]}}async function Tt(){try{let[e]=await $(["icons/index.json"]);return k.parse(e)}catch(e){return H(e),{}}}async function Wa(){return yt}async function Ve(e){try{let[t]=await $([`colors/${e}.json`]);return l.parse(t)}catch(t){H(t);}}async function Ws(e,t){let r=[];for(let s of t){let n=e.find(i=>i.name===s);if(n&&(r.push(n),n.registryDependencies)){let i=await Ws(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Ua(e,t){try{let r=t.map(n=>`styles/${e}/${n.name}.json`);return (await $(r)).map(n=>g.parse(n))}catch(r){return H(r),[]}}async function Ma(e,t,r){if(r)return r;if(t.type==="registry:ui")return e.resolvedPaths.ui??e.resolvedPaths.components;let[s,n]=t.type?.split(":")??[];return s in e.resolvedPaths?y__default.join(e.resolvedPaths[s],n):null}async function Ms(e,t$1){let{query:r,limit:s,offset:n,config:i,useCache:o}=t$1||{},a=[];for(let f of e){let h=((await ot(f,{config:i,useCache:o})).items||[]).map(u=>({name:u.name,type:u.type,description:u.description,registry:f,addCommandArgument:qs(u.name,f)}));a=a.concat(h);}r&&(a=Hs(a,{query:r,limit:a.length,keys:["name","description"]}));let c=n||0,p=s||a.length,l=a.length,m={pagination:{total:l,offset:c,limit:p,hasMore:c+p<l},items:a.slice(c,c+p)};return t.parse(m)}var Bs=z.object({name:z.string(),type:z.string().optional(),description:z.string().optional(),registry:z.string().optional(),addCommandArgument:z.string().optional()}).passthrough();function Hs(e,t){t={limit:100,threshold:-1e4,...t};let s=Us.go(t.query,e,{keys:t.keys,threshold:t.threshold,limit:t.limit}).map(n=>n.obj);return z.array(Bs).parse(s)}function Gs(e){try{return new URL(e),!0}catch{return false}}function qs(e,t){if(!Gs(t))return `${t}/${e}`;let r=t.indexOf("://")+3,s=t.indexOf("/",r);if(s===-1){let f=t.indexOf("?",r);if(f!==-1){let x=t.substring(0,f),u=t.substring(f).replace(/\bregistry\b/g,e);return x+u}return t}let n=t.substring(0,s),i=t.substring(s),o=i.indexOf("?")!==-1?i.indexOf("?"):i.length,a=i.substring(0,o),c=i.substring(o),p=a.lastIndexOf("registry"),l=a;p!==-1&&(l=a.substring(0,p)+e+a.substring(p+8));let m=c.replace(/\bregistry\b/g,e);return n+l+m}
|
|
29
|
-
export{Tt as $,j as A,ge as B,ue as C,St as D,It as E,bt as F,Le as G,Ot as H,Hi as I,is as J,io as K,ie as L,ye as M,Eo as N,oe as O,$ as P,H as Q,sa as R,Ht as S,Os as T,Xt as U,ot as V,Ks as W,Vs as X,Ka as Y,er as Z,Va as _,yt as a,Wa as aa,Js as b,Ve as ba,P as c,Ws as ca,hn as d,Ua as da,yn as e,Ma as ea,xn as f,Ms as fa,wn as g,Te as h,Ye as i,En as j,fr as k,dr as l,Et as m,Qe as n,V as o,Nn as p,$e as q,v as r,Q as s,b as t,J as u,fe as v,me as w,de as x,W as y,ee as z};//# sourceMappingURL=chunk-
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
export{Tt as $,j as A,ge as B,ue as C,St as D,It as E,bt as F,Le as G,Ot as H,Hi as I,is as J,io as K,ie as L,ye as M,Eo as N,oe as O,$ as P,H as Q,sa as R,Ht as S,Os as T,Xt as U,ot as V,Ks as W,Vs as X,Ka as Y,er as Z,Va as _,yt as a,Wa as aa,Js as b,Ve as ba,P as c,Ws as ca,hn as d,Ua as da,yn as e,Ma as ea,xn as f,Ms as fa,wn as g,Te as h,Ye as i,En as j,fr as k,dr as l,Et as m,Qe as n,V as o,Nn as p,$e as q,v as r,Q as s,b as t,J as u,fe as v,me as w,de as x,W as y,ee as z};//# sourceMappingURL=chunk-CTA6CCSY.js.map
|
|
30
|
+
//# sourceMappingURL=chunk-CTA6CCSY.js.map
|