love-ui 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import{spawnSync as W}from"child_process";import{existsSync as y}from"fs";import{mkdir as v,readdir as O,readFile as b,writeFile as S}from"fs/promises";import r from"path";import{pathToFileURL as T,fileURLToPath as E}from"url";var _=r.dirname(E(import.meta.url)),U=r.resolve(_,".."),R=r.join(U,"packages"),A=new Set([".ts",".tsx",".cts",".mts",".js",".jsx",".css",".scss",".sass",".mdx",".md"]),L=new Set(["node_modules","dist",".turbo",".next","build",".cache"]),F=new Set(["accordion","alert","alert-dialog","autocomplete","avatar","badge","breadcrumb","button","card","checkbox","checkbox-group","collapsible","combobox","command","dialog","empty","field","fieldset","form","frame","group","input","label","menu","meter","number-field","pagination","popover","preview-card","progress","radio-group","scroll-area","select","separator","sheet","skeleton","slider","switch","table","tabs","textarea","toast","toggle","toggle-group","toolbar","tooltip"]);function C(t){if(!t)return t;let e=t.split("/");return e[e.length-1]||t}function N(t){let e=t.trim();return e&&((e.startsWith("@/")||e.startsWith("~/"))&&(e=`src/${e.slice(2)}`),e.startsWith("/")&&(e=e.slice(1)),e=e.replace(/^\.\//,""),e=e.replace(/\/+$/,""),e)}function D(t){let e=C(t);return e==="ui"?"love-ui":e}function J(t){let e=t.loveui??{},n=typeof e.target=="string"?e.target.trim():"",s=e.category;if(n){let i=typeof e.includePackageName=="boolean"?e.includePackageName:!1;return{base:n.replace(/\/+$/,""),includePackageName:i}}return s==="feature"?{base:"components",includePackageName:!0}:s==="block"?{base:"components/blocks",includePackageName:!0}:{base:"components/ui",includePackageName:!0}}function z(t,e,n){let s=t.startsWith("src/")?t.slice(4):t;if(!e.includePackageName){let u=e.base.split("/").filter(Boolean),g=u[u.length-1];g&&s.startsWith(`${g}/`)&&(s=s.slice(g.length+1))}let c=`${(e.includePackageName?`${e.base}/${n}`:e.base).replace(/\/+/g,"/")}/${s}`.replace(/\/+/g,"/");return{cleanedPath:s,target:c}}async function I(t){let e=r.join(t,"components.json");try{let n=await b(e,"utf8"),i=JSON.parse(n).aliases?.components;return i?N(i):null}catch{return null}}async function B(t){let e=["tsconfig.json","jsconfig.json"].map(n=>r.join(t,n)).find(n=>y(n));if(e)try{let n=await b(e,"utf8"),i=JSON.parse(n).compilerOptions?.paths;if(i&&typeof i=="object")for(let o of Object.keys(i)){let c=i[o];if(o==="@/*"&&Array.isArray(c)&&c.some(u=>u.startsWith("src/")||u.startsWith("./src/")))return"src/components";if(o==="@/*"&&Array.isArray(c)&&c.some(u=>u.startsWith("app/")||u.startsWith("./app/")))return"app/components"}}catch{}return y(r.join(t,"src"))?"src/components":y(r.join(t,"app"))?"app/components":"components"}function M(t,e,n){let s=o=>{let c=o.startsWith("/"),u=o.endsWith("/"),g=o.split("/").filter(Boolean),l=[];for(let m of g)l[l.length-1]!==m&&l.push(m);let f=l.join("/");return`${c?"/":""}${f}${u?"/":""}`};if(n)return s(t);let i=e.replace(/\/+$/,"");if(t.startsWith("components/")){let o=t.slice(10);return s(`${i}${o}`.replace(/^\//,""))}if(t.startsWith("lib/")){if(i.startsWith("src/"))return s(`src/${t}`);if(i.startsWith("app/"))return s(`app/${t}`)}return s(t)}async function X(t,e){let n=r.dirname(r.join(e,t));await v(n,{recursive:!0})}async function V(t,e){let n=r.join(t,"package.json"),s={};try{let g=await b(n,"utf8");s=JSON.parse(g)}catch{}let i=J(s),o=C(e),c=[];async function u(g,l){let f=await O(g,{withFileTypes:!0});for(let m of f){if(L.has(m.name))continue;let h=r.join(g,m.name);if(m.isDirectory()){await u(h,l);continue}let $=r.extname(m.name);if(!A.has($)||m.name==="package.json")continue;let w=r.relative(l,h).split(r.sep).join("/"),{target:j}=z(w,i,o),P=await b(h,"utf8");c.push({path:w,target:j,content:P})}}return await u(t,t),c}async function Y(t){let e=r.join(R,"love-ui"),n=r.join(e,"src","ui",`${t}.tsx`);if(!y(n))return null;try{let s=[],i=await b(n,"utf8");i=i.replace(/from\s+["']@loveui\/ui\/lib\/utils["']/g,'from "@/lib/utils"'),s.push({path:`src/ui/${t}.tsx`,target:`components/ui/${t}.tsx`,content:i});let o=r.join(e,"src","lib","utils.ts");if(y(o)){let c=await b(o,"utf8");s.push({path:"src/lib/utils.ts",target:"lib/utils.ts",content:c})}return s}catch(s){return console.warn(`Warning: unable to read ${t} component`,s),null}}async function G(t){if(F.has(t))return await Y(t);let e=D(t),n=r.join(R,e);if(!y(n))return null;try{return await V(n,t)}catch(s){return console.warn(`Warning: unable to read bundled sources for ${t}`,s),null}}var H={"@base-ui-components/react":"1.0.0-beta.4","class-variance-authority":"^0.7.1",clsx:"^2.1.1","tailwind-merge":"^3.3.1"};async function K(t){if(F.has(t))return{...H};let e=D(t),n=r.join(R,e,"package.json");try{let s=await b(n,"utf8");return JSON.parse(s).dependencies??{}}catch{return{}}}async function q(t){return y(r.join(t,"bun.lockb"))?"bun":y(r.join(t,"pnpm-lock.yaml"))?"pnpm":y(r.join(t,"yarn.lock"))?"yarn":"npm"}async function Q(t,e,n){let s=Object.entries(t);if(s.length===0)return!0;console.log(`
3
- Installing dependencies...`);let i=s.map(([u,g])=>`${u}@${g}`),o;switch(e){case"bun":o=`bun add ${i.join(" ")}`;break;case"pnpm":o=`pnpm add ${i.join(" ")}`;break;case"yarn":o=`yarn add ${i.join(" ")}`;break;default:o=`npm install ${i.join(" ")}`}let c=W(o,{stdio:"inherit",shell:!0,cwd:n});return c.error||c.status!==0?(console.warn(`
2
+ import{spawnSync as I}from"child_process";import{existsSync as P}from"fs";import{mkdir as U,readdir as z,readFile as $,writeFile as S}from"fs/promises";import a from"path";import{pathToFileURL as J,fileURLToPath as B}from"url";var M=a.dirname(B(import.meta.url)),X=a.resolve(M,".."),C=a.join(X,"packages"),H=new Set([".ts",".tsx",".cts",".mts",".js",".jsx",".css",".scss",".sass",".mdx",".md"]),V=new Set(["node_modules","dist",".turbo",".next","build",".cache"]),A=new Set(["accordion","alert","alert-dialog","autocomplete","avatar","badge","breadcrumb","button","card","checkbox","checkbox-group","collapsible","combobox","command","dialog","empty","field","fieldset","form","frame","group","input","label","menu","meter","number-field","pagination","popover","preview-card","progress","radio-group","scroll-area","select","separator","sheet","skeleton","slider","switch","table","tabs","textarea","toast","toggle","toggle-group","toolbar","tooltip"]);function _(e){if(!e)return e;let t=e.split("/");return t[t.length-1]||e}function Y(e){let t=e.trim();return t&&((t.startsWith("@/")||t.startsWith("~/"))&&(t=`src/${t.slice(2)}`),t.startsWith("/")&&(t=t.slice(1)),t=t.replace(/^\.\//,""),t=t.replace(/\/+$/,""),t)}function N(e){let t=_(e);return t==="ui"?"love-ui":t}function q(e){let t=e.loveui??{},n=typeof t.target=="string"?t.target.trim():"",s=t.category;if(n){let i=typeof t.includePackageName=="boolean"?t.includePackageName:!1;return{base:n.replace(/\/+$/,""),includePackageName:i}}return s==="feature"?{base:"components",includePackageName:!0}:s==="block"?{base:"components/blocks",includePackageName:!0}:{base:"components/ui",includePackageName:!0}}function G(e,t,n){let s=e.startsWith("src/")?e.slice(4):e;if(!t.includePackageName){let g=t.base.split("/").filter(Boolean),p=g[g.length-1];p&&s.startsWith(`${p}/`)&&(s=s.slice(p.length+1))}let l=`${(t.includePackageName?`${t.base}/${n}`:t.base).replace(/\/+/g,"/")}/${s}`.replace(/\/+/g,"/");return{cleanedPath:s,target:l}}async function K(e){let t=a.join(e,"components.json");try{let n=await $(t,"utf8"),i=JSON.parse(n).aliases?.components;return i?Y(i):null}catch{return null}}async function Q(e){let t=["tsconfig.json","jsconfig.json"].map(n=>a.join(e,n)).find(n=>P(n));if(t)try{let n=await $(t,"utf8"),i=JSON.parse(n).compilerOptions?.paths;if(i&&typeof i=="object")for(let r of Object.keys(i)){let l=i[r];if(r==="@/*"&&Array.isArray(l)&&l.some(g=>g.startsWith("src/")||g.startsWith("./src/")))return"src/components";if(r==="@/*"&&Array.isArray(l)&&l.some(g=>g.startsWith("app/")||g.startsWith("./app/")))return"app/components"}}catch{}return P(a.join(e,"src"))?"src/components":P(a.join(e,"app"))?"app/components":"components"}function E(e,t,n){let s=r=>{let l=r.startsWith("/"),g=r.endsWith("/"),p=r.split("/").filter(Boolean),u=[];for(let w of p)u[u.length-1]!==w&&u.push(w);let d=u.join("/");return`${l?"/":""}${d}${g?"/":""}`};if(n)return s(e);let i=t.replace(/\/+$/,"");if(e.startsWith("components/")){let r=e.slice(10);return s(`${i}${r}`.replace(/^\//,""))}if(e.startsWith("lib/")){if(i.startsWith("src/"))return s(`src/${e}`);if(i.startsWith("app/"))return s(`app/${e}`)}return e.startsWith("ui/")?s(`${i}/${e}`):s(e)}async function T(e,t){let n=a.dirname(a.join(t,e));await U(n,{recursive:!0})}async function Z(e,t){let n=a.join(e,"package.json"),s={};try{let p=await $(n,"utf8");s=JSON.parse(p)}catch{}let i=q(s),r=_(t),l=[];async function g(p,u){let d=await z(p,{withFileTypes:!0});for(let w of d){if(V.has(w.name))continue;let j=a.join(p,w.name);if(w.isDirectory()){await g(j,u);continue}let F=a.extname(w.name);if(!H.has(F)||w.name==="package.json")continue;let R=a.relative(u,j).split(a.sep).join("/"),{target:x}=G(R,i,r),v=await $(j,"utf8");l.push({path:R,target:x,content:v})}}return await g(e,e),l}async function ee(e){let t=a.join(C,"love-ui"),n=a.join(t,"src","ui",`${e}.tsx`);if(!P(n))return null;try{let s=[],i=await $(n,"utf8");i=i.replace(/from\s+["']@loveui\/ui\/lib\/utils["']/g,'from "@/lib/utils"'),s.push({path:`src/ui/${e}.tsx`,target:`components/ui/${e}.tsx`,content:i});let r=a.join(t,"src","lib","utils.ts");if(P(r)){let l=await $(r,"utf8");s.push({path:"src/lib/utils.ts",target:"lib/utils.ts",content:l})}return s}catch(s){return console.warn(`Warning: unable to read ${e} component`,s),null}}async function te(e){if(A.has(e))return await ee(e);let t=N(e),n=a.join(C,t);if(!P(n))return null;try{return await Z(n,e)}catch(s){return console.warn(`Warning: unable to read bundled sources for ${e}`,s),null}}var ne={"@base-ui-components/react":"1.0.0-beta.4","class-variance-authority":"^0.7.1",clsx:"^2.1.1","tailwind-merge":"^3.3.1"};async function se(e){if(A.has(e))return{...ne};let t=N(e),n=a.join(C,t,"package.json");try{let s=await $(n,"utf8");return JSON.parse(s).dependencies??{}}catch{return{}}}async function ie(e){return P(a.join(e,"bun.lockb"))?"bun":P(a.join(e,"pnpm-lock.yaml"))?"pnpm":P(a.join(e,"yarn.lock"))?"yarn":"npm"}async function oe(e,t,n){let s=Object.entries(e);if(s.length===0)return!0;console.log(`
3
+ Installing dependencies...`);let i=s.map(([g,p])=>`${g}@${p}`),r;switch(t){case"bun":r=`bun add ${i.join(" ")}`;break;case"pnpm":r=`pnpm add ${i.join(" ")}`;break;case"yarn":r=`yarn add ${i.join(" ")}`;break;default:r=`npm install ${i.join(" ")}`}let l=I(r,{stdio:"inherit",shell:!0,cwd:n});return l.error||l.status!==0?(console.warn(`
4
4
  Failed to install dependencies. You may need to install them manually:`),console.warn(` ${i.join(`
5
5
  `)}`),!1):(console.log(`Dependencies installed successfully!
6
- `),!0)}async function Z(t=process.argv.slice(2)){(t.length===0||t.length===1&&(t[0]==="--version"||t[0]==="-v"))&&(console.log("love-ui version 1.1.9"),process.exit(0)),(t.length<2||t[0]!=="add")&&(console.log("Usage: npx love-ui add [...packages]"),console.log(" npx love-ui --version"),process.exit(1));let e=t.slice(1),n=process.cwd(),s=await I(n),i=await B(n),o=s??i,c=s!==null,u=await q(n),g={};for(let l of e){if(!l.trim())continue;console.log(`
7
- Adding ${l}...`);let f=null,m=null;if(l.startsWith("http://")||l.startsWith("https://"))try{let a=await fetch(l);a.ok?f=await a.json():console.warn(`Failed to fetch ${l}: HTTP ${a.status}`)}catch(a){console.warn(`Failed to fetch from ${l}:`,a)}else{let a=new URL(`r/${l}.json`,"https://www.loveui.dev/");try{let p=await fetch(a);p.ok&&(f=await p.json())}catch{}m=await G(l)}let h=m??f?.files??[];h=h.map(a=>{let p=a.target||a.path;return p.startsWith("registry/default/")&&(p=p.replace("registry/default/","")),{...a,target:p}});let $=h.find(a=>a.target.match(/^components\/comp-\d+\.tsx$/));if($){let a=h.filter(p=>p.target.match(/^components\/[^/]+\//)&&p.target!==$.target);if(a.length>0&&a[0]){let p=a[0].target.match(/^components\/([^/]+)\//);if(p&&p[1]){let k=p[1];$.target=`components/${k}-demo.tsx`}}}if(!h.length){console.warn(`Component "${l}" not found. Available components can be found at https://loveui.dev`);continue}c||await v(r.join(n,o),{recursive:!0});let w=0,j=0;for(let a of h){if(!a.content)continue;let p=M(a.target,o,c),k=r.join(n,p),x=y(k),d=a.content;if(d=d.replace(/@\/registry\/building-blocks\/default\/components\//g,"@/components/"),d=d.replace(/@\/registry\/building-blocks\/default\/ui\//g,"@/components/ui/"),d=d.replace(/@\/registry\/building-blocks\/default\/lib\//g,"@/lib/"),d=d.replace(/@\/registry\/default\/components\//g,"@/components/"),d=d.replace(/@\/registry\/default\/ui\//g,"@/components/ui/"),d=d.replace(/@\/registry\/default\/lib\//g,"@/lib/"),x)try{if(await b(k,"utf8")===d)continue}catch{}await X(p,n),await S(k,d,"utf8"),x?j++:w++}w>0&&console.log(`\u2713 Created ${w} file${w>1?"s":""}`),j>0&&console.log(`\u2713 Updated ${j} file${j>1?"s":""}`);let P={};f?.dependencies?Array.isArray(f.dependencies)?f.dependencies.forEach(a=>{P[a]="latest"}):P=f.dependencies:P=await K(l),Object.assign(g,P)}Object.keys(g).length>0&&await Q(g,u,n),console.log(`
8
- \u2713 Done! You can now import and use the components in your app.`)}var tt=process.argv[1]&&(import.meta.url===T(process.argv[1]).href||process.argv[1].includes("love-ui")||process.argv[1].includes("loveui"));tt&&Z().catch(t=>{console.error(t),process.exit(1)});export{Z as run};
6
+ `),!0)}async function re(e=process.argv.slice(2)){(e.length===0||e.length===1&&(e[0]==="--version"||e[0]==="-v"))&&(console.log("love-ui version 1.1.9"),process.exit(0)),(e.length<2||e[0]!=="add")&&(console.log("Usage: npx love-ui add [...packages]"),console.log(" npx love-ui --version"),process.exit(1));let t=e.slice(1),n=process.cwd(),s=await K(n),i=await Q(n),r=s??i,l=s!==null,g=await ie(n),p={};for(let u of t){if(!u.trim())continue;console.log(`
7
+ Adding ${u}...`);let d=null,w=null;if(u.startsWith("http://")||u.startsWith("https://"))try{let o=await fetch(u);o.ok?d=await o.json():console.warn(`Failed to fetch ${u}: HTTP ${o.status}`)}catch(o){console.warn(`Failed to fetch from ${u}:`,o)}else{let o=new URL(`r/${u}.json`,"https://www.loveui.dev/");try{let c=await fetch(o);c.ok&&(d=await c.json())}catch{}w=await te(u)}let j=w??d?.files??[];j=j.map(o=>{let c=o.target||o.path;return c.startsWith("registry/default/")&&(c=c.replace("registry/default/","")),{...o,target:c}});let F=j.find(o=>o.target.match(/^components\/comp-\d+\.tsx$/));if(F){let o=j.filter(c=>c.target.match(/^components\/[^/]+\//)&&c.target!==F.target);if(o.length>0&&o[0]){let c=o[0].target.match(/^components\/([^/]+)\//);if(c&&c[1]){let h=c[1];F.target=`components/${h}-demo.tsx`}}}if(!j.length){console.warn(`Component "${u}" not found. Available components can be found at https://loveui.dev`);continue}l||await U(a.join(n,r),{recursive:!0});let R=0,x=0;for(let o of j){if(!o.content)continue;let c=E(o.target,r,l),h=a.join(n,c),k=P(h),f=o.content;if(f=f.replace(/@\/registry\/building-blocks\/default\/components\//g,"@/components/"),f=f.replace(/@\/registry\/building-blocks\/default\/ui\//g,"@/components/ui/"),f=f.replace(/@\/registry\/building-blocks\/default\/lib\//g,"@/lib/"),f=f.replace(/@\/registry\/default\/components\//g,"@/components/"),f=f.replace(/@\/registry\/default\/ui\//g,"@/components/ui/"),f=f.replace(/@\/registry\/default\/lib\//g,"@/lib/"),k)try{if(await $(h,"utf8")===f)continue}catch{}await T(c,n),await S(h,f,"utf8"),k?x++:R++}if(R>0&&console.log(`\u2713 Created ${R} file${R>1?"s":""}`),x>0&&console.log(`\u2713 Updated ${x} file${x>1?"s":""}`),d?.registryDependencies&&d.registryDependencies.length>0){console.log(`
8
+ Installing ${d.registryDependencies.length} required component${d.registryDependencies.length>1?"s":""}...`);for(let o of d.registryDependencies){let c=o;o.startsWith("https://loveui.dev/building-blocks/r/")&&(c=`https://ui.loveui.dev/ui/r/${o.split("/").pop()}`);try{let h=await fetch(c);if(h.ok){let k=await h.json(),W=(k?.files??[]).map(m=>{let b=m.target||m.path;return b.startsWith("registry/default/")&&(b=b.replace("registry/default/","")),{...m,target:b}});for(let m of W){if(!m.content)continue;let b=E(m.target,r,l),D=a.join(n,b),L=P(D),y=m.content;if(y=y.replace(/@\/registry\/building-blocks\/default\/components\//g,"@/components/"),y=y.replace(/@\/registry\/building-blocks\/default\/ui\//g,"@/components/ui/"),y=y.replace(/@\/registry\/building-blocks\/default\/lib\//g,"@/lib/"),y=y.replace(/@\/registry\/default\/components\//g,"@/components/"),y=y.replace(/@\/registry\/default\/ui\//g,"@/components/ui/"),y=y.replace(/@\/registry\/default\/lib\//g,"@/lib/"),L)try{if(await $(D,"utf8")===y)continue}catch{}await T(b,n),await S(D,y,"utf8")}let O=["@loveui/shadcn-ui","jotai","lucide-react","react","react-dom"];if(k?.dependencies)if(Array.isArray(k.dependencies))k.dependencies.forEach(m=>{O.includes(m)||(p[m]="latest")});else{let m=k.dependencies;Object.keys(m).forEach(b=>{!O.includes(b)&&m[b]&&(p[b]=m[b])})}}else console.warn(` \u2717 Failed to fetch ${c}: HTTP ${h.status}`)}catch(h){console.warn(` \u2717 Failed to install ${c}:`,h.message)}}console.log("\u2713 Installed registry dependencies")}let v={};d?.dependencies?Array.isArray(d.dependencies)?d.dependencies.forEach(o=>{v[o]="latest"}):v=d.dependencies:v=await se(u),Object.assign(p,v)}Object.keys(p).length>0&&await oe(p,g,n),console.log(`
9
+ \u2713 Done! You can now import and use the components in your app.`)}var ae=process.argv[1]&&(import.meta.url===J(process.argv[1]).href||process.argv[1].includes("love-ui")||process.argv[1].includes("loveui"));ae&&re().catch(e=>{console.error(e),process.exit(1)});export{re as run};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Server as ge}from"@modelcontextprotocol/sdk/server";var L={name:"love-ui",version:"1.2.1",private:!1,license:"AGPL-3.0-or-later",type:"module",bin:{loveui:"dist/index.js","love-ui":"dist/index.js","loveui-mcp":"dist/mcp-server.js"},files:["dist","packages","*.ts","*.tsx","*.css","*.mdx"],main:"packages/love-ui/index.ts",types:"packages/love-ui/index.ts",exports:{".":{import:"./packages/love-ui/index.ts",require:"./packages/love-ui/index.ts"},"./lib/*":"./packages/love-ui/*","./components/*":"./packages/love-ui/components/*","./shadcn-ui/*":"./packages/shadcn-ui/*","./package.json":"./package.json"},dependencies:{"@modelcontextprotocol/sdk":"^1.18.1",postcss:"^8.5.6","postcss-nested":"^7.0.2"},scripts:{build:"tsup",postbuild:"node ./scripts/copy-packages.mjs",clean:"rimraf dist packages"},devDependencies:{"@types/node":"^20.14.10",rimraf:"^6.0.1",tsup:"^8.5.0"}};import{constants as X}from"fs";import{access as H,readFile as N,readdir as C}from"fs/promises";import D,{extname as W,join as P,relative as V}from"path";import{fileURLToPath as Y}from"url";import A from"postcss";import Q from"postcss-nested";var Z=D.dirname(Y(import.meta.url)),ee=D.resolve(Z,".."),U=D.join(ee,"packages"),te=new Set([".turbo",".next",".git","dist","build","storybook-static","node_modules","__tests__","__mocks__","coverage"]),se=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".json",".css",".scss",".sass",".mdx"]),ne=new Set(["package.json","tsconfig.json","tsconfig.build.json","tsconfig.test.json","README.md",".DS_Store"]),ie=new Set(["shadcn-ui","typescript-config","patterns","loveui","love-ui"]),re=e=>e.replace(/\\/g,"/"),J=async(e,s,t)=>{let n=await C(e,{withFileTypes:!0});for(let i of n){let o=P(e,i.name);if(i.isDirectory()){if(te.has(i.name))continue;await J(o,s,t);continue}let d=W(i.name);!se.has(d)||ne.has(i.name)||i.name.endsWith(".d.ts")||i.name.endsWith(".test.ts")||i.name.endsWith(".test.tsx")||i.name.endsWith(".stories.tsx")||t.push({absolute:o,relative:re(V(s,o))})}},oe=(e,s)=>{let t=e.loveui??{},n=typeof t.target=="string"?t.target.trim():"",i=t.category;if(n.length>0){let o=typeof t.includePackageName=="boolean"?t.includePackageName:!1;return{base:n.replace(/\/+$/,""),includePackageName:o}}return i==="feature"?{base:"components",includePackageName:!0}:i==="block"?{base:"components/blocks",includePackageName:!0}:{base:"components/ui",includePackageName:!0}},ae=e=>{let t=(e.loveui??{}).type;return typeof t=="string"&&t.trim().length>0?t:"registry:ui"},ce=async e=>{try{return await H(e,X.F_OK),!0}catch{return!1}},le=e=>e.startsWith("@loveui/")||e.startsWith("@repo/"),pe=e=>e.replace(/^@repo\//,"").replace(/^@loveui\//,""),G=async()=>(await C(U,{withFileTypes:!0})).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>!ie.has(s)).sort((s,t)=>s.localeCompare(t)),E=async e=>{let s=P(U,e),t=P(s,"package.json");if(!await ce(t))throw new Error(`Missing package.json for ${e}`);let n=JSON.parse(await N(t,"utf8")),i=ae(n),o=Object.keys(n.dependencies??{}),d=Object.keys(n.peerDependencies??{}),O=Object.keys(n.devDependencies??{}),k=new Set([...o,...d,...O].filter(le).filter(r=>r!=="@loveui/shadcn-ui")),T=[...new Set([...o,...d].filter(r=>!k.has(r)))],_=[...new Set(O.filter(r=>!k.has(r)&&!["@loveui/typescript-config","@types/react","@types/react-dom","typescript"].includes(r)))],w=[];for(let r of k){let m=pe(r);w.push(`https://www.loveui.dev/r/${m}.json`)}let I=[];await J(s,s,I);let u=[],c={},p=oe(n,e);for(let r of I){let m=await N(r.absolute,"utf8"),R=W(r.absolute);if(R===".css"||R===".scss"||R===".sass"){let y=await A([Q]).process(m,{from:void 0});A.parse(y.css).walkAtRules("layer",b=>{let j=`@layer ${b.params}`;c[j]??={},b.walkRules(a=>{if(a.parent&&a.parent.type==="atrule"&&a.parent.name==="media")return;let h=a.selector,l={};a.walkDecls(v=>{l[v.prop]=v.value}),Object.keys(l).length>0&&(c[j][h]=l)}),b.walkAtRules("media",a=>{let h=`@media ${a.params}`,l=c[j];l[h]??={};let v=l[h];a.walkRules($=>{let B=$.selector,x={};$.walkDecls(F=>{x[F.prop]=F.value}),Object.keys(x).length>0&&(v[B]=x)})})});continue}let g=r.relative.startsWith("src/")?r.relative.slice(4):r.relative;if(!p.includePackageName){let y=p.base.split("/").filter(Boolean),f=y[y.length-1];f&&g.startsWith(`${f}/`)&&(g=g.slice(f.length+1))}let q=e.includes("/")?e.split("/").pop()??e:e,z=(p.includePackageName?`${p.base}/${q}`:p.base).replace(/\/+$/,"");u.push({type:i,path:g,target:`${z}/${g}`.replace(/\/+/g,"/"),content:m})}let K=!u.length&&Object.keys(c).length>0?"registry:style":i;return{$schema:"https://ui.shadcn.com/schema/registry-item.json",name:e,type:K,title:n.title??e,description:n.description,author:n.author??"Connor Love <hello@loveconnor.com>",dependencies:T.length?T:void 0,devDependencies:_.length?_:void 0,registryDependencies:w.length?Array.from(new Set(w)):void 0,files:u.length?u:void 0,css:Object.keys(c).length?c:void 0}};var S="loveui://registry/",de=e=>`${S}${e}`;async function ue(){let e=new ge({name:"loveui-mcp",version:L.version??"0.0.0"});e.addResourceProvider({name:"loveui-registry",listResources:async()=>(await G()).map(t=>({uri:de(t),name:t,description:`loveui registry definition for ${t}`,mimeType:"application/json"})),readResource:async s=>{if(!s.startsWith(S))throw new Error(`Unsupported resource URI: ${s}`);let t=s.slice(S.length),n=await E(t);return{contents:[{uri:s,mimeType:"application/json",text:JSON.stringify(n,null,2)}]}}}),e.addTool({name:"get-loveui-package",description:"Fetch a loveui registry definition by package name.",inputSchema:{type:"object",additionalProperties:!1,properties:{name:{type:"string",description:"Package name, e.g. badge"}},required:["name"]},handler:async s=>{let t=s?.name;if(typeof t!="string"||t.trim()==="")throw new Error("Package name is required.");let n=await E(t);return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}}),await e.start()}ue().catch(e=>{console.error(e),process.exit(1)});
2
+ import{Server as ge}from"@modelcontextprotocol/sdk/server";var L={name:"love-ui",version:"1.2.3",private:!1,license:"AGPL-3.0-or-later",type:"module",bin:{loveui:"dist/index.js","love-ui":"dist/index.js","loveui-mcp":"dist/mcp-server.js"},files:["dist","packages","*.ts","*.tsx","*.css","*.mdx"],main:"packages/love-ui/index.ts",types:"packages/love-ui/index.ts",exports:{".":{import:"./packages/love-ui/index.ts",require:"./packages/love-ui/index.ts"},"./lib/*":"./packages/love-ui/*","./components/*":"./packages/love-ui/components/*","./shadcn-ui/*":"./packages/shadcn-ui/*","./package.json":"./package.json"},dependencies:{"@modelcontextprotocol/sdk":"^1.18.1",postcss:"^8.5.6","postcss-nested":"^7.0.2"},scripts:{build:"tsup",postbuild:"node ./scripts/copy-packages.mjs",clean:"rimraf dist packages"},devDependencies:{"@types/node":"^20.14.10",rimraf:"^6.0.1",tsup:"^8.5.0"}};import{constants as X}from"fs";import{access as H,readFile as N,readdir as C}from"fs/promises";import D,{extname as W,join as P,relative as V}from"path";import{fileURLToPath as Y}from"url";import A from"postcss";import Q from"postcss-nested";var Z=D.dirname(Y(import.meta.url)),ee=D.resolve(Z,".."),U=D.join(ee,"packages"),te=new Set([".turbo",".next",".git","dist","build","storybook-static","node_modules","__tests__","__mocks__","coverage"]),se=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".json",".css",".scss",".sass",".mdx"]),ne=new Set(["package.json","tsconfig.json","tsconfig.build.json","tsconfig.test.json","README.md",".DS_Store"]),ie=new Set(["shadcn-ui","typescript-config","patterns","loveui","love-ui"]),re=e=>e.replace(/\\/g,"/"),J=async(e,s,t)=>{let n=await C(e,{withFileTypes:!0});for(let i of n){let o=P(e,i.name);if(i.isDirectory()){if(te.has(i.name))continue;await J(o,s,t);continue}let d=W(i.name);!se.has(d)||ne.has(i.name)||i.name.endsWith(".d.ts")||i.name.endsWith(".test.ts")||i.name.endsWith(".test.tsx")||i.name.endsWith(".stories.tsx")||t.push({absolute:o,relative:re(V(s,o))})}},oe=(e,s)=>{let t=e.loveui??{},n=typeof t.target=="string"?t.target.trim():"",i=t.category;if(n.length>0){let o=typeof t.includePackageName=="boolean"?t.includePackageName:!1;return{base:n.replace(/\/+$/,""),includePackageName:o}}return i==="feature"?{base:"components",includePackageName:!0}:i==="block"?{base:"components/blocks",includePackageName:!0}:{base:"components/ui",includePackageName:!0}},ae=e=>{let t=(e.loveui??{}).type;return typeof t=="string"&&t.trim().length>0?t:"registry:ui"},ce=async e=>{try{return await H(e,X.F_OK),!0}catch{return!1}},le=e=>e.startsWith("@loveui/")||e.startsWith("@repo/"),pe=e=>e.replace(/^@repo\//,"").replace(/^@loveui\//,""),G=async()=>(await C(U,{withFileTypes:!0})).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>!ie.has(s)).sort((s,t)=>s.localeCompare(t)),E=async e=>{let s=P(U,e),t=P(s,"package.json");if(!await ce(t))throw new Error(`Missing package.json for ${e}`);let n=JSON.parse(await N(t,"utf8")),i=ae(n),o=Object.keys(n.dependencies??{}),d=Object.keys(n.peerDependencies??{}),O=Object.keys(n.devDependencies??{}),k=new Set([...o,...d,...O].filter(le).filter(r=>r!=="@loveui/shadcn-ui")),T=[...new Set([...o,...d].filter(r=>!k.has(r)))],_=[...new Set(O.filter(r=>!k.has(r)&&!["@loveui/typescript-config","@types/react","@types/react-dom","typescript"].includes(r)))],w=[];for(let r of k){let m=pe(r);w.push(`https://www.loveui.dev/r/${m}.json`)}let I=[];await J(s,s,I);let u=[],c={},p=oe(n,e);for(let r of I){let m=await N(r.absolute,"utf8"),R=W(r.absolute);if(R===".css"||R===".scss"||R===".sass"){let y=await A([Q]).process(m,{from:void 0});A.parse(y.css).walkAtRules("layer",b=>{let j=`@layer ${b.params}`;c[j]??={},b.walkRules(a=>{if(a.parent&&a.parent.type==="atrule"&&a.parent.name==="media")return;let h=a.selector,l={};a.walkDecls(v=>{l[v.prop]=v.value}),Object.keys(l).length>0&&(c[j][h]=l)}),b.walkAtRules("media",a=>{let h=`@media ${a.params}`,l=c[j];l[h]??={};let v=l[h];a.walkRules($=>{let B=$.selector,x={};$.walkDecls(F=>{x[F.prop]=F.value}),Object.keys(x).length>0&&(v[B]=x)})})});continue}let g=r.relative.startsWith("src/")?r.relative.slice(4):r.relative;if(!p.includePackageName){let y=p.base.split("/").filter(Boolean),f=y[y.length-1];f&&g.startsWith(`${f}/`)&&(g=g.slice(f.length+1))}let q=e.includes("/")?e.split("/").pop()??e:e,z=(p.includePackageName?`${p.base}/${q}`:p.base).replace(/\/+$/,"");u.push({type:i,path:g,target:`${z}/${g}`.replace(/\/+/g,"/"),content:m})}let K=!u.length&&Object.keys(c).length>0?"registry:style":i;return{$schema:"https://ui.shadcn.com/schema/registry-item.json",name:e,type:K,title:n.title??e,description:n.description,author:n.author??"Connor Love <hello@loveconnor.com>",dependencies:T.length?T:void 0,devDependencies:_.length?_:void 0,registryDependencies:w.length?Array.from(new Set(w)):void 0,files:u.length?u:void 0,css:Object.keys(c).length?c:void 0}};var S="loveui://registry/",de=e=>`${S}${e}`;async function ue(){let e=new ge({name:"loveui-mcp",version:L.version??"0.0.0"});e.addResourceProvider({name:"loveui-registry",listResources:async()=>(await G()).map(t=>({uri:de(t),name:t,description:`loveui registry definition for ${t}`,mimeType:"application/json"})),readResource:async s=>{if(!s.startsWith(S))throw new Error(`Unsupported resource URI: ${s}`);let t=s.slice(S.length),n=await E(t);return{contents:[{uri:s,mimeType:"application/json",text:JSON.stringify(n,null,2)}]}}}),e.addTool({name:"get-loveui-package",description:"Fetch a loveui registry definition by package name.",inputSchema:{type:"object",additionalProperties:!1,properties:{name:{type:"string",description:"Package name, e.g. badge"}},required:["name"]},handler:async s=>{let t=s?.name;if(typeof t!="string"||t.trim()==="")throw new Error("Package name is required.");let n=await E(t);return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}}),await e.start()}ue().catch(e=>{console.error(e),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "love-ui",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",