@salty-css/core 0.0.1-alpha.20 → 0.0.1-alpha.200
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/.saltyrc.schema.json +48 -0
- package/README.md +143 -26
- package/bin/index.cjs +1 -8
- package/bin/index.js +2 -128
- package/bin/logger.d.ts +1 -0
- package/bin/main.cjs +11 -0
- package/bin/main.d.ts +1 -0
- package/bin/main.js +260 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/index.cjs +1 -11
- package/compiler/index.d.ts +11 -6
- package/compiler/index.js +17 -172
- package/config/define-config.d.ts +1 -1
- package/config/index.cjs +1 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +10 -2
- package/css/index.cjs +1 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +9 -2
- package/css/keyframes.cjs +1 -0
- package/css/keyframes.d.ts +22 -0
- package/css/keyframes.js +34 -0
- package/css/media.cjs +1 -0
- package/css/media.d.ts +87 -0
- package/css/media.js +88 -0
- package/css/merge.cjs +1 -0
- package/css/merge.d.ts +6 -0
- package/css/merge.js +4 -0
- package/css/token.cjs +1 -0
- package/css/token.d.ts +1 -0
- package/css/token.js +4 -0
- package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
- package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-media-query.d.ts +8 -0
- package/factories/define-templates.d.ts +10 -0
- package/factories/define-variables.d.ts +12 -0
- package/factories/index.d.ts +4 -0
- package/generators/class-name-generator.d.ts +6 -0
- package/generators/index.cjs +1 -0
- package/generators/index.d.ts +2 -0
- package/generators/index.js +75 -0
- package/generators/styled-generator.d.ts +19 -0
- package/generators/styles-generator.d.ts +18 -0
- package/helpers/color.d.ts +18 -0
- package/helpers/index.cjs +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1152 -0
- package/index-BM4snbAi.js +486 -0
- package/index-CHz91O9z.cjs +38 -0
- package/package.json +34 -2
- package/parse-styles-Bjxh8lZv.js +107 -0
- package/parse-styles-D_gL6efj.cjs +7 -0
- package/parsers/index.cjs +1 -0
- package/parsers/index.d.ts +5 -0
- package/parsers/index.js +37 -0
- package/{generator → parsers}/parse-modifiers.d.ts +1 -1
- package/parsers/parse-styles.d.ts +2 -0
- package/parsers/parse-templates.d.ts +4 -0
- package/{generator → parsers}/parser-types.d.ts +1 -1
- package/parsers/property-name-check.d.ts +1 -0
- package/parsers/unit-check.d.ts +7 -0
- package/react-vanilla-file-CCXbsjIb.js +18 -0
- package/react-vanilla-file-CG_WJLam.cjs +15 -0
- package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
- package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
- package/server/index.cjs +1 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +12 -0
- package/server/should-restart.d.ts +1 -0
- package/templates/salty-reset.d.ts +2 -0
- package/types/cli-types.d.ts +10 -0
- package/types/config-types.d.ts +77 -0
- package/types/index.d.ts +52 -22
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
- package/util/module-type.d.ts +1 -0
- package/config/config-types.d.ts +0 -59
- package/generator/index.cjs +0 -1
- package/generator/index.d.ts +0 -1
- package/generator/index.js +0 -61
- package/generator/parse-styles.d.ts +0 -2
- package/generator/parse-templates.d.ts +0 -2
- package/generator/style-generator.d.ts +0 -28
- package/parse-templates-D4p3pgQR.js +0 -92
- package/parse-templates-W0YfTmOT.cjs +0 -8
- /package/{generator → parsers}/parse-tokens.d.ts +0 -0
@@ -0,0 +1,486 @@
|
|
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
|
+
};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";const $e=require("esbuild"),Ce=require("child_process"),k=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),ne=require("fs/promises"),A=require("./parse-styles-D_gL6efj.cjs"),B=require("winston"),z=require("./css/merge.cjs");var se=typeof document<"u"?document.currentScript:null;function xe(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 de=xe($e),ue=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,r])=>{if(typeof r=="object"){if(!r)return;const f=o.trim(),u=ue(r,[...t,f]);s.push(u)}else n[o]=r}),Object.keys(n).length){const o=t.map(k.dashCase).join("-"),r=A.parseStyles(n,`.${o}`);s.push(r)}return s.join(`
|
2
|
+
`)},Ne=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?pe(o,r,s):s.add(t)}),[...s]):[],ye=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:ye(i.join(e,".."))},ke=async e=>{const t=ye(e);return await ne.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Pe=async e=>{const t=await ke(e);if(t)return t.type};let J;const ge=async e=>{if(J)return J;const t=await Pe(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.tagName.toUpperCase()==="SCRIPT"&&se.src||new URL("index-CHz91O9z.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),De=e=>{G.error(e)};function me(e){return e?typeof e!="string"?me(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 _e={"*, *::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"}},O={externalModules:[],rcFile:void 0,destDir:void 0},he=e=>{if(O.externalModules.length>0)return O.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return O.externalModules=n,n},R=async e=>{if(O.destDir)return O.destDir;const t=await ie(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},oe=["salty","css","styles","styled"],Se=(e=[])=>new RegExp(`\\.(${[...oe,...e].join("|")})\\.`),U=(e,t=[])=>Se(t).test(e),je=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await ne.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):je(i.join(e,".."))},ie=async e=>{var n,o;const t=await je(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))},Te=async e=>{const t=await ie(e),s=await R(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=i.join(s,"salty.config.js"),r=await ge(e),f=he(n);await de.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:f});const u=Date.now(),{config:y}=await import(`${o}?t=${u}`);return y},be=async(e,t)=>{var ae,le;const s=await R(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async b=>{const F=await K(e,b,s);Object.entries(F).forEach(([E,$])=>{$.isMedia?n.mediaQueries.push([E,$]):$.isGlobalDefine?n.globalStyles.push($):$.isDefineVariables?n.variables.push($):$.isDefineTemplates&&n.templates.push($)})}));const o=await Te(e),r={...o},f=new Set,u=(b,F=[])=>b?Object.entries(b).flatMap(([E,$])=>{if(!$)return;if(typeof $=="object")return u($,[...F,E]);const X=me(E),Y=k.dashCase(E),ee=[...F,X].join(".");f.add(`"${ee}"`);const te=[...F.map(k.dashCase),Y].join("-"),{result:Fe}=A.parseValueTokens($);return`--${te}: ${Fe};`}):[],y=b=>b?Object.entries(b).flatMap(([F,E])=>{const $=u(E);return F==="base"?$.join(""):`${F} { ${$.join("")} }`}):[],d=b=>b?Object.entries(b).flatMap(([F,E])=>Object.entries(E).flatMap(([$,X])=>{const Y=u(X,[F]),ee=`.${F}-${$}, [data-${F}="${$}"]`,te=Y.join("");return`${ee} { ${te} }`})):[],g=b=>({...b,responsive:void 0,conditional:void 0}),m=b=>n.variables.map(F=>b==="static"?g(F._current):F._current[b]),p=z.mergeStyles(g(o.variables),m("static")),w=u(p),h=z.mergeStyles((ae=o.variables)==null?void 0:ae.responsive,m("responsive")),_=y(h),P=z.mergeStyles((le=o.variables)==null?void 0:le.conditional,m("conditional")),D=d(P),V=i.join(s,"css/_variables.css"),T=`:root { ${w.join("")} ${_.join("")} } ${D.join("")}`;c.writeFileSync(V,T),r.staticVariables=p;const H=i.join(s,"css/_global.css"),N=z.mergeStyles(o.global,n.globalStyles),q=A.parseStyles(N,"");c.writeFileSync(H,`@layer global { ${q} }`);const a=i.join(s,"css/_reset.css"),j=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:_e,l=A.parseStyles(j,"");c.writeFileSync(a,`@layer reset { ${l} }`);const C=i.join(s,"css/_templates.css"),x=z.mergeStyles(o.templates,n.templates),v=ue(x),I=Ne(x);c.writeFileSync(C,v),r.templates=x;const{mediaQueries:M}=n;r.mediaQueries=Object.fromEntries(M.map(([b,F])=>[`@${b}`,F]));const L=M.map(([b])=>`'@${b}'`).join(" | "),Q=i.join(s,"types/css-tokens.d.ts"),W=`
|
3
|
+
// Variable types
|
4
|
+
type VariableTokens = ${[...f].join("|")};
|
5
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
6
|
+
|
7
|
+
// Template types
|
8
|
+
type TemplateTokens = {
|
9
|
+
${Object.entries(I).map(([b,F])=>`${b}?: ${F}`).join(`
|
10
|
+
`)}
|
11
|
+
}
|
12
|
+
|
13
|
+
// Media query types
|
14
|
+
type MediaQueryKeys = ${L};
|
15
|
+
`;c.writeFileSync(Q,W);const Z=i.join(s,"cache/config-cache.json");c.writeFileSync(Z,JSON.stringify(r,null,2))},fe=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 f=o.exec(e);if(f){const u=f.at(1);if(oe.some(d=>u==null?void 0:u.includes(d)))return t}return"styled('div',"}),Ee=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
16
|
+
|
17
|
+
${e}`:`globalThis.saltyConfig = {};
|
18
|
+
|
19
|
+
${e}`}catch{return e}},K=async(e,t,s)=>{const n=k.toHash(t),o=i.join(s,"./temp");c.existsSync(o)||c.mkdirSync(o);const r=i.parse(t);let f=c.readFileSync(t,"utf8");f=fe(f),f=Ee(f,e);const u=i.join(s,"js",n+".js"),y=await ie(e),d=i.join(e,(y==null?void 0:y.configDir)||"","salty.config.ts"),g=he(d),m=await ge(e);await de.build({stdin:{contents:f,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:u,format:m,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},_=>{const P=c.readFileSync(_.path,"utf8");return{contents:fe(P),loader:"ts"}})}}]});const p=Date.now();return await import(`${u}?t=${p}`)},Oe=async e=>{const t=await R(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},re=async e=>{const t=await Oe(e),s=await R(e),n=i.join(s,"salty.config.js"),o=Date.now(),{config:r}=await import(`${n}?t=${o}`);return z.mergeStyles(r,t)},we=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Re=async(e,t=we(),s=!0)=>{try{const n=Date.now();t?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const o=[],r=[],f=await R(e),u=i.join(f,"index.css");s&&(()=>{c.existsSync(f)&&Ce.execSync("rm -rf "+f),c.mkdirSync(f,{recursive:!0}),c.mkdirSync(i.join(f,"css")),c.mkdirSync(i.join(f,"types")),c.mkdirSync(i.join(f,"js")),c.mkdirSync(i.join(f,"cache"))})();const d=new Set,g=new Set;async function m(a){const S=["node_modules","saltygen"],j=c.statSync(a);if(j.isDirectory()){const l=c.readdirSync(a);if(S.some(x=>a.includes(x)))return;await Promise.all(l.map(x=>m(i.join(a,x))))}else if(j.isFile()&&U(a)){d.add(a);const C=c.readFileSync(a,"utf8");/define[\w\d]+\(/.test(C)&&g.add(a)}}await m(e),await be(e,g);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...d].map(async a=>{const S=await K(e,a,f);Object.entries(S).forEach(([j,l])=>{l.isKeyframes?p.keyframes.push({value:l,src:a,name:j}):l.isClassName?p.classNames.push({...l,src:a,name:j}):l.generator&&p.components.push({...l,src:a,name:j})})}));const w=await re(e);for(const a of p.keyframes){const{value:S}=a,j=`a_${S.animationName}.css`,l=`css/${j}`,C=i.join(f,l);o.push(j),c.writeFileSync(C,S.css)}const h={};for(const a of p.components){const{src:S,name:j}=a,l=a.generator._withBuildContext({callerName:j,isProduction:t,config:w});r[l.priority]||(r[l.priority]=[]),r[l.priority].push(l.cssFileName);const C=`css/${l.cssFileName}`,x=i.join(f,C);c.writeFileSync(x,l.css),w.importStrategy==="component"&&(h[S]?h[S].push(l.cssFileName):h[S]=[l.cssFileName])}for(const a of p.classNames){const{src:S,name:j}=a,l=a.generator._withBuildContext({callerName:j,isProduction:t,config:w});r[0].push(l.cssFileName);const C=`css/${l.cssFileName}`,x=i.join(f,C);c.writeFileSync(x,l.css),w.importStrategy==="component"&&(h[S]?h[S].push(l.cssFileName):h[S]=[l.cssFileName])}w.importStrategy==="component"&&Object.entries(h).forEach(([a,S])=>{const j=S.map(I=>`@import url('./${I}');`).join(`
|
20
|
+
`),l=k.toHash(a,6),C=i.parse(a),x=k.dashCase(C.name),v=i.join(f,`css/f_${x}-${l}.css`);c.writeFileSync(v,j)});const _=o.map(a=>`@import url('./css/${a}');`).join(`
|
21
|
+
`);let T=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
22
|
+
|
23
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return c.readFileSync(i.join(f,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
24
|
+
`)}
|
25
|
+
${_}`;if(w.importStrategy!=="component"){const a=r.reduce((S,j,l)=>{const C=j.reduce((M,L)=>{var Z;const Q=i.join(f,"css",L),ce=c.readFileSync(Q,"utf8"),W=((Z=/.*-([^-]+)-\d+.css/.exec(L))==null?void 0:Z.at(1))||k.toHash(Q,6);return M.includes(W)?M:`${M}
|
26
|
+
/*start:${W}*/
|
27
|
+
${ce}
|
28
|
+
/*end:${W}*/
|
29
|
+
`},""),x=`l_${l}.css`,v=i.join(f,"css",x),I=`@layer l${l} { ${C}
|
30
|
+
}`;return c.writeFileSync(v,I),`${S}
|
31
|
+
@import url('./css/${x}');`},"");T+=a}c.writeFileSync(u,T);const N=Date.now()-n,q=N<200?"🔥":N<500?"🚀":N<1e3?"🎉":N<2e3?"🚗":N<5e3?"🤔":"🥴";G.info(`Generated CSS in ${N}ms! ${q}`)}catch(n){console.error(n)}},Ve=async(e,t)=>{try{const s=await R(e);if(U(t)){const o=[],r=await re(e),f=await K(e,t,s);if(Object.entries(f).forEach(([u,y])=>{if(y.isKeyframes&&y.css){const w=`css/${`a_${y.animationName}.css`}`,h=i.join(s,w);c.writeFileSync(h,y.css);return}if(y.isClassName){const p=y.factory._withBuildContext({name:u});o[0].push(p.cssFileName);const w=`css/${p.cssFileName}`,h=i.join(s,w);c.writeFileSync(h,p.css)}if(!y.generator)return;const d=y.generator._withBuildContext({name:u,config:r}),g=`css/${d.cssFileName}`,m=i.join(s,g);c.writeFileSync(m,d.css),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}),r.importStrategy!=="component")o.forEach((u,y)=>{const d=`l_${y}.css`,g=i.join(s,"css",d);let m=c.readFileSync(g,"utf8");u.forEach(p=>{var P;const w=i.join(s,"css",p),h=((P=/.*-([^-]+)-\d+.css/.exec(p))==null?void 0:P.at(1))||k.toHash(w,6);if(!m.includes(h)){const D=c.readFileSync(w,"utf8"),V=`/*start:${h}*/
|
32
|
+
${D}
|
33
|
+
/*end:${h}*/
|
34
|
+
`;m=`${m.replace(/\}$/,"")}
|
35
|
+
${V}
|
36
|
+
}`}}),c.writeFileSync(g,m)});else{const u=o.flat().map(p=>`@import url('./${p}');`).join(`
|
37
|
+
`),y=k.toHash(t,6),d=i.parse(t),g=k.dashCase(d.name),m=i.join(s,`css/f_${g}-${y}.css`);c.writeFileSync(m,u)}}}catch(s){console.error(s)}},Me=async(e,t,s=we())=>{try{const n=await R(e);if(U(t)){const r=c.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==r&&await ne.writeFile(t,r);const u=await re(e),y=await K(e,t,n);let d=r;if(Object.entries(y).forEach(([g,m])=>{var l;if(m.isKeyframes||!m.generator)return;const p=m.generator._withBuildContext({name:g,config:u,prod:s}),w=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!w)return console.error("Could not find the original declaration");const h=(l=w.at(1))==null?void 0:l.trim(),_=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(d);if(!_)return console.error("Could not find the original declaration");const{index:P}=_;let D=!1;const V=setTimeout(()=>D=!0,5e3);let T=0,H=!1,N=0;for(;!H&&!D;){const C=d[P+T];C==="("&&N++,C===")"&&N--,N===0&&C===")"&&(H=!0),T>d.length&&(D=!0),T++}if(!D)clearTimeout(V);else throw new Error("Failed to find the end of the styled call and timed out");const q=P+T,a=d.slice(P,q),S=d,j=` ${g} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;d=d.replace(a,j),S===d&&console.error("Minimize file failed to change content",{name:g,tagName:h})}),u.importStrategy==="component"){const g=k.toHash(t,6),m=i.parse(t);d=`import '../../saltygen/css/${`f_${k.dashCase(m.name)}-${g}.css`}';
|
38
|
+
${d}`}return d=d.replace("{ styled }","{ styledClient as styled }"),d=d.replace("@salty-css/react/styled","@salty-css/react/styled-client"),d}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=K;exports.generateConfigStyles=be;exports.generateCss=Re;exports.generateFile=Ve;exports.isSaltyFile=U;exports.logError=De;exports.logger=G;exports.minimizeFile=Me;exports.saltyFileExtensions=oe;exports.saltyFileRegExp=Se;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/core",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.200",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -10,7 +10,12 @@
|
|
10
10
|
"publishConfig": {
|
11
11
|
"access": "public"
|
12
12
|
},
|
13
|
-
"
|
13
|
+
"description": "Core library for Salty CSS. Will be used by other Salty CSS libraries and plugins.",
|
14
|
+
"homepage": "https://salty-css.dev/",
|
15
|
+
"repository": {
|
16
|
+
"type": "git",
|
17
|
+
"url": "git+https://github.com/margarita-form/salty-css.git"
|
18
|
+
},
|
14
19
|
"bugs": {
|
15
20
|
"url": "https://github.com/margarita-form/salty-css/issues"
|
16
21
|
},
|
@@ -23,13 +28,20 @@
|
|
23
28
|
"name": "core"
|
24
29
|
},
|
25
30
|
"peerDependencies": {
|
31
|
+
"color": ">=5.x",
|
26
32
|
"commander": ">=12.x",
|
33
|
+
"csstype": "^3.1.x",
|
27
34
|
"ejs": ">=3.x",
|
28
35
|
"esbuild": ">=0.21.x",
|
36
|
+
"ora": ">=8.x",
|
29
37
|
"react": ">=18.x || >=19.x",
|
30
38
|
"winston": ">=3.x"
|
31
39
|
},
|
32
40
|
"exports": {
|
41
|
+
"./bin/main": {
|
42
|
+
"import": "./bin/main.js",
|
43
|
+
"require": "./bin/main.cjs"
|
44
|
+
},
|
33
45
|
"./compiler": {
|
34
46
|
"import": "./compiler/index.js",
|
35
47
|
"require": "./compiler/index.cjs"
|
@@ -38,6 +50,22 @@
|
|
38
50
|
"import": "./css/index.js",
|
39
51
|
"require": "./css/index.cjs"
|
40
52
|
},
|
53
|
+
"./css/keyframes": {
|
54
|
+
"import": "./css/keyframes.js",
|
55
|
+
"require": "./css/keyframes.cjs"
|
56
|
+
},
|
57
|
+
"./css/media": {
|
58
|
+
"import": "./css/media.js",
|
59
|
+
"require": "./css/media.cjs"
|
60
|
+
},
|
61
|
+
"./css/token": {
|
62
|
+
"import": "./css/token.js",
|
63
|
+
"require": "./css/token.cjs"
|
64
|
+
},
|
65
|
+
"./css/merge": {
|
66
|
+
"import": "./css/merge.js",
|
67
|
+
"require": "./css/merge.cjs"
|
68
|
+
},
|
41
69
|
"./generator": {
|
42
70
|
"import": "./generator/index.js",
|
43
71
|
"require": "./generator/index.cjs"
|
@@ -53,6 +81,10 @@
|
|
53
81
|
"./util": {
|
54
82
|
"import": "./util/index.js",
|
55
83
|
"require": "./util/index.cjs"
|
84
|
+
},
|
85
|
+
"./helpers": {
|
86
|
+
"import": "./helpers/index.js",
|
87
|
+
"require": "./helpers/index.cjs"
|
56
88
|
}
|
57
89
|
},
|
58
90
|
"bin": {
|