@salty-css/vite 0.0.1-alpha.72 → 0.0.1-alpha.73

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.
Files changed (3) hide show
  1. package/index.cjs +12 -12
  2. package/index.js +178 -160
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Y=require("esbuild"),Q=require("child_process"),d=require("path"),g=require("fs"),v=require("fs/promises");var D=typeof document<"u"?document.currentScript:null;function tt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const W=tt(Y),U=t=>String.fromCharCode(t+(t>25?39:97)),et=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=U(n%52)+s;return s=U(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},st=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},R=(t,e=3)=>{const s=st(5381,JSON.stringify(t))>>>0;return et(s,e)};function M(t){return t?typeof t!="string"?M(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const nt=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,y=>{const{value:a,css:c}=p(y);return c&&s.push(c),a})}),{result:t,additionalCss:s}},B=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:t},O=(t,e,s,n)=>{if(!t)return"";const o=[],p=Object.entries(t).reduce((a,[c,r])=>{const u=c.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(u==="variants")return Object.entries(r).forEach(([i,f])=>{f&&Object.entries(f).forEach(([$,h])=>{if(!h)return;const F=`${e}.${i}-${$}`,j=O(h,F);o.push(j)})}),a;if(u==="defaultVariants")return a;if(u==="compoundVariants")return r.forEach(i=>{const{css:f,...$}=i,h=Object.entries($).reduce((j,[w,P])=>`${j}.${w}-${P}`,e),F=O(f,h);o.push(F)}),a;if(u.startsWith("@")){const i=O(r,e),f=`${u} {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const tt=require("esbuild"),et=require("child_process"),u=require("path"),d=require("fs"),B=require("fs/promises");var _=typeof document<"u"?document.currentScript:null;function st(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Z=st(tt),W=t=>String.fromCharCode(t+(t>25?39:97)),nt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=W(n%52)+s;return s=W(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},ot=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},R=(t,e=3)=>{const s=ot(5381,JSON.stringify(t))>>>0;return nt(s,e)};function D(t){return t?typeof t!="string"?D(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const rt=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:y}=n;t=t.replace(o,g=>{const{value:a,css:c}=y(g);return c&&s.push(c),a})}),{result:t,additionalCss:s}},z=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${D(n[1].replaceAll(".","-"))})`)}:{result:t},M=(t,e,s,n)=>{if(!t)return"";const o=[],y=Object.entries(t).reduce((a,[c,r])=>{const f=c.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(f==="variants")return Object.entries(r).forEach(([i,p])=>{p&&Object.entries(p).forEach(([j,m])=>{if(!m)return;const F=`${e}.${i}-${j}`,$=M(m,F);o.push($)})}),a;if(f==="defaultVariants")return a;if(f==="compoundVariants")return r.forEach(i=>{const{css:p,...j}=i,m=Object.entries(j).reduce(($,[w,T])=>`${$}.${w}-${T}`,e),F=M(p,m);o.push(F)}),a;if(f.startsWith("@")){const i=M(r,e),p=`${f} {
2
2
  ${i.replace(`
3
3
  `,`
4
4
  `)}
5
- }`;return o.push(f),a}const m=c.includes("&")?u.replace("&",e):u.startsWith(":")?`${e}${u}`:`${e} ${u}`,C=O(r,m);return o.push(C),a}const T=u.startsWith("-")?u:M(u),b=(m,C=";")=>a=`${a}${m}${C}`,l=m=>b(`${T}:${m}`);if(typeof r=="number")return l(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:S}={},x=function*(){yield B(r),yield nt(r,S)}();for(const{result:m,additionalCss:C=[]}of x)r=m,C.forEach(i=>{const f=O(i,"");b(f,"")});return l(r)},"");if(!p)return o.join(`
6
- `);if(!e)return p;let y="";return y=`${e} { ${p} }`,[y,...o].join(`
7
- `)},L=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const y=o.trim(),a=L(p,[...e,y]);s.push(a)}else n[o]=p}),Object.keys(n).length){const o=e.map(M).join("-"),p=O(n,`.${o}`);s.push(p)}return s.join(`
8
- `)},Z=()=>(console.log("current meta url:",typeof document>"u"?require("url").pathToFileURL(__filename).href:D&&D.tagName.toUpperCase()==="SCRIPT"&&D.src||new URL("index.cjs",document.baseURI).href),(typeof document>"u"?require("url").pathToFileURL(__filename).href:D&&D.tagName.toUpperCase()==="SCRIPT"&&D.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs")?"cjs":"esm"),V={externalModules:[]},z=t=>{if(V.externalModules.length>0)return V.externalModules;const e=d.join(t,"salty.config.ts"),n=g.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return V.externalModules=o,o},_=t=>d.join(t,"./saltygen"),ot=["salty","css","styles","styled"],rt=(t=[])=>new RegExp(`\\.(${[...ot,...t].join("|")})\\.`),E=(t,e=[])=>rt(e).test(t),it=async t=>{const e=_(t),s=d.join(t,"salty.config.ts"),n=d.join(e,"salty.config.js"),o=Z(),p=z(t);await W.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:p});const y=Date.now(),{config:a}=await import(`${n}?t=${y}`);return a},H=async t=>{const e=await it(t),s=new Set,n=(i,f=[])=>i?Object.entries(i).flatMap(([$,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...f,$]);const F=[...f,$].join(".");s.add(`"${F}"`);const j=[...f.map(M),M($)].join("-"),{result:w}=B(h);return`--${j}: ${w};`}):[],o=i=>i?Object.entries(i).flatMap(([f,$])=>{const h=n($);return f==="base"?h.join(""):`${f} { ${h.join("")} }`}):[],p=i=>i?Object.entries(i).flatMap(([f,$])=>Object.entries($).flatMap(([h,F])=>{const j=n(F,[f]),w=`.${f}-${h}, [data-${f}="${h}"]`,P=j.join("");return`${w} { ${P} }`})):[],y=n(e.variables),a=o(e.responsiveVariables),c=p(e.conditionalVariables),r=_(t),u=d.join(r,"css/variables.css"),T=`:root { ${y.join("")} ${a.join("")} } ${c.join("")}`;g.writeFileSync(u,T);const b=d.join(r,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;g.writeFileSync(b,S);const k=d.join(r,"css/global.css"),x=O(e.global,"");g.writeFileSync(k,x);const m=d.join(r,"css/templates.css"),C=L(e.templates);g.writeFileSync(m,C)},A=async(t,e,s)=>{const n=R(e),o=d.join(s,"js",n+".js"),p=Z(),y=z(t);await W.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,target:["es2022"],keepNames:!0,external:y});const a=Date.now();return await import(`${o}?t=${a}`)},I=async t=>{const e=_(t),s=d.join(e,"salty.config.js"),{config:n}=await import(s);return n},ct=async t=>{try{const e=[],s=[],n=_(t),o=d.join(n,"index.css");(()=>{g.existsSync(n)&&Q.execSync("rm -rf "+n),g.mkdirSync(n),g.mkdirSync(d.join(n,"css")),g.mkdirSync(d.join(n,"types"))})(),await H(t);const y=await I(t);async function a(l,S){const k=["node_modules","saltygen"],x=g.statSync(l);if(x.isDirectory()){const m=g.readdirSync(l);if(k.some(i=>l.includes(i)))return;await Promise.all(m.map(i=>a(d.join(l,i),d.join(S,i))))}else if(x.isFile()&&E(l)){const C=await A(t,l,n),i=[];Object.entries(C).forEach(([F,j])=>{if(j.isKeyframes&&j.css){const q=`${j.animationName}.css`,G=`css/${q}`,X=d.join(n,G);e.push(q),g.writeFileSync(X,j.css);return}if(!j.generator)return;const w=j.generator._withBuildContext({name:F,config:y}),P=`${w.hash}-${w.priority}.css`;s[w.priority]||(s[w.priority]=[]),s[w.priority].push(P),i.push(P);const N=`css/${P}`,K=d.join(n,N);g.writeFileSync(K,w.css)});const f=i.map(F=>`@import url('./${F}');`).join(`
9
- `),$=R(l,6),h=d.join(n,`css/${$}.css`);g.writeFileSync(h,f)}}await a(t,n);const c=e.map(l=>`@import url('./css/${l}');`).join(`
5
+ }`;return o.push(p),a}const h=c.includes("&")?f.replace("&",e):f.startsWith(":")?`${e}${f}`:`${e} ${f}`,C=M(r,h);return o.push(C),a}const x=f.startsWith("-")?f:D(f),b=(h,C=";")=>a=`${a}${h}${C}`,l=h=>b(`${x}:${h}`);if(typeof r=="number")return l(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:S}={},k=function*(){yield z(r),yield rt(r,S)}();for(const{result:h,additionalCss:C=[]}of k)r=h,C.forEach(i=>{const p=M(i,"");b(p,"")});return l(r)},"");if(!y)return o.join(`
6
+ `);if(!e)return y;let g="";return g=`${e} { ${y} }`,[g,...o].join(`
7
+ `)},U=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,y])=>{if(typeof y=="object"){if(!y)return;const g=o.trim(),a=U(y,[...e,g]);s.push(a)}else n[o]=y}),Object.keys(n).length){const o=e.map(D).join("-"),y=M(n,`.${o}`);s.push(y)}return s.join(`
8
+ `)},H=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=u.join(t,"package.json");return d.existsSync(e)?e:H(u.join(t,".."))},it=async t=>{const e=H(t);return await B.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},ct=async t=>{const e=await it(t);if(e)return e.type};let O;const L=async t=>{if(O)return O;const e=await ct(t);return e==="module"?O="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},J={externalModules:[]},K=t=>{if(J.externalModules.length>0)return J.externalModules;const e=u.join(t,"salty.config.ts"),n=d.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(y=>y.replace(/['"`]/g,"").trim());return J.externalModules=o,o},V=t=>u.join(t,"./saltygen"),at=["salty","css","styles","styled"],lt=(t=[])=>new RegExp(`\\.(${[...at,...t].join("|")})\\.`),E=(t,e=[])=>lt(e).test(t),ut=async t=>{const e=V(t),s=u.join(t,"salty.config.ts"),n=u.join(e,"salty.config.js"),o=await L(t),y=K(t);await Z.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:y});const g=Date.now(),{config:a}=await import(`${n}?t=${g}`);return a},G=async t=>{const e=await ut(t),s=new Set,n=(i,p=[])=>i?Object.entries(i).flatMap(([j,m])=>{if(!m)return;if(typeof m=="object")return n(m,[...p,j]);const F=[...p,j].join(".");s.add(`"${F}"`);const $=[...p.map(D),D(j)].join("-"),{result:w}=z(m);return`--${$}: ${w};`}):[],o=i=>i?Object.entries(i).flatMap(([p,j])=>{const m=n(j);return p==="base"?m.join(""):`${p} { ${m.join("")} }`}):[],y=i=>i?Object.entries(i).flatMap(([p,j])=>Object.entries(j).flatMap(([m,F])=>{const $=n(F,[p]),w=`.${p}-${m}, [data-${p}="${m}"]`,T=$.join("");return`${w} { ${T} }`})):[],g=n(e.variables),a=o(e.responsiveVariables),c=y(e.conditionalVariables),r=V(t),f=u.join(r,"css/variables.css"),x=`:root { ${g.join("")} ${a.join("")} } ${c.join("")}`;d.writeFileSync(f,x);const b=u.join(r,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;d.writeFileSync(b,S);const P=u.join(r,"css/global.css"),k=M(e.global,"");d.writeFileSync(P,k);const h=u.join(r,"css/templates.css"),C=U(e.templates);d.writeFileSync(h,C)},A=async(t,e,s)=>{const n=R(e),o=u.join(s,"js",n+".js"),y=await L(t),g=K(t);await Z.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:y,target:["es2022"],keepNames:!0,external:g});const a=Date.now();return await import(`${o}?t=${a}`)},q=async t=>{const e=V(t),s=u.join(e,"salty.config.js"),{config:n}=await import(s);return n},ft=async t=>{try{const e=[],s=[],n=V(t),o=u.join(n,"index.css");(()=>{d.existsSync(n)&&et.execSync("rm -rf "+n),d.mkdirSync(n),d.mkdirSync(u.join(n,"css")),d.mkdirSync(u.join(n,"types"))})(),await G(t);const g=await q(t);async function a(l,S){const P=["node_modules","saltygen"],k=d.statSync(l);if(k.isDirectory()){const h=d.readdirSync(l);if(P.some(i=>l.includes(i)))return;await Promise.all(h.map(i=>a(u.join(l,i),u.join(S,i))))}else if(k.isFile()&&E(l)){const C=await A(t,l,n),i=[];Object.entries(C).forEach(([F,$])=>{if($.isKeyframes&&$.css){const I=`${$.animationName}.css`,Q=`css/${I}`,v=u.join(n,Q);e.push(I),d.writeFileSync(v,$.css);return}if(!$.generator)return;const w=$.generator._withBuildContext({name:F,config:g}),T=`${w.hash}-${w.priority}.css`;s[w.priority]||(s[w.priority]=[]),s[w.priority].push(T),i.push(T);const N=`css/${T}`,Y=u.join(n,N);d.writeFileSync(Y,w.css)});const p=i.map(F=>`@import url('./${F}');`).join(`
9
+ `),j=R(l,6),m=u.join(n,`css/${j}.css`);d.writeFileSync(m,p)}}await a(t,n);const c=e.map(l=>`@import url('./css/${l}');`).join(`
10
10
  `);let b=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
11
11
 
12
- ${["variables.css","global.css","templates.css"].filter(l=>{try{return g.readFileSync(d.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
12
+ ${["variables.css","global.css","templates.css"].filter(l=>{try{return d.readFileSync(u.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
13
13
  `)}
14
- ${c}`;if(y.importStrategy!=="component"){const l=s.flat().map(S=>`@import url('./css/${S}');`).join(`
15
- `);b+=l}g.writeFileSync(o,b)}catch(e){console.error(e)}},at=async(t,e)=>{try{const s=[],n=d.join(t,"./saltygen"),o=d.join(n,"index.css");if(E(e)){const y=await I(t),a=await A(t,e,n);Object.entries(a).forEach(([b,l])=>{if(!l.generator)return;const S=l.generator._withBuildContext({name:b,config:y}),k=`${S.hash}-${S.priority}.css`,x=`css/${k}`,m=d.join(n,x);s.push(k),g.writeFileSync(m,S.css)});const c=g.readFileSync(o,"utf8").split(`
16
- `),r=s.map(b=>`@import url('../saltygen/css/${b}');`),T=[...new Set([...c,...r])].join(`
17
- `);g.writeFileSync(o,T)}}catch(s){console.error(s)}},lt=async(t,e)=>{try{const s=d.join(t,"./saltygen");if(E(e)){const o=g.readFileSync(e,"utf8");o.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==o&&await v.writeFile(e,o);const y=await I(t),a=await A(t,e,s);let c=o;Object.entries(a).forEach(([u,T])=>{var P;if(T.isKeyframes||!T.generator)return;const b=T.generator._withBuildContext({name:u,config:y}),l=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!l)return console.error("Could not find the original declaration");const S=(P=l.at(1))==null?void 0:P.trim(),k=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(c);if(!k)return console.error("Could not find the original declaration");const{index:x}=k;let m=!1;const C=setTimeout(()=>m=!0,5e3);let i=0,f=!1,$=0;for(;!f&&!m;){const N=c[x+i];N==="("&&$++,N===")"&&$--,$===0&&N===")"&&(f=!0),i>c.length&&(m=!0),i++}if(!m)clearTimeout(C);else throw new Error("Failed to find the end of the styled call and timed out");const h=x+i,F=c.slice(x,h),j=c,w=` ${u} = styled(${S}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;c=c.replace(F,w),j===c&&console.error("Minimize file failed to change content",{name:u,tagName:S})});const r=R(e,6);return y.importStrategy==="component"&&(c=`import '../../saltygen/css/${r}.css';
18
- ${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(s){console.error("Error in minimizeFile:",s)}},J=t=>({name:"stylegen",buildStart:()=>ct(t),load:async e=>{if(E(e))return await lt(t,e)},watchChange:{handler:async e=>{E(e)&&await at(t,e),e.includes("salty.config")&&await H(t)}}});exports.default=J;exports.saltyPlugin=J;
14
+ ${c}`;if(g.importStrategy!=="component"){const l=s.flat().map(S=>`@import url('./css/${S}');`).join(`
15
+ `);b+=l}d.writeFileSync(o,b)}catch(e){console.error(e)}},pt=async(t,e)=>{try{const s=[],n=u.join(t,"./saltygen"),o=u.join(n,"index.css");if(E(e)){const g=await q(t),a=await A(t,e,n);Object.entries(a).forEach(([b,l])=>{if(!l.generator)return;const S=l.generator._withBuildContext({name:b,config:g}),P=`${S.hash}-${S.priority}.css`,k=`css/${P}`,h=u.join(n,k);s.push(P),d.writeFileSync(h,S.css)});const c=d.readFileSync(o,"utf8").split(`
16
+ `),r=s.map(b=>`@import url('../saltygen/css/${b}');`),x=[...new Set([...c,...r])].join(`
17
+ `);d.writeFileSync(o,x)}}catch(s){console.error(s)}},yt=async(t,e)=>{try{const s=u.join(t,"./saltygen");if(E(e)){const o=d.readFileSync(e,"utf8");o.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==o&&await B.writeFile(e,o);const g=await q(t),a=await A(t,e,s);let c=o;Object.entries(a).forEach(([f,x])=>{var T;if(x.isKeyframes||!x.generator)return;const b=x.generator._withBuildContext({name:f,config:g}),l=new RegExp(`\\s${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!l)return console.error("Could not find the original declaration");const S=(T=l.at(1))==null?void 0:T.trim(),P=new RegExp(`\\s${f}[=\\s]+styled\\(`,"g").exec(c);if(!P)return console.error("Could not find the original declaration");const{index:k}=P;let h=!1;const C=setTimeout(()=>h=!0,5e3);let i=0,p=!1,j=0;for(;!p&&!h;){const N=c[k+i];N==="("&&j++,N===")"&&j--,j===0&&N===")"&&(p=!0),i>c.length&&(h=!0),i++}if(!h)clearTimeout(C);else throw new Error("Failed to find the end of the styled call and timed out");const m=k+i,F=c.slice(k,m),$=c,w=` ${f} = styled(${S}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;c=c.replace(F,w),$===c&&console.error("Minimize file failed to change content",{name:f,tagName:S})});const r=R(e,6);return g.importStrategy==="component"&&(c=`import '../../saltygen/css/${r}.css';
18
+ ${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(s){console.error("Error in minimizeFile:",s)}},X=t=>({name:"stylegen",buildStart:()=>ft(t),load:async e=>{if(E(e))return await yt(t,e)},watchChange:{handler:async e=>{E(e)&&await pt(t,e),e.includes("salty.config")&&await G(t)}}});exports.default=X;exports.saltyPlugin=X;
package/index.js CHANGED
@@ -1,113 +1,131 @@
1
1
  import * as z from "esbuild";
2
- import { execSync as Y } from "child_process";
3
- import { join as y } from "path";
4
- import { writeFileSync as T, existsSync as Q, mkdirSync as A, statSync as v, readdirSync as tt, readFileSync as O } from "fs";
5
- import { writeFile as st } from "fs/promises";
6
- const Z = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), et = (t, s) => {
2
+ import { execSync as tt } from "child_process";
3
+ import { join as f } from "path";
4
+ import { existsSync as H, writeFileSync as M, mkdirSync as A, statSync as st, readdirSync as et, readFileSync as V } from "fs";
5
+ import { readFile as nt, writeFile as ot } from "fs/promises";
6
+ const Z = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), rt = (t, s) => {
7
7
  let e = "", n;
8
8
  for (n = Math.abs(t); n > 52; n = n / 52 | 0) e = Z(n % 52) + e;
9
9
  return e = Z(n % 52) + e, e.length < s ? e = e.padStart(s, "a") : e.length > s && (e = e.slice(-s)), e;
10
- }, nt = (t, s) => {
10
+ }, ct = (t, s) => {
11
11
  let e = s.length;
12
12
  for (; e; ) t = t * 33 ^ s.charCodeAt(--e);
13
13
  return t;
14
14
  }, _ = (t, s = 3) => {
15
- const e = nt(5381, JSON.stringify(t)) >>> 0;
16
- return et(e, s);
15
+ const e = ct(5381, JSON.stringify(t)) >>> 0;
16
+ return rt(e, s);
17
17
  };
18
- function M(t) {
19
- return t ? typeof t != "string" ? M(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, e) => (e > 0 ? "-" : "") + s.toLowerCase()) : "";
18
+ function E(t) {
19
+ return t ? typeof t != "string" ? E(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, e) => (e > 0 ? "-" : "") + s.toLowerCase()) : "";
20
20
  }
21
- const ot = (t, s) => {
21
+ const it = (t, s) => {
22
22
  if (typeof t != "string") return { result: t };
23
23
  if (!s) return { result: t };
24
24
  const e = [];
25
25
  return Object.values(s).forEach((n) => {
26
- const { pattern: o, transform: p } = n;
27
- t = t.replace(o, (g) => {
28
- const { value: a, css: c } = p(g);
29
- return c && e.push(c), a;
26
+ const { pattern: o, transform: g } = n;
27
+ t = t.replace(o, (y) => {
28
+ const { value: a, css: i } = g(y);
29
+ return i && e.push(i), a;
30
30
  });
31
31
  }), { result: t, additionalCss: e };
32
- }, H = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${M(n[1].replaceAll(".", "-"))})`) } : { result: t }, E = (t, s, e, n) => {
32
+ }, K = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${E(n[1].replaceAll(".", "-"))})`) } : { result: t }, T = (t, s, e, n) => {
33
33
  if (!t) return "";
34
- const o = [], p = Object.entries(t).reduce((a, [c, r]) => {
35
- const f = c.trim();
34
+ const o = [], g = Object.entries(t).reduce((a, [i, r]) => {
35
+ const u = i.trim();
36
36
  if (typeof r == "function" && (r = r()), typeof r == "object") {
37
37
  if (!r) return a;
38
- if (f === "variants")
39
- return Object.entries(r).forEach(([i, u]) => {
40
- u && Object.entries(u).forEach(([h, m]) => {
41
- if (!m) return;
42
- const S = `${s}.${i}-${h}`, $ = E(m, S);
38
+ if (u === "variants")
39
+ return Object.entries(r).forEach(([c, p]) => {
40
+ p && Object.entries(p).forEach(([m, h]) => {
41
+ if (!h) return;
42
+ const S = `${s}.${c}-${m}`, $ = T(h, S);
43
43
  o.push($);
44
44
  });
45
45
  }), a;
46
- if (f === "defaultVariants")
46
+ if (u === "defaultVariants")
47
47
  return a;
48
- if (f === "compoundVariants")
49
- return r.forEach((i) => {
50
- const { css: u, ...h } = i, m = Object.entries(h).reduce(($, [w, D]) => `${$}.${w}-${D}`, s), S = E(u, m);
48
+ if (u === "compoundVariants")
49
+ return r.forEach((c) => {
50
+ const { css: p, ...m } = c, h = Object.entries(m).reduce(($, [j, P]) => `${$}.${j}-${P}`, s), S = T(p, h);
51
51
  o.push(S);
52
52
  }), a;
53
- if (f.startsWith("@")) {
54
- const i = E(r, s), u = `${f} {
55
- ${i.replace(`
53
+ if (u.startsWith("@")) {
54
+ const c = T(r, s), p = `${u} {
55
+ ${c.replace(`
56
56
  `, `
57
57
  `)}
58
58
  }`;
59
- return o.push(u), a;
59
+ return o.push(p), a;
60
60
  }
61
- const d = c.includes("&") ? f.replace("&", s) : f.startsWith(":") ? `${s}${f}` : `${s} ${f}`, x = E(r, d);
62
- return o.push(x), a;
61
+ const d = i.includes("&") ? u.replace("&", s) : u.startsWith(":") ? `${s}${u}` : `${s} ${u}`, k = T(r, d);
62
+ return o.push(k), a;
63
63
  }
64
- const C = f.startsWith("-") ? f : M(f), b = (d, x = ";") => a = `${a}${d}${x}`, l = (d) => b(`${C}:${d}`);
64
+ const x = u.startsWith("-") ? u : E(u), b = (d, k = ";") => a = `${a}${d}${k}`, l = (d) => b(`${x}:${d}`);
65
65
  if (typeof r == "number") return l(r);
66
66
  if (typeof r != "string")
67
67
  if ("toString" in r) r = r.toString();
68
68
  else return a;
69
- const { modifiers: j } = {}, F = function* () {
70
- yield H(r), yield ot(r, j);
69
+ const { modifiers: w } = {}, F = function* () {
70
+ yield K(r), yield it(r, w);
71
71
  }();
72
- for (const { result: d, additionalCss: x = [] } of F)
73
- r = d, x.forEach((i) => {
74
- const u = E(i, "");
75
- b(u, "");
72
+ for (const { result: d, additionalCss: k = [] } of F)
73
+ r = d, k.forEach((c) => {
74
+ const p = T(c, "");
75
+ b(p, "");
76
76
  });
77
77
  return l(r);
78
78
  }, "");
79
- if (!p) return o.join(`
79
+ if (!g) return o.join(`
80
80
  `);
81
- if (!s) return p;
82
- let g = "";
83
- return g = `${s} { ${p} }`, [g, ...o].join(`
81
+ if (!s) return g;
82
+ let y = "";
83
+ return y = `${s} { ${g} }`, [y, ...o].join(`
84
84
  `);
85
- }, J = (t, s = []) => {
85
+ }, q = (t, s = []) => {
86
86
  if (!t) return "";
87
87
  const e = [], n = {};
88
- if (Object.entries(t).forEach(([o, p]) => {
89
- if (typeof p == "object") {
90
- if (!p) return;
91
- const g = o.trim(), a = J(p, [...s, g]);
88
+ if (Object.entries(t).forEach(([o, g]) => {
89
+ if (typeof g == "object") {
90
+ if (!g) return;
91
+ const y = o.trim(), a = q(g, [...s, y]);
92
92
  e.push(a);
93
93
  } else
94
- n[o] = p;
94
+ n[o] = g;
95
95
  }), Object.keys(n).length) {
96
- const o = s.map(M).join("-"), p = E(n, `.${o}`);
97
- e.push(p);
96
+ const o = s.map(E).join("-"), g = T(n, `.${o}`);
97
+ e.push(g);
98
98
  }
99
99
  return e.join(`
100
100
  `);
101
- }, K = () => (console.log("current meta url:", import.meta.url), import.meta.url.endsWith(".cjs") ? "cjs" : "esm"), R = {
101
+ }, G = (t) => {
102
+ if (!t || t === "/") throw new Error("Could not find package.json file");
103
+ const s = f(t, "package.json");
104
+ return H(s) ? s : G(f(t, ".."));
105
+ }, at = async (t) => {
106
+ const s = G(t);
107
+ return await nt(s, "utf-8").then(JSON.parse).catch(() => {
108
+ });
109
+ }, lt = async (t) => {
110
+ const s = await at(t);
111
+ if (s)
112
+ return s.type;
113
+ };
114
+ let D;
115
+ const L = async (t) => {
116
+ if (D) return D;
117
+ const s = await lt(t);
118
+ return s === "module" ? D = "esm" : (s === "commonjs" || import.meta.url.endsWith(".cjs")) && (D = "cjs"), D || "esm";
119
+ }, R = {
102
120
  externalModules: []
103
- }, q = (t) => {
121
+ }, U = (t) => {
104
122
  if (R.externalModules.length > 0) return R.externalModules;
105
- const s = y(t, "salty.config.ts"), n = O(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
123
+ const s = f(t, "salty.config.ts"), n = V(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
106
124
  if (!n) return [];
107
- const o = n[1].split(",").map((p) => p.replace(/['"`]/g, "").trim());
125
+ const o = n[1].split(",").map((g) => g.replace(/['"`]/g, "").trim());
108
126
  return R.externalModules = o, o;
109
- }, V = (t) => y(t, "./saltygen"), rt = ["salty", "css", "styles", "styled"], it = (t = []) => new RegExp(`\\.(${[...rt, ...t].join("|")})\\.`), P = (t, s = []) => it(s).test(t), ct = async (t) => {
110
- const s = V(t), e = y(t, "salty.config.ts"), n = y(s, "salty.config.js"), o = K(), p = q(t);
127
+ }, J = (t) => f(t, "./saltygen"), ft = ["salty", "css", "styles", "styled"], ut = (t = []) => new RegExp(`\\.(${[...ft, ...t].join("|")})\\.`), O = (t, s = []) => ut(s).test(t), pt = async (t) => {
128
+ const s = J(t), e = f(t, "salty.config.ts"), n = f(s, "salty.config.js"), o = await L(t), g = U(t);
111
129
  await z.build({
112
130
  entryPoints: [e],
113
131
  minify: !0,
@@ -115,181 +133,181 @@ const ot = (t, s) => {
115
133
  bundle: !0,
116
134
  outfile: n,
117
135
  format: o,
118
- external: p
136
+ external: g
119
137
  });
120
- const g = Date.now(), { config: a } = await import(`${n}?t=${g}`);
138
+ const y = Date.now(), { config: a } = await import(`${n}?t=${y}`);
121
139
  return a;
122
- }, G = async (t) => {
123
- const s = await ct(t), e = /* @__PURE__ */ new Set(), n = (i, u = []) => i ? Object.entries(i).flatMap(([h, m]) => {
124
- if (!m) return;
125
- if (typeof m == "object") return n(m, [...u, h]);
126
- const S = [...u, h].join(".");
140
+ }, X = async (t) => {
141
+ const s = await pt(t), e = /* @__PURE__ */ new Set(), n = (c, p = []) => c ? Object.entries(c).flatMap(([m, h]) => {
142
+ if (!h) return;
143
+ if (typeof h == "object") return n(h, [...p, m]);
144
+ const S = [...p, m].join(".");
127
145
  e.add(`"${S}"`);
128
- const $ = [...u.map(M), M(h)].join("-"), { result: w } = H(m);
129
- return `--${$}: ${w};`;
130
- }) : [], o = (i) => i ? Object.entries(i).flatMap(([u, h]) => {
131
- const m = n(h);
132
- return u === "base" ? m.join("") : `${u} { ${m.join("")} }`;
133
- }) : [], p = (i) => i ? Object.entries(i).flatMap(([u, h]) => Object.entries(h).flatMap(([m, S]) => {
134
- const $ = n(S, [u]), w = `.${u}-${m}, [data-${u}="${m}"]`, D = $.join("");
135
- return `${w} { ${D} }`;
136
- })) : [], g = n(s.variables), a = o(s.responsiveVariables), c = p(s.conditionalVariables), r = V(t), f = y(r, "css/variables.css"), C = `:root { ${g.join("")} ${a.join("")} } ${c.join("")}`;
137
- T(f, C);
138
- const b = y(r, "types/css-tokens.d.ts"), j = `type VariableTokens = ${[...e].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
139
- T(b, j);
140
- const k = y(r, "css/global.css"), F = E(s.global, "");
141
- T(k, F);
142
- const d = y(r, "css/templates.css"), x = J(s.templates);
143
- T(d, x);
146
+ const $ = [...p.map(E), E(m)].join("-"), { result: j } = K(h);
147
+ return `--${$}: ${j};`;
148
+ }) : [], o = (c) => c ? Object.entries(c).flatMap(([p, m]) => {
149
+ const h = n(m);
150
+ return p === "base" ? h.join("") : `${p} { ${h.join("")} }`;
151
+ }) : [], g = (c) => c ? Object.entries(c).flatMap(([p, m]) => Object.entries(m).flatMap(([h, S]) => {
152
+ const $ = n(S, [p]), j = `.${p}-${h}, [data-${p}="${h}"]`, P = $.join("");
153
+ return `${j} { ${P} }`;
154
+ })) : [], y = n(s.variables), a = o(s.responsiveVariables), i = g(s.conditionalVariables), r = J(t), u = f(r, "css/variables.css"), x = `:root { ${y.join("")} ${a.join("")} } ${i.join("")}`;
155
+ M(u, x);
156
+ const b = f(r, "types/css-tokens.d.ts"), w = `type VariableTokens = ${[...e].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
157
+ M(b, w);
158
+ const C = f(r, "css/global.css"), F = T(s.global, "");
159
+ M(C, F);
160
+ const d = f(r, "css/templates.css"), k = q(s.templates);
161
+ M(d, k);
144
162
  }, W = async (t, s, e) => {
145
- const n = _(s), o = y(e, "js", n + ".js"), p = K(), g = q(t);
163
+ const n = _(s), o = f(e, "js", n + ".js"), g = await L(t), y = U(t);
146
164
  await z.build({
147
165
  entryPoints: [s],
148
166
  minify: !0,
149
167
  treeShaking: !0,
150
168
  bundle: !0,
151
169
  outfile: o,
152
- format: p,
170
+ format: g,
153
171
  target: ["es2022"],
154
172
  keepNames: !0,
155
- external: g
173
+ external: y
156
174
  });
157
175
  const a = Date.now();
158
176
  return await import(`${o}?t=${a}`);
159
177
  }, B = async (t) => {
160
- const s = V(t), e = y(s, "salty.config.js"), { config: n } = await import(e);
178
+ const s = J(t), e = f(s, "salty.config.js"), { config: n } = await import(e);
161
179
  return n;
162
- }, at = async (t) => {
180
+ }, gt = async (t) => {
163
181
  try {
164
- const s = [], e = [], n = V(t), o = y(n, "index.css");
182
+ const s = [], e = [], n = J(t), o = f(n, "index.css");
165
183
  (() => {
166
- Q(n) && Y("rm -rf " + n), A(n), A(y(n, "css")), A(y(n, "types"));
167
- })(), await G(t);
168
- const g = await B(t);
169
- async function a(l, j) {
170
- const k = ["node_modules", "saltygen"], F = v(l);
184
+ H(n) && tt("rm -rf " + n), A(n), A(f(n, "css")), A(f(n, "types"));
185
+ })(), await X(t);
186
+ const y = await B(t);
187
+ async function a(l, w) {
188
+ const C = ["node_modules", "saltygen"], F = st(l);
171
189
  if (F.isDirectory()) {
172
- const d = tt(l);
173
- if (k.some((i) => l.includes(i))) return;
174
- await Promise.all(d.map((i) => a(y(l, i), y(j, i))));
175
- } else if (F.isFile() && P(l)) {
176
- const x = await W(t, l, n), i = [];
177
- Object.entries(x).forEach(([S, $]) => {
190
+ const d = et(l);
191
+ if (C.some((c) => l.includes(c))) return;
192
+ await Promise.all(d.map((c) => a(f(l, c), f(w, c))));
193
+ } else if (F.isFile() && O(l)) {
194
+ const k = await W(t, l, n), c = [];
195
+ Object.entries(k).forEach(([S, $]) => {
178
196
  if ($.isKeyframes && $.css) {
179
- const I = `${$.animationName}.css`, U = `css/${I}`, X = y(n, U);
180
- s.push(I), T(X, $.css);
197
+ const I = `${$.animationName}.css`, Q = `css/${I}`, v = f(n, Q);
198
+ s.push(I), M(v, $.css);
181
199
  return;
182
200
  }
183
201
  if (!$.generator) return;
184
- const w = $.generator._withBuildContext({
202
+ const j = $.generator._withBuildContext({
185
203
  name: S,
186
- config: g
187
- }), D = `${w.hash}-${w.priority}.css`;
188
- e[w.priority] || (e[w.priority] = []), e[w.priority].push(D), i.push(D);
189
- const N = `css/${D}`, L = y(n, N);
190
- T(L, w.css);
204
+ config: y
205
+ }), P = `${j.hash}-${j.priority}.css`;
206
+ e[j.priority] || (e[j.priority] = []), e[j.priority].push(P), c.push(P);
207
+ const N = `css/${P}`, Y = f(n, N);
208
+ M(Y, j.css);
191
209
  });
192
- const u = i.map((S) => `@import url('./${S}');`).join(`
193
- `), h = _(l, 6), m = y(n, `css/${h}.css`);
194
- T(m, u);
210
+ const p = c.map((S) => `@import url('./${S}');`).join(`
211
+ `), m = _(l, 6), h = f(n, `css/${m}.css`);
212
+ M(h, p);
195
213
  }
196
214
  }
197
215
  await a(t, n);
198
- const c = s.map((l) => `@import url('./css/${l}');`).join(`
216
+ const i = s.map((l) => `@import url('./css/${l}');`).join(`
199
217
  `);
200
218
  let b = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
201
219
 
202
220
  ${["variables.css", "global.css", "templates.css"].filter((l) => {
203
221
  try {
204
- return O(y(n, "css", l), "utf8").length > 0;
222
+ return V(f(n, "css", l), "utf8").length > 0;
205
223
  } catch {
206
224
  return !1;
207
225
  }
208
226
  }).map((l) => `@import url('./css/${l}');`).join(`
209
227
  `)}
210
- ${c}`;
211
- if (g.importStrategy !== "component") {
212
- const l = e.flat().map((j) => `@import url('./css/${j}');`).join(`
228
+ ${i}`;
229
+ if (y.importStrategy !== "component") {
230
+ const l = e.flat().map((w) => `@import url('./css/${w}');`).join(`
213
231
  `);
214
232
  b += l;
215
233
  }
216
- T(o, b);
234
+ M(o, b);
217
235
  } catch (s) {
218
236
  console.error(s);
219
237
  }
220
- }, lt = async (t, s) => {
238
+ }, yt = async (t, s) => {
221
239
  try {
222
- const e = [], n = y(t, "./saltygen"), o = y(n, "index.css");
223
- if (P(s)) {
224
- const g = await B(t), a = await W(t, s, n);
240
+ const e = [], n = f(t, "./saltygen"), o = f(n, "index.css");
241
+ if (O(s)) {
242
+ const y = await B(t), a = await W(t, s, n);
225
243
  Object.entries(a).forEach(([b, l]) => {
226
244
  if (!l.generator) return;
227
- const j = l.generator._withBuildContext({
245
+ const w = l.generator._withBuildContext({
228
246
  name: b,
229
- config: g
230
- }), k = `${j.hash}-${j.priority}.css`, F = `css/${k}`, d = y(n, F);
231
- e.push(k), T(d, j.css);
247
+ config: y
248
+ }), C = `${w.hash}-${w.priority}.css`, F = `css/${C}`, d = f(n, F);
249
+ e.push(C), M(d, w.css);
232
250
  });
233
- const c = O(o, "utf8").split(`
234
- `), r = e.map((b) => `@import url('../saltygen/css/${b}');`), C = [.../* @__PURE__ */ new Set([...c, ...r])].join(`
251
+ const i = V(o, "utf8").split(`
252
+ `), r = e.map((b) => `@import url('../saltygen/css/${b}');`), x = [.../* @__PURE__ */ new Set([...i, ...r])].join(`
235
253
  `);
236
- T(o, C);
254
+ M(o, x);
237
255
  }
238
256
  } catch (e) {
239
257
  console.error(e);
240
258
  }
241
- }, ft = async (t, s) => {
259
+ }, dt = async (t, s) => {
242
260
  try {
243
- const e = y(t, "./saltygen");
244
- if (P(s)) {
245
- const o = O(s, "utf8");
246
- o.replace(/^(?!export\s)const\s.*/gm, (f) => `export ${f}`) !== o && await st(s, o);
247
- const g = await B(t), a = await W(t, s, e);
248
- let c = o;
249
- Object.entries(a).forEach(([f, C]) => {
250
- var D;
251
- if (C.isKeyframes || !C.generator) return;
252
- const b = C.generator._withBuildContext({
253
- name: f,
254
- config: g
255
- }), l = new RegExp(`\\s${f}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
261
+ const e = f(t, "./saltygen");
262
+ if (O(s)) {
263
+ const o = V(s, "utf8");
264
+ o.replace(/^(?!export\s)const\s.*/gm, (u) => `export ${u}`) !== o && await ot(s, o);
265
+ const y = await B(t), a = await W(t, s, e);
266
+ let i = o;
267
+ Object.entries(a).forEach(([u, x]) => {
268
+ var P;
269
+ if (x.isKeyframes || !x.generator) return;
270
+ const b = x.generator._withBuildContext({
271
+ name: u,
272
+ config: y
273
+ }), l = new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
256
274
  if (!l) return console.error("Could not find the original declaration");
257
- const j = (D = l.at(1)) == null ? void 0 : D.trim(), k = new RegExp(`\\s${f}[=\\s]+styled\\(`, "g").exec(c);
258
- if (!k) return console.error("Could not find the original declaration");
259
- const { index: F } = k;
275
+ const w = (P = l.at(1)) == null ? void 0 : P.trim(), C = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(i);
276
+ if (!C) return console.error("Could not find the original declaration");
277
+ const { index: F } = C;
260
278
  let d = !1;
261
- const x = setTimeout(() => d = !0, 5e3);
262
- let i = 0, u = !1, h = 0;
263
- for (; !u && !d; ) {
264
- const N = c[F + i];
265
- N === "(" && h++, N === ")" && h--, h === 0 && N === ")" && (u = !0), i > c.length && (d = !0), i++;
279
+ const k = setTimeout(() => d = !0, 5e3);
280
+ let c = 0, p = !1, m = 0;
281
+ for (; !p && !d; ) {
282
+ const N = i[F + c];
283
+ N === "(" && m++, N === ")" && m--, m === 0 && N === ")" && (p = !0), c > i.length && (d = !0), c++;
266
284
  }
267
- if (!d) clearTimeout(x);
285
+ if (!d) clearTimeout(k);
268
286
  else throw new Error("Failed to find the end of the styled call and timed out");
269
- const m = F + i, S = c.slice(F, m), $ = c, w = ` ${f} = styled(${j}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;
270
- c = c.replace(S, w), $ === c && console.error("Minimize file failed to change content", { name: f, tagName: j });
287
+ const h = F + c, S = i.slice(F, h), $ = i, j = ` ${u} = styled(${w}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;
288
+ i = i.replace(S, j), $ === i && console.error("Minimize file failed to change content", { name: u, tagName: w });
271
289
  });
272
290
  const r = _(s, 6);
273
- return g.importStrategy === "component" && (c = `import '../../saltygen/css/${r}.css';
274
- ${c}`), c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
291
+ return y.importStrategy === "component" && (i = `import '../../saltygen/css/${r}.css';
292
+ ${i}`), i = i.replace("{ styled }", "{ styledClient as styled }"), i = i.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), i;
275
293
  }
276
294
  } catch (e) {
277
295
  console.error("Error in minimizeFile:", e);
278
296
  }
279
- }, dt = (t) => ({
297
+ }, wt = (t) => ({
280
298
  name: "stylegen",
281
- buildStart: () => at(t),
299
+ buildStart: () => gt(t),
282
300
  load: async (s) => {
283
- if (P(s))
284
- return await ft(t, s);
301
+ if (O(s))
302
+ return await dt(t, s);
285
303
  },
286
304
  watchChange: {
287
305
  handler: async (s) => {
288
- P(s) && await lt(t, s), s.includes("salty.config") && await G(t);
306
+ O(s) && await yt(t, s), s.includes("salty.config") && await X(t);
289
307
  }
290
308
  }
291
309
  });
292
310
  export {
293
- dt as default,
294
- dt as saltyPlugin
311
+ wt as default,
312
+ wt as saltyPlugin
295
313
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.72",
3
+ "version": "0.0.1-alpha.73",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,6 +34,6 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.72"
37
+ "@salty-css/core": "^0.0.1-alpha.73"
38
38
  }
39
39
  }