@salty-css/webpack 0.0.1-alpha.157 → 0.0.1-alpha.158

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.
@@ -475,7 +475,6 @@ ${c}`;
475
475
  export {
476
476
  At as a,
477
477
  Rt as g,
478
- U as i,
479
478
  Jt as m,
480
479
  Nt as s
481
480
  };
@@ -1,11 +1,11 @@
1
- "use strict";const de=require("esbuild"),ye=require("child_process"),a=require("path"),f=require("fs"),K=require("fs/promises"),I=require("winston");var G=typeof document<"u"?document.currentScript:null;function ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ee=ge(de),Y=e=>String.fromCharCode(e+(e>25?39:97)),me=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=Y(n%52)+s;return s=Y(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},he=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=he(5381,JSON.stringify(e))>>>0;return me(s,t)};function M(e){return e?typeof e!="string"?M(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const be=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:i}=n;e=e.replace(o,u=>{const{value:d,css:r}=i(u);return r&&s.push(r),d})}),{result:e,additionalCss:s}},te=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},V=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((u,[d,r])=>{const c=d.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return u;if(c==="variants")return Object.entries(r).forEach(([j,x])=>{x&&Object.entries(x).forEach(([l,m])=>{if(!m)return;const w=`${t}.${j}-${l}`,b=V(m,w);n.push(b)})}),u;if(c==="defaultVariants")return u;if(c==="compoundVariants")return r.forEach(j=>{const{css:x,...l}=j,m=Object.entries(l).reduce((b,[g,F])=>`${b}.${g}-${F}`,t),w=V(x,m);n.push(w)}),u;if(c.startsWith("@")){const j=V(r,t),x=`${c} {
1
+ "use strict";const de=require("esbuild"),ye=require("child_process"),a=require("path"),f=require("fs"),B=require("fs/promises"),I=require("winston");var L=typeof document<"u"?document.currentScript:null;function ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ee=ge(de),Y=e=>String.fromCharCode(e+(e>25?39:97)),me=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=Y(n%52)+s;return s=Y(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},he=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=he(5381,JSON.stringify(e))>>>0;return me(s,t)};function M(e){return e?typeof e!="string"?M(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const be=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:i}=n;e=e.replace(o,u=>{const{value:d,css:r}=i(u);return r&&s.push(r),d})}),{result:e,additionalCss:s}},te=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},V=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((u,[d,r])=>{const c=d.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return u;if(c==="variants")return Object.entries(r).forEach(([j,x])=>{x&&Object.entries(x).forEach(([l,m])=>{if(!m)return;const w=`${t}.${j}-${l}`,b=V(m,w);n.push(b)})}),u;if(c==="defaultVariants")return u;if(c==="compoundVariants")return r.forEach(j=>{const{css:x,...l}=j,m=Object.entries(l).reduce((b,[g,F])=>`${b}.${g}-${F}`,t),w=V(x,m);n.push(w)}),u;if(c.startsWith("@")){const j=V(r,t),x=`${c} {
2
2
  ${j.replace(`
3
3
  `,`
4
4
  `)}
5
5
  }`;return n.push(x),u}const h=d.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,D=V(r,h);return n.push(D),u}const y=c.startsWith("-")?c:M(c),p=(h,D=";")=>u=`${u}${h}${D}`,k=h=>p(`${y}:${h}`);if(typeof r=="number")return k(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return u;const{modifiers:N}={},T=function*(){yield te(r),yield be(r,N)}();for(const{result:h,additionalCss:D=[]}of T)r=h,D.forEach(j=>{const x=V(j,"");p(x,"")});return k(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
6
6
  `):o:n.join(`
7
7
  `)},se=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const u=o.trim(),d=se(i,[...t,u]);s.push(d)}else n[o]=i}),Object.keys(n).length){const o=t.map(M).join("-"),i=V(n,`.${o}`);s.push(i)}return s.join(`
8
- `)},Se=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ne(n).map(o=>`"${o}"`).join(" | ")),t),{}),ne=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?ne(o,i,s):s.add(t)}),[...s]):[],re=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return f.existsSync(t)?t:re(a.join(e,".."))},$e=async e=>{const t=re(e);return await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},je=async e=>{const t=await $e(e);if(t)return t.type};let J;const oe=async e=>{if(J)return J;const t=await je(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("index-a4KtTJRO.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},B=I.createLogger({level:"debug",format:I.format.combine(I.format.colorize(),I.format.cli()),transports:[new I.transports.Console({})]});function ie(e){return e?typeof e!="string"?ie(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const we={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},q=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),O={externalModules:[],rcFile:void 0,destDir:void 0},ce=e=>{if(O.externalModules.length>0)return O.externalModules;const s=f.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return O.externalModules=n,n},W=async e=>{if(O.destDir)return O.destDir;const t=await U(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},ae=["salty","css","styles","styled"],le=(e=[])=>new RegExp(`\\.(${[...ae,...e].join("|")})\\.`),H=(e,t=[])=>le(t).test(e),fe=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):fe(a.join(e,".."))},U=async e=>{var n,o;const t=await fe(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Fe=async e=>{const t=await U(e),s=await W(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await oe(e),u=ce(n);await ee.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:u});const d=Date.now(),{config:r}=await import(`${o}?t=${d}`);return r},Ce=async(e,t)=>{const s=await Fe(e),n=new Set,o=($,C=[])=>$?Object.entries($).flatMap(([E,_])=>{if(!_)return;if(typeof _=="object")return o(_,[...C,E]);const z=ie(E),R=M(E),A=[...C,z].join(".");n.add(`"${A}"`);const L=[...C.map(M),R].join("-"),{result:pe}=te(_);return`--${L}: ${pe};`}):[],i=$=>$?Object.entries($).flatMap(([C,E])=>{const _=o(E);return C==="base"?_.join(""):`${C} { ${_.join("")} }`}):[],u=$=>$?Object.entries($).flatMap(([C,E])=>Object.entries(E).flatMap(([_,z])=>{const R=o(z,[C]),A=`.${C}-${_}, [data-${C}="${_}"]`,L=R.join("");return`${A} { ${L} }`})):[],d=$=>t.variables.map(C=>C._current[$]),r=o(q(s.variables,d("variables"))),c=i(q(s.responsiveVariables,d("responsiveVariables"))),y=u(q(s.conditionalVariables,d("conditionalVariables"))),p=await W(e),k=a.join(p,"css/_variables.css"),N=`:root { ${r.join("")} ${c.join("")} } ${y.join("")}`;f.writeFileSync(k,N);const P=a.join(p,"css/_global.css"),T=q(s.global,t.globalStyles),h=V(T,"");f.writeFileSync(P,`@layer global { ${h} }`);const D=a.join(p,"css/_reset.css"),x=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:we,l=V(x,"");f.writeFileSync(D,`@layer reset { ${l} }`);const m=a.join(p,"css/_templates.css"),w=se(s.templates),b=Se(s.templates);f.writeFileSync(m,w);const g=a.join(p,"types/css-tokens.d.ts"),S=`
8
+ `)},Se=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ne(n).map(o=>`"${o}"`).join(" | ")),t),{}),ne=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?ne(o,i,s):s.add(t)}),[...s]):[],re=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return f.existsSync(t)?t:re(a.join(e,".."))},$e=async e=>{const t=re(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},je=async e=>{const t=await $e(e);if(t)return t.type};let J;const oe=async e=>{if(J)return J;const t=await je(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:L&&L.tagName.toUpperCase()==="SCRIPT"&&L.src||new URL("index-DApKMJvn.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},G=I.createLogger({level:"debug",format:I.format.combine(I.format.colorize(),I.format.cli()),transports:[new I.transports.Console({})]});function ie(e){return e?typeof e!="string"?ie(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const we={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},q=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),O={externalModules:[],rcFile:void 0,destDir:void 0},ce=e=>{if(O.externalModules.length>0)return O.externalModules;const s=f.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return O.externalModules=n,n},W=async e=>{if(O.destDir)return O.destDir;const t=await U(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},ae=["salty","css","styles","styled"],le=(e=[])=>new RegExp(`\\.(${[...ae,...e].join("|")})\\.`),K=(e,t=[])=>le(t).test(e),fe=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):fe(a.join(e,".."))},U=async e=>{var n,o;const t=await fe(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Fe=async e=>{const t=await U(e),s=await W(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await oe(e),u=ce(n);await ee.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:u});const d=Date.now(),{config:r}=await import(`${o}?t=${d}`);return r},Ce=async(e,t)=>{const s=await Fe(e),n=new Set,o=($,C=[])=>$?Object.entries($).flatMap(([E,_])=>{if(!_)return;if(typeof _=="object")return o(_,[...C,E]);const z=ie(E),R=M(E),A=[...C,z].join(".");n.add(`"${A}"`);const H=[...C.map(M),R].join("-"),{result:pe}=te(_);return`--${H}: ${pe};`}):[],i=$=>$?Object.entries($).flatMap(([C,E])=>{const _=o(E);return C==="base"?_.join(""):`${C} { ${_.join("")} }`}):[],u=$=>$?Object.entries($).flatMap(([C,E])=>Object.entries(E).flatMap(([_,z])=>{const R=o(z,[C]),A=`.${C}-${_}, [data-${C}="${_}"]`,H=R.join("");return`${A} { ${H} }`})):[],d=$=>t.variables.map(C=>C._current[$]),r=o(q(s.variables,d("variables"))),c=i(q(s.responsiveVariables,d("responsiveVariables"))),y=u(q(s.conditionalVariables,d("conditionalVariables"))),p=await W(e),k=a.join(p,"css/_variables.css"),N=`:root { ${r.join("")} ${c.join("")} } ${y.join("")}`;f.writeFileSync(k,N);const P=a.join(p,"css/_global.css"),T=q(s.global,t.globalStyles),h=V(T,"");f.writeFileSync(P,`@layer global { ${h} }`);const D=a.join(p,"css/_reset.css"),x=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:we,l=V(x,"");f.writeFileSync(D,`@layer reset { ${l} }`);const m=a.join(p,"css/_templates.css"),w=se(s.templates),b=Se(s.templates);f.writeFileSync(m,w);const g=a.join(p,"types/css-tokens.d.ts"),S=`
9
9
  // Variable types
10
10
  type VariableTokens = ${[...n].join("|")};
11
11
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -15,7 +15,7 @@
15
15
  ${Object.entries(b).map(([$,C])=>`${$}?: ${C}`).join(`
16
16
  `)}
17
17
  }
18
- `;f.writeFileSync(g,S)},v=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const u=o.exec(e);if(u){const d=u.at(1);if(ae.some(c=>d==null?void 0:d.includes(c)))return t}return"styled('div',"}),Q=async(e,t,s)=>{const n=Z(t),o=a.join(s,"./temp");f.existsSync(o)||f.mkdirSync(o);const i=a.parse(t);let u=f.readFileSync(t,"utf8");u=v(u);const d=a.join(s,"js",n+".js"),r=await U(e),c=a.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=ce(c),p=await oe(e);await ee.build({stdin:{contents:u,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:p,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:P=>{P.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const h=f.readFileSync(T.path,"utf8");return{contents:v(h),loader:"ts"}})}}]});const k=Date.now();return await import(`${d}?t=${k}`)},X=async e=>{const t=await W(e),s=a.join(t,"salty.config.js"),n=Date.now(),{config:o}=await import(`${s}?t=${n}`);return o},ue=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ue())=>{try{const s=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const n=[],o=[],i=await W(e),u=a.join(i,"index.css");(()=>{f.existsSync(i)&&ye.execSync("rm -rf "+i),f.mkdirSync(i,{recursive:!0}),f.mkdirSync(a.join(i,"css")),f.mkdirSync(a.join(i,"types"))})();const r={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],components:[]};async function c(l){const m=["node_modules","saltygen"],w=f.statSync(l);if(w.isDirectory()){const b=f.readdirSync(l);if(m.some(F=>l.includes(F)))return;await Promise.all(b.map(F=>c(a.join(l,F))))}else if(w.isFile()&&H(l)){const g=await Q(e,l,i);Object.entries(g).forEach(([F,S])=>{S.isKeyframes?r.keyframes.push({value:S,src:l,name:F}):S.isMedia?r.mediaQueries.push(S):S.isGlobalDefine?r.globalStyles.push(S):S.isDefineVariables?r.variables.push(S):S.generator&&r.components.push({value:S.generator,src:l,name:F})})}}await c(e),await Ce(e,r);const y=await X(e);for(const l of r.keyframes){const{value:m}=l,w=`a_${m.animationName}.css`,b=`css/${w}`,g=a.join(i,b);n.push(w),f.writeFileSync(g,m.css)}const p={};for(const l of r.components){const{value:m,name:w,src:b}=l,g=m._withBuildContext({name:w,config:y,prod:t});o[g.priority]||(o[g.priority]=[]),o[g.priority].push(g.cssFileName),y.importStrategy==="component"&&(p[b]?p[b].push(g.cssFileName):p[b]=[g.cssFileName]);const F=`css/${g.cssFileName}`,S=a.join(i,F);f.writeFileSync(S,g.css)}y.importStrategy==="component"&&Object.entries(p).forEach(([l,m])=>{const w=m.map($=>`@import url('./${$}');`).join(`
18
+ `;f.writeFileSync(g,S)},v=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const u=o.exec(e);if(u){const d=u.at(1);if(ae.some(c=>d==null?void 0:d.includes(c)))return t}return"styled('div',"}),Q=async(e,t,s)=>{const n=Z(t),o=a.join(s,"./temp");f.existsSync(o)||f.mkdirSync(o);const i=a.parse(t);let u=f.readFileSync(t,"utf8");u=v(u);const d=a.join(s,"js",n+".js"),r=await U(e),c=a.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=ce(c),p=await oe(e);await ee.build({stdin:{contents:u,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:p,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:P=>{P.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const h=f.readFileSync(T.path,"utf8");return{contents:v(h),loader:"ts"}})}}]});const k=Date.now();return await import(`${d}?t=${k}`)},X=async e=>{const t=await W(e),s=a.join(t,"salty.config.js"),n=Date.now(),{config:o}=await import(`${s}?t=${n}`);return o},ue=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ue())=>{try{const s=Date.now();t?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const n=[],o=[],i=await W(e),u=a.join(i,"index.css");(()=>{f.existsSync(i)&&ye.execSync("rm -rf "+i),f.mkdirSync(i,{recursive:!0}),f.mkdirSync(a.join(i,"css")),f.mkdirSync(a.join(i,"types"))})();const r={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],components:[]};async function c(l){const m=["node_modules","saltygen"],w=f.statSync(l);if(w.isDirectory()){const b=f.readdirSync(l);if(m.some(F=>l.includes(F)))return;await Promise.all(b.map(F=>c(a.join(l,F))))}else if(w.isFile()&&K(l)){const g=await Q(e,l,i);Object.entries(g).forEach(([F,S])=>{S.isKeyframes?r.keyframes.push({value:S,src:l,name:F}):S.isMedia?r.mediaQueries.push(S):S.isGlobalDefine?r.globalStyles.push(S):S.isDefineVariables?r.variables.push(S):S.generator&&r.components.push({value:S.generator,src:l,name:F})})}}await c(e),await Ce(e,r);const y=await X(e);for(const l of r.keyframes){const{value:m}=l,w=`a_${m.animationName}.css`,b=`css/${w}`,g=a.join(i,b);n.push(w),f.writeFileSync(g,m.css)}const p={};for(const l of r.components){const{value:m,name:w,src:b}=l,g=m._withBuildContext({name:w,config:y,prod:t});o[g.priority]||(o[g.priority]=[]),o[g.priority].push(g.cssFileName),y.importStrategy==="component"&&(p[b]?p[b].push(g.cssFileName):p[b]=[g.cssFileName]);const F=`css/${g.cssFileName}`,S=a.join(i,F);f.writeFileSync(S,g.css)}y.importStrategy==="component"&&Object.entries(p).forEach(([l,m])=>{const w=m.map($=>`@import url('./${$}');`).join(`
19
19
  `),b=Z(l,6),g=a.parse(l),F=M(g.name),S=a.join(i,`css/f_${F}-${b}.css`);f.writeFileSync(S,w)});const k=n.map(l=>`@import url('./css/${l}');`).join(`
20
20
  `);let h=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
21
 
@@ -27,10 +27,10 @@ ${z}
27
27
  /*end:${R}*/
28
28
  `},""),F=`l_${b}.css`,S=a.join(i,"css",F),$=`@layer l${b} { ${g}
29
29
  }`;return f.writeFileSync(S,$),`${m}
30
- @import url('./css/${F}');`},"");h+=l}f.writeFileSync(u,h);const j=Date.now()-s,x=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";B.info(`Generated CSS in ${j}ms! ${x}`)}catch(s){console.error(s)}},ke=async(e,t)=>{try{const s=await W(e);if(H(t)){const o=[],i=await X(e),u=await Q(e,t,s);Object.entries(u).forEach(([d,r])=>{if(r.isKeyframes&&r.css){const N=`css/${`a_${r.animationName}.css`}`,P=a.join(s,N);f.writeFileSync(P,r.css);return}if(!r.generator)return;const c=r.generator._withBuildContext({name:d,config:i}),y=`css/${c.cssFileName}`,p=a.join(s,y);f.writeFileSync(p,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),i.importStrategy!=="component"&&o.forEach((d,r)=>{const c=`l_${r}.css`,y=a.join(s,"css",c);let p=f.readFileSync(y,"utf8");d.forEach(k=>{var h;const N=a.join(s,"css",k),P=((h=/.*-([^-]+)-\d+.css/.exec(k))==null?void 0:h.at(1))||Z(N,6);if(!p.includes(P)){const D=f.readFileSync(N,"utf8"),j=`/*start:${P}*/
30
+ @import url('./css/${F}');`},"");h+=l}f.writeFileSync(u,h);const j=Date.now()-s,x=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";G.info(`Generated CSS in ${j}ms! ${x}`)}catch(s){console.error(s)}},ke=async(e,t)=>{try{const s=await W(e);if(K(t)){const o=[],i=await X(e),u=await Q(e,t,s);Object.entries(u).forEach(([d,r])=>{if(r.isKeyframes&&r.css){const N=`css/${`a_${r.animationName}.css`}`,P=a.join(s,N);f.writeFileSync(P,r.css);return}if(!r.generator)return;const c=r.generator._withBuildContext({name:d,config:i}),y=`css/${c.cssFileName}`,p=a.join(s,y);f.writeFileSync(p,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),i.importStrategy!=="component"&&o.forEach((d,r)=>{const c=`l_${r}.css`,y=a.join(s,"css",c);let p=f.readFileSync(y,"utf8");d.forEach(k=>{var h;const N=a.join(s,"css",k),P=((h=/.*-([^-]+)-\d+.css/.exec(k))==null?void 0:h.at(1))||Z(N,6);if(!p.includes(P)){const D=f.readFileSync(N,"utf8"),j=`/*start:${P}*/
31
31
  ${D}
