@salty-css/vite 0.0.1-alpha.35 → 0.0.1-alpha.37

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 (4) hide show
  1. package/index.cjs +11 -11
  2. package/index.d.ts +1 -0
  3. package/index.js +55 -58
  4. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("esbuild"),z=require("child_process"),u=require("path"),m=require("fs"),J=require("fs/promises");function K(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const R=K(W),M=t=>String.fromCharCode(t+(t>25?39:97)),G=(t,s)=>{let e="",n;for(n=Math.abs(t);n>52;n=n/52|0)e=M(n%52)+e;return e=M(n%52)+e,e.length<s?e=e.padStart(s,"a"):e.length>s&&(e=e.slice(-s)),e},L=(t,s)=>{let e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return t},E=(t,s=3)=>{const e=L(5381,JSON.stringify(t))>>>0;return G(e,s)};function N(t){return t?typeof t!="string"?N(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(s,e)=>(e>0?"-":"")+s.toLowerCase()):""}const U=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:r,transform:y}=n;t=t.replace(r,$=>{const{value:a,css:f}=y($);return f&&e.push(f),a})}),{result:t,additionalCss:e}},q=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${N(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,s,e,n)=>{if(!t)return"";const r=[],y=Object.entries(t).reduce((a,[f,o])=>{const i=f.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return a;if(i==="variants")return Object.entries(o).forEach(([g,c])=>{c&&Object.entries(c).forEach(([d,l])=>{if(!l)return;const F=`${s}.${g}-${d}`,P=D(l,F);r.push(P)})}),a;if(i==="defaultVariants")return a;if(i==="compoundVariants")return o.forEach(g=>{const{css:c,...d}=g,l=Object.entries(d).reduce((P,[x,k])=>`${P}.${x}-${k}`,s),F=D(c,l);r.push(F)}),a;if(i.startsWith("@")){const g=D(o,s),c=`${i} {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const W=require("esbuild"),J=require("child_process"),p=require("path"),d=require("fs"),K=require("fs/promises");function G(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const R=G(W),M=t=>String.fromCharCode(t+(t>25?39:97)),L=(t,s)=>{let e="",n;for(n=Math.abs(t);n>52;n=n/52|0)e=M(n%52)+e;return e=M(n%52)+e,e.length<s?e=e.padStart(s,"a"):e.length>s&&(e=e.slice(-s)),e},U=(t,s)=>{let e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return t},T=(t,s=3)=>{const e=U(5381,JSON.stringify(t))>>>0;return L(e,s)};function N(t){return t?typeof t!="string"?N(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(s,e)=>(e>0?"-":"")+s.toLowerCase()):""}const X=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:r,transform:u}=n;t=t.replace(r,$=>{const{value:a,css:f}=u($);return f&&e.push(f),a})}),{result:t,additionalCss:e}},q=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${N(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,s,e,n)=>{if(!t)return"";const r=[],u=Object.entries(t).reduce((a,[f,o])=>{const i=f.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return a;if(i==="variants")return Object.entries(o).forEach(([g,c])=>{c&&Object.entries(c).forEach(([m,l])=>{if(!l)return;const F=`${s}.${g}-${m}`,P=D(l,F);r.push(P)})}),a;if(i==="defaultVariants")return a;if(i==="compoundVariants")return o.forEach(g=>{const{css:c,...m}=g,l=Object.entries(m).reduce((P,[x,k])=>`${P}.${x}-${k}`,s),F=D(c,l);r.push(F)}),a;if(i.startsWith("@")){const g=D(o,s),c=`${i} {
2
2
  ${g.replace(`
3
3
  `,`
4
4
  `)}
5
- }`;return r.push(c),a}const b=f.includes("&")?i.replace("&",s):i.startsWith(":")?`${s}${i}`:`${s} ${i}`,C=D(o,b);return r.push(C),a}const p=i.startsWith("-")?i:N(i),h=(b,C=";")=>a=`${a}${b}${C}`,j=b=>h(`${p}:${b}`);if(typeof o=="number")return j(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return a;const{modifiers:S}={},O=function*(){yield q(o),yield U(o,S)}();for(const{result:b,additionalCss:C=[]}of O)o=b,C.forEach(g=>{const c=D(g,"");h(c,"")});return j(o)},"");if(!y)return r.join(`
6
- `);if(!s)return y;let $="";return $=`${s} { ${y} }`,[$,...r].join(`
7
- `)},Z=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([r,y])=>{if(typeof y=="object"){if(!y)return;const $=r.trim(),a=Z(y,[...s,$]);e.push(a)}else n[r]=y}),Object.keys(n).length){const r=s.map(N).join("-"),y=D(n,`.${r}`);e.push(y)}return e.join(`
8
- `)},T=t=>u.join(t,"./saltygen"),X=["salty","css","styles","styled"],Y=(t=[])=>new RegExp(`\\.(${[...X,...t].join("|")})\\.`),V=(t,s=[])=>Y(s).test(t),Q=async t=>{const s=T(t),e=u.join(t,"salty.config.ts"),n=u.join(s,"salty.config.js");await R.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",external:["react"]});const r=Date.now(),{config:y}=await import(`${n}?t=${r}`);return y},I=async t=>{const s=await Q(t),e=new Set,n=(g,c=[])=>g?Object.entries(g).flatMap(([d,l])=>{if(!l)return;if(typeof l=="object")return n(l,[...c,d]);const F=[...c,d].join(".");e.add(`"${F}"`);const P=[...c.map(N),N(d)].join("-"),{result:x}=q(l);return`--${P}: ${x};`}):[],r=g=>g?Object.entries(g).flatMap(([c,d])=>{const l=n(d);return c==="base"?l.join(""):`${c} { ${l.join("")} }`}):[],y=g=>g?Object.entries(g).flatMap(([c,d])=>Object.entries(d).flatMap(([l,F])=>{const P=n(F,[c]),x=`.${c}-${l}, [data-${c}="${l}"]`,k=P.join("");return`${x} { ${k} }`})):[],$=n(s.variables),a=r(s.responsiveVariables),f=y(s.conditionalVariables),o=T(t),i=u.join(o,"css/variables.css"),p=`:root { ${$.join("")} ${a.join("")} } ${f.join("")}`;m.writeFileSync(i,p);const h=u.join(o,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;m.writeFileSync(h,S);const w=u.join(o,"css/global.css"),O=D(s.global,"");m.writeFileSync(w,O);const b=u.join(o,"css/templates.css"),C=Z(s.templates);m.writeFileSync(b,C)},_=async(t,s)=>{const e=E(t),n=u.join(s,"js",e+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const r=Date.now();return await import(`${n}?t=${r}`)},A=async t=>{const s=T(t),e=u.join(s,"salty.config.js"),{config:n}=await import(e);return n},v=async t=>{try{const s=[],e=[],n=T(t),r=u.join(n,"index.css");(()=>{m.existsSync(n)&&z.execSync("rm -rf "+n),m.mkdirSync(n),m.mkdirSync(u.join(n,"css")),m.mkdirSync(u.join(n,"types"))})(),await I(t);const $=await A(t);async function a(p,h){const j=m.statSync(p);if(j.isDirectory()){const S=m.readdirSync(p);await Promise.all(S.map(w=>a(u.join(p,w),u.join(h,w))))}else if(j.isFile()&&V(p)){const w=await _(p,n),O=[];Object.entries(w).forEach(([c,d])=>{if(d.isKeyframes&&d.css){const k=`${d.animationName}.css`,B=`css/${k}`,H=u.join(n,B);s.push(k),m.writeFileSync(H,d.css);return}if(!d.generator)return;const l=d.generator._withBuildContext({name:c,config:$}),F=`${l.hash}-${l.priority}.css`;e[l.priority]||(e[l.priority]=[]),e[l.priority].push(F),O.push(F);const P=`css/${F}`,x=u.join(n,P);m.writeFileSync(x,l.css)});const b=O.map(c=>`@import url('./${c}');`).join(`
9
- `),C=E(p,6),g=u.join(n,`css/${C}.css`);m.writeFileSync(g,b)}}await a(t,n);const f=s.map(p=>`@import url('./css/${p}');`).join(`
5
+ }`;return r.push(c),a}const b=f.includes("&")?i.replace("&",s):i.startsWith(":")?`${s}${i}`:`${s} ${i}`,C=D(o,b);return r.push(C),a}const y=i.startsWith("-")?i:N(i),h=(b,C=";")=>a=`${a}${b}${C}`,j=b=>h(`${y}:${b}`);if(typeof o=="number")return j(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return a;const{modifiers:S}={},O=function*(){yield q(o),yield X(o,S)}();for(const{result:b,additionalCss:C=[]}of O)o=b,C.forEach(g=>{const c=D(g,"");h(c,"")});return j(o)},"");if(!u)return r.join(`
6
+ `);if(!s)return u;let $="";return $=`${s} { ${u} }`,[$,...r].join(`
7
+ `)},Z=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([r,u])=>{if(typeof u=="object"){if(!u)return;const $=r.trim(),a=Z(u,[...s,$]);e.push(a)}else n[r]=u}),Object.keys(n).length){const r=s.map(N).join("-"),u=D(n,`.${r}`);e.push(u)}return e.join(`
8
+ `)},E=t=>p.join(t,"./saltygen"),Y=["salty","css","styles","styled"],Q=(t=[])=>new RegExp(`\\.(${[...Y,...t].join("|")})\\.`),V=(t,s=[])=>Q(s).test(t),v=async t=>{const s=E(t),e=p.join(t,"salty.config.ts"),n=p.join(s,"salty.config.js");await R.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",external:["react"]});const r=Date.now(),{config:u}=await import(`${n}?t=${r}`);return u},I=async t=>{const s=await v(t),e=new Set,n=(g,c=[])=>g?Object.entries(g).flatMap(([m,l])=>{if(!l)return;if(typeof l=="object")return n(l,[...c,m]);const F=[...c,m].join(".");e.add(`"${F}"`);const P=[...c.map(N),N(m)].join("-"),{result:x}=q(l);return`--${P}: ${x};`}):[],r=g=>g?Object.entries(g).flatMap(([c,m])=>{const l=n(m);return c==="base"?l.join(""):`${c} { ${l.join("")} }`}):[],u=g=>g?Object.entries(g).flatMap(([c,m])=>Object.entries(m).flatMap(([l,F])=>{const P=n(F,[c]),x=`.${c}-${l}, [data-${c}="${l}"]`,k=P.join("");return`${x} { ${k} }`})):[],$=n(s.variables),a=r(s.responsiveVariables),f=u(s.conditionalVariables),o=E(t),i=p.join(o,"css/variables.css"),y=`:root { ${$.join("")} ${a.join("")} } ${f.join("")}`;d.writeFileSync(i,y);const h=p.join(o,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;d.writeFileSync(h,S);const w=p.join(o,"css/global.css"),O=D(s.global,"");d.writeFileSync(w,O);const b=p.join(o,"css/templates.css"),C=Z(s.templates);d.writeFileSync(b,C)},_=async(t,s)=>{const e=T(t),n=p.join(s,"js",e+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const r=Date.now();return await import(`${n}?t=${r}`)},A=async t=>{const s=E(t),e=p.join(s,"salty.config.js"),{config:n}=await import(e);return n},tt=async t=>{try{const s=[],e=[],n=E(t),r=p.join(n,"index.css");(()=>{d.existsSync(n)&&J.execSync("rm -rf "+n),d.mkdirSync(n),d.mkdirSync(p.join(n,"css")),d.mkdirSync(p.join(n,"types"))})(),await I(t);const $=await A(t);async function a(y,h){const j=d.statSync(y);if(j.isDirectory()){const S=d.readdirSync(y);await Promise.all(S.map(w=>a(p.join(y,w),p.join(h,w))))}else if(j.isFile()&&V(y)){const w=await _(y,n),O=[];Object.entries(w).forEach(([c,m])=>{if(m.isKeyframes&&m.css){const k=`${m.animationName}.css`,B=`css/${k}`,H=p.join(n,B);s.push(k),d.writeFileSync(H,m.css);return}if(!m.generator)return;const l=m.generator._withBuildContext({name:c,config:$}),F=`${l.hash}-${l.priority}.css`;e[l.priority]||(e[l.priority]=[]),e[l.priority].push(F),O.push(F);const P=`css/${F}`,x=p.join(n,P);d.writeFileSync(x,l.css)});const b=O.map(c=>`@import url('./${c}');`).join(`
9
+ `),C=T(y,6),g=p.join(n,`css/${C}.css`);d.writeFileSync(g,b)}}await a(t,n);const f=s.map(y=>`@import url('./css/${y}');`).join(`
10
10
  `);let i=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
11
11
 
12
12
  ${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
13
13
  `)}
14
- ${f}`;if($.importStrategy!=="component"){const p=e.flat().map(h=>`@import url('./css/${h}');`).join(`
15
- `);i+=p}m.writeFileSync(r,i)}catch(s){console.error(s)}},tt=async(t,s)=>{try{const e=[],n=u.join(t,"./saltygen"),r=u.join(n,"index.css");if(V(s)){const $=await A(t),a=await _(s,n);Object.entries(a).forEach(([h,j])=>{if(!j.generator)return;const S=j.generator._withBuildContext({name:h,config:$}),w=`${S.hash}-${S.priority}.css`,O=`css/${w}`,b=u.join(n,O);e.push(w),m.writeFileSync(b,S.css)});const f=m.readFileSync(r,"utf8").split(`
16
- `),o=e.map(h=>`@import url('../saltygen/css/${h}');`),p=[...new Set([...f,...o])].join(`
17
- `);m.writeFileSync(r,p)}}catch(e){console.error(e)}},st=async(t,s)=>{try{const e=u.join(t,"./saltygen");if(V(s)){const r=m.readFileSync(s,"utf8");r.replace(/^(?!export\s)const\s.*/gm,i=>`export ${i}`)!==r&&await J.writeFile(s,r);const $=await A(t),a=await _(s,e);let f=r;Object.entries(a).forEach(([i,p])=>{var b;if(p.isKeyframes){console.log("value",p);return}if(!p.generator)return;const h=p.generator._withBuildContext({name:i,config:$}),j=new RegExp(`${i}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!j)return console.error("Could not find the original declaration");const S=(b=j.at(1))==null?void 0:b.trim(),w=`${i} = styled(${S}, "${h.classNames}", "${h._callerName}", ${JSON.stringify(h.props)});`,O=new RegExp(`${i}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");f=f.replace(O,w)});const o=E(s,6);return $.importStrategy==="component"&&(f=`import '../../saltygen/css/${o}.css';
18
- ${f}`),f=f.replace("{ styled }","{ styledClient as styled }"),f=f.replace("@salty-css/react/styled","@salty-css/react/styled-client"),f}}catch(e){console.error(e)}},et=t=>({name:"stylegen",buildStart:()=>v(t),load:async s=>{if(V(s))return await st(t,s)},watchChange:{handler:async s=>{V(s)&&await tt(t,s),s.includes("salty.config")&&await I(t)}}});exports.saltyPlugin=et;
14
+ ${f}`;if($.importStrategy!=="component"){const y=e.flat().map(h=>`@import url('./css/${h}');`).join(`
15
+ `);i+=y}d.writeFileSync(r,i)}catch(s){console.error(s)}},st=async(t,s)=>{try{const e=[],n=p.join(t,"./saltygen"),r=p.join(n,"index.css");if(V(s)){const $=await A(t),a=await _(s,n);Object.entries(a).forEach(([h,j])=>{if(!j.generator)return;const S=j.generator._withBuildContext({name:h,config:$}),w=`${S.hash}-${S.priority}.css`,O=`css/${w}`,b=p.join(n,O);e.push(w),d.writeFileSync(b,S.css)});const f=d.readFileSync(r,"utf8").split(`
16
+ `),o=e.map(h=>`@import url('../saltygen/css/${h}');`),y=[...new Set([...f,...o])].join(`
17
+ `);d.writeFileSync(r,y)}}catch(e){console.error(e)}},et=async(t,s)=>{try{const e=p.join(t,"./saltygen");if(V(s)){const r=d.readFileSync(s,"utf8");r.replace(/^(?!export\s)const\s.*/gm,i=>`export ${i}`)!==r&&await K.writeFile(s,r);const $=await A(t),a=await _(s,e);let f=r;Object.entries(a).forEach(([i,y])=>{var b;if(y.isKeyframes||!y.generator)return;const h=y.generator._withBuildContext({name:i,config:$}),j=new RegExp(`${i}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!j)return console.error("Could not find the original declaration");const S=(b=j.at(1))==null?void 0:b.trim(),w=`${i} = styled(${S}, "${h.classNames}", "${h._callerName}", ${JSON.stringify(h.props)});`,O=new RegExp(`${i}[=\\s]+[^()]+styled\\(([^)]|\\n|\\(.*\\){1})+\\)$`,"gm");f=f.replace(O,w)});const o=T(s,6);return $.importStrategy==="component"&&(f=`import '../../saltygen/css/${o}.css';
18
+ ${f}`),f=f.replace("{ styled }","{ styledClient as styled }"),f=f.replace("@salty-css/react/styled","@salty-css/react/styled-client"),f}}catch(e){console.error("Error in minimizeFile",e)}},z=t=>({name:"stylegen",buildStart:()=>tt(t),load:async s=>{if(V(s))return await et(t,s)},watchChange:{handler:async s=>{V(s)&&await st(t,s),s.includes("salty.config")&&await I(t)}}});exports.default=z;exports.saltyPlugin=z;
package/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export declare const saltyPlugin: (dir: string) => {
6
6
  handler: (filePath: string) => Promise<void>;
7
7
  };
8
8
  };
9
+ export default saltyPlugin;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Z from "esbuild";
2
- import { execSync as q } from "child_process";
3
- import { join as u } from "path";
4
- import { writeFileSync as C, existsSync as z, mkdirSync as T, statSync as G, readdirSync as L, readFileSync as I } from "fs";
2
+ import { execSync as K } from "child_process";
3
+ import { join as p } from "path";
4
+ import { writeFileSync as C, existsSync as q, mkdirSync as T, statSync as G, readdirSync as L, readFileSync as I } from "fs";
5
5
  import { writeFile as U } from "fs/promises";
6
6
  const _ = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), X = (t, s) => {
7
7
  let e = "", n;
@@ -23,15 +23,15 @@ const Q = (t, s) => {
23
23
  if (!s) return { result: t };
24
24
  const e = [];
25
25
  return Object.values(s).forEach((n) => {
26
- const { pattern: r, transform: y } = n;
26
+ const { pattern: r, transform: u } = n;
27
27
  t = t.replace(r, ($) => {
28
- const { value: a, css: f } = y($);
28
+ const { value: a, css: f } = u($);
29
29
  return f && e.push(f), a;
30
30
  });
31
31
  }), { result: t, additionalCss: e };
32
32
  }, B = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, O = (t, s, e, n) => {
33
33
  if (!t) return "";
34
- const r = [], y = Object.entries(t).reduce((a, [f, o]) => {
34
+ const r = [], u = Object.entries(t).reduce((a, [f, o]) => {
35
35
  const i = f.trim();
36
36
  if (typeof o == "function" && (o = o()), typeof o == "object") {
37
37
  if (!o) return a;
@@ -61,7 +61,7 @@ const Q = (t, s) => {
61
61
  const d = f.includes("&") ? i.replace("&", s) : i.startsWith(":") ? `${s}${i}` : `${s} ${i}`, x = O(o, d);
62
62
  return r.push(x), a;
63
63
  }
64
- const p = i.startsWith("-") ? i : V(i), h = (d, x = ";") => a = `${a}${d}${x}`, b = (d) => h(`${p}:${d}`);
64
+ const y = i.startsWith("-") ? i : V(i), h = (d, x = ";") => a = `${a}${d}${x}`, b = (d) => h(`${y}:${d}`);
65
65
  if (typeof o == "number") return b(o);
66
66
  if (typeof o != "string")
67
67
  if ("toString" in o) o = o.toString();
@@ -76,30 +76,30 @@ const Q = (t, s) => {
76
76
  });
77
77
  return b(o);
78
78
  }, "");
79
- if (!y) return r.join(`
79
+ if (!u) return r.join(`
80
80
  `);
81
- if (!s) return y;
81
+ if (!s) return u;
82
82
  let $ = "";
83
- return $ = `${s} { ${y} }`, [$, ...r].join(`
83
+ return $ = `${s} { ${u} }`, [$, ...r].join(`
84
84
  `);
85
85
  }, H = (t, s = []) => {
86
86
  if (!t) return "";
87
87
  const e = [], n = {};
88
- if (Object.entries(t).forEach(([r, y]) => {
89
- if (typeof y == "object") {
90
- if (!y) return;
91
- const $ = r.trim(), a = H(y, [...s, $]);
88
+ if (Object.entries(t).forEach(([r, u]) => {
89
+ if (typeof u == "object") {
90
+ if (!u) return;
91
+ const $ = r.trim(), a = H(u, [...s, $]);
92
92
  e.push(a);
93
93
  } else
94
- n[r] = y;
94
+ n[r] = u;
95
95
  }), Object.keys(n).length) {
96
- const r = s.map(V).join("-"), y = O(n, `.${r}`);
97
- e.push(y);
96
+ const r = s.map(V).join("-"), u = O(n, `.${r}`);
97
+ e.push(u);
98
98
  }
99
99
  return e.join(`
100
100
  `);
101
- }, E = (t) => u(t, "./saltygen"), v = ["salty", "css", "styles", "styled"], tt = (t = []) => new RegExp(`\\.(${[...v, ...t].join("|")})\\.`), k = (t, s = []) => tt(s).test(t), st = async (t) => {
102
- const s = E(t), e = u(t, "salty.config.ts"), n = u(s, "salty.config.js");
101
+ }, E = (t) => p(t, "./saltygen"), v = ["salty", "css", "styles", "styled"], tt = (t = []) => new RegExp(`\\.(${[...v, ...t].join("|")})\\.`), k = (t, s = []) => tt(s).test(t), st = async (t) => {
102
+ const s = E(t), e = p(t, "salty.config.ts"), n = p(s, "salty.config.js");
103
103
  await Z.build({
104
104
  entryPoints: [e],
105
105
  minify: !0,
@@ -109,8 +109,8 @@ const Q = (t, s) => {
109
109
  format: "esm",
110
110
  external: ["react"]
111
111
  });
112
- const r = Date.now(), { config: y } = await import(`${n}?t=${r}`);
113
- return y;
112
+ const r = Date.now(), { config: u } = await import(`${n}?t=${r}`);
113
+ return u;
114
114
  }, W = async (t) => {
115
115
  const s = await st(t), e = /* @__PURE__ */ new Set(), n = (g, c = []) => g ? Object.entries(g).flatMap(([m, l]) => {
116
116
  if (!l) return;
@@ -122,19 +122,19 @@ const Q = (t, s) => {
122
122
  }) : [], r = (g) => g ? Object.entries(g).flatMap(([c, m]) => {
123
123
  const l = n(m);
124
124
  return c === "base" ? l.join("") : `${c} { ${l.join("")} }`;
125
- }) : [], y = (g) => g ? Object.entries(g).flatMap(([c, m]) => Object.entries(m).flatMap(([l, S]) => {
125
+ }) : [], u = (g) => g ? Object.entries(g).flatMap(([c, m]) => Object.entries(m).flatMap(([l, S]) => {
126
126
  const D = n(S, [c]), N = `.${c}-${l}, [data-${c}="${l}"]`, P = D.join("");
127
127
  return `${N} { ${P} }`;
128
- })) : [], $ = n(s.variables), a = r(s.responsiveVariables), f = y(s.conditionalVariables), o = E(t), i = u(o, "css/variables.css"), p = `:root { ${$.join("")} ${a.join("")} } ${f.join("")}`;
129
- C(i, p);
130
- const h = u(o, "types/css-tokens.d.ts"), j = `type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
128
+ })) : [], $ = n(s.variables), a = r(s.responsiveVariables), f = u(s.conditionalVariables), o = E(t), i = p(o, "css/variables.css"), y = `:root { ${$.join("")} ${a.join("")} } ${f.join("")}`;
129
+ C(i, y);
130
+ const h = p(o, "types/css-tokens.d.ts"), j = `type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
131
131
  C(h, j);
132
- const w = u(o, "css/global.css"), F = O(s.global, "");
132
+ const w = p(o, "css/global.css"), F = O(s.global, "");
133
133
  C(w, F);
134
- const d = u(o, "css/templates.css"), x = H(s.templates);
134
+ const d = p(o, "css/templates.css"), x = H(s.templates);
135
135
  C(d, x);
136
136
  }, R = async (t, s) => {
137
- const e = A(t), n = u(s, "js", e + ".js");
137
+ const e = A(t), n = p(s, "js", e + ".js");
138
138
  await Z.build({
139
139
  entryPoints: [t],
140
140
  minify: !0,
@@ -149,26 +149,26 @@ const Q = (t, s) => {
149
149
  const r = Date.now();
150
150
  return await import(`${n}?t=${r}`);
151
151
  }, M = async (t) => {
152
- const s = E(t), e = u(s, "salty.config.js"), { config: n } = await import(e);
152
+ const s = E(t), e = p(s, "salty.config.js"), { config: n } = await import(e);
153
153
  return n;
154
154
  }, et = async (t) => {
155
155
  try {
156
- const s = [], e = [], n = E(t), r = u(n, "index.css");
156
+ const s = [], e = [], n = E(t), r = p(n, "index.css");
157
157
  (() => {
158
- z(n) && q("rm -rf " + n), T(n), T(u(n, "css")), T(u(n, "types"));
158
+ q(n) && K("rm -rf " + n), T(n), T(p(n, "css")), T(p(n, "types"));
159
159
  })(), await W(t);
160
160
  const $ = await M(t);
161
- async function a(p, h) {
162
- const b = G(p);
161
+ async function a(y, h) {
162
+ const b = G(y);
163
163
  if (b.isDirectory()) {
164
- const j = L(p);
165
- await Promise.all(j.map((w) => a(u(p, w), u(h, w))));
166
- } else if (b.isFile() && k(p)) {
167
- const w = await R(p, n), F = [];
164
+ const j = L(y);
165
+ await Promise.all(j.map((w) => a(p(y, w), p(h, w))));
166
+ } else if (b.isFile() && k(y)) {
167
+ const w = await R(y, n), F = [];
168
168
  Object.entries(w).forEach(([c, m]) => {
169
169
  if (m.isKeyframes && m.css) {
170
- const P = `${m.animationName}.css`, J = `css/${P}`, K = u(n, J);
171
- s.push(P), C(K, m.css);
170
+ const P = `${m.animationName}.css`, z = `css/${P}`, J = p(n, z);
171
+ s.push(P), C(J, m.css);
172
172
  return;
173
173
  }
174
174
  if (!m.generator) return;
@@ -177,16 +177,16 @@ const Q = (t, s) => {
177
177
  config: $
178
178
  }), S = `${l.hash}-${l.priority}.css`;
179
179
  e[l.priority] || (e[l.priority] = []), e[l.priority].push(S), F.push(S);
180
- const D = `css/${S}`, N = u(n, D);
180
+ const D = `css/${S}`, N = p(n, D);
181
181
  C(N, l.css);
182
182
  });
183
183
  const d = F.map((c) => `@import url('./${c}');`).join(`
184
- `), x = A(p, 6), g = u(n, `css/${x}.css`);
184
+ `), x = A(y, 6), g = p(n, `css/${x}.css`);
185
185
  C(g, d);
186
186
  }
187
187
  }
