@tempots/beatui 0.83.0 → 0.83.3

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.
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("node:fs"),u=require("node:path"),P=require("../index-DH37GTQj.cjs"),I=require("node:fs/promises"),Q=require("node:crypto");var x=typeof document<"u"?document.currentScript:null;const X="https://fonts.googleapis.com/css2",M="normal",K=400,W="Mozilla/5.0 (compatible; BeatUI Tailwind Plugin; +https://tempots.com)";async function Y(e){const{projectRoot:s,requests:t,logger:r}=e;if(!t||t.length===0)return null;const a=e.cacheDir?u.resolve(e.cacheDir):u.join(s,"node_modules",".beatui","google-fonts"),n=[],o=new Map;await I.mkdir(a,{recursive:!0}).catch(g=>{r?.(`Unable to create BeatUI Google Fonts cache directory: ${g}`)});for(const g of t)try{const l=z(g),f=await Z({request:g,cssUrl:l,cacheRoot:a,logger:r});if(!f)continue;const p=await re({cssText:f,cacheRoot:a,assetMap:o,logger:r});n.push(p)}catch(l){r?.(`Unexpected error while downloading Google Font "${g.family}": ${String(l)}`)}return n.length===0||o.size===0?null:{cssText:n.join(`
2
- `),assets:Array.from(o.values())}}async function Z({request:e,cssUrl:s,cacheRoot:t,logger:r}){const a=u.join(t,q(e,s));try{const n=await fetch(s,{headers:{"User-Agent":W}});if(!n.ok)throw new Error(`Failed to download Google Font CSS: ${n.status} ${n.statusText}`);const o=await n.text();return await I.writeFile(a,o),o}catch(n){if(y.existsSync(a))try{const o=await I.readFile(a,"utf8");return r?.(`Using cached Google Font CSS for ${e.family} because download failed.`),o}catch(o){r?.(`Failed to read cached Google Font CSS for ${e.family}: ${o}`)}return r?.(`Unable to download Google Font CSS for ${e.family}: ${n}`),null}}function q(e,s){const t=Q.createHash("sha1").update(s).digest("hex").slice(0,10);return`${e.family.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-")||"font"}-${t}.css`}function z(e){const{family:s}=e,t=s.trim().replace(/\s+/g," "),r=ee(e.weights),a=te(e.styles),n=new URLSearchParams;return n.append("family",se(t,r,a)),e.display&&n.append("display",e.display),e.subsets&&e.subsets.length>0&&n.append("subset",e.subsets.join(",")),e.text&&n.append("text",e.text),`${X}?${n.toString()}`}function ee(e){return!e||e.length===0?[]:Array.from(new Set(e)).sort((s,t)=>s-t)}function te(e){if(!e||e.length===0)return[M];const s=Array.from(new Set(e)),t=s.includes("italic"),r=s.includes("normal");return!t&&!r&&s.push(M),s.sort((a,n)=>a===n?0:a==="normal"?-1:1)}function se(e,s,t){if(s.length===0&&t.every(l=>l==="normal"))return e;const r=t.includes("italic"),a=t.includes("normal"),n=s.length>0?s:[K];if(!r)return`${e}:wght@${n.join(";")}`;const o=new Set;a&&n.forEach(l=>{o.add(`0,${l}`)}),n.forEach(l=>{o.add(`1,${l}`)});const g=Array.from(o).sort((l,f)=>{const[p,C]=l.split(",").map(Number),[T,v]=f.split(",").map(Number);return p-T||C-v});return`${e}:ital,wght@${g.join(";")}`}const ne=/url\(([^)]+)\)/g;async function re({cssText:e,cacheRoot:s,assetMap:t,logger:r}){let a=e;const n=new Set;let o;for(;(o=ne.exec(e))!==null;){const l=o[1].trim().replace(/^['"]|['"]$/g,"");l.startsWith("http")&&n.add(l)}for(const g of n){const l=await ae(g,s,t,r);if(!l)continue;const f=g.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),p=new RegExp(`url\\((['"])${f}\\1\\)`,"g"),C=new RegExp(`url\\(${f}\\)`,"g");a=a.replace(p,`url(${l.placeholder})`),a=a.replace(C,`url(${l.placeholder})`)}return a}async function ae(e,s,t,r){const a=t.get(e);if(a)return a;let n;try{const f=new URL(e);n=u.basename(f.pathname)}catch(f){return r?.(`Invalid Google Font URL skipped: ${e} (${f})`),null}if(!n)return r?.(`Unable to derive file name for Google Font URL: ${e}`),null;const o=u.join(s,n),g=`__BEATUI_GOOGLE_FONT_${t.size}__`;if(!y.existsSync(o))try{const f=await fetch(e,{headers:{"User-Agent":W}});if(!f.ok)return r?.(`Failed to download Google Font asset ${n}: ${f.status} ${f.statusText}`),null;const p=Buffer.from(await f.arrayBuffer());await I.writeFile(o,p)}catch(f){return r?.(`Unexpected error while downloading Google Font asset ${n}: ${String(f)}`),null}const l={url:e,fileName:n,localPath:o,placeholder:g};return t.set(e,l),l}function V(e){const s=typeof e=="string"?new URL(e):e;if(s.protocol!=="file:")throw new TypeError(`Expected file URL, received: ${s.href}`);const t=s.hostname,r=t===""||t==="localhost",a=decodeURIComponent(s.pathname);if(process.platform==="win32"){let n=a.replace(/\//g,"\\");return!r&&t?`\\\\${t}${n}`:(n.startsWith("\\")&&(n=n.slice(1)),n)}return!r&&t?`//${t}${a}`:a}const B="@tempots/beatui/tailwind.css",b="beatui.tailwind.css",w=u.dirname(V(typeof document>"u"?require("url").pathToFileURL(__filename).href:x&&x.tagName.toUpperCase()==="SCRIPT"&&x.src||new URL("tailwind/vite-plugin.cjs.js",document.baseURI).href)),j=oe(w)??w;function A(e){if(Object.keys(e).length===0)return"";let s=`:root {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("node:fs"),u=require("node:path"),P=require("../index-DH37GTQj.cjs"),I=require("node:fs/promises"),Q=require("node:crypto");var A=typeof document<"u"?document.currentScript:null;const X="https://fonts.googleapis.com/css2",M="normal",K=400,W="Mozilla/5.0 (compatible; BeatUI Tailwind Plugin; +https://tempots.com)";async function Y(e){const{projectRoot:s,requests:t,logger:r}=e;if(!t||t.length===0)return null;const a=e.cacheDir?u.resolve(e.cacheDir):u.join(s,"node_modules",".beatui","google-fonts"),n=[],o=new Map;await I.mkdir(a,{recursive:!0}).catch(m=>{r?.(`Unable to create BeatUI Google Fonts cache directory: ${m}`)});for(const m of t)try{const l=z(m),f=await Z({request:m,cssUrl:l,cacheRoot:a,logger:r});if(!f)continue;const p=await re({cssText:f,cacheRoot:a,assetMap:o,logger:r});n.push(p)}catch(l){r?.(`Unexpected error while downloading Google Font "${m.family}": ${String(l)}`)}return n.length===0||o.size===0?null:{cssText:n.join(`
2
+ `),assets:Array.from(o.values())}}async function Z({request:e,cssUrl:s,cacheRoot:t,logger:r}){const a=u.join(t,q(e,s));try{const n=await fetch(s,{headers:{"User-Agent":W}});if(!n.ok)throw new Error(`Failed to download Google Font CSS: ${n.status} ${n.statusText}`);const o=await n.text();return await I.writeFile(a,o),o}catch(n){if(S.existsSync(a))try{const o=await I.readFile(a,"utf8");return r?.(`Using cached Google Font CSS for ${e.family} because download failed.`),o}catch(o){r?.(`Failed to read cached Google Font CSS for ${e.family}: ${o}`)}return r?.(`Unable to download Google Font CSS for ${e.family}: ${n}`),null}}function q(e,s){const t=Q.createHash("sha1").update(s).digest("hex").slice(0,10);return`${e.family.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-")||"font"}-${t}.css`}function z(e){const{family:s}=e,t=s.trim().replace(/\s+/g," "),r=ee(e.weights),a=te(e.styles),n=new URLSearchParams;return n.append("family",se(t,r,a)),e.display&&n.append("display",e.display),e.subsets&&e.subsets.length>0&&n.append("subset",e.subsets.join(",")),e.text&&n.append("text",e.text),`${X}?${n.toString()}`}function ee(e){return!e||e.length===0?[]:Array.from(new Set(e)).sort((s,t)=>s-t)}function te(e){if(!e||e.length===0)return[M];const s=Array.from(new Set(e)),t=s.includes("italic"),r=s.includes("normal");return!t&&!r&&s.push(M),s.sort((a,n)=>a===n?0:a==="normal"?-1:1)}function se(e,s,t){if(s.length===0&&t.every(l=>l==="normal"))return e;const r=t.includes("italic"),a=t.includes("normal"),n=s.length>0?s:[K];if(!r)return`${e}:wght@${n.join(";")}`;const o=new Set;a&&n.forEach(l=>{o.add(`0,${l}`)}),n.forEach(l=>{o.add(`1,${l}`)});const m=Array.from(o).sort((l,f)=>{const[p,C]=l.split(",").map(Number),[T,v]=f.split(",").map(Number);return p-T||C-v});return`${e}:ital,wght@${m.join(";")}`}const ne=/url\(([^)]+)\)/g;async function re({cssText:e,cacheRoot:s,assetMap:t,logger:r}){let a=e;const n=new Set;let o;for(;(o=ne.exec(e))!==null;){const l=o[1].trim().replace(/^['"]|['"]$/g,"");l.startsWith("http")&&n.add(l)}for(const m of n){const l=await ae(m,s,t,r);if(!l)continue;const f=m.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),p=new RegExp(`url\\((['"])${f}\\1\\)`,"g"),C=new RegExp(`url\\(${f}\\)`,"g");a=a.replace(p,`url(${l.placeholder})`),a=a.replace(C,`url(${l.placeholder})`)}return a}async function ae(e,s,t,r){const a=t.get(e);if(a)return a;let n;try{const f=new URL(e);n=u.basename(f.pathname)}catch(f){return r?.(`Invalid Google Font URL skipped: ${e} (${f})`),null}if(!n)return r?.(`Unable to derive file name for Google Font URL: ${e}`),null;const o=u.join(s,n),m=`__BEATUI_GOOGLE_FONT_${t.size}__`;if(!S.existsSync(o))try{const f=await fetch(e,{headers:{"User-Agent":W}});if(!f.ok)return r?.(`Failed to download Google Font asset ${n}: ${f.status} ${f.statusText}`),null;const p=Buffer.from(await f.arrayBuffer());await I.writeFile(o,p)}catch(f){return r?.(`Unexpected error while downloading Google Font asset ${n}: ${String(f)}`),null}const l={url:e,fileName:n,localPath:o,placeholder:m};return t.set(e,l),l}function V(e){const s=typeof e=="string"?new URL(e):e;if(s.protocol!=="file:")throw new TypeError(`Expected file URL, received: ${s.href}`);const t=s.hostname,r=t===""||t==="localhost",a=decodeURIComponent(s.pathname);if(process.platform==="win32"){let n=a.replace(/\//g,"\\");return!r&&t?`\\\\${t}${n}`:(n.startsWith("\\")&&(n=n.slice(1)),n)}return!r&&t?`//${t}${a}`:a}const B="@tempots/beatui/tailwind.css",y="beatui.tailwind.css",b=u.dirname(V(typeof document>"u"?require("url").pathToFileURL(__filename).href:A&&A.tagName.toUpperCase()==="SCRIPT"&&A.src||new URL("tailwind/vite-plugin.cjs.js",document.baseURI).href)),G=oe(b)??b;function N(e){if(Object.keys(e).length===0)return"";let s=`:root {
3
3
  `;for(const[t,r]of Object.entries(e))s+=` ${t}: ${r};
4
4
  `;return s+=`}
5
- `,s}function oe(e){let s=e;const t=u.parse(s).root;for(;s&&s!==t;){const r=u.join(s,"package.json");if(y.existsSync(r))try{if(JSON.parse(y.readFileSync(r,"utf8"))?.name==="@tempots/beatui")return s}catch{}s=u.dirname(s)}return null}function ie(e){if(e==null)return null;const s=typeof e=="string"?e:e.id;if(!s)return null;const[t]=s.split("?");return t.startsWith("virtual:")||t.startsWith("\0")?null:t.startsWith("/@fs/")?decodeURIComponent(t.slice(4)):t.startsWith("file://")?V(t):u.isAbsolute(t)?t:null}function le(e){const s=new Set([u.resolve(w,b),u.resolve(w,"../",b),u.resolve(w,"../../",b),u.resolve(w,"tailwind.css"),u.resolve(w,"../tailwind.css"),u.resolve(w,"../../tailwind.css"),u.resolve(w,"../styles/tailwind.css"),u.resolve(w,"../../styles/tailwind.css"),u.resolve(j,"dist",b),u.resolve(j,b),u.resolve(j,"tailwind.css"),u.resolve(j,"src/styles/tailwind.css"),u.resolve(e,"node_modules/@tempots/beatui/tailwind.css")]);for(const t of s)if(y.existsSync(t))return t;return null}function ce(e){return e?Array.isArray(e)?e:[e]:[]}function ue(e,s){let t=e;for(const[r,a]of s)t=t.split(r).join(a);return t}async function de(e,s){const t=e.resolve;if(!t)return null;try{return await t.call(e,s,void 0,{skipSelf:!0})}catch{return null}}function H(e={}){let s=process.cwd();const t=e.injectCss!==!1,r=e.darkClass??"dark",a=e.rtlAttribute??"dir",n=e.rtlValue??"rtl";let o="/";const l=e.semanticColors!=null||e.semanticFonts!=null||e.semanticRadii!=null||e.semanticShadows!=null||e.semanticMotion!=null||e.semanticSpacing!=null||e.semanticTextShadows!=null?A(P.generateSemanticTokenVariables({colors:e.semanticColors,fonts:e.semanticFonts,radii:e.semanticRadii,shadows:e.semanticShadows,motion:e.semanticMotion,spacing:e.semanticSpacing,textShadows:e.semanticTextShadows})):"",f=e.fontFamilies?A(P.generateFontFamilyOverrideVariables(e.fontFamilies)):"",p={};e.baseSpacing&&(p[P.getSpacingVarName("base")]=e.baseSpacing),e.baseFontSize&&(p[P.getBaseFontSizeVarName()]=e.baseFontSize),e.baseMotionDuration&&(p[P.getMotionDurationVarName("base")]=e.baseMotionDuration);const C=A(p),T=ce(e.googleFonts);let v="",U=[];const L=new Map,_=new Map,O=new Map,J="/@beatui/google-fonts",E=[];let G=null,F=null,k=!1;const N=h=>{const c=[C,l,f];return v&&(h==="dev"?c.push(ue(v,L)):c.push(v)),c.filter(d=>d&&d.length>0).join(`
6
- `)};return{name:"beatui-tailwind",enforce:"pre",async configResolved(h){if(s=h.root,k=h.command==="build",o=h.base&&h.base!=="/"?h.base.endsWith("/")?h.base:`${h.base}/`:"/",t){const c=await de(this,B);F=ie(c)??le(s)}if(T.length>0){const c=Array.from(new Set(T.map(z))),d=await Y({projectRoot:s,requests:T,logger:i=>this.warn(`[BeatUI] ${i}`)});if(v=d?.cssText??"",U=d?.assets??[],L.clear(),_.clear(),O.clear(),E.length=0,U.length>0)for(const i of U){const m=`${J}/${i.fileName}`;L.set(i.placeholder,m),O.set(m,i.localPath)}else E.push(...c)}else E.length=0;t&&!F&&this.warn("[BeatUI] Unable to resolve @tempots/beatui/tailwind.css. CSS will not be auto-injected.")},configureServer(h){!t||F==null||(h.middlewares.use((c,d,i)=>{const m=c.method??"GET";if(!["GET","HEAD"].includes(m)){i();return}const S=(c.url??"").split("?")[0];if(!new Set([`/${b}`,o==="/"?null:`${o}${b}`].filter($=>!!$)).has(S)){i();return}d.setHeader("Content-Type","text/css");try{let $=y.readFileSync(F,"utf8");const D=N("dev");D&&($+=`
7
- ${D}`),d.end($)}catch($){h.config.logger.error(`[BeatUI] Failed to stream ${B}: ${String($)}`),d.statusCode=500,d.end()}}),O.size>0&&h.middlewares.use((c,d,i)=>{const m=c.method??"GET";if(!["GET","HEAD"].includes(m)){i();return}const S=(c.url??"").split("?")[0],R=S?O.get(S):void 0;if(!R){i();return}d.setHeader("Content-Type","font/woff2"),y.createReadStream(R).on("error",()=>{d.statusCode=500,d.end()}).pipe(d)}))},buildStart(){if(!k||!t||F==null)return;_.clear(),G=null;const h=F;let c=y.readFileSync(h,"utf8");const d=N("raw");if(d&&(c+=`
8
- ${d}`),G=this.emitFile({type:"asset",fileName:b,source:c}),U.length>0)for(const i of U)try{const m=y.readFileSync(i.localPath),S=this.emitFile({type:"asset",name:`assets/${i.fileName}`,source:m});_.set(i.placeholder,S)}catch(m){this.warn(`[BeatUI] Failed to include Google Font asset ${i.fileName}: ${String(m)}`)}},generateBundle(h,c){if(!k||!G)return;const d=this.getFileName(G),i=c[d];if(!i||i.type!=="asset"||typeof i.source!="string")return;let m=i.source;for(const[S,R]of _){const $=this.getFileName(R);m=m.split(S).join($)}i.source=m},transformIndexHtml(h){const c=[];if(t&&F){const i=o==="/"?`/${b}`:`${o}${b}`;c.push({tag:"link",attrs:{rel:"stylesheet",href:i},injectTo:"head-prepend"})}E.length>0&&c.push({tag:"link",attrs:{rel:"preconnect",href:"https://fonts.googleapis.com"},injectTo:"head"},{tag:"link",attrs:{rel:"preconnect",href:"https://fonts.gstatic.com",crossorigin:""},injectTo:"head"},...E.map(i=>({tag:"link",attrs:{rel:"stylesheet",href:i,"data-beatui-google-font":""},injectTo:"head"})));const d=`
5
+ `,s}function oe(e){let s=e;const t=u.parse(s).root;for(;s&&s!==t;){const r=u.join(s,"package.json");if(S.existsSync(r))try{if(JSON.parse(S.readFileSync(r,"utf8"))?.name==="@tempots/beatui")return s}catch{}s=u.dirname(s)}return null}function ie(e){if(e==null)return null;const s=typeof e=="string"?e:e.id;if(!s)return null;const[t]=s.split("?");return t.startsWith("virtual:")||t.startsWith("\0")?null:t.startsWith("/@fs/")?decodeURIComponent(t.slice(4)):t.startsWith("file://")?V(t):u.isAbsolute(t)?t:null}function le(e){const s=new Set([u.resolve(b,y),u.resolve(b,"../",y),u.resolve(b,"../../",y),u.resolve(b,"tailwind.css"),u.resolve(b,"../tailwind.css"),u.resolve(b,"../../tailwind.css"),u.resolve(b,"../styles/tailwind.css"),u.resolve(b,"../../styles/tailwind.css"),u.resolve(G,"dist",y),u.resolve(G,y),u.resolve(G,"tailwind.css"),u.resolve(G,"src/styles/tailwind.css"),u.resolve(e,"node_modules/@tempots/beatui/tailwind.css")]);for(const t of s)if(S.existsSync(t))return t;return null}function ce(e){return e?Array.isArray(e)?e:[e]:[]}function ue(e,s){let t=e;for(const[r,a]of s)t=t.split(r).join(a);return t}async function de(e,s){if(e==null||typeof e!="object")return null;const t=e.resolve;if(!t)return null;try{return await t.call(e,s,void 0,{skipSelf:!0})}catch{return null}}function H(e={}){let s=process.cwd();const t=e.injectCss!==!1,r=e.darkClass??"dark",a=e.rtlAttribute??"dir",n=e.rtlValue??"rtl";let o="/";const l=e.semanticColors!=null||e.semanticFonts!=null||e.semanticRadii!=null||e.semanticShadows!=null||e.semanticMotion!=null||e.semanticSpacing!=null||e.semanticTextShadows!=null?N(P.generateSemanticTokenVariables({colors:e.semanticColors,fonts:e.semanticFonts,radii:e.semanticRadii,shadows:e.semanticShadows,motion:e.semanticMotion,spacing:e.semanticSpacing,textShadows:e.semanticTextShadows})):"",f=e.fontFamilies?N(P.generateFontFamilyOverrideVariables(e.fontFamilies)):"",p={};e.baseSpacing&&(p[P.getSpacingVarName("base")]=e.baseSpacing),e.baseFontSize&&(p[P.getBaseFontSizeVarName()]=e.baseFontSize),e.baseMotionDuration&&(p[P.getMotionDurationVarName("base")]=e.baseMotionDuration);const C=N(p),T=ce(e.googleFonts);let v="",U=[];const L=new Map,_=new Map,O=new Map,J="/@beatui/google-fonts",E=[];let j=null,F=null,k=!1;const x=h=>{const d=[C,l,f];return v&&(h==="dev"?d.push(ue(v,L)):d.push(v)),d.filter(i=>i&&i.length>0).join(`
6
+ `)};return{name:"beatui-tailwind",enforce:"pre",async configResolved(h){if(s=h.root,k=h.command==="build",o=h.base&&h.base!=="/"?h.base.endsWith("/")?h.base:`${h.base}/`:"/",t){const i=await de(this,B);F=ie(i)??le(s)}const d=i=>{this&&typeof this.warn=="function"?this.warn(i):h.logger.warn(i)};if(T.length>0){const i=Array.from(new Set(T.map(z))),c=await Y({projectRoot:s,requests:T,logger:g=>d(`[BeatUI] ${g}`)});if(v=c?.cssText??"",U=c?.assets??[],L.clear(),_.clear(),O.clear(),E.length=0,U.length>0)for(const g of U){const w=`${J}/${g.fileName}`;L.set(g.placeholder,w),O.set(w,g.localPath)}else E.push(...i)}else E.length=0;t&&!F&&d("[BeatUI] Unable to resolve @tempots/beatui/tailwind.css. CSS will not be auto-injected.")},configureServer(h){!t||F==null||(h.middlewares.use((d,i,c)=>{const g=d.method??"GET";if(!["GET","HEAD"].includes(g)){c();return}const w=(d.url??"").split("?")[0];if(!new Set([`/${y}`,o==="/"?null:`${o}${y}`].filter($=>!!$)).has(w)){c();return}i.setHeader("Content-Type","text/css");try{let $=S.readFileSync(F,"utf8");const D=x("dev");D&&($+=`
7
+ ${D}`),i.end($)}catch($){h.config.logger.error(`[BeatUI] Failed to stream ${B}: ${String($)}`),i.statusCode=500,i.end()}}),O.size>0&&h.middlewares.use((d,i,c)=>{const g=d.method??"GET";if(!["GET","HEAD"].includes(g)){c();return}const w=(d.url??"").split("?")[0],R=w?O.get(w):void 0;if(!R){c();return}i.setHeader("Content-Type","font/woff2"),S.createReadStream(R).on("error",()=>{i.statusCode=500,i.end()}).pipe(i)}))},buildStart(){if(!k||!t||F==null)return;_.clear(),j=null;const h=F;let d=S.readFileSync(h,"utf8");const i=x("raw");if(i&&(d+=`
8
+ ${i}`),j=this.emitFile({type:"asset",fileName:y,source:d}),U.length>0)for(const c of U)try{const g=S.readFileSync(c.localPath),w=this.emitFile({type:"asset",name:`assets/${c.fileName}`,source:g});_.set(c.placeholder,w)}catch(g){this.warn(`[BeatUI] Failed to include Google Font asset ${c.fileName}: ${String(g)}`)}},generateBundle(h,d){if(!k||!j)return;const i=this.getFileName(j),c=d[i];if(!c||c.type!=="asset"||typeof c.source!="string")return;let g=c.source;for(const[w,R]of _){const $=this.getFileName(R);g=g.split(w).join($)}c.source=g},transformIndexHtml(h){const d=[];if(t&&F){const c=o==="/"?`/${y}`:`${o}${y}`;d.push({tag:"link",attrs:{rel:"stylesheet",href:c},injectTo:"head-prepend"})}E.length>0&&d.push({tag:"link",attrs:{rel:"preconnect",href:"https://fonts.googleapis.com"},injectTo:"head"},{tag:"link",attrs:{rel:"preconnect",href:"https://fonts.gstatic.com",crossorigin:""},injectTo:"head"},...E.map(c=>({tag:"link",attrs:{rel:"stylesheet",href:c,"data-beatui-google-font":""},injectTo:"head"})));const i=`
9
9
  (() => {
10
10
  const apply = () => {
11
11
  const root = document.documentElement
@@ -30,4 +30,4 @@ ${d}`),G=this.emitFile({type:"asset",fileName:b,source:c}),U.length>0)for(const
30
30
  attributeFilter: ['class', '${a.replace(/'/g,"\\'")}'],
31
31
  })
32
32
  })();
33
- `;return c.push({tag:"script",attrs:{type:"module"},children:d,injectTo:"body"}),{html:h,tags:c}}}}exports.beatuiTailwindPlugin=H;exports.default=H;
33
+ `;return d.push({tag:"script",attrs:{type:"module"},children:i,injectTo:"body"}),{html:h,tags:d}}}}exports.beatuiTailwindPlugin=H;exports.default=H;
@@ -1,37 +1,37 @@
1
- import y from "node:fs";
1
+ import S from "node:fs";
2
2
  import u from "node:path";
3
3
  import { g as V, a as H, b as J, c as Q, d as X } from "../index-Di1_W_7Q.js";
4
4
  import { mkdir as K, writeFile as D, readFile as Y } from "node:fs/promises";
5
5
  import { createHash as Z } from "node:crypto";
6
6
  const q = "https://fonts.googleapis.com/css2", N = "normal", ee = 400, M = "Mozilla/5.0 (compatible; BeatUI Tailwind Plugin; +https://tempots.com)";
7
7
  async function te(e) {
8
- const { projectRoot: s, requests: t, logger: a } = e;
8
+ const { projectRoot: s, requests: t, logger: r } = e;
9
9
  if (!t || t.length === 0)
10
10
  return null;
11
- const r = e.cacheDir ? u.resolve(e.cacheDir) : u.join(s, "node_modules", ".beatui", "google-fonts"), n = [], o = /* @__PURE__ */ new Map();
12
- await K(r, { recursive: !0 }).catch((m) => {
13
- a?.(`Unable to create BeatUI Google Fonts cache directory: ${m}`);
11
+ const a = e.cacheDir ? u.resolve(e.cacheDir) : u.join(s, "node_modules", ".beatui", "google-fonts"), n = [], o = /* @__PURE__ */ new Map();
12
+ await K(a, { recursive: !0 }).catch((g) => {
13
+ r?.(`Unable to create BeatUI Google Fonts cache directory: ${g}`);
14
14
  });
15
- for (const m of t)
15
+ for (const g of t)
16
16
  try {
17
- const i = B(m), f = await se({
18
- request: m,
17
+ const i = B(g), f = await se({
18
+ request: g,
19
19
  cssUrl: i,
20
- cacheRoot: r,
21
- logger: a
20
+ cacheRoot: a,
21
+ logger: r
22
22
  });
23
23
  if (!f)
24
24
  continue;
25
25
  const p = await ie({
26
26
  cssText: f,
27
- cacheRoot: r,
27
+ cacheRoot: a,
28
28
  assetMap: o,
29
- logger: a
29
+ logger: r
30
30
  });
31
31
  n.push(p);
32
32
  } catch (i) {
33
- a?.(
34
- `Unexpected error while downloading Google Font "${m.family}": ${String(i)}`
33
+ r?.(
34
+ `Unexpected error while downloading Google Font "${g.family}": ${String(i)}`
35
35
  );
36
36
  }
37
37
  return n.length === 0 || o.size === 0 ? null : {
@@ -44,9 +44,9 @@ async function se({
44
44
  request: e,
45
45
  cssUrl: s,
46
46
  cacheRoot: t,
47
- logger: a
47
+ logger: r
48
48
  }) {
49
- const r = u.join(t, ne(e, s));
49
+ const a = u.join(t, ne(e, s));
50
50
  try {
51
51
  const n = await fetch(s, {
52
52
  headers: {
@@ -58,20 +58,20 @@ async function se({
58
58
  `Failed to download Google Font CSS: ${n.status} ${n.statusText}`
59
59
  );
60
60
  const o = await n.text();
61
- return await D(r, o), o;
61
+ return await D(a, o), o;
62
62
  } catch (n) {
63
- if (y.existsSync(r))
63
+ if (S.existsSync(a))
64
64
  try {
65
- const o = await Y(r, "utf8");
66
- return a?.(
65
+ const o = await Y(a, "utf8");
66
+ return r?.(
67
67
  `Using cached Google Font CSS for ${e.family} because download failed.`
68
68
  ), o;
69
69
  } catch (o) {
70
- a?.(
70
+ r?.(
71
71
  `Failed to read cached Google Font CSS for ${e.family}: ${o}`
72
72
  );
73
73
  }
74
- return a?.(
74
+ return r?.(
75
75
  `Unable to download Google Font CSS for ${e.family}: ${n}`
76
76
  ), null;
77
77
  }
@@ -81,74 +81,74 @@ function ne(e, s) {
81
81
  return `${e.family.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-") || "font"}-${t}.css`;
82
82
  }
83
83
  function B(e) {
84
- const { family: s } = e, t = s.trim().replace(/\s+/g, " "), a = ae(e.weights), r = re(e.styles), n = new URLSearchParams();
85
- return n.append("family", oe(t, a, r)), e.display && n.append("display", e.display), e.subsets && e.subsets.length > 0 && n.append("subset", e.subsets.join(",")), e.text && n.append("text", e.text), `${q}?${n.toString()}`;
84
+ const { family: s } = e, t = s.trim().replace(/\s+/g, " "), r = re(e.weights), a = ae(e.styles), n = new URLSearchParams();
85
+ return n.append("family", oe(t, r, a)), e.display && n.append("display", e.display), e.subsets && e.subsets.length > 0 && n.append("subset", e.subsets.join(",")), e.text && n.append("text", e.text), `${q}?${n.toString()}`;
86
86
  }
87
- function ae(e) {
87
+ function re(e) {
88
88
  return !e || e.length === 0 ? [] : Array.from(new Set(e)).sort((s, t) => s - t);
89
89
  }
90
- function re(e) {
90
+ function ae(e) {
91
91
  if (!e || e.length === 0)
92
92
  return [N];
93
- const s = Array.from(new Set(e)), t = s.includes("italic"), a = s.includes("normal");
94
- return !t && !a && s.push(N), s.sort((r, n) => r === n ? 0 : r === "normal" ? -1 : 1);
93
+ const s = Array.from(new Set(e)), t = s.includes("italic"), r = s.includes("normal");
94
+ return !t && !r && s.push(N), s.sort((a, n) => a === n ? 0 : a === "normal" ? -1 : 1);
95
95
  }
96
96
  function oe(e, s, t) {
97
97
  if (s.length === 0 && t.every((i) => i === "normal"))
98
98
  return e;
99
- const a = t.includes("italic"), r = t.includes("normal"), n = s.length > 0 ? s : [ee];
100
- if (!a)
99
+ const r = t.includes("italic"), a = t.includes("normal"), n = s.length > 0 ? s : [ee];
100
+ if (!r)
101
101
  return `${e}:wght@${n.join(";")}`;
102
102
  const o = /* @__PURE__ */ new Set();
103
- r && n.forEach((i) => {
103
+ a && n.forEach((i) => {
104
104
  o.add(`0,${i}`);
105
105
  }), n.forEach((i) => {
106
106
  o.add(`1,${i}`);
107
107
  });
108
- const m = Array.from(o).sort((i, f) => {
109
- const [p, C] = i.split(",").map(Number), [T, v] = f.split(",").map(Number);
110
- return p - T || C - v;
108
+ const g = Array.from(o).sort((i, f) => {
109
+ const [p, v] = i.split(",").map(Number), [T, C] = f.split(",").map(Number);
110
+ return p - T || v - C;
111
111
  });
112
- return `${e}:ital,wght@${m.join(";")}`;
112
+ return `${e}:ital,wght@${g.join(";")}`;
113
113
  }
114
114
  const le = /url\(([^)]+)\)/g;
115
115
  async function ie({
116
116
  cssText: e,
117
117
  cacheRoot: s,
118
118
  assetMap: t,
119
- logger: a
119
+ logger: r
120
120
  }) {
121
- let r = e;
121
+ let a = e;
122
122
  const n = /* @__PURE__ */ new Set();
123
123
  let o;
124
124
  for (; (o = le.exec(e)) !== null; ) {
125
125
  const i = o[1].trim().replace(/^['"]|['"]$/g, "");
126
126
  i.startsWith("http") && n.add(i);
127
127
  }
128
- for (const m of n) {
129
- const i = await ce(m, s, t, a);
128
+ for (const g of n) {
129
+ const i = await ce(g, s, t, r);
130
130
  if (!i)
131
131
  continue;
132
- const f = m.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), p = new RegExp(`url\\((['"])${f}\\1\\)`, "g"), C = new RegExp(`url\\(${f}\\)`, "g");
133
- r = r.replace(p, `url(${i.placeholder})`), r = r.replace(C, `url(${i.placeholder})`);
132
+ const f = g.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), p = new RegExp(`url\\((['"])${f}\\1\\)`, "g"), v = new RegExp(`url\\(${f}\\)`, "g");
133
+ a = a.replace(p, `url(${i.placeholder})`), a = a.replace(v, `url(${i.placeholder})`);
134
134
  }
135
- return r;
135
+ return a;
136
136
  }
137
- async function ce(e, s, t, a) {
138
- const r = t.get(e);
139
- if (r)
140
- return r;
137
+ async function ce(e, s, t, r) {
138
+ const a = t.get(e);
139
+ if (a)
140
+ return a;
141
141
  let n;
142
142
  try {
143
143
  const f = new URL(e);
144
144
  n = u.basename(f.pathname);
145
145
  } catch (f) {
146
- return a?.(`Invalid Google Font URL skipped: ${e} (${f})`), null;
146
+ return r?.(`Invalid Google Font URL skipped: ${e} (${f})`), null;
147
147
  }
148
148
  if (!n)
149
- return a?.(`Unable to derive file name for Google Font URL: ${e}`), null;
150
- const o = u.join(s, n), m = `__BEATUI_GOOGLE_FONT_${t.size}__`;
151
- if (!y.existsSync(o))
149
+ return r?.(`Unable to derive file name for Google Font URL: ${e}`), null;
150
+ const o = u.join(s, n), g = `__BEATUI_GOOGLE_FONT_${t.size}__`;
151
+ if (!S.existsSync(o))
152
152
  try {
153
153
  const f = await fetch(e, {
154
154
  headers: {
@@ -156,13 +156,13 @@ async function ce(e, s, t, a) {
156
156
  }
157
157
  });
158
158
  if (!f.ok)
159
- return a?.(
159
+ return r?.(
160
160
  `Failed to download Google Font asset ${n}: ${f.status} ${f.statusText}`
161
161
  ), null;
162
162
  const p = Buffer.from(await f.arrayBuffer());
163
163
  await D(o, p);
164
164
  } catch (f) {
165
- return a?.(
165
+ return r?.(
166
166
  `Unexpected error while downloading Google Font asset ${n}: ${String(f)}`
167
167
  ), null;
168
168
  }
@@ -170,7 +170,7 @@ async function ce(e, s, t, a) {
170
170
  url: e,
171
171
  fileName: n,
172
172
  localPath: o,
173
- placeholder: m
173
+ placeholder: g
174
174
  };
175
175
  return t.set(e, i), i;
176
176
  }
@@ -178,21 +178,21 @@ function W(e) {
178
178
  const s = typeof e == "string" ? new URL(e) : e;
179
179
  if (s.protocol !== "file:")
180
180
  throw new TypeError(`Expected file URL, received: ${s.href}`);
181
- const t = s.hostname, a = t === "" || t === "localhost", r = decodeURIComponent(s.pathname);
181
+ const t = s.hostname, r = t === "" || t === "localhost", a = decodeURIComponent(s.pathname);
182
182
  if (process.platform === "win32") {
183
- let n = r.replace(/\//g, "\\");
184
- return !a && t ? `\\\\${t}${n}` : (n.startsWith("\\") && (n = n.slice(1)), n);
183
+ let n = a.replace(/\//g, "\\");
184
+ return !r && t ? `\\\\${t}${n}` : (n.startsWith("\\") && (n = n.slice(1)), n);
185
185
  }
186
- return !a && t ? `//${t}${r}` : r;
186
+ return !r && t ? `//${t}${a}` : a;
187
187
  }
188
- const j = "@tempots/beatui/tailwind.css", b = "beatui.tailwind.css", w = u.dirname(W(import.meta.url)), k = ue(w) ?? w;
189
- function _(e) {
188
+ const x = "@tempots/beatui/tailwind.css", y = "beatui.tailwind.css", b = u.dirname(W(import.meta.url)), k = ue(b) ?? b;
189
+ function j(e) {
190
190
  if (Object.keys(e).length === 0)
191
191
  return "";
192
192
  let s = `:root {
193
193
  `;
194
- for (const [t, a] of Object.entries(e))
195
- s += ` ${t}: ${a};
194
+ for (const [t, r] of Object.entries(e))
195
+ s += ` ${t}: ${r};
196
196
  `;
197
197
  return s += `}
198
198
  `, s;
@@ -201,10 +201,10 @@ function ue(e) {
201
201
  let s = e;
202
202
  const t = u.parse(s).root;
203
203
  for (; s && s !== t; ) {
204
- const a = u.join(s, "package.json");
205
- if (y.existsSync(a))
204
+ const r = u.join(s, "package.json");
205
+ if (S.existsSync(r))
206
206
  try {
207
- if (JSON.parse(y.readFileSync(a, "utf8"))?.name === "@tempots/beatui")
207
+ if (JSON.parse(S.readFileSync(r, "utf8"))?.name === "@tempots/beatui")
208
208
  return s;
209
209
  } catch {
210
210
  }
@@ -223,22 +223,22 @@ function de(e) {
223
223
  }
224
224
  function fe(e) {
225
225
  const s = /* @__PURE__ */ new Set([
226
- u.resolve(w, b),
227
- u.resolve(w, "../", b),
228
- u.resolve(w, "../../", b),
229
- u.resolve(w, "tailwind.css"),
230
- u.resolve(w, "../tailwind.css"),
231
- u.resolve(w, "../../tailwind.css"),
232
- u.resolve(w, "../styles/tailwind.css"),
233
- u.resolve(w, "../../styles/tailwind.css"),
234
- u.resolve(k, "dist", b),
235
- u.resolve(k, b),
226
+ u.resolve(b, y),
227
+ u.resolve(b, "../", y),
228
+ u.resolve(b, "../../", y),
229
+ u.resolve(b, "tailwind.css"),
230
+ u.resolve(b, "../tailwind.css"),
231
+ u.resolve(b, "../../tailwind.css"),
232
+ u.resolve(b, "../styles/tailwind.css"),
233
+ u.resolve(b, "../../styles/tailwind.css"),
234
+ u.resolve(k, "dist", y),
235
+ u.resolve(k, y),
236
236
  u.resolve(k, "tailwind.css"),
237
237
  u.resolve(k, "src/styles/tailwind.css"),
238
238
  u.resolve(e, "node_modules/@tempots/beatui/tailwind.css")
239
239
  ]);
240
240
  for (const t of s)
241
- if (y.existsSync(t))
241
+ if (S.existsSync(t))
242
242
  return t;
243
243
  return null;
244
244
  }
@@ -247,11 +247,13 @@ function he(e) {
247
247
  }
248
248
  function me(e, s) {
249
249
  let t = e;
250
- for (const [a, r] of s)
251
- t = t.split(a).join(r);
250
+ for (const [r, a] of s)
251
+ t = t.split(r).join(a);
252
252
  return t;
253
253
  }
254
254
  async function ge(e, s) {
255
+ if (e == null || typeof e != "object")
256
+ return null;
255
257
  const t = e.resolve;
256
258
  if (!t)
257
259
  return null;
@@ -263,9 +265,9 @@ async function ge(e, s) {
263
265
  }
264
266
  function $e(e = {}) {
265
267
  let s = process.cwd();
266
- const t = e.injectCss !== !1, a = e.darkClass ?? "dark", r = e.rtlAttribute ?? "dir", n = e.rtlValue ?? "rtl";
268
+ const t = e.injectCss !== !1, r = e.darkClass ?? "dark", a = e.rtlAttribute ?? "dir", n = e.rtlValue ?? "rtl";
267
269
  let o = "/";
268
- const i = e.semanticColors != null || e.semanticFonts != null || e.semanticRadii != null || e.semanticShadows != null || e.semanticMotion != null || e.semanticSpacing != null || e.semanticTextShadows != null ? _(
270
+ const i = e.semanticColors != null || e.semanticFonts != null || e.semanticRadii != null || e.semanticShadows != null || e.semanticMotion != null || e.semanticSpacing != null || e.semanticTextShadows != null ? j(
269
271
  V({
270
272
  colors: e.semanticColors,
271
273
  fonts: e.semanticFonts,
@@ -275,157 +277,160 @@ function $e(e = {}) {
275
277
  spacing: e.semanticSpacing,
276
278
  textShadows: e.semanticTextShadows
277
279
  })
278
- ) : "", f = e.fontFamilies ? _(
280
+ ) : "", f = e.fontFamilies ? j(
279
281
  H(e.fontFamilies)
280
282
  ) : "", p = {};
281
283
  e.baseSpacing && (p[J("base")] = e.baseSpacing), e.baseFontSize && (p[Q()] = e.baseFontSize), e.baseMotionDuration && (p[X("base")] = e.baseMotionDuration);
282
- const C = _(p), T = he(e.googleFonts);
283
- let v = "", E = [];
284
- const x = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), z = "/@beatui/google-fonts", U = [];
285
- let O = null, F = null, A = !1;
284
+ const v = j(p), T = he(e.googleFonts);
285
+ let C = "", E = [];
286
+ const A = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), z = "/@beatui/google-fonts", U = [];
287
+ let O = null, F = null, _ = !1;
286
288
  const I = (h) => {
287
- const c = [
288
- C,
289
+ const d = [
290
+ v,
289
291
  i,
290
292
  f
291
293
  ];
292
- return v && (h === "dev" ? c.push(
293
- me(v, x)
294
- ) : c.push(v)), c.filter((d) => d && d.length > 0).join(`
294
+ return C && (h === "dev" ? d.push(
295
+ me(C, A)
296
+ ) : d.push(C)), d.filter((l) => l && l.length > 0).join(`
295
297
  `);
296
298
  };
297
299
  return {
298
300
  name: "beatui-tailwind",
299
301
  enforce: "pre",
300
302
  async configResolved(h) {
301
- if (s = h.root, A = h.command === "build", o = h.base && h.base !== "/" ? h.base.endsWith("/") ? h.base : `${h.base}/` : "/", t) {
302
- const c = await ge(
303
+ if (s = h.root, _ = h.command === "build", o = h.base && h.base !== "/" ? h.base.endsWith("/") ? h.base : `${h.base}/` : "/", t) {
304
+ const l = await ge(
303
305
  this,
304
- j
306
+ x
305
307
  );
306
- F = de(c) ?? fe(s);
308
+ F = de(l) ?? fe(s);
307
309
  }
310
+ const d = (l) => {
311
+ this && typeof this.warn == "function" ? this.warn(l) : h.logger.warn(l);
312
+ };
308
313
  if (T.length > 0) {
309
- const c = Array.from(
314
+ const l = Array.from(
310
315
  // eslint-disable-next-line tempots/require-async-signal-disposal -- This is an array, not a Signal
311
316
  new Set(T.map(B))
312
- ), d = await te({
317
+ ), c = await te({
313
318
  projectRoot: s,
314
319
  requests: T,
315
- logger: (l) => this.warn(`[BeatUI] ${l}`)
320
+ logger: (m) => d(`[BeatUI] ${m}`)
316
321
  });
317
- if (v = d?.cssText ?? "", E = d?.assets ?? [], x.clear(), P.clear(), G.clear(), U.length = 0, E.length > 0)
318
- for (const l of E) {
319
- const g = `${z}/${l.fileName}`;
320
- x.set(l.placeholder, g), G.set(g, l.localPath);
322
+ if (C = c?.cssText ?? "", E = c?.assets ?? [], A.clear(), P.clear(), G.clear(), U.length = 0, E.length > 0)
323
+ for (const m of E) {
324
+ const w = `${z}/${m.fileName}`;
325
+ A.set(m.placeholder, w), G.set(w, m.localPath);
321
326
  }
322
327
  else
323
- U.push(...c);
328
+ U.push(...l);
324
329
  } else
325
330
  U.length = 0;
326
- t && !F && this.warn(
331
+ t && !F && d(
327
332
  "[BeatUI] Unable to resolve @tempots/beatui/tailwind.css. CSS will not be auto-injected."
328
333
  );
329
334
  },
330
335
  configureServer(h) {
331
- !t || F == null || (h.middlewares.use((c, d, l) => {
332
- const g = c.method ?? "GET";
333
- if (!["GET", "HEAD"].includes(g)) {
334
- l();
336
+ !t || F == null || (h.middlewares.use((d, l, c) => {
337
+ const m = d.method ?? "GET";
338
+ if (!["GET", "HEAD"].includes(m)) {
339
+ c();
335
340
  return;
336
341
  }
337
- const S = (c.url ?? "").split("?")[0];
342
+ const w = (d.url ?? "").split("?")[0];
338
343
  if (!new Set(
339
344
  [
340
- `/${b}`,
341
- o === "/" ? null : `${o}${b}`
345
+ `/${y}`,
346
+ o === "/" ? null : `${o}${y}`
342
347
  ].filter(($) => !!$)
343
- ).has(S)) {
344
- l();
348
+ ).has(w)) {
349
+ c();
345
350
  return;
346
351
  }
347
- d.setHeader("Content-Type", "text/css");
352
+ l.setHeader("Content-Type", "text/css");
348
353
  try {
349
- let $ = y.readFileSync(F, "utf8");
354
+ let $ = S.readFileSync(F, "utf8");
350
355
  const L = I("dev");
351
356
  L && ($ += `
352
- ${L}`), d.end($);
357
+ ${L}`), l.end($);
353
358
  } catch ($) {
354
359
  h.config.logger.error(
355
- `[BeatUI] Failed to stream ${j}: ${String($)}`
356
- ), d.statusCode = 500, d.end();
360
+ `[BeatUI] Failed to stream ${x}: ${String($)}`
361
+ ), l.statusCode = 500, l.end();
357
362
  }
358
- }), G.size > 0 && h.middlewares.use((c, d, l) => {
359
- const g = c.method ?? "GET";
360
- if (!["GET", "HEAD"].includes(g)) {
361
- l();
363
+ }), G.size > 0 && h.middlewares.use((d, l, c) => {
364
+ const m = d.method ?? "GET";
365
+ if (!["GET", "HEAD"].includes(m)) {
366
+ c();
362
367
  return;
363
368
  }
364
- const S = (c.url ?? "").split("?")[0], R = S ? G.get(S) : void 0;
369
+ const w = (d.url ?? "").split("?")[0], R = w ? G.get(w) : void 0;
365
370
  if (!R) {
366
- l();
371
+ c();
367
372
  return;
368
373
  }
369
- d.setHeader("Content-Type", "font/woff2"), y.createReadStream(R).on("error", () => {
370
- d.statusCode = 500, d.end();
371
- }).pipe(d);
374
+ l.setHeader("Content-Type", "font/woff2"), S.createReadStream(R).on("error", () => {
375
+ l.statusCode = 500, l.end();
376
+ }).pipe(l);
372
377
  }));
373
378
  },
374
379
  buildStart() {
375
- if (!A || !t || F == null) return;
380
+ if (!_ || !t || F == null) return;
376
381
  P.clear(), O = null;
377
382
  const h = F;
378
- let c = y.readFileSync(h, "utf8");
379
- const d = I("raw");
380
- if (d && (c += `
381
- ${d}`), O = this.emitFile({
383
+ let d = S.readFileSync(h, "utf8");
384
+ const l = I("raw");
385
+ if (l && (d += `
386
+ ${l}`), O = this.emitFile({
382
387
  type: "asset",
383
- fileName: b,
384
- source: c
388
+ fileName: y,
389
+ source: d
385
390
  }), E.length > 0)
386
- for (const l of E)
391
+ for (const c of E)
387
392
  try {
388
- const g = y.readFileSync(l.localPath), S = this.emitFile({
393
+ const m = S.readFileSync(c.localPath), w = this.emitFile({
389
394
  type: "asset",
390
- name: `assets/${l.fileName}`,
391
- source: g
395
+ name: `assets/${c.fileName}`,
396
+ source: m
392
397
  });
393
- P.set(l.placeholder, S);
394
- } catch (g) {
398
+ P.set(c.placeholder, w);
399
+ } catch (m) {
395
400
  this.warn(
396
- `[BeatUI] Failed to include Google Font asset ${l.fileName}: ${String(
397
- g
401
+ `[BeatUI] Failed to include Google Font asset ${c.fileName}: ${String(
402
+ m
398
403
  )}`
399
404
  );
400
405
  }
401
406
  },
402
- generateBundle(h, c) {
403
- if (!A || !O)
407
+ generateBundle(h, d) {
408
+ if (!_ || !O)
404
409
  return;
405
- const d = this.getFileName(O), l = c[d];
406
- if (!l || l.type !== "asset" || typeof l.source != "string")
410
+ const l = this.getFileName(O), c = d[l];
411
+ if (!c || c.type !== "asset" || typeof c.source != "string")
407
412
  return;
408
- let g = l.source;
409
- for (const [S, R] of P) {
413
+ let m = c.source;
414
+ for (const [w, R] of P) {
410
415
  const $ = this.getFileName(R);
411
- g = g.split(S).join($);
416
+ m = m.split(w).join($);
412
417
  }
413
- l.source = g;
418
+ c.source = m;
414
419
  },
415
420
  transformIndexHtml(h) {
416
- const c = [];
421
+ const d = [];
417
422
  if (t && F) {
418
- const l = o === "/" ? `/${b}` : `${o}${b}`;
419
- c.push({
423
+ const c = o === "/" ? `/${y}` : `${o}${y}`;
424
+ d.push({
420
425
  tag: "link",
421
426
  attrs: {
422
427
  rel: "stylesheet",
423
- href: l
428
+ href: c
424
429
  },
425
430
  injectTo: "head-prepend"
426
431
  });
427
432
  }
428
- U.length > 0 && c.push(
433
+ U.length > 0 && d.push(
429
434
  {
430
435
  tag: "link",
431
436
  attrs: {
@@ -443,26 +448,26 @@ ${d}`), O = this.emitFile({
443
448
  },
444
449
  injectTo: "head"
445
450
  },
446
- ...U.map((l) => ({
451
+ ...U.map((c) => ({
447
452
  tag: "link",
448
453
  attrs: {
449
454
  rel: "stylesheet",
450
- href: l,
455
+ href: c,
451
456
  "data-beatui-google-font": ""
452
457
  },
453
458
  injectTo: "head"
454
459
  }))
455
460
  );
456
- const d = `
461
+ const l = `
457
462
  (() => {
458
463
  const apply = () => {
459
464
  const root = document.documentElement
460
465
  const target = document.body
461
466
  if (!target) return
462
- const hasDark = root.classList.contains('${a.replace(/'/g, "\\'")}')
467
+ const hasDark = root.classList.contains('${r.replace(/'/g, "\\'")}')
463
468
  target.classList.toggle('b-dark', hasDark)
464
469
  target.classList.toggle('b-light', !hasDark)
465
- const dirValue = root.getAttribute('${r.replace(/'/g, "\\'")}')
470
+ const dirValue = root.getAttribute('${a.replace(/'/g, "\\'")}')
466
471
  const isRtl = dirValue === '${n.replace(/'/g, "\\'")}'
467
472
  target.classList.toggle('b-rtl', isRtl)
468
473
  target.classList.toggle('b-ltr', !isRtl)
@@ -475,16 +480,16 @@ ${d}`), O = this.emitFile({
475
480
  const observer = new MutationObserver(apply)
476
481
  observer.observe(document.documentElement, {
477
482
  attributes: true,
478
- attributeFilter: ['class', '${r.replace(/'/g, "\\'")}'],
483
+ attributeFilter: ['class', '${a.replace(/'/g, "\\'")}'],
479
484
  })
480
485
  })();
481
486
  `;
482
- return c.push({
487
+ return d.push({
483
488
  tag: "script",
484
489
  attrs: { type: "module" },
485
- children: d,
490
+ children: l,
486
491
  injectTo: "body"
487
- }), { html: h, tags: c };
492
+ }), { html: h, tags: d };
488
493
  }
489
494
  };
490
495
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/beatui",
3
- "version": "0.83.0",
3
+ "version": "0.83.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.es.js",