32
32
  /*end:${P}*/
33
33
  `;p=`${p.replace(/\}$/,"")}
34
34
  ${j}
35
- }`}}),f.writeFileSync(y,p)})}}catch(s){console.error(s)}},De=async(e,t,s=ue())=>{try{const n=await W(e);if(H(t)){const i=f.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==i&&await K.writeFile(t,i);const d=await X(e),r=await Q(e,t,n);let c=i;if(Object.entries(r).forEach(([y,p])=>{var S;if(p.isKeyframes||!p.generator)return;const k=p.generator._withBuildContext({name:y,config:d,prod:s}),N=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!N)return console.error("Could not find the original declaration");const P=(S=N.at(1))==null?void 0:S.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:h}=T;let D=!1;const j=setTimeout(()=>D=!0,5e3);let x=0,l=!1,m=0;for(;!l&&!D;){const $=c[h+x];$==="("&&m++,$===")"&&m--,m===0&&$===")"&&(l=!0),x>c.length&&(D=!0),x++}if(!D)clearTimeout(j);else throw new Error("Failed to find the end of the styled call and timed out");const w=h+x,b=c.slice(h,w),g=c,F=` ${y} = styled(${P}, "${k.classNames}", ${JSON.stringify(k.props)});`;c=c.replace(b,F),g===c&&console.error("Minimize file failed to change content",{name:y,tagName:P})}),d.importStrategy==="component"){const y=Z(t,6),p=a.parse(t);c=`import '../../saltygen/css/${`f_${M(p.name)}-${y}.css`}';
36
- ${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=xe;exports.generateFile=ke;exports.isSaltyFile=H;exports.minimizeFile=De;exports.saltyFileRegExp=le;
35
+ }`}}),f.writeFileSync(y,p)})}}catch(s){console.error(s)}},De=async(e,t,s=ue())=>{try{const n=await W(e);if(K(t)){const i=f.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==i&&await B.writeFile(t,i);const d=await X(e),r=await Q(e,t,n);let c=i;if(Object.entries(r).forEach(([y,p])=>{var S;if(p.isKeyframes||!p.generator)return;const k=p.generator._withBuildContext({name:y,config:d,prod:s}),N=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!N)return console.error("Could not find the original declaration");const P=(S=N.at(1))==null?void 0:S.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:h}=T;let D=!1;const j=setTimeout(()=>D=!0,5e3);let x=0,l=!1,m=0;for(;!l&&!D;){const $=c[h+x];$==="("&&m++,$===")"&&m--,m===0&&$===")"&&(l=!0),x>c.length&&(D=!0),x++}if(!D)clearTimeout(j);else throw new Error("Failed to find the end of the styled call and timed out");const w=h+x,b=c.slice(h,w),g=c,F=` ${y} = styled(${P}, "${k.classNames}", ${JSON.stringify(k.props)});`;c=c.replace(b,F),g===c&&console.error("Minimize file failed to change content",{name:y,tagName:P})}),d.importStrategy==="component"){const y=Z(t,6),p=a.parse(t);c=`import '../../saltygen/css/${`f_${M(p.name)}-${y}.css`}';
36
+ ${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=xe;exports.generateFile=ke;exports.minimizeFile=De;exports.saltyFileRegExp=le;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),o=require("./index-a4KtTJRO.cjs"),y=require("fs/promises"),f=async e=>{if(e.includes("salty.config"))return!0;if(!o.isSaltyFile(e))return!1;const n=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},d=(e,t,r=!1,n=!1)=>{var l,i,u;(i=(l=e.module)==null?void 0:l.rules)==null||i.push({test:o.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:t}}]}),r||(u=e.plugins)==null||u.push({apply:h=>{h.hooks.watchRun.tapPromise({name:"generateCss"},async a=>{console.log("generateCss"),await o.generateCss(t),a.hooks.emit.tapPromise({name:"generateCssInner"},async s=>{console.log("generateCssInner")}),a.hooks.invalid.tap({name:"generateCssInner"},async s=>{if(console.log("compiler.hooks.invalid"),!s)return;const c=await f(s);console.log("shouldRestart",{shouldRestart:c,file:s}),c&&(()=>{var g;console.log("restarting"),(g=a.watching)==null||g.invalidate()})()})})}})};exports.default=d;exports.saltyPlugin=d;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("path"),n=require("./index-DApKMJvn.cjs"),u=(e,a,i=!1,p=!1)=>{var l,o,t,r;(o=(l=e.module)==null?void 0:l.rules)==null||o.push({test:n.saltyFileRegExp(),use:[{loader:g.resolve(__dirname,p?"./loader.cjs":"./loader.js"),options:{dir:a}}]}),i||(t=e.plugins)==null||t.push({apply:s=>{s.hooks.watchRun.tapPromise({name:"generateCss"},async c=>{console.log("generateCss"),await n.generateCss(a)})}}),(r=e.plugins)==null||r.push({apply:s=>{s.hooks.watchRun.tap({name:"generateCss2"},async c=>{console.log("outside of server check")})}})};exports.default=u;exports.saltyPlugin=u;
package/index.js CHANGED
@@ -1,39 +1,30 @@
1
- import { resolve as d } from "path";
2
- import { i as f, s as p, g as h } from "./index-jvM0uSOz.js";
3
- import { readFile as m } from "fs/promises";
4
- const y = async (s) => {
5
- if (s.includes("salty.config")) return !0;
6
- if (!f(s)) return !1;
7
- const a = await m(s, "utf-8");
8
- return !!/.+define[A-Z]\w+/.test(a);
9
- }, v = (s, t, n = !1, a = !1) => {
10
- var r, i, l;
11
- (i = (r = s.module) == null ? void 0 : r.rules) == null || i.push({
12
- test: p(),
1
+ import { resolve as i } from "path";
2
+ import { s as m, g as c } from "./index-BnjzfeiU.js";
3
+ const d = (e, a, p = !1, n = !1) => {
4
+ var o, l, t, r;
5
+ (l = (o = e.module) == null ? void 0 : o.rules) == null || l.push({
6
+ test: m(),
13
7
  use: [
14
8
  {
15
- loader: d(__dirname, a ? "./loader.cjs" : "./loader.js"),
16
- options: { dir: t }
9
+ loader: i(__dirname, n ? "./loader.cjs" : "./loader.js"),
10
+ options: { dir: a }
17
11
  }
18
12
  ]
19
- }), n || (l = s.plugins) == null || l.push({
20
- apply: (g) => {
21
- g.hooks.watchRun.tapPromise({ name: "generateCss" }, async (o) => {
22
- console.log("generateCss"), await h(t), o.hooks.emit.tapPromise({ name: "generateCssInner" }, async (e) => {
23
- console.log("generateCssInner");
24
- }), o.hooks.invalid.tap({ name: "generateCssInner" }, async (e) => {
25
- if (console.log("compiler.hooks.invalid"), !e) return;
26
- const c = await y(e);
27
- console.log("shouldRestart", { shouldRestart: c, file: e }), c && (() => {
28
- var u;
29
- console.log("restarting"), (u = o.watching) == null || u.invalidate();
30
- })();
31
- });
13
+ }), p || (t = e.plugins) == null || t.push({
14
+ apply: (s) => {
15
+ s.hooks.watchRun.tapPromise({ name: "generateCss" }, async (u) => {
16
+ console.log("generateCss"), await c(a);
17
+ });
18
+ }
19
+ }), (r = e.plugins) == null || r.push({
20
+ apply: (s) => {
21
+ s.hooks.watchRun.tap({ name: "generateCss2" }, async (u) => {
22
+ console.log("outside of server check");
32
23
  });
33
24
  }
34
25
  });
35
26
  };
36
27
  export {
37
- v as default,
38
- v as saltyPlugin
28
+ d as default,
29
+ d as saltyPlugin
39
30
  };
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-a4KtTJRO.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
1
+ "use strict";const i=require("./index-DApKMJvn.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
package/loader.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, m as i } from "./index-jvM0uSOz.js";
1
+ import { a as e, m as i } from "./index-BnjzfeiU.js";
2
2
  async function s() {
3
3
  const { dir: t } = this.getOptions(), { resourcePath: a } = this;
4
4
  return await e(t, a), await i(t, a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
3
- "version": "0.0.1-alpha.157",
3
+ "version": "0.0.1-alpha.158",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.157",
37
+ "@salty-css/core": "^0.0.1-alpha.158",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }