@salty-css/core 0.0.1-alpha.8 → 0.0.1-alpha.80
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 +105 -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 +10 -0
- package/bin/main.d.ts +1 -0
- package/bin/main.js +232 -0
- package/bin/prettier.d.ts +1 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/index.cjs +9 -9
- package/compiler/index.d.ts +5 -5
- package/compiler/index.js +176 -142
- package/config/config-types.d.ts +10 -4
- package/dash-case-DKzpenwY.cjs +1 -0
- package/dash-case-DMQMcCO6.js +19 -0
- package/generator/index.cjs +1 -1
- package/generator/index.js +30 -20
- package/generator/style-generator.d.ts +9 -8
- package/index-84Wroia-.cjs +1 -0
- package/index-D_732b92.js +4 -0
- package/package.json +23 -3
- package/parse-templates-DUUSaubj.js +96 -0
- package/parse-templates-DVK3iZIl.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/types/index.d.ts +13 -4
- package/util/camel-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
package/compiler/index.js
CHANGED
@@ -1,180 +1,214 @@
|
|
1
|
-
import * as
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
import * as z from "esbuild";
|
2
|
+
import { execSync as U } from "child_process";
|
3
|
+
import { t as J, d as _ } from "../dash-case-DMQMcCO6.js";
|
4
|
+
import { join as n } from "path";
|
5
|
+
import { existsSync as W, writeFileSync as j, mkdirSync as v, statSync as X, readdirSync as Y, readFileSync as N } from "fs";
|
6
|
+
import { readFile as Z, writeFile as Q } from "fs/promises";
|
7
|
+
import { p as tt, a as st, b as et } from "../parse-templates-DUUSaubj.js";
|
8
|
+
const H = (t) => {
|
9
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
10
|
+
const s = n(t, "package.json");
|
11
|
+
return W(s) ? s : H(n(t, ".."));
|
12
|
+
}, nt = async (t) => {
|
13
|
+
const s = H(t);
|
14
|
+
return await Z(s, "utf-8").then(JSON.parse).catch(() => {
|
15
|
+
});
|
16
|
+
}, ot = async (t) => {
|
17
|
+
const s = await nt(t);
|
18
|
+
if (s)
|
19
|
+
return s.type;
|
20
|
+
};
|
21
|
+
let M;
|
22
|
+
const K = async (t) => {
|
23
|
+
if (M) return M;
|
24
|
+
const s = await ot(t);
|
25
|
+
return s === "module" ? M = "esm" : (s === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
26
|
+
}, V = {
|
27
|
+
externalModules: []
|
28
|
+
}, G = (t) => {
|
29
|
+
if (V.externalModules.length > 0) return V.externalModules;
|
30
|
+
const s = n(t, "salty.config.ts"), e = N(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
31
|
+
if (!e) return [];
|
32
|
+
const i = e[1].split(",").map((w) => w.replace(/['"`]/g, "").trim());
|
33
|
+
return V.externalModules = i, i;
|
34
|
+
}, E = (t) => n(t, "./saltygen"), ct = ["salty", "css", "styles", "styled"], rt = (t = []) => new RegExp(`\\.(${[...ct, ...t].join("|")})\\.`), O = (t, s = []) => rt(s).test(t), at = async (t) => {
|
35
|
+
const s = E(t), o = n(t, "salty.config.ts"), e = n(s, "salty.config.js"), i = await K(t), w = G(t);
|
36
|
+
await z.build({
|
37
|
+
entryPoints: [o],
|
17
38
|
minify: !0,
|
18
39
|
treeShaking: !0,
|
19
40
|
bundle: !0,
|
20
|
-
outfile:
|
21
|
-
format:
|
22
|
-
external:
|
41
|
+
outfile: e,
|
42
|
+
format: i,
|
43
|
+
external: w
|
23
44
|
});
|
24
|
-
const
|
25
|
-
return
|
26
|
-
},
|
27
|
-
const
|
28
|
-
if (!
|
29
|
-
if (typeof
|
30
|
-
const C = [...l,
|
31
|
-
|
32
|
-
const
|
33
|
-
return `--${
|
34
|
-
}) : [],
|
35
|
-
const
|
36
|
-
return l === "base" ?
|
37
|
-
}) : [],
|
38
|
-
const
|
39
|
-
return `${
|
40
|
-
})) : [],
|
41
|
-
|
42
|
-
const
|
43
|
-
|
44
|
-
const
|
45
|
-
|
46
|
-
const
|
47
|
-
|
48
|
-
},
|
49
|
-
const
|
50
|
-
await
|
45
|
+
const f = Date.now(), { config: y } = await import(`${e}?t=${f}`);
|
46
|
+
return y;
|
47
|
+
}, it = async (t) => {
|
48
|
+
const s = await at(t), o = /* @__PURE__ */ new Set(), e = (a, l = []) => a ? Object.entries(a).flatMap(([g, p]) => {
|
49
|
+
if (!p) return;
|
50
|
+
if (typeof p == "object") return e(p, [...l, g]);
|
51
|
+
const C = [...l, g].join(".");
|
52
|
+
o.add(`"${C}"`);
|
53
|
+
const m = [...l.map(_), _(g)].join("-"), { result: h } = et(p);
|
54
|
+
return `--${m}: ${h};`;
|
55
|
+
}) : [], i = (a) => a ? Object.entries(a).flatMap(([l, g]) => {
|
56
|
+
const p = e(g);
|
57
|
+
return l === "base" ? p.join("") : `${l} { ${p.join("")} }`;
|
58
|
+
}) : [], w = (a) => a ? Object.entries(a).flatMap(([l, g]) => Object.entries(g).flatMap(([p, C]) => {
|
59
|
+
const m = e(C, [l]), h = `.${l}-${p}, [data-${l}="${p}"]`, P = m.join("");
|
60
|
+
return `${h} { ${P} }`;
|
61
|
+
})) : [], f = e(s.variables), y = i(s.responsiveVariables), c = w(s.conditionalVariables), x = E(t), $ = n(x, "css/variables.css"), k = `:root { ${f.join("")} ${y.join("")} } ${c.join("")}`;
|
62
|
+
j($, k);
|
63
|
+
const d = n(x, "types/css-tokens.d.ts"), u = `type VariableTokens = ${[...o].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
64
|
+
j(d, u);
|
65
|
+
const S = n(x, "css/global.css"), F = tt(s.global, "");
|
66
|
+
j(S, F);
|
67
|
+
const b = n(x, "css/templates.css"), D = st(s.templates);
|
68
|
+
j(b, D);
|
69
|
+
}, R = async (t, s, o) => {
|
70
|
+
const e = J(s), i = n(o, "js", e + ".js"), w = await K(t), f = G(t);
|
71
|
+
await z.build({
|
51
72
|
entryPoints: [s],
|
52
73
|
minify: !0,
|
53
74
|
treeShaking: !0,
|
54
75
|
bundle: !0,
|
55
|
-
outfile:
|
56
|
-
format:
|
76
|
+
outfile: i,
|
77
|
+
format: w,
|
57
78
|
target: ["es2022"],
|
58
79
|
keepNames: !0,
|
59
|
-
external:
|
80
|
+
external: f
|
60
81
|
});
|
61
|
-
const
|
62
|
-
return await import(`${
|
63
|
-
},
|
64
|
-
const
|
65
|
-
return
|
66
|
-
},
|
82
|
+
const y = Date.now();
|
83
|
+
return await import(`${i}?t=${y}`);
|
84
|
+
}, B = async (t) => {
|
85
|
+
const s = E(t), o = n(s, "salty.config.js"), { config: e } = await import(o);
|
86
|
+
return e;
|
87
|
+
}, dt = async (t) => {
|
67
88
|
try {
|
68
|
-
const
|
89
|
+
const s = [], o = [], e = E(t), i = n(e, "index.css");
|
69
90
|
(() => {
|
70
|
-
|
71
|
-
})(), await
|
72
|
-
const
|
73
|
-
async function
|
74
|
-
const
|
75
|
-
if (
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
91
|
+
W(e) && U("rm -rf " + e), v(e), v(n(e, "css")), v(n(e, "types"));
|
92
|
+
})(), await it(t);
|
93
|
+
const f = await B(t);
|
94
|
+
async function y(r, u) {
|
95
|
+
const S = ["node_modules", "saltygen"], F = X(r);
|
96
|
+
if (F.isDirectory()) {
|
97
|
+
const b = Y(r);
|
98
|
+
if (S.some((a) => r.includes(a))) return;
|
99
|
+
await Promise.all(b.map((a) => y(n(r, a), n(u, a))));
|
100
|
+
} else if (F.isFile() && O(r)) {
|
101
|
+
const D = await R(t, r, e), a = [];
|
102
|
+
Object.entries(D).forEach(([C, m]) => {
|
103
|
+
if (m.isKeyframes && m.css) {
|
104
|
+
const I = `${m.animationName}.css`, A = `css/${I}`, L = n(e, A);
|
105
|
+
s.push(I), j(L, m.css);
|
84
106
|
return;
|
85
107
|
}
|
86
|
-
if (!
|
87
|
-
const
|
88
|
-
name:
|
89
|
-
config:
|
90
|
-
}),
|
91
|
-
|
92
|
-
const
|
93
|
-
|
108
|
+
if (!m.generator) return;
|
109
|
+
const h = m.generator._withBuildContext({
|
110
|
+
name: C,
|
111
|
+
config: f
|
112
|
+
}), P = `${h.hash}-${h.priority}.css`;
|
113
|
+
o[h.priority] || (o[h.priority] = []), o[h.priority].push(P), a.push(P);
|
114
|
+
const T = `css/${P}`, q = n(e, T);
|
115
|
+
j(q, h.css);
|
94
116
|
});
|
95
|
-
const
|
96
|
-
`),
|
97
|
-
|
117
|
+
const l = a.map((C) => `@import url('./${C}');`).join(`
|
118
|
+
`), g = J(r, 6), p = n(e, `css/${g}.css`);
|
119
|
+
j(p, l);
|
98
120
|
}
|
99
121
|
}
|
100
|
-
await
|
101
|
-
const
|
122
|
+
await y(t, e);
|
123
|
+
const c = s.map((r) => `@import url('./css/${r}');`).join(`
|
102
124
|
`);
|
103
|
-
let
|
125
|
+
let d = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
104
126
|
|
105
|
-
${["
|
127
|
+
${["variables.css", "global.css", "templates.css"].filter((r) => {
|
128
|
+
try {
|
129
|
+
return N(n(e, "css", r), "utf8").length > 0;
|
130
|
+
} catch {
|
131
|
+
return !1;
|
132
|
+
}
|
133
|
+
}).map((r) => `@import url('./css/${r}');`).join(`
|
106
134
|
`)}
|
107
|
-
${
|
108
|
-
if (
|
109
|
-
const r =
|
135
|
+
${c}`;
|
136
|
+
if (f.importStrategy !== "component") {
|
137
|
+
const r = o.flat().map((u) => `@import url('./css/${u}');`).join(`
|
110
138
|
`);
|
111
|
-
|
139
|
+
d += r;
|
112
140
|
}
|
113
|
-
|
114
|
-
} catch (
|
115
|
-
console.error(
|
141
|
+
j(i, d);
|
142
|
+
} catch (s) {
|
143
|
+
console.error(s);
|
116
144
|
}
|
117
|
-
},
|
145
|
+
}, mt = async (t, s) => {
|
118
146
|
try {
|
119
|
-
const
|
120
|
-
if (O(
|
121
|
-
const
|
122
|
-
Object.entries(
|
123
|
-
if (!
|
124
|
-
const u =
|
125
|
-
name:
|
126
|
-
config:
|
127
|
-
}),
|
128
|
-
|
147
|
+
const o = [], e = n(t, "./saltygen"), i = n(e, "index.css");
|
148
|
+
if (O(s)) {
|
149
|
+
const f = await B(t), y = await R(t, s, e);
|
150
|
+
Object.entries(y).forEach(([d, r]) => {
|
151
|
+
if (!r.generator) return;
|
152
|
+
const u = r.generator._withBuildContext({
|
153
|
+
name: d,
|
154
|
+
config: f
|
155
|
+
}), S = `${u.hash}-${u.priority}.css`, F = `css/${S}`, b = n(e, F);
|
156
|
+
o.push(S), j(b, u.css);
|
129
157
|
});
|
130
|
-
const
|
131
|
-
`),
|
158
|
+
const c = N(i, "utf8").split(`
|
159
|
+
`), x = o.map((d) => `@import url('../saltygen/css/${d}');`), k = [.../* @__PURE__ */ new Set([...c, ...x])].join(`
|
132
160
|
`);
|
133
|
-
|
161
|
+
j(i, k);
|
134
162
|
}
|
135
|
-
} catch (
|
136
|
-
console.error(
|
163
|
+
} catch (o) {
|
164
|
+
console.error(o);
|
137
165
|
}
|
138
|
-
},
|
166
|
+
}, ht = async (t, s) => {
|
139
167
|
try {
|
140
|
-
const
|
141
|
-
if (O(
|
142
|
-
|
143
|
-
|
144
|
-
const
|
145
|
-
let
|
146
|
-
Object.entries(
|
147
|
-
var
|
148
|
-
if (
|
149
|
-
|
150
|
-
|
168
|
+
const o = n(t, "./saltygen");
|
169
|
+
if (O(s)) {
|
170
|
+
const i = N(s, "utf8");
|
171
|
+
i.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== i && await Q(s, i);
|
172
|
+
const f = await B(t), y = await R(t, s, o);
|
173
|
+
let c = i;
|
174
|
+
Object.entries(y).forEach(([$, k]) => {
|
175
|
+
var P;
|
176
|
+
if (k.isKeyframes || !k.generator) return;
|
177
|
+
const d = k.generator._withBuildContext({
|
178
|
+
name: $,
|
179
|
+
config: f
|
180
|
+
}), r = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
|
181
|
+
if (!r) return console.error("Could not find the original declaration");
|
182
|
+
const u = (P = r.at(1)) == null ? void 0 : P.trim(), S = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(c);
|
183
|
+
if (!S) return console.error("Could not find the original declaration");
|
184
|
+
const { index: F } = S;
|
185
|
+
let b = !1;
|
186
|
+
const D = setTimeout(() => b = !0, 5e3);
|
187
|
+
let a = 0, l = !1, g = 0;
|
188
|
+
for (; !l && !b; ) {
|
189
|
+
const T = c[F + a];
|
190
|
+
T === "(" && g++, T === ")" && g--, g === 0 && T === ")" && (l = !0), a > c.length && (b = !0), a++;
|
151
191
|
}
|
152
|
-
if (!
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}), h = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
|
157
|
-
if (!h)
|
158
|
-
return console.error("Could not find the original declaration");
|
159
|
-
const u = (m = h.at(1)) == null ? void 0 : m.trim(), { element: g, variantKeys: j } = f.props, F = `${y} = styled(${u}, "${f.classNames}", "${f._callerName}", ${JSON.stringify(g)}, ${JSON.stringify(
|
160
|
-
j
|
161
|
-
)});`, x = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
|
162
|
-
a = a.replace(x, F);
|
192
|
+
if (!b) clearTimeout(D);
|
193
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
194
|
+
const p = F + a, C = c.slice(F, p), m = c, h = ` ${$} = styled(${u}, "${d.classNames}", "${d._callerName}", ${JSON.stringify(d.props)});`;
|
195
|
+
c = c.replace(C, h), m === c && console.error("Minimize file failed to change content", { name: $, tagName: u });
|
163
196
|
});
|
164
|
-
const
|
165
|
-
return
|
166
|
-
${
|
197
|
+
const x = J(s, 6);
|
198
|
+
return f.importStrategy === "component" && (c = `import '../../saltygen/css/${x}.css';
|
199
|
+
${c}`), c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
167
200
|
}
|
168
|
-
} catch (
|
169
|
-
console.error(
|
201
|
+
} catch (o) {
|
202
|
+
console.error("Error in minimizeFile:", o);
|
170
203
|
}
|
171
204
|
};
|
172
205
|
export {
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
206
|
+
R as compileSaltyFile,
|
207
|
+
it as generateConfigStyles,
|
208
|
+
dt as generateCss,
|
209
|
+
mt as generateFile,
|
177
210
|
O as isSaltyFile,
|
178
|
-
|
179
|
-
ct as
|
211
|
+
ht as minimizeFile,
|
212
|
+
ct as saltyFileExtensions,
|
213
|
+
rt as saltyFileRegExp
|
180
214
|
};
|
package/config/config-types.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { CssStyles } from '../types';
|
2
|
-
|
3
|
-
|
4
|
-
};
|
2
|
+
import { OrString } from '../types/util-types';
|
3
|
+
export type GlobalStyles = Record<string, CssStyles>;
|
5
4
|
export type CssVariables = Record<string, unknown>;
|
6
5
|
export interface CssResponsiveVariables {
|
7
6
|
[key: string]: CssVariables;
|
@@ -11,6 +10,9 @@ export interface CssConditionalVariables {
|
|
11
10
|
[key: PropertyKey]: CssVariables;
|
12
11
|
};
|
13
12
|
}
|
13
|
+
type CssTemplate = CssStyles | {
|
14
|
+
[key: PropertyKey]: CssTemplate;
|
15
|
+
};
|
14
16
|
export interface CssTemplates {
|
15
17
|
[key: PropertyKey]: {
|
16
18
|
[key: PropertyKey]: CssTemplate;
|
@@ -46,7 +48,7 @@ export interface SaltyConfig {
|
|
46
48
|
/**
|
47
49
|
* The global styles that are imported in the root of the project.
|
48
50
|
*/
|
49
|
-
global?:
|
51
|
+
global?: GlobalStyles;
|
50
52
|
/**
|
51
53
|
* The templates that can be used in styles to create reusable css.
|
52
54
|
*/
|
@@ -55,5 +57,9 @@ export interface SaltyConfig {
|
|
55
57
|
* The modifiers that can transform css values.
|
56
58
|
*/
|
57
59
|
modifiers?: CssModifiers;
|
60
|
+
/**
|
61
|
+
* Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
|
62
|
+
*/
|
63
|
+
externalModules?: ('react' | 'react-dom' | OrString)[];
|
58
64
|
}
|
59
65
|
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=3)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,t)=>(t>0?"-":"")+r.toLowerCase()):""}exports.dashCase=s;exports.toHash=c;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const n = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), o = (e, r) => {
|
2
|
+
let t = "", a;
|
3
|
+
for (a = Math.abs(e); a > 52; a = a / 52 | 0) t = n(a % 52) + t;
|
4
|
+
return t = n(a % 52) + t, t.length < r ? t = t.padStart(r, "a") : t.length > r && (t = t.slice(-r)), t;
|
5
|
+
}, i = (e, r) => {
|
6
|
+
let t = r.length;
|
7
|
+
for (; t; ) e = e * 33 ^ r.charCodeAt(--t);
|
8
|
+
return e;
|
9
|
+
}, c = (e, r = 3) => {
|
10
|
+
const t = i(5381, JSON.stringify(e)) >>> 0;
|
11
|
+
return o(t, r);
|
12
|
+
};
|
13
|
+
function s(e) {
|
14
|
+
return e ? typeof e != "string" ? s(String(e)) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
|
15
|
+
}
|
16
|
+
export {
|
17
|
+
s as d,
|
18
|
+
c as t
|
19
|
+
};
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";var m=Object.defineProperty;var l=(a,t,s)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>l(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-DKzpenwY.cjs"),p=require("../parse-templates-DVK3iZIl.cjs");class g{constructor(t,s){c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return u.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?p.getTemplateKeys(this._context.config.templates):[]}get css(){var e;const{base:t={},variants:s={},compoundVariants:r=[]}=this.params,i={...t,variants:s,compoundVariants:r};return p.parseStyles(i,`.${this.cssClassName}`,this.priority,(e=this._context)==null?void 0:e.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var n;const o=(n=this.params.defaultVariants)==null?void 0:n[e];return o!==void 0?`${e}=${String(o)}`:e}):void 0,r=new Set([]),i=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return i&&i.forEach((e,o,n)=>{const h=n.at(1);h&&r.add(h)}),{element:t,variantKeys:s,propValueKeys:[...r]}}_withBuildContext(t){this._context=t;const{name:s,config:r}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=g;
|
package/generator/index.js
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
var h = Object.defineProperty;
|
2
|
+
var m = (e, t, s) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
|
+
var c = (e, t, s) => m(e, typeof t != "symbol" ? t + "" : t, s);
|
4
|
+
import { t as l } from "../dash-case-DMQMcCO6.js";
|
5
|
+
import { g, p as u } from "../parse-templates-DUUSaubj.js";
|
6
|
+
class d {
|
7
|
+
constructor(t, s) {
|
8
|
+
c(this, "_callerName");
|
9
|
+
c(this, "_context");
|
10
|
+
this.tagName = t, this.params = s;
|
6
11
|
}
|
7
12
|
get hash() {
|
8
|
-
return
|
13
|
+
return l(this.params.base || this.params);
|
9
14
|
}
|
10
15
|
get priority() {
|
11
16
|
var t;
|
12
|
-
return typeof this.tagName == "function" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
17
|
+
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
13
18
|
}
|
14
19
|
get classNames() {
|
15
|
-
const t = [this.hash], { className: s } = this.
|
20
|
+
const t = [this.hash], { className: s } = this.params;
|
16
21
|
return s && t.push(s), t.join(" ");
|
17
22
|
}
|
18
23
|
get cssClassName() {
|
@@ -23,29 +28,34 @@ class p {
|
|
23
28
|
}
|
24
29
|
get templateKeys() {
|
25
30
|
var t;
|
26
|
-
return (t = this._context) != null && t.config.templates ?
|
31
|
+
return (t = this._context) != null && t.config.templates ? g(this._context.config.templates) : [];
|
27
32
|
}
|
28
33
|
get css() {
|
29
|
-
var
|
30
|
-
|
34
|
+
var a;
|
35
|
+
const { base: t = {}, variants: s = {}, compoundVariants: r = [] } = this.params, i = { ...t, variants: s, compoundVariants: r };
|
36
|
+
return u(i, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
|
31
37
|
}
|
32
38
|
get props() {
|
33
|
-
const { element: t } = this.
|
34
|
-
var
|
35
|
-
const
|
36
|
-
return
|
37
|
-
}) : void 0;
|
38
|
-
return {
|
39
|
+
const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
|
40
|
+
var n;
|
41
|
+
const o = (n = this.params.defaultVariants) == null ? void 0 : n[a];
|
42
|
+
return o !== void 0 ? `${a}=${String(o)}` : a;
|
43
|
+
}) : void 0, r = /* @__PURE__ */ new Set([]), i = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
|
44
|
+
return i && i.forEach((a, o, n) => {
|
45
|
+
const p = n.at(1);
|
46
|
+
p && r.add(p);
|
47
|
+
}), {
|
39
48
|
element: t,
|
40
|
-
variantKeys: s
|
49
|
+
variantKeys: s,
|
50
|
+
propValueKeys: [...r]
|
41
51
|
};
|
42
52
|
}
|
43
53
|
_withBuildContext(t) {
|
44
54
|
this._context = t;
|
45
|
-
const { name: s, config:
|
55
|
+
const { name: s, config: r } = t;
|
46
56
|
return this._callerName = s, this;
|
47
57
|
}
|
48
58
|
}
|
49
59
|
export {
|
50
|
-
|
60
|
+
d as StyleComponentGenerator
|
51
61
|
};
|
@@ -1,14 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { StyledParams, Tag } from '../types';
|
2
|
+
export interface GeneratorProps {
|
3
|
+
element?: string;
|
4
|
+
variantKeys?: string[];
|
5
|
+
propValueKeys?: string[];
|
6
|
+
}
|
2
7
|
export declare class StyleComponentGenerator {
|
3
8
|
tagName: Tag<any>;
|
4
|
-
|
5
|
-
private options;
|
9
|
+
params: StyledParams;
|
6
10
|
_callerName: string | undefined;
|
7
11
|
_context: {
|
8
12
|
name: string;
|
9
13
|
config: any;
|
10
14
|
} | undefined;
|
11
|
-
constructor(tagName: Tag<any>,
|
15
|
+
constructor(tagName: Tag<any>, params: StyledParams);
|
12
16
|
get hash(): string;
|
13
17
|
get priority(): number;
|
14
18
|
get classNames(): string;
|
@@ -16,10 +20,7 @@ export declare class StyleComponentGenerator {
|
|
16
20
|
get cssDisplayNameVar(): string;
|
17
21
|
get templateKeys(): string[];
|
18
22
|
get css(): string;
|
19
|
-
get props():
|
20
|
-
element: string | undefined;
|
21
|
-
variantKeys: string[] | undefined;
|
22
|
-
};
|
23
|
+
get props(): GeneratorProps;
|
23
24
|
_withBuildContext(context: {
|
24
25
|
name: string;
|
25
26
|
config: any;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="/* Empty */";exports.default=e;
|
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.80",
|
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
|
},
|
@@ -19,13 +24,22 @@
|
|
19
24
|
"!**/*.tsbuildinfo"
|
20
25
|
],
|
21
26
|
"nx": {
|
27
|
+
"sourceRoot": "libs/core/src",
|
22
28
|
"name": "core"
|
23
29
|
},
|
24
30
|
"peerDependencies": {
|
25
|
-
"
|
31
|
+
"commander": ">=12.x",
|
32
|
+
"ejs": ">=3.x",
|
33
|
+
"esbuild": ">=0.21.x",
|
34
|
+
"ora": ">=8.x",
|
35
|
+
"react": ">=18.x || >=19.x",
|
26
36
|
"winston": ">=3.x"
|
27
37
|
},
|
28
38
|
"exports": {
|
39
|
+
"./bin/main": {
|
40
|
+
"import": "./bin/main.js",
|
41
|
+
"require": "./bin/main.cjs"
|
42
|
+
},
|
29
43
|
"./compiler": {
|
30
44
|
"import": "./compiler/index.js",
|
31
45
|
"require": "./compiler/index.cjs"
|
@@ -50,5 +64,11 @@
|
|
50
64
|
"import": "./util/index.js",
|
51
65
|
"require": "./util/index.cjs"
|
52
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"
|
53
73
|
}
|
54
74
|
}
|