@salty-css/webpack 0.0.1-alpha.50 → 0.0.1-alpha.51

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