@salty-css/webpack 0.0.1-alpha.269 → 0.0.1-alpha.270
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/index.cjs +1 -1
- package/index.js +18 -24
- package/loader.cjs +1 -1
- package/loader.js +5 -5
- package/package.json +2 -2
- package/index-Cpurtg_y.js +0 -706
- package/index-DBDB_Jqo.cjs +0 -46
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("path"),s=require("@salty-css/core/compiler"),y=require("@salty-css/core/server"),d=require("fs"),i=(a,e,n=!1,c=!1)=>{var l,r,o;(r=(l=a.module)==null?void 0:l.rules)==null||r.push({test:s.saltyFileRegExp(),use:[{loader:f.resolve(__dirname,c?"./loader.cjs":"./loader.js"),options:{dir:e}}]}),n||(o=a.plugins)==null||o.push({apply:p=>{let u=!1;p.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{u||(u=!0,await s.generateCss(e),d.watch(e,{recursive:!0},async(g,t)=>{await y.checkShouldRestart(t)?await s.generateCss(e,!1,!1):s.isSaltyFile(t)&&await s.generateFile(e,t)}))})}})};exports.default=i;exports.saltyPlugin=i;
|
package/index.js
CHANGED
@@ -1,35 +1,29 @@
|
|
1
|
-
import { resolve as
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { watch as
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
const t = await g(e, "utf-8");
|
10
|
-
return !!(/.+define[A-Z]\w+/.test(t) || /.+keyframes\(.+/.test(t));
|
11
|
-
}, _ = (e, s, r = !1, t = !1) => {
|
12
|
-
var l, o, i;
|
13
|
-
(o = (l = e.module) == null ? void 0 : l.rules) == null || o.push({
|
14
|
-
test: y(),
|
1
|
+
import { resolve as m } from "path";
|
2
|
+
import { saltyFileRegExp as f, generateCss as i, isSaltyFile as c, generateFile as y } from "@salty-css/core/compiler";
|
3
|
+
import { checkShouldRestart as d } from "@salty-css/core/server";
|
4
|
+
import { watch as h } from "fs";
|
5
|
+
const k = (t, e, u = !1, n = !1) => {
|
6
|
+
var a, l, o;
|
7
|
+
(l = (a = t.module) == null ? void 0 : a.rules) == null || l.push({
|
8
|
+
test: f(),
|
15
9
|
use: [
|
16
10
|
{
|
17
|
-
loader:
|
18
|
-
options: { dir:
|
11
|
+
loader: m(__dirname, n ? "./loader.cjs" : "./loader.js"),
|
12
|
+
options: { dir: e }
|
19
13
|
}
|
20
14
|
]
|
21
|
-
}),
|
22
|
-
apply: (
|
23
|
-
let
|
24
|
-
|
25
|
-
|
26
|
-
await
|
15
|
+
}), u || (o = t.plugins) == null || o.push({
|
16
|
+
apply: (p) => {
|
17
|
+
let r = !1;
|
18
|
+
p.hooks.beforeCompile.tapPromise({ name: "generateCss" }, async () => {
|
19
|
+
r || (r = !0, await i(e), h(e, { recursive: !0 }, async (g, s) => {
|
20
|
+
await d(s) ? await i(e, !1, !1) : c(s) && await y(e, s);
|
27
21
|
}));
|
28
22
|
});
|
29
23
|
}
|
30
24
|
});
|
31
25
|
};
|
32
26
|
export {
|
33
|
-
|
34
|
-
|
27
|
+
k as default,
|
28
|
+
k as saltyPlugin
|
35
29
|
};
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("
|
1
|
+
"use strict";const i=require("@salty-css/core/compiler");async function r(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=r;
|
package/loader.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
async function
|
3
|
-
const { dir: t } = this.getOptions(), { resourcePath:
|
4
|
-
return await
|
1
|
+
import { generateFile as i, minimizeFile as a } from "@salty-css/core/compiler";
|
2
|
+
async function n() {
|
3
|
+
const { dir: t } = this.getOptions(), { resourcePath: e } = this;
|
4
|
+
return await i(t, e), await a(t, e);
|
5
5
|
}
|
6
6
|
export {
|
7
|
-
|
7
|
+
n as default
|
8
8
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/webpack",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.270",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@salty-css/core": "^0.0.1-alpha.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.270",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|
package/index-Cpurtg_y.js
DELETED
@@ -1,706 +0,0 @@
|
|
1
|
-
var zt = Object.defineProperty;
|
2
|
-
var Wt = (e, t, s) => t in e ? zt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
|
-
var st = (e, t, s) => Wt(e, typeof t != "symbol" ? t + "" : t, s);
|
4
|
-
import * as Pt from "esbuild";
|
5
|
-
import { execSync as Jt } from "child_process";
|
6
|
-
import { join as u, parse as ot } from "path";
|
7
|
-
import { existsSync as dt, writeFileSync as _, readFileSync as z, mkdirSync as K, statSync as Rt, readdirSync as At } from "fs";
|
8
|
-
import { readFile as Ft } from "fs/promises";
|
9
|
-
import { createLogger as It, transports as Gt, format as ut } from "winston";
|
10
|
-
import pt from "typescript";
|
11
|
-
const St = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), Ht = (e, t) => {
|
12
|
-
let s = "", n;
|
13
|
-
for (n = Math.abs(e); n > 52; n = n / 52 | 0) s = St(n % 52) + s;
|
14
|
-
return s = St(n % 52) + s, s.length < t ? s = s.padStart(t, "a") : s.length > t && (s = s.slice(-t)), s;
|
15
|
-
}, Qt = (e, t) => {
|
16
|
-
let s = t.length;
|
17
|
-
for (; s; ) e = e * 33 ^ t.charCodeAt(--s);
|
18
|
-
return e;
|
19
|
-
}, G = (e, t = 5) => {
|
20
|
-
const s = Qt(5381, JSON.stringify(e)) >>> 0;
|
21
|
-
return Ht(s, t);
|
22
|
-
};
|
23
|
-
function W(e) {
|
24
|
-
return e ? typeof e != "string" ? W(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "-" : "") + t.toLowerCase()) : "";
|
25
|
-
}
|
26
|
-
const Kt = (e) => (t) => {
|
27
|
-
if (typeof t != "string" || !e) return;
|
28
|
-
let s = t;
|
29
|
-
const n = [];
|
30
|
-
return Object.values(e).forEach((o) => {
|
31
|
-
const { pattern: i, transform: r } = o;
|
32
|
-
s = s.replace(i, (m) => {
|
33
|
-
const { value: y, css: d } = r(m);
|
34
|
-
return d && n.push(d), y;
|
35
|
-
});
|
36
|
-
}), { transformed: s, additionalCss: n };
|
37
|
-
}, Nt = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) => {
|
38
|
-
const i = W(o[1].replaceAll(".", "-"));
|
39
|
-
return i.startsWith("-") ? `-${i}` : `var(--${i})`;
|
40
|
-
}) }, Lt = Nt(), Bt = (e) => (t) => {
|
41
|
-
const { screenSize: s, axis: n = "horizontal", minMultiplier: o = 0.5, maxMultiplier: i = 1.5 } = e, r = Math.round(t / s * 1e4) / 100, m = n === "vertical" ? "vh" : "vw", y = Math.round(o * t), d = Math.round(i * t);
|
42
|
-
return `clamp(${y}px, ${r}${m}, ${d}px)`;
|
43
|
-
}, Zt = [
|
44
|
-
"top",
|
45
|
-
"right",
|
46
|
-
"bottom",
|
47
|
-
"left",
|
48
|
-
"min-width",
|
49
|
-
/.*width.*/,
|
50
|
-
/^[^line]*height.*/,
|
51
|
-
// Exclude line-height
|
52
|
-
/padding.*/,
|
53
|
-
/margin.*/,
|
54
|
-
/border.*/,
|
55
|
-
/inset.*/,
|
56
|
-
/.*radius.*/,
|
57
|
-
/.*spacing.*/,
|
58
|
-
/.*gap.*/,
|
59
|
-
/.*indent.*/,
|
60
|
-
/.*offset.*/,
|
61
|
-
/.*size.*/,
|
62
|
-
/.*thickness.*/,
|
63
|
-
/.*font-size.*/
|
64
|
-
], Ut = (e, t, s) => {
|
65
|
-
if (Zt.some((o) => typeof o == "string" ? o === e : o.test(e))) {
|
66
|
-
const o = "px";
|
67
|
-
if (o.startsWith("viewport-clamp:"))
|
68
|
-
try {
|
69
|
-
const r = o.split(":")[1];
|
70
|
-
return Bt({
|
71
|
-
screenSize: parseInt(r)
|
72
|
-
})(Number(t));
|
73
|
-
} catch (r) {
|
74
|
-
throw console.error(r), new Error(`Invalid viewport-clamp value: ${o}`);
|
75
|
-
}
|
76
|
-
return `${t}${o}`;
|
77
|
-
}
|
78
|
-
return `${t}`;
|
79
|
-
}, qt = ["Webkit", "Moz", "ms", "O"], Xt = (e) => e.startsWith("-") ? e : qt.some((t) => e.startsWith(t)) ? `-${W(e)}` : W(e), nt = async (e, t = "", s, n = !1) => {
|
80
|
-
if (!e) throw new Error("No styles provided to parseStyles function!");
|
81
|
-
const o = /* @__PURE__ */ new Set(), i = Object.entries(e), r = async ([p, f]) => {
|
82
|
-
const $ = p.trim().replace(/^\?+/g, ""), P = Xt($), v = (D, R = ";") => `${P}:${D}${R}`, V = { scope: t, config: s };
|
83
|
-
if (typeof f == "function") return r([p, f(V)]);
|
84
|
-
if (f instanceof Promise) return r([p, await f]);
|
85
|
-
if (typeof f == "object") {
|
86
|
-
if (!f) return;
|
87
|
-
if (f.isColor) return v(f.toString());
|
88
|
-
if ($ === "defaultVariants") return;
|
89
|
-
if ($ === "variants") {
|
90
|
-
const F = Object.entries(f);
|
91
|
-
for (const [O, l] of F) {
|
92
|
-
if (!l) continue;
|
93
|
-
const w = Object.entries(l);
|
94
|
-
for (const [S, a] of w) {
|
95
|
-
if (!a) continue;
|
96
|
-
const j = `${t}.${O}-${S}`;
|
97
|
-
(await nt(a, j, s)).forEach((M) => o.add(M));
|
98
|
-
}
|
99
|
-
}
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
if ($ === "compoundVariants") {
|
103
|
-
for (const F of f) {
|
104
|
-
const { css: O, ...l } = F, w = Object.entries(l).reduce((a, [j, N]) => `${a}.${j}-${N}`, t);
|
105
|
-
(await nt(O, w, s)).forEach((a) => o.add(a));
|
106
|
-
}
|
107
|
-
return;
|
108
|
-
}
|
109
|
-
if ($.startsWith("@")) {
|
110
|
-
const F = $, O = await Y(f, t, s), l = `${F} { ${O} }`;
|
111
|
-
o.add(l);
|
112
|
-
return;
|
113
|
-
}
|
114
|
-
const D = p.includes("&") ? $.replaceAll("&", t) : $.startsWith(":") ? `${t}${$}` : `${t} ${$}`;
|
115
|
-
(await nt(f, D, s)).forEach((F) => o.add(F));
|
116
|
-
return;
|
117
|
-
}
|
118
|
-
if (typeof f == "number") {
|
119
|
-
const D = Ut(P, f);
|
120
|
-
return v(D);
|
121
|
-
}
|
122
|
-
if (typeof f != "string")
|
123
|
-
if ("toString" in f) f = f.toString();
|
124
|
-
else throw new Error(`Invalid value type for property ${P}`);
|
125
|
-
return v(f);
|
126
|
-
}, m = i.map(r), { modifiers: y } = {}, d = [Nt(), Kt(y)], g = (await Promise.all(m).then((p) => Promise.all(
|
127
|
-
p.map((f) => d.reduce(async ($, P) => {
|
128
|
-
const v = await $;
|
129
|
-
if (!v) return v;
|
130
|
-
const V = await P(v);
|
131
|
-
if (!V) return v;
|
132
|
-
const { transformed: D, additionalCss: R } = V;
|
133
|
-
let F = "";
|
134
|
-
if (R)
|
135
|
-
for (const O of R)
|
136
|
-
F += await Y(O, "");
|
137
|
-
return `${F}${D}`;
|
138
|
-
}, Promise.resolve(f)))
|
139
|
-
))).filter((p) => p !== void 0).join(`
|
140
|
-
`);
|
141
|
-
if (!g.trim()) return Array.from(o);
|
142
|
-
const h = t ? `${t} {
|
143
|
-
${g}
|
144
|
-
}` : g;
|
145
|
-
return o.has(h) ? Array.from(o) : [h, ...o];
|
146
|
-
}, Y = async (e, t, s, n = !1) => (await nt(e, t, s, n)).join(`
|
147
|
-
`), xt = async (e, t = []) => {
|
148
|
-
if (!e) return "";
|
149
|
-
const s = [], n = {};
|
150
|
-
for (const [o, i] of Object.entries(e))
|
151
|
-
if (typeof i != "function") if (i && typeof i == "object") {
|
152
|
-
const r = o.trim(), m = await xt(i, [...t, r]);
|
153
|
-
s.push(m);
|
154
|
-
} else
|
155
|
-
n[o] = i;
|
156
|
-
if (Object.keys(n).length) {
|
157
|
-
const o = t.map(W).join("-"), i = "t_" + G(o, 4), r = await Y(n, `.${o}, .${i}`);
|
158
|
-
s.push(r);
|
159
|
-
}
|
160
|
-
return s.join(`
|
161
|
-
`);
|
162
|
-
}, Yt = (e) => e ? Object.entries(e).reduce((t, [s, n]) => (typeof n == "function" ? t[s] = "any" : typeof n == "object" && (t[s] = vt(n).map((o) => `"${o}"`).join(" | ")), t), {}) : {}, vt = (e, t = "", s = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([n, o]) => {
|
163
|
-
const i = t ? `${t}.${n}` : n;
|
164
|
-
return typeof o == "object" ? vt(o, i, s) : s.add(t);
|
165
|
-
}), [...s]) : [], _t = (e) => {
|
166
|
-
if (!e || e === "/") throw new Error("Could not find package.json file");
|
167
|
-
const t = u(e, "package.json");
|
168
|
-
return dt(t) ? t : _t(u(e, ".."));
|
169
|
-
}, te = async (e) => {
|
170
|
-
const t = _t(e);
|
171
|
-
return await Ft(t, "utf-8").then(JSON.parse).catch(() => {
|
172
|
-
});
|
173
|
-
}, ee = async (e) => {
|
174
|
-
const t = await te(e);
|
175
|
-
if (t)
|
176
|
-
return t.type;
|
177
|
-
};
|
178
|
-
let Q;
|
179
|
-
const Tt = async (e) => {
|
180
|
-
if (Q) return Q;
|
181
|
-
const t = await ee(e);
|
182
|
-
return t === "module" ? Q = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (Q = "cjs"), Q || "esm";
|
183
|
-
}, mt = It({
|
184
|
-
level: "debug",
|
185
|
-
format: ut.combine(ut.colorize(), ut.cli()),
|
186
|
-
transports: [new Gt.Console({})]
|
187
|
-
});
|
188
|
-
function Dt(e) {
|
189
|
-
return e ? typeof e != "string" ? Dt(String(e)) : e.replace(/[^\d\w]/g, ".") : "";
|
190
|
-
}
|
191
|
-
const se = {
|
192
|
-
/** Set box model to border-box */
|
193
|
-
"*, *::before, *::after": {
|
194
|
-
boxSizing: "border-box"
|
195
|
-
},
|
196
|
-
/** Remove default margin and padding */
|
197
|
-
"*": {
|
198
|
-
margin: 0
|
199
|
-
},
|
200
|
-
/** Remove adjust font properties */
|
201
|
-
html: {
|
202
|
-
lineHeight: 1.15,
|
203
|
-
textSizeAdjust: "100%",
|
204
|
-
WebkitFontSmoothing: "antialiased"
|
205
|
-
},
|
206
|
-
/** Make media elements responsive */
|
207
|
-
"img, picture, video, canvas, svg": {
|
208
|
-
display: "block",
|
209
|
-
maxWidth: "100%"
|
210
|
-
},
|
211
|
-
/** Avoid overflow of text */
|
212
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
213
|
-
overflowWrap: "break-word"
|
214
|
-
},
|
215
|
-
/** Improve text wrapping */
|
216
|
-
p: {
|
217
|
-
textWrap: "pretty"
|
218
|
-
},
|
219
|
-
"h1, h2, h3, h4, h5, h6": {
|
220
|
-
textWrap: "balance"
|
221
|
-
},
|
222
|
-
/** Improve link color */
|
223
|
-
a: {
|
224
|
-
color: "currentColor"
|
225
|
-
},
|
226
|
-
/** Improve button line height */
|
227
|
-
button: {
|
228
|
-
lineHeight: "1em",
|
229
|
-
color: "currentColor"
|
230
|
-
},
|
231
|
-
/** Improve form elements */
|
232
|
-
"input, optgroup, select, textarea": {
|
233
|
-
fontFamily: "inherit",
|
234
|
-
fontSize: "100%",
|
235
|
-
lineHeight: "1.15em"
|
236
|
-
}
|
237
|
-
}, L = (...e) => e.flat().reduce((t, s) => s != null && s._current ? { ...t, ...s._current } : { ...t, ...s }, {}), ne = (...e) => e.flat().reduce((t, s) => ({ ...t, ...s._children }), {});
|
238
|
-
class oe {
|
239
|
-
constructor(t) {
|
240
|
-
st(this, "_path");
|
241
|
-
this.params = t;
|
242
|
-
}
|
243
|
-
get _current() {
|
244
|
-
return this.params.template;
|
245
|
-
}
|
246
|
-
get isDefineTemplate() {
|
247
|
-
return !0;
|
248
|
-
}
|
249
|
-
_setPath(t) {
|
250
|
-
return this._path = t, this;
|
251
|
-
}
|
252
|
-
}
|
253
|
-
class re {
|
254
|
-
constructor(t) {
|
255
|
-
st(this, "_path");
|
256
|
-
st(this, "templates", []);
|
257
|
-
this.params = t, Object.entries(t).forEach(([s, n]) => {
|
258
|
-
this.templates.push(
|
259
|
-
new oe({
|
260
|
-
name: s,
|
261
|
-
template: n
|
262
|
-
})
|
263
|
-
);
|
264
|
-
});
|
265
|
-
}
|
266
|
-
get _current() {
|
267
|
-
return this.params;
|
268
|
-
}
|
269
|
-
get _children() {
|
270
|
-
return Object.fromEntries(
|
271
|
-
this.templates.map((t) => [t.params.name, t])
|
272
|
-
);
|
273
|
-
}
|
274
|
-
get isDefineTemplates() {
|
275
|
-
return !0;
|
276
|
-
}
|
277
|
-
_setPath(t) {
|
278
|
-
return this._path = t, this.templates.forEach((s) => s._setPath(t)), this;
|
279
|
-
}
|
280
|
-
}
|
281
|
-
const ie = (e) => new re(e), ae = (e, t) => new Promise((s, n) => {
|
282
|
-
const o = setTimeout(() => {
|
283
|
-
n(new Error("Timeout"));
|
284
|
-
}, 100), i = pt.createSourceFile("temp.ts", e, pt.ScriptTarget.Latest, !0);
|
285
|
-
function r(m) {
|
286
|
-
if (pt.isVariableDeclaration(m) && m.name.getText() === t) {
|
287
|
-
const y = m.getStart(), d = m.getEnd();
|
288
|
-
clearTimeout(o), s([y, d]);
|
289
|
-
}
|
290
|
-
m.forEachChild(r);
|
291
|
-
}
|
292
|
-
r(i);
|
293
|
-
}), J = {
|
294
|
-
externalModules: [],
|
295
|
-
rcFile: void 0,
|
296
|
-
destDir: void 0
|
297
|
-
}, Et = (e) => {
|
298
|
-
if (J.externalModules.length > 0) return J.externalModules;
|
299
|
-
const s = z(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
300
|
-
if (!s) return [];
|
301
|
-
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
302
|
-
return J.externalModules = n, n;
|
303
|
-
}, H = async (e) => {
|
304
|
-
if (J.destDir) return J.destDir;
|
305
|
-
const t = await yt(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
|
306
|
-
return J.destDir = s, s;
|
307
|
-
}, kt = ["salty", "css", "styles", "styled"], ce = (e = []) => new RegExp(`\\.(${[...kt, ...e].join("|")})\\.`), ht = (e, t = []) => ce(t).test(e), Vt = async (e) => {
|
308
|
-
if (J.rcFile) return J.rcFile;
|
309
|
-
if (e === "/") throw new Error("Could not find .saltyrc.json file");
|
310
|
-
const t = u(e, ".saltyrc.json"), s = await Ft(t, "utf-8").then(JSON.parse).catch(() => {
|
311
|
-
});
|
312
|
-
return s ? (J.rcFile = s, s) : Vt(u(e, ".."));
|
313
|
-
}, yt = async (e) => {
|
314
|
-
var n, o;
|
315
|
-
const t = await Vt(e), s = (n = t.projects) == null ? void 0 : n.find((i) => e.endsWith(i.dir || ""));
|
316
|
-
return s || ((o = t.projects) == null ? void 0 : o.find((i) => i.dir === t.defaultProject));
|
317
|
-
}, le = async (e) => {
|
318
|
-
const t = await yt(e), s = await H(e), n = u(e, (t == null ? void 0 : t.configDir) || "", "salty.config.ts"), o = u(s, "salty.config.js"), i = await Tt(e), r = Et(n);
|
319
|
-
await Pt.build({
|
320
|
-
entryPoints: [n],
|
321
|
-
minify: !0,
|
322
|
-
treeShaking: !0,
|
323
|
-
bundle: !0,
|
324
|
-
outfile: o,
|
325
|
-
format: i,
|
326
|
-
external: r
|
327
|
-
});
|
328
|
-
const m = Date.now(), { config: y } = await import(`${o}?t=${m}`);
|
329
|
-
return { config: y, path: o };
|
330
|
-
}, fe = async (e, t) => {
|
331
|
-
var wt, bt;
|
332
|
-
const s = await H(e), n = {
|
333
|
-
mediaQueries: [],
|
334
|
-
globalStyles: [],
|
335
|
-
variables: [],
|
336
|
-
templates: []
|
337
|
-
};
|
338
|
-
await Promise.all(
|
339
|
-
[...t].map(async (C) => {
|
340
|
-
const { contents: x, outputFilePath: q } = await rt(e, C, s);
|
341
|
-
Object.entries(x).forEach(([E, T]) => {
|
342
|
-
T.isMedia ? n.mediaQueries.push([E, T]) : T.isGlobalDefine ? n.globalStyles.push(T) : T.isDefineVariables ? n.variables.push(T) : T.isDefineTemplates && n.templates.push(T._setPath(`${E};;${q}`));
|
343
|
-
});
|
344
|
-
})
|
345
|
-
);
|
346
|
-
const { config: o, path: i } = await le(e), r = { ...o }, { mediaQueries: m } = n;
|
347
|
-
r.mediaQueries = Object.fromEntries(m.map(([C, x]) => [`@${C}`, x]));
|
348
|
-
const y = m.map(([C]) => `'@${C}'`).join(" | "), d = /* @__PURE__ */ new Set(), c = async (C, x = []) => {
|
349
|
-
if (!C) return [];
|
350
|
-
const q = Object.entries(C).map(async ([T, I]) => {
|
351
|
-
const X = async (k) => {
|
352
|
-
if (!k) return;
|
353
|
-
if (k instanceof Promise) return await X(await k);
|
354
|
-
if (typeof k == "function") return await X(await k());
|
355
|
-
if (typeof k == "object") return await c(k, [...x, T]);
|
356
|
-
const ct = Dt(T), lt = W(T), ft = [...x, ct].join(".");
|
357
|
-
d.add(`"${ft}"`);
|
358
|
-
const et = [...x.map(W), lt].join("-"), Ct = Lt(k);
|
359
|
-
return Ct ? `--${et}: ${Ct.transformed};` : `--${et}: ${k};`;
|
360
|
-
};
|
361
|
-
return await X(I);
|
362
|
-
});
|
363
|
-
return (await Promise.all(q)).flat();
|
364
|
-
}, g = async (C) => {
|
365
|
-
if (!C) return [];
|
366
|
-
const x = Object.entries(C).map(async ([E, T]) => {
|
367
|
-
const I = await c(T);
|
368
|
-
return E === "base" ? I.join("") : r.mediaQueries[E] ? `${r.mediaQueries[E]} { ${I.join("")} }` : `${E} { ${I.join("")} }`;
|
369
|
-
});
|
370
|
-
return (await Promise.all(x)).flat();
|
371
|
-
}, h = async (C) => {
|
372
|
-
if (!C) return [];
|
373
|
-
const x = Object.entries(C).map(async ([E, T]) => {
|
374
|
-
const I = Object.entries(T).map(async ([k, ct]) => {
|
375
|
-
const lt = await c(ct, [E]), ft = `.${E}-${k}, [data-${E}="${k}"]`, et = lt.join("");
|
376
|
-
return `${ft} { ${et} }`;
|
377
|
-
});
|
378
|
-
return (await Promise.all(I)).flat();
|
379
|
-
});
|
380
|
-
return (await Promise.all(x)).flat();
|
381
|
-
}, b = (C) => ({ ...C, responsive: void 0, conditional: void 0 }), p = (C) => n.variables.map((x) => C === "static" ? b(x._current) : x._current[C]), f = L(b(o.variables), p("static")), $ = await c(f), P = L((wt = o.variables) == null ? void 0 : wt.responsive, p("responsive")), v = await g(P), V = L((bt = o.variables) == null ? void 0 : bt.conditional, p("conditional")), D = await h(V), R = u(s, "css/_variables.css"), F = `:root { ${$.join("")} ${v.join("")} } ${D.join("")}`;
|
382
|
-
_(R, F), r.staticVariables = f;
|
383
|
-
const O = u(s, "css/_global.css"), l = L(o.global, n.globalStyles), w = await Y(l, "");
|
384
|
-
_(O, `@layer global { ${w} }`);
|
385
|
-
const S = u(s, "css/_reset.css"), j = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : se, N = await Y(j, "");
|
386
|
-
_(S, `@layer reset { ${N} }`);
|
387
|
-
const M = u(s, "css/_templates.css"), A = L(o.templates, n.templates), B = await xt(A), Z = Yt(A);
|
388
|
-
_(M, `@layer templates { ${B} }`), r.templates = A;
|
389
|
-
const tt = o.templates ? [ie(o.templates)._setPath(`config;;${i}`)] : [], it = ne(n.templates, tt);
|
390
|
-
r.templatePaths = Object.fromEntries(Object.entries(it).map(([C, x]) => [C, x._path]));
|
391
|
-
const U = u(s, "types/css-tokens.d.ts"), Ot = `
|
392
|
-
// Variable types
|
393
|
-
type VariableTokens = ${[...d].join("|")};
|
394
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
395
|
-
|
396
|
-
// Template types
|
397
|
-
type TemplateTokens = {
|
398
|
-
${Object.entries(Z).map(([C, x]) => `${C}?: ${x}`).join(`
|
399
|
-
`)}
|
400
|
-
}
|
401
|
-
|
402
|
-
// Media query types
|
403
|
-
type MediaQueryKeys = ${y || "''"};
|
404
|
-
`;
|
405
|
-
_(U, Ot);
|
406
|
-
const Mt = u(s, "cache/config-cache.json");
|
407
|
-
_(Mt, JSON.stringify(r, null, 2));
|
408
|
-
}, jt = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
|
409
|
-
if (/^['"`]/.test(s)) return t;
|
410
|
-
const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
411
|
-
if (!o.test(e)) return t;
|
412
|
-
const r = o.exec(e);
|
413
|
-
if (r) {
|
414
|
-
const m = r.at(1);
|
415
|
-
if (kt.some((d) => m == null ? void 0 : m.includes(d))) return t;
|
416
|
-
}
|
417
|
-
return "styled('div',";
|
418
|
-
}), ue = (e, t) => {
|
419
|
-
try {
|
420
|
-
const s = z(u(t, "saltygen/cache/config-cache.json"), "utf8");
|
421
|
-
return s ? `globalThis.saltyConfig = ${s};
|
422
|
-
|
423
|
-
${e}` : `globalThis.saltyConfig = {};
|
424
|
-
|
425
|
-
${e}`;
|
426
|
-
} catch {
|
427
|
-
return e;
|
428
|
-
}
|
429
|
-
}, rt = async (e, t, s) => {
|
430
|
-
const n = G(t), o = u(s, "./temp");
|
431
|
-
dt(o) || K(o);
|
432
|
-
const i = ot(t);
|
433
|
-
let r = z(t, "utf8");
|
434
|
-
r = jt(r), r = ue(r, e);
|
435
|
-
const m = u(s, "js", n + ".js"), y = await yt(e), d = u(e, (y == null ? void 0 : y.configDir) || "", "salty.config.ts"), c = Et(d), g = await Tt(e);
|
436
|
-
await Pt.build({
|
437
|
-
stdin: {
|
438
|
-
contents: r,
|
439
|
-
sourcefile: i.base,
|
440
|
-
resolveDir: i.dir,
|
441
|
-
loader: "tsx"
|
442
|
-
},
|
443
|
-
minify: !1,
|
444
|
-
treeShaking: !0,
|
445
|
-
bundle: !0,
|
446
|
-
outfile: m,
|
447
|
-
format: g,
|
448
|
-
target: ["node20"],
|
449
|
-
keepNames: !0,
|
450
|
-
external: c,
|
451
|
-
packages: "external",
|
452
|
-
plugins: [
|
453
|
-
{
|
454
|
-
name: "test",
|
455
|
-
setup: (p) => {
|
456
|
-
p.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (f) => {
|
457
|
-
const $ = z(f.path, "utf8");
|
458
|
-
return { contents: jt($), loader: "ts" };
|
459
|
-
});
|
460
|
-
}
|
461
|
-
}
|
462
|
-
]
|
463
|
-
});
|
464
|
-
const h = Date.now();
|
465
|
-
return { contents: await import(`${m}?t=${h}`), outputFilePath: m };
|
466
|
-
}, pe = async (e) => {
|
467
|
-
const t = await H(e), s = u(t, "cache/config-cache.json"), n = z(s, "utf8");
|
468
|
-
if (!n) throw new Error("Could not find config cache file");
|
469
|
-
return JSON.parse(n);
|
470
|
-
}, gt = async (e) => {
|
471
|
-
const t = await pe(e), s = await H(e), n = u(s, "salty.config.js"), o = Date.now(), { config: i } = await import(`${n}?t=${o}`);
|
472
|
-
return L(i, t);
|
473
|
-
}, $t = () => {
|
474
|
-
try {
|
475
|
-
return process.env.NODE_ENV === "production";
|
476
|
-
} catch {
|
477
|
-
return !1;
|
478
|
-
}
|
479
|
-
}, be = async (e, t = $t(), s = !0) => {
|
480
|
-
try {
|
481
|
-
const n = Date.now();
|
482
|
-
t ? mt.info("Generating CSS in production mode! 🔥") : mt.info("Generating CSS in development mode! 🚀");
|
483
|
-
const o = [], i = [], r = await H(e), m = u(r, "index.css");
|
484
|
-
s && (() => {
|
485
|
-
dt(r) && Jt("rm -rf " + r), K(r, { recursive: !0 }), K(u(r, "css")), K(u(r, "types")), K(u(r, "js")), K(u(r, "cache"));
|
486
|
-
})();
|
487
|
-
const d = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
|
488
|
-
async function g(l) {
|
489
|
-
const w = ["node_modules", "saltygen"], S = Rt(l);
|
490
|
-
if (S.isDirectory()) {
|
491
|
-
const a = At(l);
|
492
|
-
if (w.some((N) => l.includes(N))) return;
|
493
|
-
await Promise.all(a.map((N) => g(u(l, N))));
|
494
|
-
} else if (S.isFile() && ht(l)) {
|
495
|
-
d.add(l);
|
496
|
-
const j = z(l, "utf8");
|
497
|
-
/define[\w\d]+\(/.test(j) && c.add(l);
|
498
|
-
}
|
499
|
-
}
|
500
|
-
await g(e), await fe(e, c);
|
501
|
-
const h = {
|
502
|
-
keyframes: [],
|
503
|
-
components: [],
|
504
|
-
classNames: []
|
505
|
-
};
|
506
|
-
await Promise.all(
|
507
|
-
[...d].map(async (l) => {
|
508
|
-
const { contents: w } = await rt(e, l, r);
|
509
|
-
for (let [S, a] of Object.entries(w))
|
510
|
-
a instanceof Promise && (a = await a), a.isKeyframes ? h.keyframes.push({
|
511
|
-
value: a,
|
512
|
-
src: l,
|
513
|
-
name: S
|
514
|
-
}) : a.isClassName ? h.classNames.push({
|
515
|
-
...a,
|
516
|
-
src: l,
|
517
|
-
name: S
|
518
|
-
}) : a.generator && h.components.push({
|
519
|
-
...a,
|
520
|
-
src: l,
|
521
|
-
name: S
|
522
|
-
});
|
523
|
-
})
|
524
|
-
);
|
525
|
-
const b = await gt(e);
|
526
|
-
for (const l of h.keyframes) {
|
527
|
-
const { value: w } = l, S = `a_${w.animationName}.css`, a = `css/${S}`, j = u(r, a);
|
528
|
-
o.push(S), _(j, w.css);
|
529
|
-
}
|
530
|
-
const p = {};
|
531
|
-
for (const l of h.components) {
|
532
|
-
const { src: w, name: S } = l;
|
533
|
-
p[w] || (p[w] = []);
|
534
|
-
const a = l.generator._withBuildContext({
|
535
|
-
callerName: S,
|
536
|
-
isProduction: t,
|
537
|
-
config: b
|
538
|
-
});
|
539
|
-
i[a.priority] || (i[a.priority] = []);
|
540
|
-
const j = await a.css;
|
541
|
-
if (!j) continue;
|
542
|
-
i[a.priority].push(a.cssFileName);
|
543
|
-
const N = `css/${a.cssFileName}`, M = u(r, N);
|
544
|
-
_(M, j), b.importStrategy === "component" && p[w].push(a.cssFileName);
|
545
|
-
}
|
546
|
-
for (const l of h.classNames) {
|
547
|
-
const { src: w, name: S } = l;
|
548
|
-
p[w] || (p[w] = []);
|
549
|
-
const a = l.generator._withBuildContext({
|
550
|
-
callerName: S,
|
551
|
-
isProduction: t,
|
552
|
-
config: b
|
553
|
-
}), j = await a.css;
|
554
|
-
if (!j) continue;
|
555
|
-
i[a.priority] || (i[a.priority] = []), i[a.priority].push(a.cssFileName);
|
556
|
-
const N = `css/${a.cssFileName}`, M = u(r, N);
|
557
|
-
_(M, j), b.importStrategy === "component" && p[w].push(a.cssFileName);
|
558
|
-
}
|
559
|
-
b.importStrategy === "component" && Object.entries(p).forEach(([l, w]) => {
|
560
|
-
const S = w.map((A) => `@import url('./${A}');`).join(`
|
561
|
-
`), a = G(l, 6), j = ot(l), N = W(j.name), M = u(r, `css/f_${N}-${a}.css`);
|
562
|
-
_(M, S || "/* Empty file */");
|
563
|
-
});
|
564
|
-
const f = o.map((l) => `@import url('./css/${l}');`).join(`
|
565
|
-
`);
|
566
|
-
let D = `/*!
|
567
|
-
* Generated with Salty CSS (https://salty-css.dev)
|
568
|
-
* Do not edit this file directly
|
569
|
-
*/
|
570
|
-
@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
571
|
-
|
572
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
573
|
-
try {
|
574
|
-
return z(u(r, "css", l), "utf8").length > 0;
|
575
|
-
} catch {
|
576
|
-
return !1;
|
577
|
-
}
|
578
|
-
}).map((l) => `@import url('./css/${l}');`).join(
|
579
|
-
`
|
580
|
-
`
|
581
|
-
)}
|
582
|
-
${f}`;
|
583
|
-
if (b.importStrategy !== "component") {
|
584
|
-
const l = i.reduce((w, S, a) => {
|
585
|
-
const j = S.reduce((B, Z) => {
|
586
|
-
var at;
|
587
|
-
const tt = u(r, "css", Z), it = z(tt, "utf8"), U = ((at = /.*-([^-]+)-\d+.css/.exec(Z)) == null ? void 0 : at.at(1)) || G(tt, 6);
|
588
|
-
return B.includes(U) ? B : `${B}
|
589
|
-
/*start:${U}-${Z}*/
|
590
|
-
${it}
|
591
|
-
/*end:${U}*/
|
592
|
-
`;
|
593
|
-
}, ""), N = `l_${a}.css`, M = u(r, "css", N), A = `@layer l${a} { ${j}
|
594
|
-
}`;
|
595
|
-
return _(M, A), `${w}
|
596
|
-
@import url('./css/${N}');`;
|
597
|
-
}, "");
|
598
|
-
D += l;
|
599
|
-
}
|
600
|
-
_(m, D);
|
601
|
-
const F = Date.now() - n, O = F < 200 ? "🔥" : F < 500 ? "🚀" : F < 1e3 ? "🎉" : F < 2e3 ? "🚗" : F < 5e3 ? "🤔" : "🥴";
|
602
|
-
mt.info(`Generated CSS in ${F}ms! ${O}`);
|
603
|
-
} catch (n) {
|
604
|
-
console.error(n);
|
605
|
-
}
|
606
|
-
}, Ce = async (e, t, s = $t()) => {
|
607
|
-
try {
|
608
|
-
const n = await H(e);
|
609
|
-
if (ht(t)) {
|
610
|
-
const i = [], r = await gt(e), { contents: m } = await rt(e, t, n);
|
611
|
-
for (const [y, d] of Object.entries(m)) {
|
612
|
-
if (d.isKeyframes && d.css) {
|
613
|
-
const f = `css/${`a_${d.animationName}.css`}`, $ = u(n, f);
|
614
|
-
_($, await d.css);
|
615
|
-
continue;
|
616
|
-
}
|
617
|
-
if (d.isClassName) {
|
618
|
-
const p = d.generator._withBuildContext({
|
619
|
-
callerName: y,
|
620
|
-
isProduction: s,
|
621
|
-
config: r
|
622
|
-
}), f = await p.css;
|
623
|
-
if (!f) continue;
|
624
|
-
i[p.priority] || (i[p.priority] = []), i[p.priority].push(p.cssFileName);
|
625
|
-
const $ = `css/${p.cssFileName}`, P = u(n, $);
|
626
|
-
_(P, f);
|
627
|
-
continue;
|
628
|
-
}
|
629
|
-
if (!d.generator) continue;
|
630
|
-
const c = d.generator._withBuildContext({
|
631
|
-
callerName: y,
|
632
|
-
isProduction: s,
|
633
|
-
config: r
|
634
|
-
}), g = await c.css;
|
635
|
-
if (!g) continue;
|
636
|
-
const h = `css/${c.cssFileName}`, b = u(n, h);
|
637
|
-
_(b, g), i[c.priority] || (i[c.priority] = []), i[c.priority].push(c.cssFileName);
|
638
|
-
}
|
639
|
-
if (r.importStrategy !== "component")
|
640
|
-
i.forEach((y, d) => {
|
641
|
-
const c = `l_${d}.css`, g = u(n, "css", c);
|
642
|
-
let h = z(g, "utf8");
|
643
|
-
y.forEach((b) => {
|
644
|
-
var P;
|
645
|
-
const p = u(n, "css", b), f = ((P = /.*-([^-]+)-\d+.css/.exec(b)) == null ? void 0 : P.at(1)) || G(p, 6);
|
646
|
-
if (!h.includes(f)) {
|
647
|
-
const v = z(p, "utf8"), V = `/*start:${f}-${b}*/
|
648
|
-
${v}
|
649
|
-
/*end:${f}*/
|
650
|
-
`;
|
651
|
-
h = `${h.replace(/\}$/, "")}
|
652
|
-
${V}
|
653
|
-
}`;
|
654
|
-
}
|
655
|
-
}), _(g, h);
|
656
|
-
});
|
657
|
-
else {
|
658
|
-
const y = i.flat().map((b) => `@import url('./${b}');`).join(`
|
659
|
-
`), d = G(t, 6), c = ot(t), g = W(c.name), h = u(n, `css/f_${g}-${d}.css`);
|
660
|
-
_(h, y || "/* Empty file */");
|
661
|
-
}
|
662
|
-
}
|
663
|
-
} catch (n) {
|
664
|
-
console.error(n);
|
665
|
-
}
|
666
|
-
}, Se = async (e, t, s = $t()) => {
|
667
|
-
var n, o;
|
668
|
-
try {
|
669
|
-
const i = await H(e);
|
670
|
-
if (ht(t)) {
|
671
|
-
const m = z(t, "utf8"), y = await gt(e), { contents: d } = await rt(e, t, i);
|
672
|
-
let c = m;
|
673
|
-
for (const [g, h] of Object.entries(d)) {
|
674
|
-
if (h.isKeyframes || !h.generator) continue;
|
675
|
-
const b = h.generator._withBuildContext({
|
676
|
-
callerName: g,
|
677
|
-
isProduction: s,
|
678
|
-
config: y
|
679
|
-
}), [p, f] = await ae(c, g), $ = c.slice(p, f);
|
680
|
-
if (h.isClassName) {
|
681
|
-
const P = c, v = ` ${g} = className("${b.classNames}")`;
|
682
|
-
c = c.replace($, v), P === c && console.error("Minimize file failed to change content", { name: g });
|
683
|
-
}
|
684
|
-
if ($.includes("styled")) {
|
685
|
-
const P = (o = (n = /styled\(([^,]+),/.exec($)) == null ? void 0 : n.at(1)) == null ? void 0 : o.trim(), v = c, V = ` ${g} = styled(${P}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;
|
686
|
-
c = c.replace($, V), v === c && console.error("Minimize file failed to change content", { name: g, tagName: P });
|
687
|
-
}
|
688
|
-
}
|
689
|
-
if (y.importStrategy === "component") {
|
690
|
-
const g = G(t, 6), h = ot(t);
|
691
|
-
c = `import '../../saltygen/css/${`f_${W(h.name)}-${g}.css`}';
|
692
|
-
${c}`;
|
693
|
-
}
|
694
|
-
return c = c.replace("@salty-css/react/class-name", "@salty-css/react/class-name-client"), c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
695
|
-
}
|
696
|
-
} catch (i) {
|
697
|
-
console.error("Error in minimizeFile:", i);
|
698
|
-
}
|
699
|
-
};
|
700
|
-
export {
|
701
|
-
Ce as a,
|
702
|
-
be as g,
|
703
|
-
ht as i,
|
704
|
-
Se as m,
|
705
|
-
ce as s
|
706
|
-
};
|
package/index-DBDB_Jqo.cjs
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
"use strict";var Vt=Object.defineProperty;var Mt=(e,t,s)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var et=(e,t,s)=>Mt(e,typeof t!="symbol"?t+"":t,s);const zt=require("esbuild"),Rt=require("child_process"),c=require("path"),p=require("fs"),bt=require("fs/promises"),Z=require("winston"),ft=require("typescript");var ut=typeof document<"u"?document.currentScript:null;function Wt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const jt=Wt(zt),$t=e=>String.fromCharCode(e+(e>25?39:97)),Jt=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=$t(n%52)+s;return s=$t(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},At=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},I=(e,t=5)=>{const s=At(5381,JSON.stringify(e))>>>0;return Jt(s,t)};function z(e){return e?typeof e!="string"?z(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const It=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:i}=o;s=s.replace(r,d=>{const{value:g,css:y}=i(d);return y&&n.push(y),g})}),{transformed:s,additionalCss:n}},Ft=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>{const r=z(o[1].replaceAll(".","-"));return r.startsWith("-")?`-${r}`:`var(--${r})`})},qt=Ft(),Gt=e=>t=>{const{screenSize:s,axis:n="horizontal",minMultiplier:o=.5,maxMultiplier:r=1.5}=e,i=Math.round(t/s*1e4)/100,d=n==="vertical"?"vh":"vw",g=Math.round(o*t),y=Math.round(r*t);return`clamp(${g}px, ${i}${d}, ${y}px)`},Ht=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Lt=(e,t,s)=>{if(Ht.some(o=>typeof o=="string"?o===e:o.test(e))){const o="px";if(o.startsWith("viewport-clamp:"))try{const i=o.split(":")[1];return Gt({screenSize:parseInt(i)})(Number(t))}catch(i){throw console.error(i),new Error(`Invalid viewport-clamp value: ${o}`)}return`${t}${o}`}return`${t}`},Qt=["Webkit","Moz","ms","O"],Kt=e=>e.startsWith("-")?e:Qt.some(t=>e.startsWith(t))?`-${z(e)}`:z(e),st=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,r=Object.entries(e),i=async([m,u])=>{const $=m.trim().replace(/^\?+/g,""),P=Kt($),v=(k,W=";")=>`${P}:${k}${W}`,O={scope:t,config:s};if(typeof u=="function")return i([m,u(O)]);if(u instanceof Promise)return i([m,await u]);if(typeof u=="object"){if(!u)return;if(u.isColor)return v(u.toString());if($==="defaultVariants")return;if($==="variants"){const N=Object.entries(u);for(const[V,f]of N){if(!f)continue;const S=Object.entries(f);for(const[F,a]of S){if(!a)continue;const C=`${t}.${V}-${F}`;(await st(a,C,s)).forEach(M=>o.add(M))}}return}if($==="compoundVariants"){for(const N of u){const{css:V,...f}=N,S=Object.entries(f).reduce((a,[C,x])=>`${a}.${C}-${x}`,t);(await st(V,S,s)).forEach(a=>o.add(a))}return}if($.startsWith("@")){const N=$,V=await X(u,t,s),f=`${N} { ${V} }`;o.add(f);return}const k=m.includes("&")?$.replaceAll("&",t):$.startsWith(":")?`${t}${$}`:`${t} ${$}`;(await st(u,k,s)).forEach(N=>o.add(N));return}if(typeof u=="number"){const k=Lt(P,u);return v(k)}if(typeof u!="string")if("toString"in u)u=u.toString();else throw new Error(`Invalid value type for property ${P}`);return v(u)},d=r.map(i),{modifiers:g}={},y=[Ft(),It(g)],w=(await Promise.all(d).then(m=>Promise.all(m.map(u=>y.reduce(async($,P)=>{const v=await $;if(!v)return v;const O=await P(v);if(!O)return v;const{transformed:k,additionalCss:W}=O;let N="";if(W)for(const V of W)N+=await X(V,"");return`${N}${k}`},Promise.resolve(u)))))).filter(m=>m!==void 0).join(`
|
2
|
-
`);if(!w.trim())return Array.from(o);const h=t?`${t} {
|
3
|
-
${w}
|
4
|
-
}`:w;return o.has(h)?Array.from(o):[h,...o]},X=async(e,t,s,n=!1)=>(await st(e,t,s,n)).join(`
|
5
|
-
`),Ct=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,r]of Object.entries(e))if(typeof r!="function")if(r&&typeof r=="object"){const i=o.trim(),d=await Ct(r,[...t,i]);s.push(d)}else n[o]=r;if(Object.keys(n).length){const o=t.map(z).join("-"),r="t_"+I(o,4),i=await X(n,`.${o}, .${r}`);s.push(i)}return s.join(`
|
6
|
-
`)},Ut=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=Pt(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},Pt=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?Pt(o,r,s):s.add(t)}),[...s]):[],Nt=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return p.existsSync(t)?t:Nt(c.join(e,".."))},Bt=async e=>{const t=Nt(e);return await bt.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Zt=async e=>{const t=await Bt(e);if(t)return t.type};let G;const xt=async e=>{if(G)return G;const t=await Zt(e);return t==="module"?G="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ut&&ut.tagName.toUpperCase()==="SCRIPT"&&ut.src||new URL("index-DBDB_Jqo.cjs",document.baseURI).href).endsWith(".cjs"))&&(G="cjs"),G||"esm"},pt=Z.createLogger({level:"debug",format:Z.format.combine(Z.format.colorize(),Z.format.cli()),transports:[new Z.transports.Console({})]});function _t(e){return e?typeof e!="string"?_t(String(e)):e.replace(/[^\d\w]/g,"."):""}const Xt={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},H=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Yt=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{});class te{constructor(t){et(this,"_path");this.params=t}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(t){return this._path=t,this}}class ee{constructor(t){et(this,"_path");et(this,"templates",[]);this.params=t,Object.entries(t).forEach(([s,n])=>{this.templates.push(new te({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(t=>[t.params.name,t]))}get isDefineTemplates(){return!0}_setPath(t){return this._path=t,this.templates.forEach(s=>s._setPath(t)),this}}const se=e=>new ee(e),ne=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),r=ft.createSourceFile("temp.ts",e,ft.ScriptTarget.Latest,!0);function i(d){if(ft.isVariableDeclaration(d)&&d.name.getText()===t){const g=d.getStart(),y=d.getEnd();clearTimeout(o),s([g,y])}d.forEachChild(i)}i(r)}),R={externalModules:[],rcFile:void 0,destDir:void 0},vt=e=>{if(R.externalModules.length>0)return R.externalModules;const s=p.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return R.externalModules=n,n},q=async e=>{if(R.destDir)return R.destDir;const t=await mt(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},Tt=["salty","css","styles","styled"],kt=(e=[])=>new RegExp(`\\.(${[...Tt,...e].join("|")})\\.`),nt=(e,t=[])=>kt(t).test(e),Dt=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await bt.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):Dt(c.join(e,".."))},mt=async e=>{var n,o;const t=await Dt(e),s=(n=t.projects)==null?void 0:n.find(r=>e.endsWith(r.dir||""));return s||((o=t.projects)==null?void 0:o.find(r=>r.dir===t.defaultProject))},oe=async e=>{const t=await mt(e),s=await q(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),r=await xt(e),i=vt(n);await jt.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:i});const d=Date.now(),{config:g}=await import(`${o}?t=${d}`);return{config:g,path:o}},ie=async(e,t)=>{var ht,gt;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async j=>{const{contents:_,outputFilePath:U}=await ot(e,j,s);Object.entries(_).forEach(([D,T])=>{T.isMedia?n.mediaQueries.push([D,T]):T.isGlobalDefine?n.globalStyles.push(T):T.isDefineVariables?n.variables.push(T):T.isDefineTemplates&&n.templates.push(T._setPath(`${D};;${U}`))})}));const{config:o,path:r}=await oe(e),i={...o},{mediaQueries:d}=n;i.mediaQueries=Object.fromEntries(d.map(([j,_])=>[`@${j}`,_]));const g=d.map(([j])=>`'@${j}'`).join(" | "),y=new Set,l=async(j,_=[])=>{if(!j)return[];const U=Object.entries(j).map(async([T,A])=>{const B=async E=>{if(!E)return;if(E instanceof Promise)return await B(await E);if(typeof E=="function")return await B(await E());if(typeof E=="object")return await l(E,[..._,T]);const at=_t(T),ct=z(T),lt=[..._,at].join(".");y.add(`"${lt}"`);const tt=[..._.map(z),ct].join("-"),wt=qt(E);return wt?`--${tt}: ${wt.transformed};`:`--${tt}: ${E};`};return await B(A)});return(await Promise.all(U)).flat()},w=async j=>{if(!j)return[];const _=Object.entries(j).map(async([D,T])=>{const A=await l(T);return D==="base"?A.join(""):i.mediaQueries[D]?`${i.mediaQueries[D]} { ${A.join("")} }`:`${D} { ${A.join("")} }`});return(await Promise.all(_)).flat()},h=async j=>{if(!j)return[];const _=Object.entries(j).map(async([D,T])=>{const A=Object.entries(T).map(async([E,at])=>{const ct=await l(at,[D]),lt=`.${D}-${E}, [data-${D}="${E}"]`,tt=ct.join("");return`${lt} { ${tt} }`});return(await Promise.all(A)).flat()});return(await Promise.all(_)).flat()},b=j=>({...j,responsive:void 0,conditional:void 0}),m=j=>n.variables.map(_=>j==="static"?b(_._current):_._current[j]),u=H(b(o.variables),m("static")),$=await l(u),P=H((ht=o.variables)==null?void 0:ht.responsive,m("responsive")),v=await w(P),O=H((gt=o.variables)==null?void 0:gt.conditional,m("conditional")),k=await h(O),W=c.join(s,"css/_variables.css"),N=`:root { ${$.join("")} ${v.join("")} } ${k.join("")}`;p.writeFileSync(W,N),i.staticVariables=u;const V=c.join(s,"css/_global.css"),f=H(o.global,n.globalStyles),S=await X(f,"");p.writeFileSync(V,`@layer global { ${S} }`);const F=c.join(s,"css/_reset.css"),C=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Xt,x=await X(C,"");p.writeFileSync(F,`@layer reset { ${x} }`);const M=c.join(s,"css/_templates.css"),J=H(o.templates,n.templates),L=await Ct(J),Q=Ut(J);p.writeFileSync(M,`@layer templates { ${L} }`),i.templates=J;const Y=o.templates?[se(o.templates)._setPath(`config;;${r}`)]:[],it=Yt(n.templates,Y);i.templatePaths=Object.fromEntries(Object.entries(it).map(([j,_])=>[j,_._path]));const K=c.join(s,"types/css-tokens.d.ts"),Et=`
|
7
|
-
// Variable types
|
8
|
-
type VariableTokens = ${[...y].join("|")};
|
9
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
10
|
-
|
11
|
-
// Template types
|
12
|
-
type TemplateTokens = {
|
13
|
-
${Object.entries(Q).map(([j,_])=>`${j}?: ${_}`).join(`
|
14
|
-
`)}
|
15
|
-
}
|
16
|
-
|
17
|
-
// Media query types
|
18
|
-
type MediaQueryKeys = ${g||"''"};
|
19
|
-
`;p.writeFileSync(K,Et);const Ot=c.join(s,"cache/config-cache.json");p.writeFileSync(Ot,JSON.stringify(i,null,2))},St=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const d=i.at(1);if(Tt.some(y=>d==null?void 0:d.includes(y)))return t}return"styled('div',"}),re=(e,t)=>{try{const s=p.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
20
|
-
|
21
|
-
${e}`:`globalThis.saltyConfig = {};
|
22
|
-
|
23
|
-
${e}`}catch{return e}},ot=async(e,t,s)=>{const n=I(t),o=c.join(s,"./temp");p.existsSync(o)||p.mkdirSync(o);const r=c.parse(t);let i=p.readFileSync(t,"utf8");i=St(i),i=re(i,e);const d=c.join(s,"js",n+".js"),g=await mt(e),y=c.join(e,(g==null?void 0:g.configDir)||"","salty.config.ts"),l=vt(y),w=await xt(e);await jt.build({stdin:{contents:i,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:w,target:["node20"],keepNames:!0,external:l,packages:"external",plugins:[{name:"test",setup:m=>{m.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},u=>{const $=p.readFileSync(u.path,"utf8");return{contents:St($),loader:"ts"}})}}]});const h=Date.now();return{contents:await import(`${d}?t=${h}`),outputFilePath:d}},ae=async e=>{const t=await q(e),s=c.join(t,"cache/config-cache.json"),n=p.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},dt=async e=>{const t=await ae(e),s=await q(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:r}=await import(`${n}?t=${o}`);return H(r,t)},yt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ce=async(e,t=yt(),s=!0)=>{try{const n=Date.now();t?pt.info("Generating CSS in production mode! 🔥"):pt.info("Generating CSS in development mode! 🚀");const o=[],r=[],i=await q(e),d=c.join(i,"index.css");s&&(()=>{p.existsSync(i)&&Rt.execSync("rm -rf "+i),p.mkdirSync(i,{recursive:!0}),p.mkdirSync(c.join(i,"css")),p.mkdirSync(c.join(i,"types")),p.mkdirSync(c.join(i,"js")),p.mkdirSync(c.join(i,"cache"))})();const y=new Set,l=new Set;async function w(f){const S=["node_modules","saltygen"],F=p.statSync(f);if(F.isDirectory()){const a=p.readdirSync(f);if(S.some(x=>f.includes(x)))return;await Promise.all(a.map(x=>w(c.join(f,x))))}else if(F.isFile()&&nt(f)){y.add(f);const C=p.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&l.add(f)}}await w(e),await ie(e,l);const h={keyframes:[],components:[],classNames:[]};await Promise.all([...y].map(async f=>{const{contents:S}=await ot(e,f,i);for(let[F,a]of Object.entries(S))a instanceof Promise&&(a=await a),a.isKeyframes?h.keyframes.push({value:a,src:f,name:F}):a.isClassName?h.classNames.push({...a,src:f,name:F}):a.generator&&h.components.push({...a,src:f,name:F})}));const b=await dt(e);for(const f of h.keyframes){const{value:S}=f,F=`a_${S.animationName}.css`,a=`css/${F}`,C=c.join(i,a);o.push(F),p.writeFileSync(C,S.css)}const m={};for(const f of h.components){const{src:S,name:F}=f;m[S]||(m[S]=[]);const a=f.generator._withBuildContext({callerName:F,isProduction:t,config:b});r[a.priority]||(r[a.priority]=[]);const C=await a.css;if(!C)continue;r[a.priority].push(a.cssFileName);const x=`css/${a.cssFileName}`,M=c.join(i,x);p.writeFileSync(M,C),b.importStrategy==="component"&&m[S].push(a.cssFileName)}for(const f of h.classNames){const{src:S,name:F}=f;m[S]||(m[S]=[]);const a=f.generator._withBuildContext({callerName:F,isProduction:t,config:b}),C=await a.css;if(!C)continue;r[a.priority]||(r[a.priority]=[]),r[a.priority].push(a.cssFileName);const x=`css/${a.cssFileName}`,M=c.join(i,x);p.writeFileSync(M,C),b.importStrategy==="component"&&m[S].push(a.cssFileName)}b.importStrategy==="component"&&Object.entries(m).forEach(([f,S])=>{const F=S.map(J=>`@import url('./${J}');`).join(`
|
24
|
-
`),a=I(f,6),C=c.parse(f),x=z(C.name),M=c.join(i,`css/f_${x}-${a}.css`);p.writeFileSync(M,F||"/* Empty file */")});const u=o.map(f=>`@import url('./css/${f}');`).join(`
|
25
|
-
`);let k=`/*!
|
26
|
-
* Generated with Salty CSS (https://salty-css.dev)
|
27
|
-
* Do not edit this file directly
|
28
|
-
*/
|
29
|
-
@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
30
|
-
|
31
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return p.readFileSync(c.join(i,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
32
|
-
`)}
|
33
|
-
${u}`;if(b.importStrategy!=="component"){const f=r.reduce((S,F,a)=>{const C=F.reduce((L,Q)=>{var rt;const Y=c.join(i,"css",Q),it=p.readFileSync(Y,"utf8"),K=((rt=/.*-([^-]+)-\d+.css/.exec(Q))==null?void 0:rt.at(1))||I(Y,6);return L.includes(K)?L:`${L}
|
34
|
-
/*start:${K}-${Q}*/
|
35
|
-
${it}
|
36
|
-
/*end:${K}*/
|
37
|
-
`},""),x=`l_${a}.css`,M=c.join(i,"css",x),J=`@layer l${a} { ${C}
|
38
|
-
}`;return p.writeFileSync(M,J),`${S}
|
39
|
-
@import url('./css/${x}');`},"");k+=f}p.writeFileSync(d,k);const N=Date.now()-n,V=N<200?"🔥":N<500?"🚀":N<1e3?"🎉":N<2e3?"🚗":N<5e3?"🤔":"🥴";pt.info(`Generated CSS in ${N}ms! ${V}`)}catch(n){console.error(n)}},le=async(e,t,s=yt())=>{try{const n=await q(e);if(nt(t)){const r=[],i=await dt(e),{contents:d}=await ot(e,t,n);for(const[g,y]of Object.entries(d)){if(y.isKeyframes&&y.css){const u=`css/${`a_${y.animationName}.css`}`,$=c.join(n,u);p.writeFileSync($,await y.css);continue}if(y.isClassName){const m=y.generator._withBuildContext({callerName:g,isProduction:s,config:i}),u=await m.css;if(!u)continue;r[m.priority]||(r[m.priority]=[]),r[m.priority].push(m.cssFileName);const $=`css/${m.cssFileName}`,P=c.join(n,$);p.writeFileSync(P,u);continue}if(!y.generator)continue;const l=y.generator._withBuildContext({callerName:g,isProduction:s,config:i}),w=await l.css;if(!w)continue;const h=`css/${l.cssFileName}`,b=c.join(n,h);p.writeFileSync(b,w),r[l.priority]||(r[l.priority]=[]),r[l.priority].push(l.cssFileName)}if(i.importStrategy!=="component")r.forEach((g,y)=>{const l=`l_${y}.css`,w=c.join(n,"css",l);let h=p.readFileSync(w,"utf8");g.forEach(b=>{var P;const m=c.join(n,"css",b),u=((P=/.*-([^-]+)-\d+.css/.exec(b))==null?void 0:P.at(1))||I(m,6);if(!h.includes(u)){const v=p.readFileSync(m,"utf8"),O=`/*start:${u}-${b}*/
|
40
|
-
${v}
|
41
|
-
/*end:${u}*/
|
42
|
-
`;h=`${h.replace(/\}$/,"")}
|
43
|
-
${O}
|
44
|
-
}`}}),p.writeFileSync(w,h)});else{const g=r.flat().map(b=>`@import url('./${b}');`).join(`
|
45
|
-
`),y=I(t,6),l=c.parse(t),w=z(l.name),h=c.join(n,`css/f_${w}-${y}.css`);p.writeFileSync(h,g||"/* Empty file */")}}}catch(n){console.error(n)}},fe=async(e,t,s=yt())=>{var n,o;try{const r=await q(e);if(nt(t)){const d=p.readFileSync(t,"utf8"),g=await dt(e),{contents:y}=await ot(e,t,r);let l=d;for(const[w,h]of Object.entries(y)){if(h.isKeyframes||!h.generator)continue;const b=h.generator._withBuildContext({callerName:w,isProduction:s,config:g}),[m,u]=await ne(l,w),$=l.slice(m,u);if(h.isClassName){const P=l,v=` ${w} = className("${b.classNames}")`;l=l.replace($,v),P===l&&console.error("Minimize file failed to change content",{name:w})}if($.includes("styled")){const P=(o=(n=/styled\(([^,]+),/.exec($))==null?void 0:n.at(1))==null?void 0:o.trim(),v=l,O=` ${w} = styled(${P}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;l=l.replace($,O),v===l&&console.error("Minimize file failed to change content",{name:w,tagName:P})}}if(g.importStrategy==="component"){const w=I(t,6),h=c.parse(t);l=`import '../../saltygen/css/${`f_${z(h.name)}-${w}.css`}';
|
46
|
-
${l}`}return l=l.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(r){console.error("Error in minimizeFile:",r)}};exports.generateCss=ce;exports.generateFile=le;exports.isSaltyFile=nt;exports.minimizeFile=fe;exports.saltyFileRegExp=kt;
|