188
188
  await a(t, n);
189
- const f = s.map((p) => `@import url('./css/${p}');`).join(`
189
+ const f = s.map((y) => `@import url('./css/${y}');`).join(`
190
190
  `);
191
191
  let i = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
192
192
 
@@ -194,9 +194,9 @@ ${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@
194
194
  `)}
195
195
  ${f}`;
196
196
  if ($.importStrategy !== "component") {
197
- const p = e.flat().map((h) => `@import url('./css/${h}');`).join(`
197
+ const y = e.flat().map((h) => `@import url('./css/${h}');`).join(`
198
198
  `);
199
- i += p;
199
+ i += y;
200
200
  }
201
201
  C(r, i);
202
202
  } catch (s) {
@@ -204,7 +204,7 @@ ${f}`;
204
204
  }
205
205
  }, nt = async (t, s) => {
206
206
  try {
207
- const e = [], n = u(t, "./saltygen"), r = u(n, "index.css");
207
+ const e = [], n = p(t, "./saltygen"), r = p(n, "index.css");
208
208
  if (k(s)) {
209
209
  const $ = await M(t), a = await R(s, n);
210
210
  Object.entries(a).forEach(([h, b]) => {
@@ -212,39 +212,35 @@ ${f}`;
212
212
  const j = b.generator._withBuildContext({
213
213
  name: h,
214
214
  config: $
215
- }), w = `${j.hash}-${j.priority}.css`, F = `css/${w}`, d = u(n, F);
215
+ }), w = `${j.hash}-${j.priority}.css`, F = `css/${w}`, d = p(n, F);
216
216
  e.push(w), C(d, j.css);
