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