@salty-css/webpack 0.0.1-alpha.235 → 0.0.1-alpha.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index-C97eBBve.cjs +42 -0
- package/index-CHPE5cnj.js +678 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/loader.cjs +1 -1
- package/loader.js +1 -1
- package/package.json +2 -2
- package/index-B5IaIfZg.cjs +0 -42
- package/index-gNPxxbk_.js +0 -678
package/loader.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/webpack",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.236",
|
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.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.236",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|
package/index-B5IaIfZg.cjs
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
"use strict";var Vt=Object.defineProperty;var Mt=(t,e,s)=>e in t?Vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var st=(t,e,s)=>Mt(t,typeof e!="symbol"?e+"":e,s);const vt=require("esbuild"),Rt=require("child_process"),c=require("path"),f=require("fs"),bt=require("fs/promises"),U=require("winston"),lt=require("typescript");var ft=typeof document<"u"?document.currentScript:null;function zt(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 St=zt(vt),wt=t=>String.fromCharCode(t+(t>25?39:97)),Jt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=wt(n%52)+s;return s=wt(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},Wt=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},W=(t,e=5)=>{const s=Wt(5381,JSON.stringify(t))>>>0;return Jt(s,e)};function R(t){return t?typeof t!="string"?R(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 At=t=>e=>{if(typeof e!="string"||!t)return;let s=e;const n=[];return Object.values(t).forEach(o=>{const{pattern:i,transform:r}=o;s=s.replace(i,y=>{const{value:g,css:h}=r(y);return h&&n.push(h),g})}),{transformed:s,additionalCss:n}},jt=t=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${R(o[1].replaceAll(".","-"))})`)},qt=jt(),It=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Ht=(t,e,s)=>It.some(o=>typeof o=="string"?o===t:o.test(t))?`${e}px`:`${e}`,Lt=["Webkit","Moz","ms","O"],Gt=t=>t.startsWith("-")?t:Lt.some(e=>t.startsWith(e))?`-${R(t)}`:R(t),nt=async(t,e="",s,n=!1)=>{if(!t)throw new Error("No styles provided to parseStyles function!");const o=new Set,i=Object.entries(t),r=async([p,d])=>{const b=p.trim(),P=Gt(b),x=(M,k=";")=>`${P}:${M}${k}`,O={scope:e,config:s};if(typeof d=="function")return r([p,d(O)]);if(d instanceof Promise)return r([p,await d]);if(typeof d=="object"){if(!d)return;if(d.isColor)return x(d.toString());if(b==="defaultVariants")return;if(b==="variants"){const D=Object.entries(d);for(const[a,$]of D){if(!$)return;const C=Object.entries($);for(const[l,j]of C){if(!j)return;const N=`${e}.${a}-${l}`;(await nt(j,N,s)).forEach(J=>o.add(J))}}return}if(b==="compoundVariants"){for(const D of d){const{css:a,...$}=D,C=Object.entries($).reduce((j,[N,E])=>`${j}.${N}-${E}`,e);(await nt(a,C,s)).forEach(j=>o.add(j))}return}if(b.startsWith("@")){const D=b,a=await B(d,e,s),$=`${D} { ${a} }`;o.add($);return}const M=p.includes("&")?b.replace("&",e):b.startsWith(":")?`${e}${b}`:`${e} ${b}`;(await nt(d,M,s)).forEach(D=>o.add(D));return}if(typeof d=="number"){const M=Ht(P,d);return x(M)}if(typeof d!="string")if("toString"in d)d=d.toString();else throw new Error(`Invalid value type for property ${P}`);return x(d)},y=i.map(r),{modifiers:g}={},h=[jt(),At(g)],w=(await Promise.all(y).then(p=>Promise.all(p.map(d=>h.reduce(async(b,P)=>{const x=await b;if(!x)return x;const O=await P(x);if(!O)return x;const{transformed:M,additionalCss:k}=O;let D="";if(k)for(const a of k)D+=await B(a,"");return`${D}${M}`},Promise.resolve(d)))))).filter(p=>p!==void 0).join(`
|
2
|
-
`);if(!w.trim())return Array.from(o);const m=e?`${e} {
|
3
|
-
${w}
|
4
|
-
}`:w;return o.has(m)?Array.from(o):[m,...o]},B=async(t,e,s,n=!1)=>(await nt(t,e,s,n)).join(`
|
5
|
-
`),Ft=async(t,e=[])=>{if(!t)return"";const s=[],n={};for(const[o,i]of Object.entries(t))if(typeof i!="function")if(i&&typeof i=="object"){const r=o.trim(),y=await Ft(i,[...e,r]);s.push(y)}else n[o]=i;if(Object.keys(n).length){const o=e.map(R).join("-"),i="t_"+W(o,4),r=await B(n,`.${o}, .${i}`);s.push(r)}return s.join(`
|
6
|
-
`)},Kt=t=>t?Object.entries(t).reduce((e,[s,n])=>(typeof n=="function"?e[s]="any":typeof n=="object"&&(e[s]=Ct(n).map(o=>`"${o}"`).join(" | ")),e),{}):{},Ct=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?Ct(o,i,s):s.add(e)}),[...s]):[],Pt=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=c.join(t,"package.json");return f.existsSync(e)?e:Pt(c.join(t,".."))},Qt=async t=>{const e=Pt(t);return await bt.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},Ut=async t=>{const e=await Qt(t);if(e)return e.type};let I;const Nt=async t=>{if(I)return I;const e=await Ut(t);return e==="module"?I="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.tagName.toUpperCase()==="SCRIPT"&&ft.src||new URL("index-B5IaIfZg.cjs",document.baseURI).href).endsWith(".cjs"))&&(I="cjs"),I||"esm"},ut=U.createLogger({level:"debug",format:U.format.combine(U.format.colorize(),U.format.cli()),transports:[new U.transports.Console({})]});function _t(t){return t?typeof t!="string"?_t(String(t)):t.replace(/[^\d\w]/g,"."):""}const Bt={"*, *::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"}},H=(...t)=>t.flat().reduce((e,s)=>s!=null&&s._current?{...e,...s._current}:{...e,...s},{}),Zt=(...t)=>t.flat().reduce((e,s)=>({...e,...s._children}),{});class Xt{constructor(e){st(this,"_path");this.params=e}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(e){return this._path=e,this}}class Yt{constructor(e){st(this,"_path");st(this,"templates",[]);this.params=e,Object.entries(e).forEach(([s,n])=>{this.templates.push(new Xt({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(e=>[e.params.name,e]))}get isDefineTemplates(){return!0}_setPath(e){return this._path=e,this.templates.forEach(s=>s._setPath(e)),this}}const te=t=>new Yt(t),ee=(t,e)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),i=lt.createSourceFile("temp.ts",t,lt.ScriptTarget.Latest,!0);function r(y){if(lt.isVariableDeclaration(y)&&y.name.getText()===e){const g=y.getStart(),h=y.getEnd();clearTimeout(o),s([g,h])}y.forEachChild(r)}r(i)}),z={externalModules:[],rcFile:void 0,destDir:void 0},xt=t=>{if(z.externalModules.length>0)return z.externalModules;const s=f.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return z.externalModules=n,n},A=async t=>{if(z.destDir)return z.destDir;const e=await dt(t),s=c.join(t,(e==null?void 0:e.saltygenDir)||"saltygen");return z.destDir=s,s},Tt=["salty","css","styles","styled"],kt=(t=[])=>new RegExp(`\\.(${[...Tt,...t].join("|")})\\.`),ot=(t,e=[])=>kt(e).test(t),Dt=async t=>{if(z.rcFile)return z.rcFile;if(t==="/")throw new Error("Could not find .saltyrc.json file");const e=c.join(t,".saltyrc.json"),s=await bt.readFile(e,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Dt(c.join(t,".."))},dt=async t=>{var n,o;const e=await Dt(t),s=(n=e.projects)==null?void 0:n.find(i=>t.endsWith(i.dir||""));return s||((o=e.projects)==null?void 0:o.find(i=>i.dir===e.defaultProject))},se=async t=>{const e=await dt(t),s=await A(t),n=c.join(t,(e==null?void 0:e.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),i=await Nt(t),r=xt(n);await St.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:r});const y=Date.now(),{config:g}=await import(`${o}?t=${y}`);return{config:g,path:o}},ne=async(t,e)=>{var yt,ht;const s=await A(t),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...e].map(async F=>{const{contents:_,outputFilePath:Q}=await it(t,F,s);Object.entries(_).forEach(([v,T])=>{T.isMedia?n.mediaQueries.push([v,T]):T.isGlobalDefine?n.globalStyles.push(T):T.isDefineVariables?n.variables.push(T):T.isDefineTemplates&&n.templates.push(T._setPath(`${v};;${Q}`))})}));const{config:o,path:i}=await se(t),r={...o},y=new Set,g=async(F,_=[])=>{if(!F)return[];const Q=Object.entries(F).map(async([T,q])=>{const tt=async V=>{if(!V)return;if(V instanceof Promise)return await tt(await V);if(typeof V=="function")return await tt(await V());if(typeof V=="object")return await g(V,[..._,T]);const rt=_t(T),at=R(T),ct=[..._,rt].join(".");y.add(`"${ct}"`);const et=[..._.map(R),at].join("-"),gt=qt(V);return gt?`--${et}: ${gt.transformed};`:`--${et}: ${V};`};return await tt(q)});return(await Promise.all(Q)).flat()},h=async F=>{if(!F)return[];const _=Object.entries(F).map(async([v,T])=>{const q=await g(T);return v==="base"?q.join(""):`${v} { ${q.join("")} }`});return(await Promise.all(_)).flat()},u=async F=>{if(!F)return[];const _=Object.entries(F).map(async([v,T])=>{const q=Object.entries(T).map(async([V,rt])=>{const at=await g(rt,[v]),ct=`.${v}-${V}, [data-${v}="${V}"]`,et=at.join("");return`${ct} { ${et} }`});return(await Promise.all(q)).flat()});return(await Promise.all(_)).flat()},w=F=>({...F,responsive:void 0,conditional:void 0}),m=F=>n.variables.map(_=>F==="static"?w(_._current):_._current[F]),S=H(w(o.variables),m("static")),p=await g(S),d=H((yt=o.variables)==null?void 0:yt.responsive,m("responsive")),b=await h(d),P=H((ht=o.variables)==null?void 0:ht.conditional,m("conditional")),x=await u(P),O=c.join(s,"css/_variables.css"),M=`:root { ${p.join("")} ${b.join("")} } ${x.join("")}`;f.writeFileSync(O,M),r.staticVariables=S;const k=c.join(s,"css/_global.css"),D=H(o.global,n.globalStyles),a=await B(D,"");f.writeFileSync(k,`@layer global { ${a} }`);const $=c.join(s,"css/_reset.css"),l=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Bt,j=await B(l,"");f.writeFileSync($,`@layer reset { ${j} }`);const N=c.join(s,"css/_templates.css"),E=H(o.templates,n.templates),J=await Ft(E),L=Kt(E);f.writeFileSync(N,`@layer templates { ${J} }`),r.templates=E;const G=o.templates?[te(o.templates)._setPath(`config;;${i}`)]:[],Z=Zt(n.templates,G);r.templatePaths=Object.fromEntries(Object.entries(Z).map(([F,_])=>[F,_._path]));const{mediaQueries:X}=n;r.mediaQueries=Object.fromEntries(X.map(([F,_])=>[`@${F}`,_]));const K=X.map(([F])=>`'@${F}'`).join(" | "),Y=c.join(s,"types/css-tokens.d.ts"),Et=`
|
7
|
-
// Variable types
|
8
|
-
type VariableTokens = ${[...y].join("|")};
|
9
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
10
|
-
|
11
|
-
// Template types
|
12
|
-
type TemplateTokens = {
|
13
|
-
${Object.entries(L).map(([F,_])=>`${F}?: ${_}`).join(`
|
14
|
-
`)}
|
15
|
-
}
|
16
|
-
|
17
|
-
// Media query types
|
18
|
-
type MediaQueryKeys = ${K||"''"};
|
19
|
-
`;f.writeFileSync(Y,Et);const Ot=c.join(s,"cache/config-cache.json");f.writeFileSync(Ot,JSON.stringify(r,null,2))},$t=t=>t.replace(/styled\(([^"'`{,]+),/g,(e,s)=>{if(/^['"`]/.test(s))return e;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(t))return e;const r=o.exec(t);if(r){const y=r.at(1);if(Tt.some(h=>y==null?void 0:y.includes(h)))return e}return"styled('div',"}),oe=(t,e)=>{try{const s=f.readFileSync(c.join(e,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
20
|
-
|
21
|
-
${t}`:`globalThis.saltyConfig = {};
|
22
|
-
|
23
|
-
${t}`}catch{return t}},it=async(t,e,s)=>{const n=W(e),o=c.join(s,"./temp");f.existsSync(o)||f.mkdirSync(o);const i=c.parse(e);let r=f.readFileSync(e,"utf8");r=$t(r),r=oe(r,t);const y=c.join(s,"js",n+".js"),g=await dt(t),h=c.join(t,(g==null?void 0:g.configDir)||"","salty.config.ts"),u=xt(h),w=await Nt(t);await St.build({stdin:{contents:r,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:w,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},d=>{const b=f.readFileSync(d.path,"utf8");return{contents:$t(b),loader:"ts"}})}}]});const m=Date.now();return{contents:await import(`${y}?t=${m}`),outputFilePath:y}},ie=async t=>{const e=await A(t),s=c.join(e,"cache/config-cache.json"),n=f.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},pt=async t=>{const e=await ie(t),s=await A(t),n=c.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return H(i,e)},mt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},re=async(t,e=mt(),s=!0)=>{try{const n=Date.now();e?ut.info("Generating CSS in production mode! 🔥"):ut.info("Generating CSS in development mode! 🚀");const o=[],i=[],r=await A(t),y=c.join(r,"index.css");s&&(()=>{f.existsSync(r)&&Rt.execSync("rm -rf "+r),f.mkdirSync(r,{recursive:!0}),f.mkdirSync(c.join(r,"css")),f.mkdirSync(c.join(r,"types")),f.mkdirSync(c.join(r,"js")),f.mkdirSync(c.join(r,"cache"))})();const h=new Set,u=new Set;async function w(a){const $=["node_modules","saltygen"],C=f.statSync(a);if(C.isDirectory()){const l=f.readdirSync(a);if($.some(N=>a.includes(N)))return;await Promise.all(l.map(N=>w(c.join(a,N))))}else if(C.isFile()&&ot(a)){h.add(a);const j=f.readFileSync(a,"utf8");/define[\w\d]+\(/.test(j)&&u.add(a)}}await w(t),await ne(t,u);const m={keyframes:[],components:[],classNames:[]};await Promise.all([...h].map(async a=>{const{contents:$}=await it(t,a,r);for(let[C,l]of Object.entries($))l instanceof Promise&&(l=await l),l.isKeyframes?m.keyframes.push({value:l,src:a,name:C}):l.isClassName?m.classNames.push({...l,src:a,name:C}):l.generator&&m.components.push({...l,src:a,name:C})}));const S=await pt(t);for(const a of m.keyframes){const{value:$}=a,C=`a_${$.animationName}.css`,l=`css/${C}`,j=c.join(r,l);o.push(C),f.writeFileSync(j,$.css)}const p={};for(const a of m.components){const{src:$,name:C}=a;p[$]||(p[$]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:e,config:S});i[l.priority]||(i[l.priority]=[]);const j=await l.css;if(!j)continue;i[l.priority].push(l.cssFileName);const N=`css/${l.cssFileName}`,E=c.join(r,N);f.writeFileSync(E,j),S.importStrategy==="component"&&p[$].push(l.cssFileName)}for(const a of m.classNames){const{src:$,name:C}=a;p[$]||(p[$]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:e,config:S}),j=await l.css;if(!j)continue;i[l.priority]||(i[l.priority]=[]),i[l.priority].push(l.cssFileName);const N=`css/${l.cssFileName}`,E=c.join(r,N);f.writeFileSync(E,j),S.importStrategy==="component"&&p[$].push(l.cssFileName)}S.importStrategy==="component"&&Object.entries(p).forEach(([a,$])=>{const C=$.map(J=>`@import url('./${J}');`).join(`
|
24
|
-
`),l=W(a,6),j=c.parse(a),N=R(j.name),E=c.join(r,`css/f_${N}-${l}.css`);f.writeFileSync(E,C||"/* Empty file */")});const d=o.map(a=>`@import url('./css/${a}');`).join(`
|
25
|
-
`);let O=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
26
|
-
|
27
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return f.readFileSync(c.join(r,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
28
|
-
`)}
|
29
|
-
${d}`;if(S.importStrategy!=="component"){const a=i.reduce(($,C,l)=>{const j=C.reduce((L,G)=>{var Y;const Z=c.join(r,"css",G),X=f.readFileSync(Z,"utf8"),K=((Y=/.*-([^-]+)-\d+.css/.exec(G))==null?void 0:Y.at(1))||W(Z,6);return L.includes(K)?L:`${L}
|
30
|
-
/*start:${K}-${G}*/
|
31
|
-
${X}
|
32
|
-
/*end:${K}*/
|
33
|
-
`},""),N=`l_${l}.css`,E=c.join(r,"css",N),J=`@layer l${l} { ${j}
|
34
|
-
}`;return f.writeFileSync(E,J),`${$}
|
35
|
-
@import url('./css/${N}');`},"");O+=a}f.writeFileSync(y,O);const k=Date.now()-n,D=k<200?"🔥":k<500?"🚀":k<1e3?"🎉":k<2e3?"🚗":k<5e3?"🤔":"🥴";ut.info(`Generated CSS in ${k}ms! ${D}`)}catch(n){console.error(n)}},ae=async(t,e,s=mt())=>{try{const n=await A(t);if(ot(e)){const i=[],r=await pt(t),{contents:y}=await it(t,e,n);for(const[g,h]of Object.entries(y)){if(h.isKeyframes&&h.css){const d=`css/${`a_${h.animationName}.css`}`,b=c.join(n,d);f.writeFileSync(b,await h.css);return}if(h.isClassName){const p=h.generator._withBuildContext({callerName:g,isProduction:s,config:r}),d=await p.css;if(!d)continue;i[p.priority]||(i[p.priority]=[]),i[p.priority].push(p.cssFileName);const b=`css/${p.cssFileName}`,P=c.join(n,b);f.writeFileSync(P,d)}if(!h.generator)return;const u=h.generator._withBuildContext({callerName:g,isProduction:s,config:r}),w=await u.css;if(!w)continue;const m=`css/${u.cssFileName}`,S=c.join(n,m);f.writeFileSync(S,w),i[u.priority]||(i[u.priority]=[]),i[u.priority].push(u.cssFileName)}if(r.importStrategy!=="component")i.forEach((g,h)=>{const u=`l_${h}.css`,w=c.join(n,"css",u);let m=f.readFileSync(w,"utf8");g.forEach(S=>{var P;const p=c.join(n,"css",S),d=((P=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:P.at(1))||W(p,6);if(!m.includes(d)){const x=f.readFileSync(p,"utf8"),O=`/*start:${d}-${S}*/
|
36
|
-
${x}
|
37
|
-
/*end:${d}*/
|
38
|
-
`;m=`${m.replace(/\}$/,"")}
|
39
|
-
${O}
|
40
|
-
}`}}),f.writeFileSync(w,m)});else{const g=i.flat().map(S=>`@import url('./${S}');`).join(`
|
41
|
-
`),h=W(e,6),u=c.parse(e),w=R(u.name),m=c.join(n,`css/f_${w}-${h}.css`);f.writeFileSync(m,g||"/* Empty file */")}}}catch(n){console.error(n)}},ce=async(t,e,s=mt())=>{var n,o;try{const i=await A(t);if(ot(e)){const y=f.readFileSync(e,"utf8"),g=await pt(t),{contents:h}=await it(t,e,i);let u=y;for(const[w,m]of Object.entries(h)){if(m.isKeyframes||!m.generator)continue;const S=m.generator._withBuildContext({callerName:w,isProduction:s,config:g}),[p,d]=await ee(u,w),b=u.slice(p,d);if(m.isClassName){const P=u,x=` ${w} = className("${S.classNames}")`;u=u.replace(b,x),P===u&&console.error("Minimize file failed to change content",{name:w})}if(b.includes("styled")){const P=(o=(n=/styled\(([^,]+),/.exec(b))==null?void 0:n.at(1))==null?void 0:o.trim(),x=u,O=` ${w} = styled(${P}, "${S.classNames}", ${JSON.stringify(S.clientProps)})`;u=u.replace(b,O),x===u&&console.error("Minimize file failed to change content",{name:w,tagName:P})}}if(g.importStrategy==="component"){const w=W(e,6),m=c.parse(e);u=`import '../../saltygen/css/${`f_${R(m.name)}-${w}.css`}';
|
42
|
-
${u}`}return u=u.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),u=u.replace("{ styled }","{ styledClient as styled }"),u=u.replace("@salty-css/react/styled","@salty-css/react/styled-client"),u}}catch(i){console.error("Error in minimizeFile:",i)}};exports.generateCss=re;exports.generateFile=ae;exports.isSaltyFile=ot;exports.minimizeFile=ce;exports.saltyFileRegExp=kt;
|