@salty-css/webpack 0.0.1-alpha.23 → 0.0.1-alpha.230
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/README.md +463 -26
- package/index-BLikDM5S.cjs +42 -0
- package/index-DTqX17j6.js +658 -0
- package/index.cjs +1 -15
- package/index.d.ts +2 -1
- package/index.js +25 -215
- package/loader.cjs +1 -0
- package/loader.js +8 -0
- package/package.json +9 -4
package/index.d.ts
CHANGED
package/index.js
CHANGED
@@ -1,225 +1,35 @@
|
|
1
|
-
import {
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
const e = L(5381, JSON.stringify(t)) >>> 0;
|
16
|
-
return K(e, s);
|
17
|
-
};
|
18
|
-
function T(t) {
|
19
|
-
return t ? typeof t != "string" ? T(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, e) => (e > 0 ? "-" : "") + s.toLowerCase()) : "";
|
20
|
-
}
|
21
|
-
const z = (t, s) => {
|
22
|
-
if (typeof t != "string") return { result: t };
|
23
|
-
if (!s) return { result: t };
|
24
|
-
const e = [];
|
25
|
-
return Object.values(s).forEach((n) => {
|
26
|
-
const { pattern: r, transform: a } = n;
|
27
|
-
t = t.replace(r, (g) => {
|
28
|
-
const { value: l, css: b } = a(g);
|
29
|
-
return b && e.push(b), l;
|
30
|
-
});
|
31
|
-
}), { result: t, additionalCss: e };
|
32
|
-
}, Z = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${T(n[1].replaceAll(".", "-"))})`) } : { result: t }, k = (t, s, e, n) => {
|
33
|
-
if (!t) return "";
|
34
|
-
const r = [], a = Object.entries(t).reduce((l, [b, o]) => {
|
35
|
-
const u = b.trim();
|
36
|
-
if (typeof o == "function" && (o = o()), typeof o == "object") {
|
37
|
-
if (!o) return l;
|
38
|
-
if (u === "variants")
|
39
|
-
return Object.entries(o).forEach(([f, i]) => {
|
40
|
-
i && Object.entries(i).forEach(([p, c]) => {
|
41
|
-
if (!c) return;
|
42
|
-
const h = `${s}.${f}-${p}`, j = k(c, h);
|
43
|
-
r.push(j);
|
44
|
-
});
|
45
|
-
}), l;
|
46
|
-
if (u === "defaultVariants")
|
47
|
-
return l;
|
48
|
-
if (u === "compoundVariants")
|
49
|
-
return o.forEach((f) => {
|
50
|
-
const { css: i, ...p } = f, c = Object.entries(p).reduce((j, [C, O]) => `${j}.${C}-${O}`, s), h = k(i, c);
|
51
|
-
r.push(h);
|
52
|
-
}), l;
|
53
|
-
if (u.startsWith("@")) {
|
54
|
-
const f = k(o, s), i = `${u} {
|
55
|
-
${f.replace(`
|
56
|
-
`, `
|
57
|
-
`)}
|
58
|
-
}`;
|
59
|
-
return r.push(i), l;
|
60
|
-
}
|
61
|
-
const $ = b.includes("&") ? u.replace("&", s) : u.startsWith(":") ? `${s}${u}` : `${s} ${u}`, d = k(o, $);
|
62
|
-
return r.push(d), l;
|
63
|
-
}
|
64
|
-
const y = u.startsWith("-") ? u : T(u), S = ($, d = ";") => l = `${l}${$}${d}`, D = ($) => S(`${y}:${$}`);
|
65
|
-
if (typeof o == "number") return D(o);
|
66
|
-
if (typeof o != "string")
|
67
|
-
if ("toString" in o) o = o.toString();
|
68
|
-
else return l;
|
69
|
-
const { modifiers: F } = {}, V = function* () {
|
70
|
-
yield Z(o), yield z(o, F);
|
71
|
-
}();
|
72
|
-
for (const { result: $, additionalCss: d = [] } of V)
|
73
|
-
o = $, d.forEach((f) => {
|
74
|
-
const i = k(f, "");
|
75
|
-
S(i, "");
|
76
|
-
});
|
77
|
-
return D(o);
|
78
|
-
}, "");
|
79
|
-
if (!a) return r.join(`
|
80
|
-
`);
|
81
|
-
if (!s) return a;
|
82
|
-
let g = "";
|
83
|
-
return g = `${s} { ${a} }`, [g, ...r].join(`
|
84
|
-
`);
|
85
|
-
}, R = (t, s = []) => {
|
86
|
-
if (!t) return "";
|
87
|
-
const e = [], n = {};
|
88
|
-
if (Object.entries(t).forEach(([r, a]) => {
|
89
|
-
if (typeof a == "object") {
|
90
|
-
if (!a) return;
|
91
|
-
const g = r.trim(), l = R(a, [...s, g]);
|
92
|
-
e.push(l);
|
93
|
-
} else
|
94
|
-
n[r] = a;
|
95
|
-
}), Object.keys(n).length) {
|
96
|
-
const r = s.map(T).join("-"), a = k(n, `.${r}`);
|
97
|
-
e.push(a);
|
98
|
-
}
|
99
|
-
return e.join(`
|
100
|
-
`);
|
101
|
-
}, N = (t) => m(t, "./saltygen"), U = ["salty", "css", "styles", "styled"], I = (t = []) => new RegExp(`\\.(${[...U, ...t].join("|")})\\.`), X = (t, s = []) => I(s).test(t), Y = async (t) => {
|
102
|
-
const s = N(t), e = m(t, "salty.config.ts"), n = m(s, "salty.config.js");
|
103
|
-
await A.build({
|
104
|
-
entryPoints: [e],
|
105
|
-
minify: !0,
|
106
|
-
treeShaking: !0,
|
107
|
-
bundle: !0,
|
108
|
-
outfile: n,
|
109
|
-
format: "esm",
|
110
|
-
external: ["react"]
|
111
|
-
});
|
112
|
-
const r = Date.now(), { config: a } = await import(`${n}?t=${r}`);
|
113
|
-
return a;
|
114
|
-
}, Q = async (t) => {
|
115
|
-
const s = await Y(t), e = /* @__PURE__ */ new Set(), n = (f, i = []) => f ? Object.entries(f).flatMap(([p, c]) => {
|
116
|
-
if (!c) return;
|
117
|
-
if (typeof c == "object") return n(c, [...i, p]);
|
118
|
-
const h = [...i, p].join(".");
|
119
|
-
e.add(`"${h}"`);
|
120
|
-
const j = [...i.map(T), T(p)].join("-"), { result: C } = Z(c);
|
121
|
-
return `--${j}: ${C};`;
|
122
|
-
}) : [], r = (f) => f ? Object.entries(f).flatMap(([i, p]) => {
|
123
|
-
const c = n(p);
|
124
|
-
return i === "base" ? c.join("") : `${i} { ${c.join("")} }`;
|
125
|
-
}) : [], a = (f) => f ? Object.entries(f).flatMap(([i, p]) => Object.entries(p).flatMap(([c, h]) => {
|
126
|
-
const j = n(h, [i]), C = `.${i}-${c}, [data-${i}="${c}"]`, O = j.join("");
|
127
|
-
return `${C} { ${O} }`;
|
128
|
-
})) : [], g = n(s.variables), l = r(s.responsiveVariables), b = a(s.conditionalVariables), o = N(t), u = m(o, "css/variables.css"), y = `:root { ${g.join("")} ${l.join("")} } ${b.join("")}`;
|
129
|
-
w(u, y);
|
130
|
-
const S = m(o, "types/css-tokens.d.ts"), F = `type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
131
|
-
w(S, F);
|
132
|
-
const P = m(o, "css/global.css"), V = k(s.global, "");
|
133
|
-
w(P, V);
|
134
|
-
const $ = m(o, "css/templates.css"), d = R(s.templates);
|
135
|
-
w($, d);
|
136
|
-
}, v = async (t, s) => {
|
137
|
-
const e = M(t), n = m(s, "js", e + ".js");
|
138
|
-
await A.build({
|
139
|
-
entryPoints: [t],
|
140
|
-
minify: !0,
|
141
|
-
treeShaking: !0,
|
142
|
-
bundle: !0,
|
143
|
-
outfile: n,
|
144
|
-
format: "esm",
|
145
|
-
target: ["es2022"],
|
146
|
-
keepNames: !0,
|
147
|
-
external: ["react"]
|
148
|
-
});
|
149
|
-
const r = Date.now();
|
150
|
-
return await import(`${n}?t=${r}`);
|
151
|
-
}, tt = async (t) => {
|
152
|
-
const s = N(t), e = m(s, "salty.config.js"), { config: n } = await import(e);
|
153
|
-
return n;
|
154
|
-
}, st = async (t) => {
|
155
|
-
try {
|
156
|
-
const s = [], e = [], n = N(t), r = m(n, "index.css");
|
157
|
-
(() => {
|
158
|
-
B(n) && q("rm -rf " + n), x(n), x(m(n, "css")), x(m(n, "types"));
|
159
|
-
})(), await Q(t);
|
160
|
-
const g = await tt(t);
|
161
|
-
async function l(y, S) {
|
162
|
-
const D = G(y);
|
163
|
-
if (D.isDirectory()) {
|
164
|
-
const F = J(y);
|
165
|
-
await Promise.all(F.map((P) => l(m(y, P), m(S, P))));
|
166
|
-
} else if (D.isFile() && X(y)) {
|
167
|
-
const P = await v(y, n), V = [];
|
168
|
-
Object.entries(P).forEach(([i, p]) => {
|
169
|
-
if (p.isKeyframes && p.css) {
|
170
|
-
const O = `${p.animationName}.css`, W = `css/${O}`, _ = m(n, W);
|
171
|
-
s.push(O), w(_, p.css);
|
172
|
-
return;
|
173
|
-
}
|
174
|
-
if (!p.generator) return;
|
175
|
-
const c = p.generator._withBuildContext({
|
176
|
-
name: i,
|
177
|
-
config: g
|
178
|
-
}), h = `${c.hash}-${c.priority}.css`;
|
179
|
-
e[c.priority] || (e[c.priority] = []), e[c.priority].push(h), V.push(h);
|
180
|
-
const j = `css/${h}`, C = m(n, j);
|
181
|
-
w(C, c.css);
|
182
|
-
});
|
183
|
-
const $ = V.map((i) => `@import url('./${i}');`).join(`
|
184
|
-
`), d = M(y, 6), f = m(n, `css/${d}.css`);
|
185
|
-
w(f, $);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
await l(t, n);
|
189
|
-
const b = s.map((y) => `@import url('./css/${y}');`).join(`
|
190
|
-
`);
|
191
|
-
let u = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
192
|
-
|
193
|
-
${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
|
194
|
-
`)}
|
195
|
-
${b}`;
|
196
|
-
if (g.importStrategy !== "component") {
|
197
|
-
const y = e.flat().map((S) => `@import url('./css/${S}');`).join(`
|
198
|
-
`);
|
199
|
-
u += y;
|
200
|
-
}
|
201
|
-
w(r, u);
|
202
|
-
} catch (s) {
|
203
|
-
console.error(s);
|
204
|
-
}
|
205
|
-
}, it = (t, s) => {
|
206
|
-
var e, n, r;
|
207
|
-
(n = (e = t.module) == null ? void 0 : e.rules) == null || n.push({
|
208
|
-
test: I(),
|
1
|
+
import { resolve as p } from "path";
|
2
|
+
import { i as f, s as d, g as u, a as y } from "./index-DTqX17j6.js";
|
3
|
+
import { readFile as g } from "fs/promises";
|
4
|
+
import { watch as m } from "fs";
|
5
|
+
const w = async (s) => {
|
6
|
+
if (!s || s.includes("node_modules") || s.includes("saltygen")) return !1;
|
7
|
+
if (s.includes("salty.config")) return !0;
|
8
|
+
if (!f(s)) return !1;
|
9
|
+
const t = await g(s, "utf-8");
|
10
|
+
return !!/.+define[A-Z]\w+/.test(t);
|
11
|
+
}, j = (s, e, r = !1, t = !1) => {
|
12
|
+
var l, o, i;
|
13
|
+
(o = (l = s.module) == null ? void 0 : l.rules) == null || o.push({
|
14
|
+
test: d(),
|
209
15
|
use: [
|
210
16
|
{
|
211
|
-
loader:
|
212
|
-
options: { dir:
|
17
|
+
loader: p(__dirname, t ? "./loader.cjs" : "./loader.js"),
|
18
|
+
options: { dir: e }
|
213
19
|
}
|
214
20
|
]
|
215
|
-
}),
|
216
|
-
apply: (
|
217
|
-
|
218
|
-
|
21
|
+
}), r || (i = s.plugins) == null || i.push({
|
22
|
+
apply: (c) => {
|
23
|
+
let n = !1;
|
24
|
+
c.hooks.beforeCompile.tapPromise({ name: "generateCss" }, async () => {
|
25
|
+
n || (n = !0, await u(e), m(e, { recursive: !0 }, async (h, a) => {
|
26
|
+
await w(a) ? await u(e, !1, !1) : f(a) && await y(e, a);
|
27
|
+
}));
|
219
28
|
});
|
220
29
|
}
|
221
30
|
});
|
222
31
|
};
|
223
32
|
export {
|
224
|
-
|
33
|
+
j as default,
|
34
|
+
j as saltyPlugin
|
225
35
|
};
|
package/loader.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const i=require("./index-BLikDM5S.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
|
package/loader.js
ADDED
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.230",
|
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": "Webpack plugin for Salty CSS",
|
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
|
},
|
@@ -28,8 +33,8 @@
|
|
28
33
|
"require": "./index.cjs"
|
29
34
|
}
|
30
35
|
},
|
31
|
-
"
|
32
|
-
"@salty-css/core": "^0.0.1-alpha.
|
36
|
+
"dependencies": {
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.230",
|
33
38
|
"webpack": ">=5.x"
|
34
39
|
}
|
35
40
|
}
|