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