217
217
  });
218
218
  const f = I(r, "utf8").split(`
219
- `), o = e.map((h) => `@import url('../saltygen/css/${h}');`), p = [.../* @__PURE__ */ new Set([...f, ...o])].join(`
219
+ `), o = e.map((h) => `@import url('../saltygen/css/${h}');`), y = [.../* @__PURE__ */ new Set([...f, ...o])].join(`
220
220
  `);
221
- C(r, p);
221
+ C(r, y);
222
222
  }
223
223
  } catch (e) {
224
224
  console.error(e);
225
225
  }
226
226
  }, rt = async (t, s) => {
227
227
  try {
228
- const e = u(t, "./saltygen");
228
+ const e = p(t, "./saltygen");
229
229
  if (k(s)) {
230
230
  const r = I(s, "utf8");
231
231
  r.replace(/^(?!export\s)const\s.*/gm, (i) => `export ${i}`) !== r && await U(s, r);
232
232
  const $ = await M(t), a = await R(s, e);
233
233
  let f = r;
234
- Object.entries(a).forEach(([i, p]) => {
234
+ Object.entries(a).forEach(([i, y]) => {
235
235
  var d;
236
- if (p.isKeyframes) {
237
- console.log("value", p);
238
- return;
239
- }
240
- if (!p.generator) return;
241
- const h = p.generator._withBuildContext({
236
+ if (y.isKeyframes || !y.generator) return;
237
+ const h = y.generator._withBuildContext({
242
238
  name: i,
243
239
  config: $
244
240
  }), b = new RegExp(`${i}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(r);
245
241
  if (!b)
246
242
  return console.error("Could not find the original declaration");
247
- const j = (d = b.at(1)) == null ? void 0 : d.trim(), w = `${i} = styled(${j}, "${h.classNames}", "${h._callerName}", ${JSON.stringify(h.props)});`, F = new RegExp(`${i}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
243
+ const j = (d = b.at(1)) == null ? void 0 : d.trim(), w = `${i} = styled(${j}, "${h.classNames}", "${h._callerName}", ${JSON.stringify(h.props)});`, F = new RegExp(`${i}[=\\s]+[^()]+styled\\(([^)]|\\n|\\(.*\\){1})+\\)$`, "gm");
248
244
  f = f.replace(F, w);
249
245
  });
250
246
  const o = A(s, 6);
@@ -252,7 +248,7 @@ ${f}`;
252
248
  ${f}`), f = f.replace("{ styled }", "{ styledClient as styled }"), f = f.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), f;
253
249
  }
254
250
  } catch (e) {
255
- console.error(e);
251
+ console.error("Error in minimizeFile", e);
256
252
  }
257
253
  }, lt = (t) => ({
258
254
  name: "stylegen",
@@ -268,5 +264,6 @@ ${f}`), f = f.replace("{ styled }", "{ styledClient as styled }"), f = f.replace
268
264
  }
269
265
  });
270
266
  export {
267
+ lt as default,
271
268
  lt as saltyPlugin
272
269
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.35",
3
+ "version": "0.0.1-alpha.37",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -29,6 +29,6 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@salty-css/core": "^0.0.1-alpha.35"
32
+ "@salty-css/core": "^0.0.1-alpha.37"
33
33
  }
34
34
  }