@salty-css/core 0.0.1-alpha.14 → 0.0.1-alpha.140
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 +40 -0
- package/README.md +143 -26
- package/bin/bin-util.d.ts +2 -0
- package/bin/index.cjs +2 -0
- package/bin/index.d.ts +2 -0
- package/bin/index.js +3 -0
- package/bin/logger.d.ts +2 -0
- package/bin/main.cjs +11 -0
- package/bin/main.d.ts +1 -0
- package/bin/main.js +260 -0
- package/bin/prettier.d.ts +1 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/index.cjs +1 -11
- package/compiler/index.d.ts +4 -6
- package/compiler/index.js +16 -178
- package/config/config-types.d.ts +15 -5
- package/dash-case-BJEkFEGQ.cjs +1 -0
- package/dash-case-DBThphLm.js +19 -0
- package/generator/index.cjs +1 -1
- package/generator/index.js +51 -32
- package/generator/parse-styles.d.ts +1 -1
- package/generator/parse-templates.d.ts +2 -0
- package/generator/style-generator.d.ts +8 -0
- package/index-84Wroia-.cjs +1 -0
- package/index-Bywmnn_7.cjs +22 -0
- package/index-ChAB4YZW.js +349 -0
- package/index-D_732b92.js +4 -0
- package/package.json +20 -2
- package/parse-templates-CgZo0YA1.js +97 -0
- package/parse-templates-DD4hQEpv.cjs +8 -0
- package/pascal-case-BQpR5PdN.js +6 -0
- package/pascal-case-iWoaJWwT.cjs +1 -0
- package/react-styled-file-CGVf5n1B.js +11 -0
- package/react-styled-file-Dkubsz-U.cjs +8 -0
- package/react-vanilla-file-CCXbsjIb.js +18 -0
- package/react-vanilla-file-CG_WJLam.cjs +15 -0
- package/salty.config-BhBY_oOk.js +10 -0
- package/salty.config-Dk6ZcCxI.cjs +7 -0
- package/templates/salty-reset.d.ts +2 -0
- package/types/index.d.ts +46 -19
- package/util/camel-case.d.ts +1 -0
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.d.ts +2 -0
- package/util/index.js +7 -15
- package/util/module-type.d.ts +1 -0
- package/util/pascal-case.d.ts +1 -0
- package/parse-templates-BOSK0Tb6.js +0 -90
- package/parse-templates-BY1Xai-_.cjs +0 -8
@@ -0,0 +1,349 @@
|
|
1
|
+
import * as Y from "esbuild";
|
2
|
+
import { execSync as lt } from "child_process";
|
3
|
+
import { t as B, d as z } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as r, parse as H } from "path";
|
5
|
+
import { existsSync as K, writeFileSync as w, mkdirSync as J, readFileSync as V, statSync as pt, readdirSync as ft } from "fs";
|
6
|
+
import { readFile as dt, writeFile as ut } from "fs/promises";
|
7
|
+
import { p as U, a as gt, b as mt, c as yt } from "./parse-templates-CgZo0YA1.js";
|
8
|
+
import { createLogger as ht, format as I, transports as $t } from "winston";
|
9
|
+
const Q = (t) => {
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
+
const e = r(t, "package.json");
|
12
|
+
return K(e) ? e : Q(r(t, ".."));
|
13
|
+
}, bt = async (t) => {
|
14
|
+
const e = Q(t);
|
15
|
+
return await dt(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
+
});
|
17
|
+
}, St = async (t) => {
|
18
|
+
const e = await bt(t);
|
19
|
+
if (e)
|
20
|
+
return e.type;
|
21
|
+
};
|
22
|
+
let R;
|
23
|
+
const tt = async (t) => {
|
24
|
+
if (R) return R;
|
25
|
+
const e = await St(t);
|
26
|
+
return e === "module" ? R = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (R = "cjs"), R || "esm";
|
27
|
+
}, O = ht({
|
28
|
+
level: "debug",
|
29
|
+
format: I.combine(I.colorize(), I.cli()),
|
30
|
+
transports: [new $t.Console({})]
|
31
|
+
}), Mt = (t) => {
|
32
|
+
O.error(t);
|
33
|
+
};
|
34
|
+
function et(t) {
|
35
|
+
return t ? typeof t != "string" ? et(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, n) => (n > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
+
}
|
37
|
+
const wt = {
|
38
|
+
/** Set box model to border-box */
|
39
|
+
"*, *::before, *::after": {
|
40
|
+
boxSizing: "border-box"
|
41
|
+
},
|
42
|
+
/** Remove default margin and padding */
|
43
|
+
"*": {
|
44
|
+
margin: 0
|
45
|
+
},
|
46
|
+
/** Remove adjust font properties */
|
47
|
+
html: {
|
48
|
+
lineHeight: 1.15,
|
49
|
+
textSizeAdjust: "100%",
|
50
|
+
WebkitFontSmoothing: "antialiased"
|
51
|
+
},
|
52
|
+
/** Make media elements responsive */
|
53
|
+
"img, picture, video, canvas, svg": {
|
54
|
+
display: "block",
|
55
|
+
maxWidth: "100%"
|
56
|
+
},
|
57
|
+
/** Avoid overflow of text */
|
58
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
59
|
+
overflowWrap: "break-word"
|
60
|
+
},
|
61
|
+
/** Improve text wrapping */
|
62
|
+
p: {
|
63
|
+
textWrap: "pretty"
|
64
|
+
},
|
65
|
+
"h1, h2, h3, h4, h5, h6": {
|
66
|
+
textWrap: "balance"
|
67
|
+
},
|
68
|
+
/** Improve link color */
|
69
|
+
a: {
|
70
|
+
color: "currentColor"
|
71
|
+
},
|
72
|
+
/** Improve button line height */
|
73
|
+
button: {
|
74
|
+
lineHeight: "1em",
|
75
|
+
color: "currentColor"
|
76
|
+
},
|
77
|
+
/** Improve form elements */
|
78
|
+
"input, optgroup, select, textarea": {
|
79
|
+
fontFamily: "inherit",
|
80
|
+
fontSize: "100%",
|
81
|
+
lineHeight: "1.15em"
|
82
|
+
}
|
83
|
+
}, A = {
|
84
|
+
externalModules: []
|
85
|
+
}, st = (t) => {
|
86
|
+
if (A.externalModules.length > 0) return A.externalModules;
|
87
|
+
const e = r(t, "salty.config.ts"), a = V(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
+
if (!a) return [];
|
89
|
+
const c = a[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
|
+
return A.externalModules = c, c;
|
91
|
+
}, W = (t) => r(t, "./saltygen"), nt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...nt, ...t].join("|")})\\.`), L = (t, e = []) => xt(e).test(t), Ct = async (t) => {
|
92
|
+
const e = W(t), n = r(t, "salty.config.ts"), a = r(e, "salty.config.js"), c = await tt(t), s = st(t);
|
93
|
+
await Y.build({
|
94
|
+
entryPoints: [n],
|
95
|
+
minify: !0,
|
96
|
+
treeShaking: !0,
|
97
|
+
bundle: !0,
|
98
|
+
outfile: a,
|
99
|
+
format: c,
|
100
|
+
external: s
|
101
|
+
});
|
102
|
+
const d = Date.now(), { config: u } = await import(`${a}?t=${d}`);
|
103
|
+
return u;
|
104
|
+
}, Ft = async (t) => {
|
105
|
+
const e = await Ct(t), n = /* @__PURE__ */ new Set(), a = (l, p = []) => l ? Object.entries(l).flatMap(([h, f]) => {
|
106
|
+
if (!f) return;
|
107
|
+
if (typeof f == "object") return a(f, [...p, h]);
|
108
|
+
const M = et(h), v = z(h), _ = [...p, M].join(".");
|
109
|
+
n.add(`"${_}"`);
|
110
|
+
const j = [...p.map(z), v].join("-"), { result: T } = yt(f);
|
111
|
+
return `--${j}: ${T};`;
|
112
|
+
}) : [], c = (l) => l ? Object.entries(l).flatMap(([p, h]) => {
|
113
|
+
const f = a(h);
|
114
|
+
return p === "base" ? f.join("") : `${p} { ${f.join("")} }`;
|
115
|
+
}) : [], s = (l) => l ? Object.entries(l).flatMap(([p, h]) => Object.entries(h).flatMap(([f, M]) => {
|
116
|
+
const v = a(M, [p]), _ = `.${p}-${f}, [data-${p}="${f}"]`, j = v.join("");
|
117
|
+
return `${_} { ${j} }`;
|
118
|
+
})) : [], d = a(e.variables), u = c(e.responsiveVariables), $ = s(e.conditionalVariables), o = W(t), g = r(o, "css/_variables.css"), C = `:root { ${d.join("")} ${u.join("")} } ${$.join("")}`;
|
119
|
+
w(g, C);
|
120
|
+
const x = r(o, "css/_global.css"), m = U(e.global, "");
|
121
|
+
w(x, `@layer global { ${m} }`);
|
122
|
+
const b = r(o, "css/_reset.css"), y = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : wt, k = U(y, "");
|
123
|
+
w(b, `@layer reset { ${k} }`);
|
124
|
+
const i = r(o, "css/_templates.css"), S = gt(e.templates), D = mt(e.templates);
|
125
|
+
w(i, S);
|
126
|
+
const F = r(o, "types/css-tokens.d.ts"), N = `
|
127
|
+
// Variable types
|
128
|
+
type VariableTokens = ${[...n].join("|")};
|
129
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
|
+
|
131
|
+
// Template types
|
132
|
+
type TemplateTokens = {
|
133
|
+
${Object.entries(D).map(([l, p]) => `${l}?: ${p}`).join(`
|
134
|
+
`)}
|
135
|
+
}
|
136
|
+
`;
|
137
|
+
w(F, N);
|
138
|
+
}, X = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, n) => {
|
139
|
+
const a = /^['"`]/.test(n);
|
140
|
+
if (a && console.log("String tag", n), a) return e;
|
141
|
+
const c = new RegExp(`import[^;]*${n}[,\\s{][^;]*from\\s?([^{};]+);`), s = c.test(t);
|
142
|
+
if (s || console.log("Not imported", n), !s) return e;
|
143
|
+
const d = c.exec(t);
|
144
|
+
if (d) {
|
145
|
+
const u = d.at(1), $ = nt.some((o) => u == null ? void 0 : u.includes(o));
|
146
|
+
if ($ && console.log("Salty import for", n, `"${d.at(0)}"`), $) return e;
|
147
|
+
}
|
148
|
+
return console.log("Replacing", n), "styled('div',";
|
149
|
+
}), Z = async (t, e, n) => {
|
150
|
+
console.log({ sourceFilePath: e });
|
151
|
+
const a = B(e), c = r(n, "./temp");
|
152
|
+
K(c) || J(c);
|
153
|
+
const s = H(e);
|
154
|
+
let d = V(e, "utf8");
|
155
|
+
d = X(d);
|
156
|
+
const u = r(n, "js", a + ".js"), $ = st(t), o = await tt(t);
|
157
|
+
await Y.build({
|
158
|
+
stdin: {
|
159
|
+
contents: d,
|
160
|
+
sourcefile: s.base,
|
161
|
+
resolveDir: s.dir,
|
162
|
+
loader: "tsx"
|
163
|
+
},
|
164
|
+
minify: !1,
|
165
|
+
treeShaking: !0,
|
166
|
+
bundle: !0,
|
167
|
+
outfile: u,
|
168
|
+
format: o,
|
169
|
+
target: ["node20"],
|
170
|
+
keepNames: !0,
|
171
|
+
external: $,
|
172
|
+
packages: "external",
|
173
|
+
plugins: [
|
174
|
+
{
|
175
|
+
name: "test",
|
176
|
+
setup: (x) => {
|
177
|
+
x.onLoad({ filter: /.*.css.ts/ }, (m) => {
|
178
|
+
console.log("Loading", {
|
179
|
+
sourceFilePath: e,
|
180
|
+
args: m
|
181
|
+
});
|
182
|
+
const b = V(m.path, "utf8");
|
183
|
+
return { contents: X(b) };
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
]
|
188
|
+
});
|
189
|
+
const g = Date.now();
|
190
|
+
return await import(`${u}?t=${g}`);
|
191
|
+
}, G = async (t) => {
|
192
|
+
const e = W(t), n = r(e, "salty.config.js"), a = Date.now(), { config: c } = await import(`${n}?t=${a}`);
|
193
|
+
return c;
|
194
|
+
}, ot = () => {
|
195
|
+
try {
|
196
|
+
return process.env.NODE_ENV === "production";
|
197
|
+
} catch {
|
198
|
+
return !1;
|
199
|
+
}
|
200
|
+
}, _t = async (t, e = ot()) => {
|
201
|
+
try {
|
202
|
+
const n = Date.now();
|
203
|
+
e ? O.info("Generating CSS in production mode! 🔥") : O.info("Generating CSS in development mode! 🚀");
|
204
|
+
const a = [], c = [], s = W(t), d = r(s, "index.css");
|
205
|
+
(() => {
|
206
|
+
K(s) && lt("rm -rf " + s), J(s), J(r(s, "css")), J(r(s, "types"));
|
207
|
+
})(), await Ft(t);
|
208
|
+
const $ = await G(t);
|
209
|
+
async function o(i, S) {
|
210
|
+
const D = ["node_modules", "saltygen"], F = pt(i);
|
211
|
+
if (F.isDirectory()) {
|
212
|
+
const E = ft(i);
|
213
|
+
if (D.some((l) => i.includes(l))) return;
|
214
|
+
await Promise.all(E.map((l) => o(r(i, l), r(S, l))));
|
215
|
+
} else if (F.isFile() && L(i)) {
|
216
|
+
const N = await Z(t, i, s), l = [];
|
217
|
+
Object.entries(N).forEach(([_, j]) => {
|
218
|
+
if (j.isKeyframes && j.css) {
|
219
|
+
const q = `a_${j.animationName}.css`, ct = `css/${q}`, it = r(s, ct);
|
220
|
+
a.push(q), w(it, j.css);
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
if (!j.generator) return;
|
224
|
+
const T = j.generator._withBuildContext({
|
225
|
+
name: _,
|
226
|
+
config: $,
|
227
|
+
prod: e
|
228
|
+
});
|
229
|
+
c[T.priority] || (c[T.priority] = []), c[T.priority].push(T.cssFileName), l.push(T.cssFileName);
|
230
|
+
const rt = `css/${T.cssFileName}`, at = r(s, rt);
|
231
|
+
w(at, T.css);
|
232
|
+
});
|
233
|
+
const p = l.map((_) => `@import url('./${_}');`).join(`
|
234
|
+
`), h = B(i, 6), f = H(i), M = z(f.name), v = r(s, `css/f_${M}-${h}.css`);
|
235
|
+
w(v, p);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
await o(t, s);
|
239
|
+
const g = a.map((i) => `@import url('./css/${i}');`).join(`
|
240
|
+
`);
|
241
|
+
let b = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
242
|
+
|
243
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((i) => {
|
244
|
+
try {
|
245
|
+
return V(r(s, "css", i), "utf8").length > 0;
|
246
|
+
} catch {
|
247
|
+
return !1;
|
248
|
+
}
|
249
|
+
}).map((i) => `@import url('./css/${i}');`).join(`
|
250
|
+
`)}
|
251
|
+
${g}`;
|
252
|
+
if ($.importStrategy !== "component") {
|
253
|
+
const i = c.reduce((S, D, F) => {
|
254
|
+
const E = D.reduce((h, f) => {
|
255
|
+
const M = V(r(s, "css", f), "utf8");
|
256
|
+
return `${h}
|
257
|
+
${M}`;
|
258
|
+
}, ""), N = `l_${F}.css`, l = r(s, "css", N), p = `@layer l${F} { ${E} }`;
|
259
|
+
return w(l, p), `${S}
|
260
|
+
@import url('./css/${N}');`;
|
261
|
+
}, "");
|
262
|
+
b += i;
|
263
|
+
}
|
264
|
+
w(d, b);
|
265
|
+
const y = Date.now() - n, k = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
|
266
|
+
O.info(`Generated CSS in ${y}ms! ${k}`);
|
267
|
+
} catch (n) {
|
268
|
+
console.error(n);
|
269
|
+
}
|
270
|
+
}, Vt = async (t, e) => {
|
271
|
+
try {
|
272
|
+
const n = [], a = r(t, "./saltygen"), c = r(a, "index.css");
|
273
|
+
if (L(e)) {
|
274
|
+
const d = await G(t), u = await Z(t, e, a);
|
275
|
+
Object.entries(u).forEach(([x, m]) => {
|
276
|
+
if (m.isKeyframes && m.css) {
|
277
|
+
const i = `css/${`a_${m.animationName}.css`}`, S = r(a, i);
|
278
|
+
w(S, m.css);
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
if (!m.generator) return;
|
282
|
+
const b = m.generator._withBuildContext({
|
283
|
+
name: x,
|
284
|
+
config: d
|
285
|
+
}), P = `css/${b.cssFileName}`, y = r(a, P);
|
286
|
+
n.push(b.cssFileName), w(y, b.css);
|
287
|
+
});
|
288
|
+
const $ = V(c, "utf8").split(`
|
289
|
+
`), o = n.map((x) => `@import url('../saltygen/css/${x}');`), C = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
290
|
+
`);
|
291
|
+
w(c, C);
|
292
|
+
}
|
293
|
+
} catch (n) {
|
294
|
+
console.error(n);
|
295
|
+
}
|
296
|
+
}, Rt = async (t, e, n = ot()) => {
|
297
|
+
try {
|
298
|
+
const a = r(t, "./saltygen");
|
299
|
+
if (L(e)) {
|
300
|
+
const s = V(e, "utf8");
|
301
|
+
s.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== s && await ut(e, s);
|
302
|
+
const u = await G(t), $ = await Z(t, e, a);
|
303
|
+
let o = s;
|
304
|
+
if (Object.entries($).forEach(([g, C]) => {
|
305
|
+
var h;
|
306
|
+
if (C.isKeyframes || !C.generator) return;
|
307
|
+
const x = C.generator._withBuildContext({
|
308
|
+
name: g,
|
309
|
+
config: u,
|
310
|
+
prod: n
|
311
|
+
}), m = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
312
|
+
if (!m) return console.error("Could not find the original declaration");
|
313
|
+
const b = (h = m.at(1)) == null ? void 0 : h.trim(), P = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(o);
|
314
|
+
if (!P) return console.error("Could not find the original declaration");
|
315
|
+
const { index: y } = P;
|
316
|
+
let k = !1;
|
317
|
+
const i = setTimeout(() => k = !0, 5e3);
|
318
|
+
let S = 0, D = !1, F = 0;
|
319
|
+
for (; !D && !k; ) {
|
320
|
+
const f = o[y + S];
|
321
|
+
f === "(" && F++, f === ")" && F--, F === 0 && f === ")" && (D = !0), S > o.length && (k = !0), S++;
|
322
|
+
}
|
323
|
+
if (!k) clearTimeout(i);
|
324
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
325
|
+
const E = y + S, N = o.slice(y, E), l = o, p = ` ${g} = styled(${b}, "${x.classNames}", ${JSON.stringify(x.props)});`;
|
326
|
+
o = o.replace(N, p), l === o && console.error("Minimize file failed to change content", { name: g, tagName: b });
|
327
|
+
}), u.importStrategy === "component") {
|
328
|
+
const g = B(e, 6), C = H(e);
|
329
|
+
o = `import '../../saltygen/css/${`f_${z(C.name)}-${g}.css`}';
|
330
|
+
${o}`;
|
331
|
+
}
|
332
|
+
return o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
333
|
+
}
|
334
|
+
} catch (a) {
|
335
|
+
console.error("Error in minimizeFile:", a);
|
336
|
+
}
|
337
|
+
};
|
338
|
+
export {
|
339
|
+
Mt as a,
|
340
|
+
xt as b,
|
341
|
+
Ft as c,
|
342
|
+
Z as d,
|
343
|
+
Vt as e,
|
344
|
+
_t as g,
|
345
|
+
L as i,
|
346
|
+
O as l,
|
347
|
+
Rt as m,
|
348
|
+
nt as s
|
349
|
+
};
|
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.140",
|
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,11 +28,18 @@
|
|
23
28
|
"name": "core"
|
24
29
|
},
|
25
30
|
"peerDependencies": {
|
31
|
+
"commander": ">=12.x",
|
32
|
+
"ejs": ">=3.x",
|
26
33
|
"esbuild": ">=0.21.x",
|
34
|
+
"ora": ">=8.x",
|
27
35
|
"react": ">=18.x || >=19.x",
|
28
36
|
"winston": ">=3.x"
|
29
37
|
},
|
30
38
|
"exports": {
|
39
|
+
"./bin/main": {
|
40
|
+
"import": "./bin/main.js",
|
41
|
+
"require": "./bin/main.cjs"
|
42
|
+
},
|
31
43
|
"./compiler": {
|
32
44
|
"import": "./compiler/index.js",
|
33
45
|
"require": "./compiler/index.cjs"
|
@@ -52,5 +64,11 @@
|
|
52
64
|
"import": "./util/index.js",
|
53
65
|
"require": "./util/index.cjs"
|
54
66
|
}
|
67
|
+
},
|
68
|
+
"bin": {
|
69
|
+
"salty": "./bin/index.js",
|
70
|
+
"salty-css": "./bin/index.js",
|
71
|
+
"salty-css-cjs": "./bin/index.cjs",
|
72
|
+
"@salty-css/core": "./bin/index.js"
|
55
73
|
}
|
56
74
|
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { d as l } from "./dash-case-DBThphLm.js";
|
2
|
+
const W = (t, s) => {
|
3
|
+
if (typeof t != "string") return { result: t };
|
4
|
+
if (!s) return { result: t };
|
5
|
+
const r = [];
|
6
|
+
return Object.values(s).forEach((n) => {
|
7
|
+
const { pattern: o, transform: p } = n;
|
8
|
+
t = t.replace(o, (i) => {
|
9
|
+
const { value: d, css: e } = p(i);
|
10
|
+
return e && r.push(e), d;
|
11
|
+
});
|
12
|
+
}), { result: t, additionalCss: r };
|
13
|
+
}, N = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${l(n[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, s, r) => {
|
14
|
+
if (!t) return "";
|
15
|
+
const n = [], o = Object.entries(t).reduce((i, [d, e]) => {
|
16
|
+
const c = d.trim();
|
17
|
+
if (typeof e == "function" && (e = e()), typeof e == "object") {
|
18
|
+
if (!e) return i;
|
19
|
+
if (c === "variants")
|
20
|
+
return Object.entries(e).forEach(([f, u]) => {
|
21
|
+
u && Object.entries(u).forEach(([y, j]) => {
|
22
|
+
if (!j) return;
|
23
|
+
const b = `${s}.${f}-${y}`, m = a(j, b, r);
|
24
|
+
n.push(m);
|
25
|
+
});
|
26
|
+
}), i;
|
27
|
+
if (c === "defaultVariants")
|
28
|
+
return i;
|
29
|
+
if (c === "compoundVariants")
|
30
|
+
return e.forEach((f) => {
|
31
|
+
const { css: u, ...y } = f, j = Object.entries(y).reduce((m, [k, w]) => `${m}.${k}-${w}`, s), b = a(u, j, r);
|
32
|
+
n.push(b);
|
33
|
+
}), i;
|
34
|
+
if (c.startsWith("@")) {
|
35
|
+
const f = a(e, s, r), u = `${c} {
|
36
|
+
${f.replace(`
|
37
|
+
`, `
|
38
|
+
`)}
|
39
|
+
}`;
|
40
|
+
return n.push(u), i;
|
41
|
+
}
|
42
|
+
const $ = d.includes("&") ? c.replace("&", s) : c.startsWith(":") ? `${s}${c}` : `${s} ${c}`, h = a(e, $, r);
|
43
|
+
return n.push(h), i;
|
44
|
+
}
|
45
|
+
if (r != null && r.templates && r.templates[c]) {
|
46
|
+
const h = e.split(".").reduce((f, u) => f[u], r.templates[c]);
|
47
|
+
if (h) {
|
48
|
+
const f = a(h, "");
|
49
|
+
return `${i}${f}`;
|
50
|
+
}
|
51
|
+
return console.warn(`Template "${c}" with path of "${e}" was not found in config!`), i;
|
52
|
+
}
|
53
|
+
const S = c.startsWith("-") ? c : l(c), O = ($, h = ";") => i = `${i}${$}${h}`, T = ($) => O(`${S}:${$}`);
|
54
|
+
if (typeof e == "number") return T(e);
|
55
|
+
if (typeof e != "string")
|
56
|
+
if ("toString" in e) e = e.toString();
|
57
|
+
else return i;
|
58
|
+
const { modifiers: V } = r || {}, g = function* () {
|
59
|
+
yield N(e), yield W(e, V);
|
60
|
+
}();
|
61
|
+
for (const { result: $, additionalCss: h = [] } of g)
|
62
|
+
e = $, h.forEach((f) => {
|
63
|
+
const u = a(f, "");
|
64
|
+
O(u, "");
|
65
|
+
});
|
66
|
+
return T(e);
|
67
|
+
}, "");
|
68
|
+
return o ? s ? [`${s} { ${o} }`, ...n].join(`
|
69
|
+
`) : o : n.join(`
|
70
|
+
`);
|
71
|
+
}, P = (t, s = []) => {
|
72
|
+
if (!t) return "";
|
73
|
+
const r = [], n = {};
|
74
|
+
if (Object.entries(t).forEach(([o, p]) => {
|
75
|
+
if (typeof p == "object") {
|
76
|
+
if (!p) return;
|
77
|
+
const i = o.trim(), d = P(p, [...s, i]);
|
78
|
+
r.push(d);
|
79
|
+
} else
|
80
|
+
n[o] = p;
|
81
|
+
}), Object.keys(n).length) {
|
82
|
+
const o = s.map(l).join("-"), p = a(n, `.${o}`);
|
83
|
+
r.push(p);
|
84
|
+
}
|
85
|
+
return r.join(`
|
86
|
+
`);
|
87
|
+
}, x = (t) => Object.keys(t), A = (t) => Object.entries(t).reduce((s, [r, n]) => (typeof n == "object" && (s[r] = E(n).map((o) => `"${o}"`).join(" | ")), s), {}), E = (t, s = "", r = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
88
|
+
const p = s ? `${s}.${n}` : n;
|
89
|
+
return typeof o == "object" ? E(o, p, r) : r.add(s);
|
90
|
+
}), [...r]) : [];
|
91
|
+
export {
|
92
|
+
P as a,
|
93
|
+
A as b,
|
94
|
+
N as c,
|
95
|
+
x as g,
|
96
|
+
a as p
|
97
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";const b=require("./dash-case-BJEkFEGQ.cjs"),K=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,i=>{const{value:d,css:r}=p(i);return r&&e.push(r),d})}),{result:t,additionalCss:e}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${b.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},h=(t,s,e)=>{if(!t)return"";const n=[],o=Object.entries(t).reduce((i,[d,r])=>{const c=d.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(c==="variants")return Object.entries(r).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,y])=>{if(!y)return;const j=`${s}.${f}-${l}`,m=h(y,j,e);n.push(m)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(f=>{const{css:u,...l}=f,y=Object.entries(l).reduce((m,[W,q])=>`${m}.${W}-${q}`,s),j=h(u,y,e);n.push(j)}),i;if(c.startsWith("@")){const f=h(r,s,e),u=`${c} {
|
2
|
+
${f.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return n.push(u),i}const a=d.includes("&")?c.replace("&",s):c.startsWith(":")?`${s}${c}`:`${s} ${c}`,$=h(r,a,e);return n.push($),i}if(e!=null&&e.templates&&e.templates[c]){const $=r.split(".").reduce((f,u)=>f[u],e.templates[c]);if($){const f=h($,"");return`${i}${f}`}return console.warn(`Template "${c}" with path of "${r}" was not found in config!`),i}const g=c.startsWith("-")?c:b.dashCase(c),T=(a,$=";")=>i=`${i}${a}${$}`,O=a=>T(`${g}:${a}`);if(typeof r=="number")return O(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:k}=e||{},w=function*(){yield S(r),yield K(r,k)}();for(const{result:a,additionalCss:$=[]}of w)r=a,$.forEach(f=>{const u=h(f,"");T(u,"")});return O(r)},"");return o?s?[`${s} { ${o} }`,...n].join(`
|
6
|
+
`):o:n.join(`
|
7
|
+
`)},E=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const i=o.trim(),d=E(p,[...s,i]);e.push(d)}else n[o]=p}),Object.keys(n).length){const o=s.map(b.dashCase).join("-"),p=h(n,`.${o}`);e.push(p)}return e.join(`
|
8
|
+
`)},N=t=>Object.keys(t),P=t=>Object.entries(t).reduce((s,[e,n])=>(typeof n=="object"&&(s[e]=V(n).map(o=>`"${o}"`).join(" | ")),s),{}),V=(t,s="",e=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const p=s?`${s}.${n}`:n;return typeof o=="object"?V(o,p,e):e.add(s)}),[...e]):[];exports.getTemplateKeys=N;exports.getTemplateTypes=P;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=S;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";function r(e){return e?typeof e!="string"?r(String(e)):e.replace(/\s/g,"-").replace(/[-_]([a-z0-9])/g,a=>a[1].toUpperCase()).replace(/^[a-z]/,a=>a.toUpperCase()):""}exports.pascalCase=r;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { styled } from "@salty-css/react/styled";
|
2
|
+
|
3
|
+
export const <%- name %> = styled('<%- tag %>', {
|
4
|
+
<% if(className) { %>className: '<%- className %>',<% } %>
|
5
|
+
base: {
|
6
|
+
// Add your styles here
|
7
|
+
}
|
8
|
+
})`;exports.default=e;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
const n = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
2
|
+
|
3
|
+
interface <%- componentName %>Props {
|
4
|
+
text?: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
8
|
+
return (
|
9
|
+
<<%- styledComponentName %>>
|
10
|
+
{text}
|
11
|
+
</<%- styledComponentName %>>
|
12
|
+
);
|
13
|
+
};
|
14
|
+
|
15
|
+
export default <%- componentName %>;`;
|
16
|
+
export {
|
17
|
+
n as default
|
18
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
2
|
+
|
3
|
+
interface <%- componentName %>Props {
|
4
|
+
text?: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
8
|
+
return (
|
9
|
+
<<%- styledComponentName %>>
|
10
|
+
{text}
|
11
|
+
</<%- styledComponentName %>>
|
12
|
+
);
|
13
|
+
};
|
14
|
+
|
15
|
+
export default <%- componentName %>;`;exports.default=e;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { defineConfig } from '@salty-css/core/config';
|
2
|
+
|
3
|
+
export const config = defineConfig({
|
4
|
+
// Add your custom config here
|
5
|
+
externalModules: ['react', 'react-dom']
|
6
|
+
});
|
7
|
+
`;exports.default=e;
|