@salty-css/webpack 0.0.1-alpha.139 → 0.0.1-alpha.140

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.
@@ -0,0 +1,29 @@
1
+ "use strict";const pe=require("esbuild"),de=require("child_process"),a=require("path"),u=require("fs"),X=require("fs/promises"),z=require("winston");var W=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 Y=ge(pe),G=e=>String.fromCharCode(e+(e>25?39:97)),ye=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=G(n%52)+s;return s=G(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},me=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},q=(e,t=5)=>{const s=me(5381,JSON.stringify(e))>>>0;return ye(s,t)};function E(e){return e?typeof e!="string"?E(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 he=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:o}=n;e=e.replace(i,l=>{const{value:d,css:c}=o(l);return c&&s.push(c),d})}),{result:e,additionalCss:s}},Q=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${E(n[1].replaceAll(".","-"))})`)}:{result:e},O=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((l,[d,c])=>{const r=d.trim();if(typeof c=="function"&&(c=c()),typeof c=="object"){if(!c)return l;if(r==="variants")return Object.entries(c).forEach(([f,y])=>{y&&Object.entries(y).forEach(([N,b])=>{if(!b)return;const T=`${t}.${f}-${N}`,k=O(b,T);n.push(k)})}),l;if(r==="defaultVariants")return l;if(r==="compoundVariants")return c.forEach(f=>{const{css:y,...N}=f,b=Object.entries(N).reduce((k,[p,m])=>`${k}.${p}-${m}`,t),T=O(y,b);n.push(T)}),l;if(r.startsWith("@")){const f=O(c,t),y=`${r} {
2
+ ${f.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return n.push(y),l}const g=d.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,w=O(c,g);return n.push(w),l}const h=r.startsWith("-")?r:E(r),F=(g,w=";")=>l=`${l}${g}${w}`,j=g=>F(`${h}:${g}`);if(typeof c=="number")return j(c);if(typeof c!="string")if("toString"in c)c=c.toString();else return l;const{modifiers:S}={},_=function*(){yield Q(c),yield he(c,S)}();for(const{result:g,additionalCss:w=[]}of _)c=g,w.forEach(f=>{const y=O(f,"");F(y,"")});return j(c)},"");return i?t?[`${t} { ${i} }`,...n].join(`
6
+ `):i:n.join(`
7
+ `)},v=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,o])=>{if(typeof o=="object"){if(!o)return;const l=i.trim(),d=v(o,[...t,l]);s.push(d)}else n[i]=o}),Object.keys(n).length){const i=t.map(E).join("-"),o=O(n,`.${i}`);s.push(o)}return s.join(`
8
+ `)},Se=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ee(n).map(i=>`"${i}"`).join(" | ")),t),{}),ee=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?ee(i,o,s):s.add(t)}),[...s]):[],te=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return u.existsSync(t)?t:te(a.join(e,".."))},$e=async e=>{const t=te(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},be=async e=>{const t=await $e(e);if(t)return t.type};let R;const se=async e=>{if(R)return R;const t=await be(e);return t==="module"?R="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-D0sdFJc4.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},Z=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]});function ne(e){return e?typeof e!="string"?ne(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 je={"*, *::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"}},I={externalModules:[]},oe=e=>{if(I.externalModules.length>0)return I.externalModules;const t=a.join(e,"salty.config.ts"),n=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return I.externalModules=i,i},J=e=>a.join(e,"./saltygen"),re=["salty","css","styles","styled"],ie=(e=[])=>new RegExp(`\\.(${[...re,...e].join("|")})\\.`),L=(e,t=[])=>ie(t).test(e),we=async e=>{const t=J(e),s=a.join(e,"salty.config.ts"),n=a.join(t,"salty.config.js"),i=await se(e),o=oe(e);await Y.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const l=Date.now(),{config:d}=await import(`${n}?t=${l}`);return d},Fe=async e=>{const t=await we(e),s=new Set,n=(p,m=[])=>p?Object.entries(p).flatMap(([C,$])=>{if(!$)return;if(typeof $=="object")return n($,[...m,C]);const M=ne(C),A=E(C),V=[...m,M].join(".");s.add(`"${V}"`);const P=[...m.map(E),A].join("-"),{result:D}=Q($);return`--${P}: ${D};`}):[],i=p=>p?Object.entries(p).flatMap(([m,C])=>{const $=n(C);return m==="base"?$.join(""):`${m} { ${$.join("")} }`}):[],o=p=>p?Object.entries(p).flatMap(([m,C])=>Object.entries(C).flatMap(([$,M])=>{const A=n(M,[m]),V=`.${m}-${$}, [data-${m}="${$}"]`,P=A.join("");return`${V} { ${P} }`})):[],l=n(t.variables),d=i(t.responsiveVariables),c=o(t.conditionalVariables),r=J(e),h=a.join(r,"css/_variables.css"),F=`:root { ${l.join("")} ${d.join("")} } ${c.join("")}`;u.writeFileSync(h,F);const j=a.join(r,"css/_global.css"),S=O(t.global,"");u.writeFileSync(j,`@layer global { ${S} }`);const x=a.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:je,w=O(g,"");u.writeFileSync(x,`@layer reset { ${w} }`);const f=a.join(r,"css/_templates.css"),y=v(t.templates),N=Se(t.templates);u.writeFileSync(f,y);const b=a.join(r,"types/css-tokens.d.ts"),k=`
9
+ // Variable types
10
+ type VariableTokens = ${[...s].join("|")};
11
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
12
+
13
+ // Template types
14
+ type TemplateTokens = {
15
+ ${Object.entries(N).map(([p,m])=>`${p}?: ${m}`).join(`
16
+ `)}
17
+ }
18
+ `;u.writeFileSync(b,k)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{const n=/^['"`]/.test(s);if(n&&console.log("String tag",s),n)return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`),o=i.test(e);if(o||console.log("Not imported",s),!o)return t;const l=i.exec(e);if(l){const d=l.at(1),c=re.some(r=>d==null?void 0:d.includes(r));if(c&&console.log("Salty import for",s,`"${l.at(0)}"`),c)return t}return console.log("Replacing",s),"styled('div',"}),H=async(e,t,s)=>{console.log({sourceFilePath:t});const n=q(t),i=a.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=a.parse(t);let l=u.readFileSync(t,"utf8");l=U(l);const d=a.join(s,"js",n+".js"),c=oe(e),r=await se(e);await Y.build({stdin:{contents:l,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:r,target:["node20"],keepNames:!0,external:c,packages:"external",plugins:[{name:"test",setup:j=>{j.onLoad({filter:/.*.css.ts/},S=>{console.log("Loading",{sourceFilePath:t,args:S});const x=u.readFileSync(S.path,"utf8");return{contents:U(x)}})}}]});const h=Date.now();return await import(`${d}?t=${h}`)},B=async e=>{const t=J(e),s=a.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ce())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=J(e),l=a.join(o,"index.css");(()=>{u.existsSync(o)&&de.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(a.join(o,"css")),u.mkdirSync(a.join(o,"types"))})(),await Fe(e);const c=await B(e);async function r(f,y){const N=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const T=u.readdirSync(f);if(N.some(p=>f.includes(p)))return;await Promise.all(T.map(p=>r(a.join(f,p),a.join(y,p))))}else if(b.isFile()&&L(f)){const k=await H(e,f,o),p=[];Object.entries(k).forEach(([V,P])=>{if(P.isKeyframes&&P.css){const K=`a_${P.animationName}.css`,fe=`css/${K}`,ue=a.join(o,fe);n.push(K),u.writeFileSync(ue,P.css);return}if(!P.generator)return;const D=P.generator._withBuildContext({name:V,config:c,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),p.push(D.cssFileName);const ae=`css/${D.cssFileName}`,le=a.join(o,ae);u.writeFileSync(le,D.css)});const m=p.map(V=>`@import url('./${V}');`).join(`
19
+ `),C=q(f,6),$=a.parse(f),M=E($.name),A=a.join(o,`css/f_${M}-${C}.css`);u.writeFileSync(A,m)}}await r(e,o);const h=n.map(f=>`@import url('./css/${f}');`).join(`
20
+ `);let x=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
+
22
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(a.join(o,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
23
+ `)}
24
+ ${h}`;if(c.importStrategy!=="component"){const f=i.reduce((y,N,b)=>{const T=N.reduce((C,$)=>{const M=u.readFileSync(a.join(o,"css",$),"utf8");return`${C}
25
+ ${M}`},""),k=`l_${b}.css`,p=a.join(o,"css",k),m=`@layer l${b} { ${T} }`;return u.writeFileSync(p,m),`${y}
26
+ @import url('./css/${k}');`},"");x+=f}u.writeFileSync(l,x);const g=Date.now()-s,w=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";Z.info(`Generated CSS in ${g}ms! ${w}`)}catch(s){console.error(s)}},Ce=async(e,t)=>{try{const s=[],n=a.join(e,"./saltygen"),i=a.join(n,"index.css");if(L(t)){const l=await B(e),d=await H(e,t,n);Object.entries(d).forEach(([j,S])=>{if(S.isKeyframes&&S.css){const f=`css/${`a_${S.animationName}.css`}`,y=a.join(n,f);u.writeFileSync(y,S.css);return}if(!S.generator)return;const x=S.generator._withBuildContext({name:j,config:l}),_=`css/${x.cssFileName}`,g=a.join(n,_);s.push(x.cssFileName),u.writeFileSync(g,x.css)});const c=u.readFileSync(i,"utf8").split(`
27
+ `),r=s.map(j=>`@import url('../saltygen/css/${j}');`),F=[...new Set([...c,...r])].join(`
28
+ `);u.writeFileSync(i,F)}}catch(s){console.error(s)}},ke=async(e,t,s=ce())=>{try{const n=a.join(e,"./saltygen");if(L(t)){const o=u.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,h=>`export ${h}`)!==o&&await X.writeFile(t,o);const d=await B(e),c=await H(e,t,n);let r=o;if(Object.entries(c).forEach(([h,F])=>{var C;if(F.isKeyframes||!F.generator)return;const j=F.generator._withBuildContext({name:h,config:d,prod:s}),S=new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!S)return console.error("Could not find the original declaration");const x=(C=S.at(1))==null?void 0:C.trim(),_=new RegExp(`\\s${h}[=\\s]+styled\\(`,"g").exec(r);if(!_)return console.error("Could not find the original declaration");const{index:g}=_;let w=!1;const f=setTimeout(()=>w=!0,5e3);let y=0,N=!1,b=0;for(;!N&&!w;){const $=r[g+y];$==="("&&b++,$===")"&&b--,b===0&&$===")"&&(N=!0),y>r.length&&(w=!0),y++}if(!w)clearTimeout(f);else throw new Error("Failed to find the end of the styled call and timed out");const T=g+y,k=r.slice(g,T),p=r,m=` ${h} = styled(${x}, "${j.classNames}", ${JSON.stringify(j.props)});`;r=r.replace(k,m),p===r&&console.error("Minimize file failed to change content",{name:h,tagName:x})}),d.importStrategy==="component"){const h=q(t,6),F=a.parse(t);r=`import '../../saltygen/css/${`f_${E(F.name)}-${h}.css`}';
29
+ ${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=xe;exports.generateFile=Ce;exports.minimizeFile=ke;exports.saltyFileRegExp=ie;
@@ -0,0 +1,434 @@
1
+ import * as v from "esbuild";
2
+ import { execSync as dt } from "child_process";
3
+ import { join as f, parse as L } from "path";
4
+ import { existsSync as B, writeFileSync as k, readFileSync as A, mkdirSync as W, statSync as gt, readdirSync as mt } from "fs";
5
+ import { readFile as yt, writeFile as ht } from "fs/promises";
6
+ import { createLogger as $t, format as Z, transports as bt } from "winston";
7
+ const Y = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), St = (t, e) => {
8
+ let s = "", n;
9
+ for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = Y(n % 52) + s;
10
+ return s = Y(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
11
+ }, jt = (t, e) => {
12
+ let s = e.length;
13
+ for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
14
+ return t;
15
+ }, K = (t, e = 5) => {
16
+ const s = jt(5381, JSON.stringify(t)) >>> 0;
17
+ return St(s, e);
18
+ };
19
+ function V(t) {
20
+ return t ? typeof t != "string" ? V(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
21
+ }
22
+ const wt = (t, e) => {
23
+ if (typeof t != "string") return { result: t };
24
+ if (!e) return { result: t };
25
+ const s = [];
26
+ return Object.values(e).forEach((n) => {
27
+ const { pattern: i, transform: o } = n;
28
+ t = t.replace(i, (a) => {
29
+ const { value: u, css: c } = o(a);
30
+ return c && s.push(c), u;
31
+ });
32
+ }), { result: t, additionalCss: s };
33
+ }, tt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, O = (t, e, s) => {
34
+ if (!t) return "";
35
+ const n = [], i = Object.entries(t).reduce((a, [u, c]) => {
36
+ const r = u.trim();
37
+ if (typeof c == "function" && (c = c()), typeof c == "object") {
38
+ if (!c) return a;
39
+ if (r === "variants")
40
+ return Object.entries(c).forEach(([l, g]) => {
41
+ g && Object.entries(g).forEach(([N, b]) => {
42
+ if (!b) return;
43
+ const T = `${e}.${l}-${N}`, F = O(b, T);
44
+ n.push(F);
45
+ });
46
+ }), a;
47
+ if (r === "defaultVariants")
48
+ return a;
49
+ if (r === "compoundVariants")
50
+ return c.forEach((l) => {
51
+ const { css: g, ...N } = l, b = Object.entries(N).reduce((F, [p, m]) => `${F}.${p}-${m}`, e), T = O(g, b);
52
+ n.push(T);
53
+ }), a;
54
+ if (r.startsWith("@")) {
55
+ const l = O(c, e), g = `${r} {
56
+ ${l.replace(`
57
+ `, `
58
+ `)}
59
+ }`;
60
+ return n.push(g), a;
61
+ }
62
+ const d = u.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`, j = O(c, d);
63
+ return n.push(j), a;
64
+ }
65
+ const y = r.startsWith("-") ? r : V(r), w = (d, j = ";") => a = `${a}${d}${j}`, S = (d) => w(`${y}:${d}`);
66
+ if (typeof c == "number") return S(c);
67
+ if (typeof c != "string")
68
+ if ("toString" in c) c = c.toString();
69
+ else return a;
70
+ const { modifiers: h } = {}, D = function* () {
71
+ yield tt(c), yield wt(c, h);
72
+ }();
73
+ for (const { result: d, additionalCss: j = [] } of D)
74
+ c = d, j.forEach((l) => {
75
+ const g = O(l, "");
76
+ w(g, "");
77
+ });
78
+ return S(c);
79
+ }, "");
80
+ return i ? e ? [`${e} { ${i} }`, ...n].join(`
81
+ `) : i : n.join(`
82
+ `);
83
+ }, et = (t, e = []) => {
84
+ if (!t) return "";
85
+ const s = [], n = {};
86
+ if (Object.entries(t).forEach(([i, o]) => {
87
+ if (typeof o == "object") {
88
+ if (!o) return;
89
+ const a = i.trim(), u = et(o, [...e, a]);
90
+ s.push(u);
91
+ } else
92
+ n[i] = o;
93
+ }), Object.keys(n).length) {
94
+ const i = e.map(V).join("-"), o = O(n, `.${i}`);
95
+ s.push(o);
96
+ }
97
+ return s.join(`
98
+ `);
99
+ }, xt = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = st(n).map((i) => `"${i}"`).join(" | ")), e), {}), st = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
100
+ const o = e ? `${e}.${n}` : n;
101
+ return typeof i == "object" ? st(i, o, s) : s.add(e);
102
+ }), [...s]) : [], nt = (t) => {
103
+ if (!t || t === "/") throw new Error("Could not find package.json file");
104
+ const e = f(t, "package.json");
105
+ return B(e) ? e : nt(f(t, ".."));
106
+ }, Ct = async (t) => {
107
+ const e = nt(t);
108
+ return await yt(e, "utf-8").then(JSON.parse).catch(() => {
109
+ });
110
+ }, Ft = async (t) => {
111
+ const e = await Ct(t);
112
+ if (e)
113
+ return e.type;
114
+ };
115
+ let R;
116
+ const ot = async (t) => {
117
+ if (R) return R;
118
+ const e = await Ft(t);
119
+ return e === "module" ? R = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (R = "cjs"), R || "esm";
120
+ }, I = $t({
121
+ level: "debug",
122
+ format: Z.combine(Z.colorize(), Z.cli()),
123
+ transports: [new bt.Console({})]
124
+ });
125
+ function rt(t) {
126
+ return t ? typeof t != "string" ? rt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
127
+ }
128
+ const kt = {
129
+ /** Set box model to border-box */
130
+ "*, *::before, *::after": {
131
+ boxSizing: "border-box"
132
+ },
133
+ /** Remove default margin and padding */
134
+ "*": {
135
+ margin: 0
136
+ },
137
+ /** Remove adjust font properties */
138
+ html: {
139
+ lineHeight: 1.15,
140
+ textSizeAdjust: "100%",
141
+ WebkitFontSmoothing: "antialiased"
142
+ },
143
+ /** Make media elements responsive */
144
+ "img, picture, video, canvas, svg": {
145
+ display: "block",
146
+ maxWidth: "100%"
147
+ },
148
+ /** Avoid overflow of text */
149
+ "p, h1, h2, h3, h4, h5, h6": {
150
+ overflowWrap: "break-word"
151
+ },
152
+ /** Improve text wrapping */
153
+ p: {
154
+ textWrap: "pretty"
155
+ },
156
+ "h1, h2, h3, h4, h5, h6": {
157
+ textWrap: "balance"
158
+ },
159
+ /** Improve link color */
160
+ a: {
161
+ color: "currentColor"
162
+ },
163
+ /** Improve button line height */
164
+ button: {
165
+ lineHeight: "1em",
166
+ color: "currentColor"
167
+ },
168
+ /** Improve form elements */
169
+ "input, optgroup, select, textarea": {
170
+ fontFamily: "inherit",
171
+ fontSize: "100%",
172
+ lineHeight: "1.15em"
173
+ }
174
+ }, H = {
175
+ externalModules: []
176
+ }, it = (t) => {
177
+ if (H.externalModules.length > 0) return H.externalModules;
178
+ const e = f(t, "salty.config.ts"), n = A(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
179
+ if (!n) return [];
180
+ const i = n[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
181
+ return H.externalModules = i, i;
182
+ }, z = (t) => f(t, "./saltygen"), ct = ["salty", "css", "styles", "styled"], Nt = (t = []) => new RegExp(`\\.(${[...ct, ...t].join("|")})\\.`), G = (t, e = []) => Nt(e).test(t), Tt = async (t) => {
183
+ const e = z(t), s = f(t, "salty.config.ts"), n = f(e, "salty.config.js"), i = await ot(t), o = it(t);
184
+ await v.build({
185
+ entryPoints: [s],
186
+ minify: !0,
187
+ treeShaking: !0,
188
+ bundle: !0,
189
+ outfile: n,
190
+ format: i,
191
+ external: o
192
+ });
193
+ const a = Date.now(), { config: u } = await import(`${n}?t=${a}`);
194
+ return u;
195
+ }, Pt = async (t) => {
196
+ const e = await Tt(t), s = /* @__PURE__ */ new Set(), n = (p, m = []) => p ? Object.entries(p).flatMap(([C, $]) => {
197
+ if (!$) return;
198
+ if (typeof $ == "object") return n($, [...m, C]);
199
+ const M = rt(C), J = V(C), _ = [...m, M].join(".");
200
+ s.add(`"${_}"`);
201
+ const P = [...m.map(V), J].join("-"), { result: E } = tt($);
202
+ return `--${P}: ${E};`;
203
+ }) : [], i = (p) => p ? Object.entries(p).flatMap(([m, C]) => {
204
+ const $ = n(C);
205
+ return m === "base" ? $.join("") : `${m} { ${$.join("")} }`;
206
+ }) : [], o = (p) => p ? Object.entries(p).flatMap(([m, C]) => Object.entries(C).flatMap(([$, M]) => {
207
+ const J = n(M, [m]), _ = `.${m}-${$}, [data-${m}="${$}"]`, P = J.join("");
208
+ return `${_} { ${P} }`;
209
+ })) : [], a = n(e.variables), u = i(e.responsiveVariables), c = o(e.conditionalVariables), r = z(t), y = f(r, "css/_variables.css"), w = `:root { ${a.join("")} ${u.join("")} } ${c.join("")}`;
210
+ k(y, w);
211
+ const S = f(r, "css/_global.css"), h = O(e.global, "");
212
+ k(S, `@layer global { ${h} }`);
213
+ const x = f(r, "css/_reset.css"), d = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : kt, j = O(d, "");
214
+ k(x, `@layer reset { ${j} }`);
215
+ const l = f(r, "css/_templates.css"), g = et(e.templates), N = xt(e.templates);
216
+ k(l, g);
217
+ const b = f(r, "types/css-tokens.d.ts"), F = `
218
+ // Variable types
219
+ type VariableTokens = ${[...s].join("|")};
220
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
221
+
222
+ // Template types
223
+ type TemplateTokens = {
224
+ ${Object.entries(N).map(([p, m]) => `${p}?: ${m}`).join(`
225
+ `)}
226
+ }
227
+ `;
228
+ k(b, F);
229
+ }, Q = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
230
+ const n = /^['"`]/.test(s);
231
+ if (n && console.log("String tag", s), n) return e;
232
+ const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`), o = i.test(t);
233
+ if (o || console.log("Not imported", s), !o) return e;
234
+ const a = i.exec(t);
235
+ if (a) {
236
+ const u = a.at(1), c = ct.some((r) => u == null ? void 0 : u.includes(r));
237
+ if (c && console.log("Salty import for", s, `"${a.at(0)}"`), c) return e;
238
+ }
239
+ return console.log("Replacing", s), "styled('div',";
240
+ }), q = async (t, e, s) => {
241
+ console.log({ sourceFilePath: e });
242
+ const n = K(e), i = f(s, "./temp");
243
+ B(i) || W(i);
244
+ const o = L(e);
245
+ let a = A(e, "utf8");
246
+ a = Q(a);
247
+ const u = f(s, "js", n + ".js"), c = it(t), r = await ot(t);
248
+ await v.build({
249
+ stdin: {
250
+ contents: a,
251
+ sourcefile: o.base,
252
+ resolveDir: o.dir,
253
+ loader: "tsx"
254
+ },
255
+ minify: !1,
256
+ treeShaking: !0,
257
+ bundle: !0,
258
+ outfile: u,
259
+ format: r,
260
+ target: ["node20"],
261
+ keepNames: !0,
262
+ external: c,
263
+ packages: "external",
264
+ plugins: [
265
+ {
266
+ name: "test",
267
+ setup: (S) => {
268
+ S.onLoad({ filter: /.*.css.ts/ }, (h) => {
269
+ console.log("Loading", {
270
+ sourceFilePath: e,
271
+ args: h
272
+ });
273
+ const x = A(h.path, "utf8");
274
+ return { contents: Q(x) };
275
+ });
276
+ }
277
+ }
278
+ ]
279
+ });
280
+ const y = Date.now();
281
+ return await import(`${u}?t=${y}`);
282
+ }, U = async (t) => {
283
+ const e = z(t), s = f(e, "salty.config.js"), n = Date.now(), { config: i } = await import(`${s}?t=${n}`);
284
+ return i;
285
+ }, at = () => {
286
+ try {
287
+ return process.env.NODE_ENV === "production";
288
+ } catch {
289
+ return !1;
290
+ }
291
+ }, _t = async (t, e = at()) => {
292
+ try {
293
+ const s = Date.now();
294
+ e ? I.info("Generating CSS in production mode! 🔥") : I.info("Generating CSS in development mode! 🚀");
295
+ const n = [], i = [], o = z(t), a = f(o, "index.css");
296
+ (() => {
297
+ B(o) && dt("rm -rf " + o), W(o), W(f(o, "css")), W(f(o, "types"));
298
+ })(), await Pt(t);
299
+ const c = await U(t);
300
+ async function r(l, g) {
301
+ const N = ["node_modules", "saltygen"], b = gt(l);
302
+ if (b.isDirectory()) {
303
+ const T = mt(l);
304
+ if (N.some((p) => l.includes(p))) return;
305
+ await Promise.all(T.map((p) => r(f(l, p), f(g, p))));
306
+ } else if (b.isFile() && G(l)) {
307
+ const F = await q(t, l, o), p = [];
308
+ Object.entries(F).forEach(([_, P]) => {
309
+ if (P.isKeyframes && P.css) {
310
+ const X = `a_${P.animationName}.css`, pt = `css/${X}`, ut = f(o, pt);
311
+ n.push(X), k(ut, P.css);
312
+ return;
313
+ }
314
+ if (!P.generator) return;
315
+ const E = P.generator._withBuildContext({
316
+ name: _,
317
+ config: c,
318
+ prod: e
319
+ });
320
+ i[E.priority] || (i[E.priority] = []), i[E.priority].push(E.cssFileName), p.push(E.cssFileName);
321
+ const lt = `css/${E.cssFileName}`, ft = f(o, lt);
322
+ k(ft, E.css);
323
+ });
324
+ const m = p.map((_) => `@import url('./${_}');`).join(`
325
+ `), C = K(l, 6), $ = L(l), M = V($.name), J = f(o, `css/f_${M}-${C}.css`);
326
+ k(J, m);
327
+ }
328
+ }
329
+ await r(t, o);
330
+ const y = n.map((l) => `@import url('./css/${l}');`).join(`
331
+ `);
332
+ let x = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
333
+
334
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
335
+ try {
336
+ return A(f(o, "css", l), "utf8").length > 0;
337
+ } catch {
338
+ return !1;
339
+ }
340
+ }).map((l) => `@import url('./css/${l}');`).join(`
341
+ `)}
342
+ ${y}`;
343
+ if (c.importStrategy !== "component") {
344
+ const l = i.reduce((g, N, b) => {
345
+ const T = N.reduce((C, $) => {
346
+ const M = A(f(o, "css", $), "utf8");
347
+ return `${C}
348
+ ${M}`;
349
+ }, ""), F = `l_${b}.css`, p = f(o, "css", F), m = `@layer l${b} { ${T} }`;
350
+ return k(p, m), `${g}
351
+ @import url('./css/${F}');`;
352
+ }, "");
353
+ x += l;
354
+ }
355
+ k(a, x);
356
+ const d = Date.now() - s, j = d < 200 ? "🔥" : d < 500 ? "🚀" : d < 1e3 ? "🎉" : d < 2e3 ? "🚗" : d < 5e3 ? "🤔" : "🥴";
357
+ I.info(`Generated CSS in ${d}ms! ${j}`);
358
+ } catch (s) {
359
+ console.error(s);
360
+ }
361
+ }, At = async (t, e) => {
362
+ try {
363
+ const s = [], n = f(t, "./saltygen"), i = f(n, "index.css");
364
+ if (G(e)) {
365
+ const a = await U(t), u = await q(t, e, n);
366
+ Object.entries(u).forEach(([S, h]) => {
367
+ if (h.isKeyframes && h.css) {
368
+ const l = `css/${`a_${h.animationName}.css`}`, g = f(n, l);
369
+ k(g, h.css);
370
+ return;
371
+ }
372
+ if (!h.generator) return;
373
+ const x = h.generator._withBuildContext({
374
+ name: S,
375
+ config: a
376
+ }), D = `css/${x.cssFileName}`, d = f(n, D);
377
+ s.push(x.cssFileName), k(d, x.css);
378
+ });
379
+ const c = A(i, "utf8").split(`
380
+ `), r = s.map((S) => `@import url('../saltygen/css/${S}');`), w = [.../* @__PURE__ */ new Set([...c, ...r])].join(`
381
+ `);
382
+ k(i, w);
383
+ }
384
+ } catch (s) {
385
+ console.error(s);
386
+ }
387
+ }, Rt = async (t, e, s = at()) => {
388
+ try {
389
+ const n = f(t, "./saltygen");
390
+ if (G(e)) {
391
+ const o = A(e, "utf8");
392
+ o.replace(/^(?!export\s)const\s.*/gm, (y) => `export ${y}`) !== o && await ht(e, o);
393
+ const u = await U(t), c = await q(t, e, n);
394
+ let r = o;
395
+ if (Object.entries(c).forEach(([y, w]) => {
396
+ var C;
397
+ if (w.isKeyframes || !w.generator) return;
398
+ const S = w.generator._withBuildContext({
399
+ name: y,
400
+ config: u,
401
+ prod: s
402
+ }), h = new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
403
+ if (!h) return console.error("Could not find the original declaration");
404
+ const x = (C = h.at(1)) == null ? void 0 : C.trim(), D = new RegExp(`\\s${y}[=\\s]+styled\\(`, "g").exec(r);
405
+ if (!D) return console.error("Could not find the original declaration");
406
+ const { index: d } = D;
407
+ let j = !1;
408
+ const l = setTimeout(() => j = !0, 5e3);
409
+ let g = 0, N = !1, b = 0;
410
+ for (; !N && !j; ) {
411
+ const $ = r[d + g];
412
+ $ === "(" && b++, $ === ")" && b--, b === 0 && $ === ")" && (N = !0), g > r.length && (j = !0), g++;
413
+ }
414
+ if (!j) clearTimeout(l);
415
+ else throw new Error("Failed to find the end of the styled call and timed out");
416
+ const T = d + g, F = r.slice(d, T), p = r, m = ` ${y} = styled(${x}, "${S.classNames}", ${JSON.stringify(S.props)});`;
417
+ r = r.replace(F, m), p === r && console.error("Minimize file failed to change content", { name: y, tagName: x });
418
+ }), u.importStrategy === "component") {
419
+ const y = K(e, 6), w = L(e);
420
+ r = `import '../../saltygen/css/${`f_${V(w.name)}-${y}.css`}';
421
+ ${r}`;
422
+ }
423
+ return r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
424
+ }
425
+ } catch (n) {
426
+ console.error("Error in minimizeFile:", n);
427
+ }
428
+ };
429
+ export {
430
+ At as a,
431
+ _t as g,
432
+ Rt as m,
433
+ Nt as s
434
+ };
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-Cld5pSWN.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-D0sdFJc4.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as n } from "path";
2
- import { s as u, g as i } from "./index-CZ0pA4e_.js";
2
+ import { s as u, g as i } from "./index-SUW5aXyU.js";
3
3
  const g = (s, e, o = !1, r = !1) => {
4
4
  var a, l, t;
5
5
  (l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-Cld5pSWN.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-D0sdFJc4.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-CZ0pA4e_.js";
1
+ import { a as e, m as i } from "./index-SUW5aXyU.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.139",
3
+ "version": "0.0.1-alpha.140",
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.139",
37
+ "@salty-css/core": "^0.0.1-alpha.140",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }
package/index-CZ0pA4e_.js DELETED
@@ -1,417 +0,0 @@
1
- import * as Q from "esbuild";
2
- import { execSync as ut } from "child_process";
3
- import { join as l, parse as B } from "path";
4
- import { existsSync as K, writeFileSync as N, readFileSync as R, mkdirSync as W, statSync as dt, readdirSync as gt } from "fs";
5
- import { readFile as mt, writeFile as yt } from "fs/promises";
6
- import { createLogger as ht, format as Z, transports as $t } from "winston";
7
- const Y = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), bt = (t, e) => {
8
- let s = "", n;
9
- for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = Y(n % 52) + s;
10
- return s = Y(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
11
- }, St = (t, e) => {
12
- let s = e.length;
13
- for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
14
- return t;
15
- }, G = (t, e = 5) => {
16
- const s = St(5381, JSON.stringify(t)) >>> 0;
17
- return bt(s, e);
18
- };
19
- function V(t) {
20
- return t ? typeof t != "string" ? V(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
21
- }
22
- const jt = (t, e) => {
23
- if (typeof t != "string") return { result: t };
24
- if (!e) return { result: t };
25
- const s = [];
26
- return Object.values(e).forEach((n) => {
27
- const { pattern: i, transform: o } = n;
28
- t = t.replace(i, (f) => {
29
- const { value: y, css: a } = o(f);
30
- return a && s.push(a), y;
31
- });
32
- }), { result: t, additionalCss: s };
33
- }, v = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, O = (t, e, s) => {
34
- if (!t) return "";
35
- const n = [], i = Object.entries(t).reduce((f, [y, a]) => {
36
- const r = y.trim();
37
- if (typeof a == "function" && (a = a()), typeof a == "object") {
38
- if (!a) return f;
39
- if (r === "variants")
40
- return Object.entries(a).forEach(([c, u]) => {
41
- u && Object.entries(u).forEach(([x, j]) => {
42
- if (!j) return;
43
- const T = `${e}.${c}-${x}`, k = O(j, T);
44
- n.push(k);
45
- });
46
- }), f;
47
- if (r === "defaultVariants")
48
- return f;
49
- if (r === "compoundVariants")
50
- return a.forEach((c) => {
51
- const { css: u, ...x } = c, j = Object.entries(x).reduce((k, [d, m]) => `${k}.${d}-${m}`, e), T = O(u, j);
52
- n.push(T);
53
- }), f;
54
- if (r.startsWith("@")) {
55
- const c = O(a, e), u = `${r} {
56
- ${c.replace(`
57
- `, `
58
- `)}
59
- }`;
60
- return n.push(u), f;
61
- }
62
- const p = y.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`, h = O(a, p);
63
- return n.push(h), f;
64
- }
65
- const $ = r.startsWith("-") ? r : V(r), w = (p, h = ";") => f = `${f}${p}${h}`, S = (p) => w(`${$}:${p}`);
66
- if (typeof a == "number") return S(a);
67
- if (typeof a != "string")
68
- if ("toString" in a) a = a.toString();
69
- else return f;
70
- const { modifiers: g } = {}, P = function* () {
71
- yield v(a), yield jt(a, g);
72
- }();
73
- for (const { result: p, additionalCss: h = [] } of P)
74
- a = p, h.forEach((c) => {
75
- const u = O(c, "");
76
- w(u, "");
77
- });
78
- return S(a);
79
- }, "");
80
- return i ? e ? [`${e} { ${i} }`, ...n].join(`
81
- `) : i : n.join(`
82
- `);
83
- }, tt = (t, e = []) => {
84
- if (!t) return "";
85
- const s = [], n = {};
86
- if (Object.entries(t).forEach(([i, o]) => {
87
- if (typeof o == "object") {
88
- if (!o) return;
89
- const f = i.trim(), y = tt(o, [...e, f]);
90
- s.push(y);
91
- } else
92
- n[i] = o;
93
- }), Object.keys(n).length) {
94
- const i = e.map(V).join("-"), o = O(n, `.${i}`);
95
- s.push(o);
96
- }
97
- return s.join(`
98
- `);
99
- }, wt = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = et(n).map((i) => `"${i}"`).join(" | ")), e), {}), et = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
100
- const o = e ? `${e}.${n}` : n;
101
- return typeof i == "object" ? et(i, o, s) : s.add(e);
102
- }), [...s]) : [], st = (t) => {
103
- if (!t || t === "/") throw new Error("Could not find package.json file");
104
- const e = l(t, "package.json");
105
- return K(e) ? e : st(l(t, ".."));
106
- }, xt = async (t) => {
107
- const e = st(t);
108
- return await mt(e, "utf-8").then(JSON.parse).catch(() => {
109
- });
110
- }, Ft = async (t) => {
111
- const e = await xt(t);
112
- if (e)
113
- return e.type;
114
- };
115
- let A;
116
- const nt = async (t) => {
117
- if (A) return A;
118
- const e = await Ft(t);
119
- return e === "module" ? A = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (A = "cjs"), A || "esm";
120
- }, I = ht({
121
- level: "debug",
122
- format: Z.combine(Z.colorize(), Z.cli()),
123
- transports: [new $t.Console({})]
124
- });
125
- function ot(t) {
126
- return t ? typeof t != "string" ? ot(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
127
- }
128
- const Ct = {
129
- /** Set box model to border-box */
130
- "*, *::before, *::after": {
131
- boxSizing: "border-box"
132
- },
133
- /** Remove default margin and padding */
134
- "*": {
135
- margin: 0
136
- },
137
- /** Remove adjust font properties */
138
- html: {
139
- lineHeight: 1.15,
140
- textSizeAdjust: "100%",
141
- WebkitFontSmoothing: "antialiased"
142
- },
143
- /** Make media elements responsive */
144
- "img, picture, video, canvas, svg": {
145
- display: "block",
146
- maxWidth: "100%"
147
- },
148
- /** Avoid overflow of text */
149
- "p, h1, h2, h3, h4, h5, h6": {
150
- overflowWrap: "break-word"
151
- },
152
- /** Improve text wrapping */
153
- p: {
154
- textWrap: "pretty"
155
- },
156
- "h1, h2, h3, h4, h5, h6": {
157
- textWrap: "balance"
158
- },
159
- /** Improve link color */
160
- a: {
161
- color: "currentColor"
162
- },
163
- /** Improve button line height */
164
- button: {
165
- lineHeight: "1em",
166
- color: "currentColor"
167
- },
168
- /** Improve form elements */
169
- "input, optgroup, select, textarea": {
170
- fontFamily: "inherit",
171
- fontSize: "100%",
172
- lineHeight: "1.15em"
173
- }
174
- }, H = {
175
- externalModules: []
176
- }, rt = (t) => {
177
- if (H.externalModules.length > 0) return H.externalModules;
178
- const e = l(t, "salty.config.ts"), n = R(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
179
- if (!n) return [];
180
- const i = n[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
181
- return H.externalModules = i, i;
182
- }, z = (t) => l(t, "./saltygen"), it = ["salty", "css", "styles", "styled"], kt = (t = []) => new RegExp(`\\.(${[...it, ...t].join("|")})\\.`), L = (t, e = []) => kt(e).test(t), Nt = async (t) => {
183
- const e = z(t), s = l(t, "salty.config.ts"), n = l(e, "salty.config.js"), i = await nt(t), o = rt(t);
184
- await Q.build({
185
- entryPoints: [s],
186
- minify: !0,
187
- treeShaking: !0,
188
- bundle: !0,
189
- outfile: n,
190
- format: i,
191
- external: o
192
- });
193
- const f = Date.now(), { config: y } = await import(`${n}?t=${f}`);
194
- return y;
195
- }, Pt = async (t) => {
196
- const e = await Nt(t), s = /* @__PURE__ */ new Set(), n = (d, m = []) => d ? Object.entries(d).flatMap(([F, b]) => {
197
- if (!b) return;
198
- if (typeof b == "object") return n(b, [...m, F]);
199
- const M = ot(F), J = V(F), _ = [...m, M].join(".");
200
- s.add(`"${_}"`);
201
- const D = [...m.map(V), J].join("-"), { result: E } = v(b);
202
- return `--${D}: ${E};`;
203
- }) : [], i = (d) => d ? Object.entries(d).flatMap(([m, F]) => {
204
- const b = n(F);
205
- return m === "base" ? b.join("") : `${m} { ${b.join("")} }`;
206
- }) : [], o = (d) => d ? Object.entries(d).flatMap(([m, F]) => Object.entries(F).flatMap(([b, M]) => {
207
- const J = n(M, [m]), _ = `.${m}-${b}, [data-${m}="${b}"]`, D = J.join("");
208
- return `${_} { ${D} }`;
209
- })) : [], f = n(e.variables), y = i(e.responsiveVariables), a = o(e.conditionalVariables), r = z(t), $ = l(r, "css/_variables.css"), w = `:root { ${f.join("")} ${y.join("")} } ${a.join("")}`;
210
- N($, w);
211
- const S = l(r, "css/_global.css"), g = O(e.global, "");
212
- N(S, `@layer global { ${g} }`);
213
- const C = l(r, "css/_reset.css"), p = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : Ct, h = O(p, "");
214
- N(C, `@layer reset { ${h} }`);
215
- const c = l(r, "css/_templates.css"), u = tt(e.templates), x = wt(e.templates);
216
- N(c, u);
217
- const j = l(r, "types/css-tokens.d.ts"), k = `
218
- // Variable types
219
- type VariableTokens = ${[...s].join("|")};
220
- type PropertyValueToken = \`{\${VariableTokens}}\`;
221
-
222
- // Template types
223
- type TemplateTokens = {
224
- ${Object.entries(x).map(([d, m]) => `${d}?: ${m}`).join(`
225
- `)}
226
- }
227
- `;
228
- N(j, k);
229
- }, q = async (t, e, s) => {
230
- const n = G(e), i = l(s, "./temp");
231
- K(i) || W(i);
232
- const o = B(e);
233
- let f = R(e, "utf8");
234
- f = f.replace(/styled\(([^"'`{,]+),/g, (S, g) => {
235
- if (/^['"`]/.test(g)) return S;
236
- const P = new RegExp(`import[^;]*${g}[,\\s{][^;]*from\\s?([^{};]+);`), p = P.test(f);
237
- if (p || console.log("Not imported", g), !p) return S;
238
- const h = P.exec(f);
239
- if (h) {
240
- const c = h.at(1), u = it.some((x) => c == null ? void 0 : c.includes(x));
241
- if (u && console.log("Salty import", g, h.at(0)), u) return S;
242
- }
243
- return console.log("Replacing", g), "styled('div',";
244
- });
245
- const y = l(s, "js", n + ".js"), a = rt(t), r = await nt(t);
246
- await Q.build({
247
- stdin: {
248
- contents: f,
249
- sourcefile: o.base,
250
- resolveDir: o.dir,
251
- loader: "tsx"
252
- },
253
- minify: !1,
254
- treeShaking: !0,
255
- bundle: !0,
256
- outfile: y,
257
- format: r,
258
- target: ["node20"],
259
- keepNames: !0,
260
- external: a,
261
- packages: "external"
262
- });
263
- const $ = Date.now();
264
- return await import(`${y}?t=${$}`);
265
- }, U = async (t) => {
266
- const e = z(t), s = l(e, "salty.config.js"), n = Date.now(), { config: i } = await import(`${s}?t=${n}`);
267
- return i;
268
- }, ct = () => {
269
- try {
270
- return process.env.NODE_ENV === "production";
271
- } catch {
272
- return !1;
273
- }
274
- }, Mt = async (t, e = ct()) => {
275
- try {
276
- const s = Date.now();
277
- e ? I.info("Generating CSS in production mode! 🔥") : I.info("Generating CSS in development mode! 🚀");
278
- const n = [], i = [], o = z(t), f = l(o, "index.css");
279
- (() => {
280
- K(o) && ut("rm -rf " + o), W(o), W(l(o, "css")), W(l(o, "types"));
281
- })(), await Pt(t);
282
- const a = await U(t);
283
- async function r(c, u) {
284
- const x = ["node_modules", "saltygen"], j = dt(c);
285
- if (j.isDirectory()) {
286
- const T = gt(c);
287
- if (x.some((d) => c.includes(d))) return;
288
- await Promise.all(T.map((d) => r(l(c, d), l(u, d))));
289
- } else if (j.isFile() && L(c)) {
290
- const k = await q(t, c, o), d = [];
291
- Object.entries(k).forEach(([_, D]) => {
292
- if (D.isKeyframes && D.css) {
293
- const X = `a_${D.animationName}.css`, ft = `css/${X}`, pt = l(o, ft);
294
- n.push(X), N(pt, D.css);
295
- return;
296
- }
297
- if (!D.generator) return;
298
- const E = D.generator._withBuildContext({
299
- name: _,
300
- config: a,
301
- prod: e
302
- });
303
- i[E.priority] || (i[E.priority] = []), i[E.priority].push(E.cssFileName), d.push(E.cssFileName);
304
- const at = `css/${E.cssFileName}`, lt = l(o, at);
305
- N(lt, E.css);
306
- });
307
- const m = d.map((_) => `@import url('./${_}');`).join(`
308
- `), F = G(c, 6), b = B(c), M = V(b.name), J = l(o, `css/f_${M}-${F}.css`);
309
- N(J, m);
310
- }
311
- }
312
- await r(t, o);
313
- const $ = n.map((c) => `@import url('./css/${c}');`).join(`
314
- `);
315
- let C = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
316
-
317
- ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((c) => {
318
- try {
319
- return R(l(o, "css", c), "utf8").length > 0;
320
- } catch {
321
- return !1;
322
- }
323
- }).map((c) => `@import url('./css/${c}');`).join(`
324
- `)}
325
- ${$}`;
326
- if (a.importStrategy !== "component") {
327
- const c = i.reduce((u, x, j) => {
328
- const T = x.reduce((F, b) => {
329
- const M = R(l(o, "css", b), "utf8");
330
- return `${F}
331
- ${M}`;
332
- }, ""), k = `l_${j}.css`, d = l(o, "css", k), m = `@layer l${j} { ${T} }`;
333
- return N(d, m), `${u}
334
- @import url('./css/${k}');`;
335
- }, "");
336
- C += c;
337
- }
338
- N(f, C);
339
- const p = Date.now() - s, h = p < 200 ? "🔥" : p < 500 ? "🚀" : p < 1e3 ? "🎉" : p < 2e3 ? "🚗" : p < 5e3 ? "🤔" : "🥴";
340
- I.info(`Generated CSS in ${p}ms! ${h}`);
341
- } catch (s) {
342
- console.error(s);
343
- }
344
- }, _t = async (t, e) => {
345
- try {
346
- const s = [], n = l(t, "./saltygen"), i = l(n, "index.css");
347
- if (L(e)) {
348
- const f = await U(t), y = await q(t, e, n);
349
- Object.entries(y).forEach(([S, g]) => {
350
- if (g.isKeyframes && g.css) {
351
- const c = `css/${`a_${g.animationName}.css`}`, u = l(n, c);
352
- N(u, g.css);
353
- return;
354
- }
355
- if (!g.generator) return;
356
- const C = g.generator._withBuildContext({
357
- name: S,
358
- config: f
359
- }), P = `css/${C.cssFileName}`, p = l(n, P);
360
- s.push(C.cssFileName), N(p, C.css);
361
- });
362
- const a = R(i, "utf8").split(`
363
- `), r = s.map((S) => `@import url('../saltygen/css/${S}');`), w = [.../* @__PURE__ */ new Set([...a, ...r])].join(`
364
- `);
365
- N(i, w);
366
- }
367
- } catch (s) {
368
- console.error(s);
369
- }
370
- }, At = async (t, e, s = ct()) => {
371
- try {
372
- const n = l(t, "./saltygen");
373
- if (L(e)) {
374
- const o = R(e, "utf8");
375
- o.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== o && await yt(e, o);
376
- const y = await U(t), a = await q(t, e, n);
377
- let r = o;
378
- if (Object.entries(a).forEach(([$, w]) => {
379
- var F;
380
- if (w.isKeyframes || !w.generator) return;
381
- const S = w.generator._withBuildContext({
382
- name: $,
383
- config: y,
384
- prod: s
385
- }), g = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
386
- if (!g) return console.error("Could not find the original declaration");
387
- const C = (F = g.at(1)) == null ? void 0 : F.trim(), P = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(r);
388
- if (!P) return console.error("Could not find the original declaration");
389
- const { index: p } = P;
390
- let h = !1;
391
- const c = setTimeout(() => h = !0, 5e3);
392
- let u = 0, x = !1, j = 0;
393
- for (; !x && !h; ) {
394
- const b = r[p + u];
395
- b === "(" && j++, b === ")" && j--, j === 0 && b === ")" && (x = !0), u > r.length && (h = !0), u++;
396
- }
397
- if (!h) clearTimeout(c);
398
- else throw new Error("Failed to find the end of the styled call and timed out");
399
- const T = p + u, k = r.slice(p, T), d = r, m = ` ${$} = styled(${C}, "${S.classNames}", ${JSON.stringify(S.props)});`;
400
- r = r.replace(k, m), d === r && console.error("Minimize file failed to change content", { name: $, tagName: C });
401
- }), y.importStrategy === "component") {
402
- const $ = G(e, 6), w = B(e);
403
- r = `import '../../saltygen/css/${`f_${V(w.name)}-${$}.css`}';
404
- ${r}`;
405
- }
406
- return r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
407
- }
408
- } catch (n) {
409
- console.error("Error in minimizeFile:", n);
410
- }
411
- };
412
- export {
413
- _t as a,
414
- Mt as g,
415
- At as m,
416
- kt as s
417
- };
@@ -1,29 +0,0 @@
1
- "use strict";const ue=require("esbuild"),pe=require("child_process"),l=require("path"),u=require("fs"),U=require("fs/promises"),z=require("winston");var W=typeof document<"u"?document.currentScript:null;function de(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 X=de(ue),G=e=>String.fromCharCode(e+(e>25?39:97)),ye=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=G(n%52)+s;return s=G(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},ge=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},q=(e,t=5)=>{const s=ge(5381,JSON.stringify(e))>>>0;return ye(s,t)};function E(e){return e?typeof e!="string"?E(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 me=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:o}=n;e=e.replace(i,f=>{const{value:h,css:a}=o(f);return a&&s.push(a),h})}),{result:e,additionalCss:s}},Y=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${E(n[1].replaceAll(".","-"))})`)}:{result:e},O=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((f,[h,a])=>{const r=h.trim();if(typeof a=="function"&&(a=a()),typeof a=="object"){if(!a)return f;if(r==="variants")return Object.entries(a).forEach(([c,d])=>{d&&Object.entries(d).forEach(([x,w])=>{if(!w)return;const T=`${t}.${c}-${x}`,N=O(w,T);n.push(N)})}),f;if(r==="defaultVariants")return f;if(r==="compoundVariants")return a.forEach(c=>{const{css:d,...x}=c,w=Object.entries(x).reduce((N,[y,m])=>`${N}.${y}-${m}`,t),T=O(d,w);n.push(T)}),f;if(r.startsWith("@")){const c=O(a,t),d=`${r} {
2
- ${c.replace(`
3
- `,`
4
- `)}
5
- }`;return n.push(d),f}const p=h.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,$=O(a,p);return n.push($),f}const S=r.startsWith("-")?r:E(r),F=(p,$=";")=>f=`${f}${p}${$}`,j=p=>F(`${S}:${p}`);if(typeof a=="number")return j(a);if(typeof a!="string")if("toString"in a)a=a.toString();else return f;const{modifiers:g}={},P=function*(){yield Y(a),yield me(a,g)}();for(const{result:p,additionalCss:$=[]}of P)a=p,$.forEach(c=>{const d=O(c,"");F(d,"")});return j(a)},"");return i?t?[`${t} { ${i} }`,...n].join(`
6
- `):i:n.join(`
7
- `)},Q=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,o])=>{if(typeof o=="object"){if(!o)return;const f=i.trim(),h=Q(o,[...t,f]);s.push(h)}else n[i]=o}),Object.keys(n).length){const i=t.map(E).join("-"),o=O(n,`.${i}`);s.push(o)}return s.join(`
8
- `)},he=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=v(n).map(i=>`"${i}"`).join(" | ")),t),{}),v=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?v(i,o,s):s.add(t)}),[...s]):[],ee=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ee(l.join(e,".."))},$e=async e=>{const t=ee(e);return await U.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Se=async e=>{const t=await $e(e);if(t)return t.type};let R;const te=async e=>{if(R)return R;const t=await Se(e);return t==="module"?R="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-Cld5pSWN.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},Z=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]});function se(e){return e?typeof e!="string"?se(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={"*, *::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"}},I={externalModules:[]},ne=e=>{if(I.externalModules.length>0)return I.externalModules;const t=l.join(e,"salty.config.ts"),n=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return I.externalModules=i,i},J=e=>l.join(e,"./saltygen"),oe=["salty","css","styles","styled"],re=(e=[])=>new RegExp(`\\.(${[...oe,...e].join("|")})\\.`),H=(e,t=[])=>re(t).test(e),je=async e=>{const t=J(e),s=l.join(e,"salty.config.ts"),n=l.join(t,"salty.config.js"),i=await te(e),o=ne(e);await X.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const f=Date.now(),{config:h}=await import(`${n}?t=${f}`);return h},we=async e=>{const t=await je(e),s=new Set,n=(y,m=[])=>y?Object.entries(y).flatMap(([C,b])=>{if(!b)return;if(typeof b=="object")return n(b,[...m,C]);const M=se(C),A=E(C),V=[...m,M].join(".");s.add(`"${V}"`);const _=[...m.map(E),A].join("-"),{result:D}=Y(b);return`--${_}: ${D};`}):[],i=y=>y?Object.entries(y).flatMap(([m,C])=>{const b=n(C);return m==="base"?b.join(""):`${m} { ${b.join("")} }`}):[],o=y=>y?Object.entries(y).flatMap(([m,C])=>Object.entries(C).flatMap(([b,M])=>{const A=n(M,[m]),V=`.${m}-${b}, [data-${m}="${b}"]`,_=A.join("");return`${V} { ${_} }`})):[],f=n(t.variables),h=i(t.responsiveVariables),a=o(t.conditionalVariables),r=J(e),S=l.join(r,"css/_variables.css"),F=`:root { ${f.join("")} ${h.join("")} } ${a.join("")}`;u.writeFileSync(S,F);const j=l.join(r,"css/_global.css"),g=O(t.global,"");u.writeFileSync(j,`@layer global { ${g} }`);const k=l.join(r,"css/_reset.css"),p=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:be,$=O(p,"");u.writeFileSync(k,`@layer reset { ${$} }`);const c=l.join(r,"css/_templates.css"),d=Q(t.templates),x=he(t.templates);u.writeFileSync(c,d);const w=l.join(r,"types/css-tokens.d.ts"),N=`
9
- // Variable types
10
- type VariableTokens = ${[...s].join("|")};
11
- type PropertyValueToken = \`{\${VariableTokens}}\`;
12
-
13
- // Template types
14
- type TemplateTokens = {
15
- ${Object.entries(x).map(([y,m])=>`${y}?: ${m}`).join(`
16
- `)}
17
- }
18
- `;u.writeFileSync(w,N)},L=async(e,t,s)=>{const n=q(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=l.parse(t);let f=u.readFileSync(t,"utf8");f=f.replace(/styled\(([^"'`{,]+),/g,(j,g)=>{if(/^['"`]/.test(g))return j;const P=new RegExp(`import[^;]*${g}[,\\s{][^;]*from\\s?([^{};]+);`),p=P.test(f);if(p||console.log("Not imported",g),!p)return j;const $=P.exec(f);if($){const c=$.at(1),d=oe.some(x=>c==null?void 0:c.includes(x));if(d&&console.log("Salty import",g,$.at(0)),d)return j}return console.log("Replacing",g),"styled('div',"});const h=l.join(s,"js",n+".js"),a=ne(e),r=await te(e);await X.build({stdin:{contents:f,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:r,target:["node20"],keepNames:!0,external:a,packages:"external"});const S=Date.now();return await import(`${h}?t=${S}`)},B=async e=>{const t=J(e),s=l.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ie=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Fe=async(e,t=ie())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=J(e),f=l.join(o,"index.css");(()=>{u.existsSync(o)&&pe.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(l.join(o,"css")),u.mkdirSync(l.join(o,"types"))})(),await we(e);const a=await B(e);async function r(c,d){const x=["node_modules","saltygen"],w=u.statSync(c);if(w.isDirectory()){const T=u.readdirSync(c);if(x.some(y=>c.includes(y)))return;await Promise.all(T.map(y=>r(l.join(c,y),l.join(d,y))))}else if(w.isFile()&&H(c)){const N=await L(e,c,o),y=[];Object.entries(N).forEach(([V,_])=>{if(_.isKeyframes&&_.css){const K=`a_${_.animationName}.css`,le=`css/${K}`,fe=l.join(o,le);n.push(K),u.writeFileSync(fe,_.css);return}if(!_.generator)return;const D=_.generator._withBuildContext({name:V,config:a,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),y.push(D.cssFileName);const ce=`css/${D.cssFileName}`,ae=l.join(o,ce);u.writeFileSync(ae,D.css)});const m=y.map(V=>`@import url('./${V}');`).join(`
19
- `),C=q(c,6),b=l.parse(c),M=E(b.name),A=l.join(o,`css/f_${M}-${C}.css`);u.writeFileSync(A,m)}}await r(e,o);const S=n.map(c=>`@import url('./css/${c}');`).join(`
20
- `);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
-
22
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(c=>{try{return u.readFileSync(l.join(o,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
23
- `)}
24
- ${S}`;if(a.importStrategy!=="component"){const c=i.reduce((d,x,w)=>{const T=x.reduce((C,b)=>{const M=u.readFileSync(l.join(o,"css",b),"utf8");return`${C}
25
- ${M}`},""),N=`l_${w}.css`,y=l.join(o,"css",N),m=`@layer l${w} { ${T} }`;return u.writeFileSync(y,m),`${d}
26
- @import url('./css/${N}');`},"");k+=c}u.writeFileSync(f,k);const p=Date.now()-s,$=p<200?"🔥":p<500?"🚀":p<1e3?"🎉":p<2e3?"🚗":p<5e3?"🤔":"🥴";Z.info(`Generated CSS in ${p}ms! ${$}`)}catch(s){console.error(s)}},xe=async(e,t)=>{try{const s=[],n=l.join(e,"./saltygen"),i=l.join(n,"index.css");if(H(t)){const f=await B(e),h=await L(e,t,n);Object.entries(h).forEach(([j,g])=>{if(g.isKeyframes&&g.css){const c=`css/${`a_${g.animationName}.css`}`,d=l.join(n,c);u.writeFileSync(d,g.css);return}if(!g.generator)return;const k=g.generator._withBuildContext({name:j,config:f}),P=`css/${k.cssFileName}`,p=l.join(n,P);s.push(k.cssFileName),u.writeFileSync(p,k.css)});const a=u.readFileSync(i,"utf8").split(`
27
- `),r=s.map(j=>`@import url('../saltygen/css/${j}');`),F=[...new Set([...a,...r])].join(`
28
- `);u.writeFileSync(i,F)}}catch(s){console.error(s)}},Ce=async(e,t,s=ie())=>{try{const n=l.join(e,"./saltygen");if(H(t)){const o=u.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,S=>`export ${S}`)!==o&&await U.writeFile(t,o);const h=await B(e),a=await L(e,t,n);let r=o;if(Object.entries(a).forEach(([S,F])=>{var C;if(F.isKeyframes||!F.generator)return;const j=F.generator._withBuildContext({name:S,config:h,prod:s}),g=new RegExp(`\\s${S}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!g)return console.error("Could not find the original declaration");const k=(C=g.at(1))==null?void 0:C.trim(),P=new RegExp(`\\s${S}[=\\s]+styled\\(`,"g").exec(r);if(!P)return console.error("Could not find the original declaration");const{index:p}=P;let $=!1;const c=setTimeout(()=>$=!0,5e3);let d=0,x=!1,w=0;for(;!x&&!$;){const b=r[p+d];b==="("&&w++,b===")"&&w--,w===0&&b===")"&&(x=!0),d>r.length&&($=!0),d++}if(!$)clearTimeout(c);else throw new Error("Failed to find the end of the styled call and timed out");const T=p+d,N=r.slice(p,T),y=r,m=` ${S} = styled(${k}, "${j.classNames}", ${JSON.stringify(j.props)});`;r=r.replace(N,m),y===r&&console.error("Minimize file failed to change content",{name:S,tagName:k})}),h.importStrategy==="component"){const S=q(t,6),F=l.parse(t);r=`import '../../saltygen/css/${`f_${E(F.name)}-${S}.css`}';
29
- ${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Fe;exports.generateFile=xe;exports.minimizeFile=Ce;exports.saltyFileRegExp=re;