@salty-css/core 0.0.1-alpha.114 → 0.0.1-alpha.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -48
- package/bin/main.cjs +6 -6
- package/bin/main.js +125 -125
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +3 -3
- package/{dash-case-DKzpenwY.cjs → dash-case-8PdMJjFC.cjs} +1 -1
- package/{dash-case-DMQMcCO6.js → dash-case-D_tXuO4I.js} +1 -1
- package/generator/index.cjs +1 -1
- package/generator/index.js +27 -26
- package/index-V5AY9k9D.js +257 -0
- package/index-eyW1pjj1.cjs +21 -0
- package/package.json +1 -1
- package/{parse-templates-BNINfXOG.js → parse-templates-D1FebDfR.js} +30 -30
- package/{parse-templates-C1-wQz7G.cjs → parse-templates-lpgqU05M.cjs} +1 -1
- package/types/index.d.ts +15 -5
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
- package/index-BYjQglAA.js +0 -253
- package/index-Cj4Em07G.cjs +0 -21
package/index-BYjQglAA.js
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
import * as K from "esbuild";
|
2
|
-
import { execSync as Q } from "child_process";
|
3
|
-
import { t as B, d as H } from "./dash-case-DMQMcCO6.js";
|
4
|
-
import { join as a, parse as tt } from "path";
|
5
|
-
import { existsSync as I, writeFileSync as x, mkdirSync as V, readFileSync as E, statSync as et, readdirSync as st } from "fs";
|
6
|
-
import { readFile as nt, writeFile as ot } from "fs/promises";
|
7
|
-
import { p as at, a as rt, b as ct, c as it } from "./parse-templates-BNINfXOG.js";
|
8
|
-
import { createLogger as lt, format as J, transports as pt } from "winston";
|
9
|
-
const L = (t) => {
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
-
const e = a(t, "package.json");
|
12
|
-
return I(e) ? e : L(a(t, ".."));
|
13
|
-
}, ft = async (t) => {
|
14
|
-
const e = L(t);
|
15
|
-
return await nt(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, ut = async (t) => {
|
18
|
-
const e = await ft(t);
|
19
|
-
if (e)
|
20
|
-
return e.type;
|
21
|
-
};
|
22
|
-
let M;
|
23
|
-
const q = async (t) => {
|
24
|
-
if (M) return M;
|
25
|
-
const e = await ut(t);
|
26
|
-
return e === "module" ? M = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
27
|
-
}, R = lt({
|
28
|
-
level: "debug",
|
29
|
-
format: J.combine(J.colorize(), J.cli()),
|
30
|
-
transports: [new pt.Console({})]
|
31
|
-
}), Ct = (t) => {
|
32
|
-
R.error(t);
|
33
|
-
}, O = {
|
34
|
-
externalModules: []
|
35
|
-
}, A = (t) => {
|
36
|
-
if (O.externalModules.length > 0) return O.externalModules;
|
37
|
-
const e = a(t, "salty.config.ts"), s = E(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
38
|
-
if (!s) return [];
|
39
|
-
const n = s[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
40
|
-
return O.externalModules = n, n;
|
41
|
-
}, N = (t) => a(t, "./saltygen"), gt = ["salty", "css", "styles", "styled"], dt = (t = []) => new RegExp(`\\.(${[...gt, ...t].join("|")})\\.`), _ = (t, e = []) => dt(e).test(t), mt = async (t) => {
|
42
|
-
const e = N(t), c = a(t, "salty.config.ts"), s = a(e, "salty.config.js"), n = await q(t), l = A(t);
|
43
|
-
await K.build({
|
44
|
-
entryPoints: [c],
|
45
|
-
minify: !0,
|
46
|
-
treeShaking: !0,
|
47
|
-
bundle: !0,
|
48
|
-
outfile: s,
|
49
|
-
format: n,
|
50
|
-
external: l
|
51
|
-
});
|
52
|
-
const b = Date.now(), { config: f } = await import(`${s}?t=${b}`);
|
53
|
-
return f;
|
54
|
-
}, yt = async (t) => {
|
55
|
-
const e = await mt(t), c = /* @__PURE__ */ new Set(), s = (i, p = []) => i ? Object.entries(i).flatMap(([d, u]) => {
|
56
|
-
if (!u) return;
|
57
|
-
if (typeof u == "object") return s(u, [...p, d]);
|
58
|
-
const C = [...p, d].join(".");
|
59
|
-
c.add(`"${C}"`);
|
60
|
-
const y = [...p.map(H), H(d)].join("-"), { result: h } = it(u);
|
61
|
-
return `--${y}: ${h};`;
|
62
|
-
}) : [], n = (i) => i ? Object.entries(i).flatMap(([p, d]) => {
|
63
|
-
const u = s(d);
|
64
|
-
return p === "base" ? u.join("") : `${p} { ${u.join("")} }`;
|
65
|
-
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, d]) => Object.entries(d).flatMap(([u, C]) => {
|
66
|
-
const y = s(C, [p]), h = `.${p}-${u}, [data-${p}="${u}"]`, T = y.join("");
|
67
|
-
return `${h} { ${T} }`;
|
68
|
-
})) : [], b = s(e.variables), f = n(e.responsiveVariables), $ = l(e.conditionalVariables), o = N(t), D = a(o, "css/variables.css"), g = `:root { ${b.join("")} ${f.join("")} } ${$.join("")}`;
|
69
|
-
x(D, g);
|
70
|
-
const w = a(o, "css/global.css"), S = at(e.global, "");
|
71
|
-
x(w, S);
|
72
|
-
const r = a(o, "css/templates.css"), m = rt(e.templates), F = ct(e.templates);
|
73
|
-
x(r, m);
|
74
|
-
const j = a(o, "types/css-tokens.d.ts"), P = `
|
75
|
-
// Variable types
|
76
|
-
type VariableTokens = ${[...c].join("|")};
|
77
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
78
|
-
|
79
|
-
// Template types
|
80
|
-
type TemplateTokens = {
|
81
|
-
${Object.entries(F).map(([i, p]) => `${i}?: ${p}`).join(`
|
82
|
-
`)}
|
83
|
-
}
|
84
|
-
`;
|
85
|
-
x(j, P);
|
86
|
-
}, z = async (t, e, c) => {
|
87
|
-
const s = B(e), n = a(c, "./temp");
|
88
|
-
I(n) || V(n);
|
89
|
-
const l = tt(e);
|
90
|
-
let b = E(e, "utf8");
|
91
|
-
b = b.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
92
|
-
const f = a(c, "js", s + ".js"), $ = A(t), o = await q(t);
|
93
|
-
await K.build({
|
94
|
-
stdin: {
|
95
|
-
contents: b,
|
96
|
-
sourcefile: l.base,
|
97
|
-
resolveDir: l.dir,
|
98
|
-
loader: "tsx"
|
99
|
-
},
|
100
|
-
minify: !1,
|
101
|
-
treeShaking: !0,
|
102
|
-
bundle: !0,
|
103
|
-
outfile: f,
|
104
|
-
format: o,
|
105
|
-
target: ["node20"],
|
106
|
-
keepNames: !0,
|
107
|
-
external: $,
|
108
|
-
packages: "external"
|
109
|
-
});
|
110
|
-
const D = Date.now();
|
111
|
-
return await import(`${f}?t=${D}`);
|
112
|
-
}, G = async (t) => {
|
113
|
-
const e = N(t), c = a(e, "salty.config.js"), { config: s } = await import(c);
|
114
|
-
return s;
|
115
|
-
}, U = () => {
|
116
|
-
try {
|
117
|
-
return process.env.NODE_ENV === "production";
|
118
|
-
} catch {
|
119
|
-
return !1;
|
120
|
-
}
|
121
|
-
}, Ft = async (t, e = U()) => {
|
122
|
-
try {
|
123
|
-
e ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
|
124
|
-
const c = [], s = [], n = N(t), l = a(n, "index.css");
|
125
|
-
(() => {
|
126
|
-
I(n) && Q("rm -rf " + n), V(n), V(a(n, "css")), V(a(n, "types"));
|
127
|
-
})(), await yt(t);
|
128
|
-
const f = await G(t);
|
129
|
-
async function $(r, m) {
|
130
|
-
const F = ["node_modules", "saltygen"], j = et(r);
|
131
|
-
if (j.isDirectory()) {
|
132
|
-
const k = st(r);
|
133
|
-
if (F.some((i) => r.includes(i))) return;
|
134
|
-
await Promise.all(k.map((i) => $(a(r, i), a(m, i))));
|
135
|
-
} else if (j.isFile() && _(r)) {
|
136
|
-
const P = await z(t, r, n), i = [];
|
137
|
-
Object.entries(P).forEach(([C, y]) => {
|
138
|
-
if (y.isKeyframes && y.css) {
|
139
|
-
const W = `${y.animationName}.css`, Y = `css/${W}`, Z = a(n, Y);
|
140
|
-
c.push(W), x(Z, y.css);
|
141
|
-
return;
|
142
|
-
}
|
143
|
-
if (!y.generator) return;
|
144
|
-
const h = y.generator._withBuildContext({
|
145
|
-
name: C,
|
146
|
-
config: f,
|
147
|
-
prod: e
|
148
|
-
}), T = `${h.hash}-${h.priority}.css`;
|
149
|
-
s[h.priority] || (s[h.priority] = []), s[h.priority].push(T), i.push(T);
|
150
|
-
const v = `css/${T}`, X = a(n, v);
|
151
|
-
x(X, h.css);
|
152
|
-
});
|
153
|
-
const p = i.map((C) => `@import url('./${C}');`).join(`
|
154
|
-
`), d = B(r, 6), u = a(n, `css/${d}.css`);
|
155
|
-
x(u, p);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
await $(t, n);
|
159
|
-
const o = c.map((r) => `@import url('./css/${r}');`).join(`
|
160
|
-
`);
|
161
|
-
let S = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
162
|
-
|
163
|
-
${["variables.css", "global.css", "templates.css"].filter((r) => {
|
164
|
-
try {
|
165
|
-
return E(a(n, "css", r), "utf8").length > 0;
|
166
|
-
} catch {
|
167
|
-
return !1;
|
168
|
-
}
|
169
|
-
}).map((r) => `@import url('./css/${r}');`).join(`
|
170
|
-
`)}
|
171
|
-
${o}`;
|
172
|
-
if (f.importStrategy !== "component") {
|
173
|
-
const r = s.flat().map((m) => `@import url('./css/${m}');`).join(`
|
174
|
-
`);
|
175
|
-
S += r;
|
176
|
-
}
|
177
|
-
x(l, S);
|
178
|
-
} catch (c) {
|
179
|
-
console.error(c);
|
180
|
-
}
|
181
|
-
}, kt = async (t, e) => {
|
182
|
-
try {
|
183
|
-
const c = [], s = a(t, "./saltygen"), n = a(s, "index.css");
|
184
|
-
if (_(e)) {
|
185
|
-
const b = await G(t), f = await z(t, e, s);
|
186
|
-
Object.entries(f).forEach(([w, S]) => {
|
187
|
-
if (!S.generator) return;
|
188
|
-
const r = S.generator._withBuildContext({
|
189
|
-
name: w,
|
190
|
-
config: b
|
191
|
-
}), m = `${r.hash}-${r.priority}.css`, F = `css/${m}`, j = a(s, F);
|
192
|
-
c.push(m), x(j, r.css);
|
193
|
-
});
|
194
|
-
const $ = E(n, "utf8").split(`
|
195
|
-
`), o = c.map((w) => `@import url('../saltygen/css/${w}');`), g = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
196
|
-
`);
|
197
|
-
x(n, g);
|
198
|
-
}
|
199
|
-
} catch (c) {
|
200
|
-
console.error(c);
|
201
|
-
}
|
202
|
-
}, Tt = async (t, e, c = U()) => {
|
203
|
-
try {
|
204
|
-
const s = a(t, "./saltygen");
|
205
|
-
if (_(e)) {
|
206
|
-
const l = E(e, "utf8");
|
207
|
-
l.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== l && await ot(e, l);
|
208
|
-
const f = await G(t), $ = await z(t, e, s);
|
209
|
-
let o = l;
|
210
|
-
Object.entries($).forEach(([g, w]) => {
|
211
|
-
var T;
|
212
|
-
if (w.isKeyframes || !w.generator) return;
|
213
|
-
const S = w.generator._withBuildContext({
|
214
|
-
name: g,
|
215
|
-
config: f,
|
216
|
-
prod: c
|
217
|
-
}), r = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
218
|
-
if (!r) return console.error("Could not find the original declaration");
|
219
|
-
const m = (T = r.at(1)) == null ? void 0 : T.trim(), F = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(o);
|
220
|
-
if (!F) return console.error("Could not find the original declaration");
|
221
|
-
const { index: j } = F;
|
222
|
-
let k = !1;
|
223
|
-
const P = setTimeout(() => k = !0, 5e3);
|
224
|
-
let i = 0, p = !1, d = 0;
|
225
|
-
for (; !p && !k; ) {
|
226
|
-
const v = o[j + i];
|
227
|
-
v === "(" && d++, v === ")" && d--, d === 0 && v === ")" && (p = !0), i > o.length && (k = !0), i++;
|
228
|
-
}
|
229
|
-
if (!k) clearTimeout(P);
|
230
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
231
|
-
const u = j + i, C = o.slice(j, u), y = o, h = ` ${g} = styled(${m}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
232
|
-
o = o.replace(C, h), y === o && console.error("Minimize file failed to change content", { name: g, tagName: m });
|
233
|
-
});
|
234
|
-
const D = B(e, 6);
|
235
|
-
return f.importStrategy === "component" && (o = `import '../../saltygen/css/${D}.css';
|
236
|
-
${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
237
|
-
}
|
238
|
-
} catch (s) {
|
239
|
-
console.error("Error in minimizeFile:", s);
|
240
|
-
}
|
241
|
-
};
|
242
|
-
export {
|
243
|
-
Ct as a,
|
244
|
-
dt as b,
|
245
|
-
yt as c,
|
246
|
-
z as d,
|
247
|
-
kt as e,
|
248
|
-
Ft as g,
|
249
|
-
_ as i,
|
250
|
-
R as l,
|
251
|
-
Tt as m,
|
252
|
-
gt as s
|
253
|
-
};
|
package/index-Cj4Em07G.cjs
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";const te=require("esbuild"),se=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),o=require("path"),a=require("fs"),H=require("fs/promises"),O=require("./parse-templates-C1-wQz7G.cjs"),M=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return a.existsSync(t)?t:G(o.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let v;const L=async e=>{if(v)return v;const t=await ie(e);return t==="module"?v="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-Cj4Em07G.cjs",document.baseURI).href).endsWith(".cjs"))&&(v="cjs"),v||"esm"},V=M.createLogger({level:"debug",format:M.format.combine(M.format.colorize(),M.format.cli()),transports:[new M.transports.Console({})]}),re=e=>{V.error(e)},I={externalModules:[]},W=e=>{if(I.externalModules.length>0)return I.externalModules;const t=o.join(e,"salty.config.ts"),s=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const i=s[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return I.externalModules=i,i},R=e=>o.join(e,"./saltygen"),K=["salty","css","styles","styled"],A=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),_=(e,t=[])=>A(t).test(e),ce=async e=>{const t=R(e),n=o.join(e,"salty.config.ts"),s=o.join(t,"salty.config.js"),i=await L(e),p=W(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:i,external:p});const S=Date.now(),{config:f}=await import(`${s}?t=${S}`);return f},X=async e=>{const t=await ce(e),n=new Set,s=(l,u=[])=>l?Object.entries(l).flatMap(([g,d])=>{if(!d)return;if(typeof d=="object")return s(d,[...u,g]);const C=[...u,g].join(".");n.add(`"${C}"`);const h=[...u.map(N.dashCase),N.dashCase(g)].join("-"),{result:j}=O.parseValueTokens(d);return`--${h}: ${j};`}):[],i=l=>l?Object.entries(l).flatMap(([u,g])=>{const d=s(g);return u==="base"?d.join(""):`${u} { ${d.join("")} }`}):[],p=l=>l?Object.entries(l).flatMap(([u,g])=>Object.entries(g).flatMap(([d,C])=>{const h=s(C,[u]),j=`.${u}-${d}, [data-${u}="${d}"]`,T=h.join("");return`${j} { ${T} }`})):[],S=s(t.variables),f=i(t.responsiveVariables),b=p(t.conditionalVariables),r=R(e),P=o.join(r,"css/variables.css"),y=`:root { ${S.join("")} ${f.join("")} } ${b.join("")}`;a.writeFileSync(P,y);const w=o.join(r,"css/global.css"),F=O.parseStyles(t.global,"");a.writeFileSync(w,F);const c=o.join(r,"css/templates.css"),m=O.parseTemplates(t.templates),x=O.getTemplateTypes(t.templates);a.writeFileSync(c,m);const $=o.join(r,"types/css-tokens.d.ts"),D=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...n].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(x).map(([l,u])=>`${l}?: ${u}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;a.writeFileSync($,D)},J=async(e,t,n)=>{const s=N.toHash(t),i=o.join(n,"./temp");a.existsSync(i)||a.mkdirSync(i);const p=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(n,"js",s+".js"),b=W(e),r=await L(e);await U.build({stdin:{contents:S,sourcefile:p.base,resolveDir:p.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:f,format:r,target:["node20"],keepNames:!0,external:b,packages:"external"});const P=Date.now();return await import(`${f}?t=${P}`)},z=async e=>{const t=R(e),n=o.join(t,"salty.config.js"),{config:s}=await import(n);return s},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=Y())=>{try{t?V.info("Generating CSS in production mode! 🔥"):V.info("Generating CSS in development mode! 🚀");const n=[],s=[],i=R(e),p=o.join(i,"index.css");(()=>{a.existsSync(i)&&se.execSync("rm -rf "+i),a.mkdirSync(i),a.mkdirSync(o.join(i,"css")),a.mkdirSync(o.join(i,"types"))})(),await X(e);const f=await z(e);async function b(c,m){const x=["node_modules","saltygen"],$=a.statSync(c);if($.isDirectory()){const k=a.readdirSync(c);if(x.some(l=>c.includes(l)))return;await Promise.all(k.map(l=>b(o.join(c,l),o.join(m,l))))}else if($.isFile()&&_(c)){const D=await J(e,c,i),l=[];Object.entries(D).forEach(([C,h])=>{if(h.isKeyframes&&h.css){const B=`${h.animationName}.css`,Q=`css/${B}`,ee=o.join(i,Q);n.push(B),a.writeFileSync(ee,h.css);return}if(!h.generator)return;const j=h.generator._withBuildContext({name:C,config:f,prod:t}),T=`${j.hash}-${j.priority}.css`;s[j.priority]||(s[j.priority]=[]),s[j.priority].push(T),l.push(T);const E=`css/${T}`,Z=o.join(i,E);a.writeFileSync(Z,j.css)});const u=l.map(C=>`@import url('./${C}');`).join(`
|
12
|
-
`),g=N.toHash(c,6),d=o.join(i,`css/${g}.css`);a.writeFileSync(d,u)}}await b(e,i);const r=n.map(c=>`@import url('./css/${c}');`).join(`
|
13
|
-
`);let F=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["variables.css","global.css","templates.css"].filter(c=>{try{return a.readFileSync(o.join(i,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
16
|
-
`)}
|
17
|
-
${r}`;if(f.importStrategy!=="component"){const c=s.flat().map(m=>`@import url('./css/${m}');`).join(`
|
18
|
-
`);F+=c}a.writeFileSync(p,F)}catch(n){console.error(n)}},le=async(e,t)=>{try{const n=[],s=o.join(e,"./saltygen"),i=o.join(s,"index.css");if(_(t)){const S=await z(e),f=await J(e,t,s);Object.entries(f).forEach(([w,F])=>{if(!F.generator)return;const c=F.generator._withBuildContext({name:w,config:S}),m=`${c.hash}-${c.priority}.css`,x=`css/${m}`,$=o.join(s,x);n.push(m),a.writeFileSync($,c.css)});const b=a.readFileSync(i,"utf8").split(`
|
19
|
-
`),r=n.map(w=>`@import url('../saltygen/css/${w}');`),y=[...new Set([...b,...r])].join(`
|
20
|
-
`);a.writeFileSync(i,y)}}catch(n){console.error(n)}},pe=async(e,t,n=Y())=>{try{const s=o.join(e,"./saltygen");if(_(t)){const p=a.readFileSync(t,"utf8");p.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==p&&await H.writeFile(t,p);const f=await z(e),b=await J(e,t,s);let r=p;Object.entries(b).forEach(([y,w])=>{var T;if(w.isKeyframes||!w.generator)return;const F=w.generator._withBuildContext({name:y,config:f,prod:n}),c=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(p);if(!c)return console.error("Could not find the original declaration");const m=(T=c.at(1))==null?void 0:T.trim(),x=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(r);if(!x)return console.error("Could not find the original declaration");const{index:$}=x;let k=!1;const D=setTimeout(()=>k=!0,5e3);let l=0,u=!1,g=0;for(;!u&&!k;){const E=r[$+l];E==="("&&g++,E===")"&&g--,g===0&&E===")"&&(u=!0),l>r.length&&(k=!0),l++}if(!k)clearTimeout(D);else throw new Error("Failed to find the end of the styled call and timed out");const d=$+l,C=r.slice($,d),h=r,j=` ${y} = styled(${m}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(C,j),h===r&&console.error("Minimize file failed to change content",{name:y,tagName:m})});const P=N.toHash(t,6);return f.importStrategy==="component"&&(r=`import '../../saltygen/css/${P}.css';
|
21
|
-
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(s){console.error("Error in minimizeFile:",s)}};exports.compileSaltyFile=J;exports.generateConfigStyles=X;exports.generateCss=ae;exports.generateFile=le;exports.isSaltyFile=_;exports.logError=re;exports.logger=V;exports.minimizeFile=pe;exports.saltyFileExtensions=K;exports.saltyFileRegExp=A;
|