@salty-css/core 0.0.1-alpha.7 → 0.0.1-alpha.70
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 +219 -0
- package/bin/prettier.d.ts +1 -0
- package/compiler/index.cjs +9 -9
- package/compiler/index.d.ts +5 -5
- package/compiler/index.js +149 -133
- package/config/config-types.d.ts +12 -6
- 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,196 @@
|
|
1
|
-
import * as
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import { toHash as T, dashCase as I } from "../util/index.js";
|
1
|
+
import * as z from "esbuild";
|
2
|
+
import { execSync as q } from "child_process";
|
3
|
+
import { t as v, d as _ } from "../dash-case-DMQMcCO6.js";
|
5
4
|
import { join as o } from "path";
|
6
|
-
import { writeFileSync as
|
7
|
-
import { writeFile as
|
8
|
-
import { p as
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
import { writeFileSync as F, existsSync as A, mkdirSync as E, statSync as L, readdirSync as U, readFileSync as M } from "fs";
|
6
|
+
import { writeFile as X } from "fs/promises";
|
7
|
+
import { p as Y, a as Z, b as Q } from "../parse-templates-DUUSaubj.js";
|
8
|
+
const W = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", V = {
|
9
|
+
externalModules: []
|
10
|
+
}, H = (t) => {
|
11
|
+
if (V.externalModules.length > 0) return V.externalModules;
|
12
|
+
const e = o(t, "salty.config.ts"), s = M(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
13
|
+
if (!s) return [];
|
14
|
+
const a = s[1].split(",").map((w) => w.replace(/['"`]/g, "").trim());
|
15
|
+
return V.externalModules = a, a;
|
16
|
+
}, N = (t) => o(t, "./saltygen"), tt = ["salty", "css", "styles", "styled"], st = (t = []) => new RegExp(`\\.(${[...tt, ...t].join("|")})\\.`), O = (t, e = []) => st(e).test(t), et = async (t) => {
|
17
|
+
const e = N(t), n = o(t, "salty.config.ts"), s = o(e, "salty.config.js"), a = W(), w = H(t);
|
18
|
+
await z.build({
|
16
19
|
entryPoints: [n],
|
17
20
|
minify: !0,
|
18
21
|
treeShaking: !0,
|
19
22
|
bundle: !0,
|
20
|
-
outfile:
|
21
|
-
format:
|
22
|
-
external:
|
23
|
+
outfile: s,
|
24
|
+
format: a,
|
25
|
+
external: w
|
23
26
|
});
|
24
|
-
const
|
25
|
-
return
|
26
|
-
},
|
27
|
-
const e = await
|
28
|
-
if (!
|
29
|
-
if (typeof
|
30
|
-
const C = [...l,
|
27
|
+
const f = Date.now(), { config: y } = await import(`${s}?t=${f}`);
|
28
|
+
return y;
|
29
|
+
}, nt = async (t) => {
|
30
|
+
const e = await et(t), n = /* @__PURE__ */ new Set(), s = (i, l = []) => i ? Object.entries(i).flatMap(([m, p]) => {
|
31
|
+
if (!p) return;
|
32
|
+
if (typeof p == "object") return s(p, [...l, m]);
|
33
|
+
const C = [...l, m].join(".");
|
31
34
|
n.add(`"${C}"`);
|
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
|
51
|
-
entryPoints: [
|
35
|
+
const d = [...l.map(_), _(m)].join("-"), { result: h } = Q(p);
|
36
|
+
return `--${d}: ${h};`;
|
37
|
+
}) : [], a = (i) => i ? Object.entries(i).flatMap(([l, m]) => {
|
38
|
+
const p = s(m);
|
39
|
+
return l === "base" ? p.join("") : `${l} { ${p.join("")} }`;
|
40
|
+
}) : [], w = (i) => i ? Object.entries(i).flatMap(([l, m]) => Object.entries(m).flatMap(([p, C]) => {
|
41
|
+
const d = s(C, [l]), h = `.${l}-${p}, [data-${l}="${p}"]`, k = d.join("");
|
42
|
+
return `${h} { ${k} }`;
|
43
|
+
})) : [], f = s(e.variables), y = a(e.responsiveVariables), r = w(e.conditionalVariables), S = N(t), $ = o(S, "css/variables.css"), D = `:root { ${f.join("")} ${y.join("")} } ${r.join("")}`;
|
44
|
+
F($, D);
|
45
|
+
const g = o(S, "types/css-tokens.d.ts"), u = `type VariableTokens = ${[...n].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
46
|
+
F(g, u);
|
47
|
+
const j = o(S, "css/global.css"), x = Y(e.global, "");
|
48
|
+
F(j, x);
|
49
|
+
const b = o(S, "css/templates.css"), T = Z(e.templates);
|
50
|
+
F(b, T);
|
51
|
+
}, R = async (t, e, n) => {
|
52
|
+
const s = v(e), a = o(n, "js", s + ".js"), w = W(), f = H(t);
|
53
|
+
await z.build({
|
54
|
+
entryPoints: [e],
|
52
55
|
minify: !0,
|
53
56
|
treeShaking: !0,
|
54
57
|
bundle: !0,
|
55
|
-
outfile:
|
56
|
-
format:
|
58
|
+
outfile: a,
|
59
|
+
format: w,
|
57
60
|
target: ["es2022"],
|
58
61
|
keepNames: !0,
|
59
|
-
external:
|
62
|
+
external: f
|
60
63
|
});
|
61
|
-
const
|
62
|
-
return await import(`${
|
63
|
-
},
|
64
|
-
const e =
|
65
|
-
return
|
66
|
-
},
|
64
|
+
const y = Date.now();
|
65
|
+
return await import(`${a}?t=${y}`);
|
66
|
+
}, B = async (t) => {
|
67
|
+
const e = N(t), n = o(e, "salty.config.js"), { config: s } = await import(n);
|
68
|
+
return s;
|
69
|
+
}, pt = async (t) => {
|
67
70
|
try {
|
68
|
-
const e = [], n = [],
|
71
|
+
const e = [], n = [], s = N(t), a = o(s, "index.css");
|
69
72
|
(() => {
|
70
|
-
|
71
|
-
})(), await
|
72
|
-
const
|
73
|
-
async function
|
74
|
-
const
|
75
|
-
if (
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
73
|
+
A(s) && q("rm -rf " + s), E(s), E(o(s, "css")), E(o(s, "types"));
|
74
|
+
})(), await nt(t);
|
75
|
+
const f = await B(t);
|
76
|
+
async function y(c, u) {
|
77
|
+
const j = ["node_modules", "saltygen"], x = L(c);
|
78
|
+
if (x.isDirectory()) {
|
79
|
+
const b = U(c);
|
80
|
+
if (j.some((i) => c.includes(i))) return;
|
81
|
+
await Promise.all(b.map((i) => y(o(c, i), o(u, i))));
|
82
|
+
} else if (x.isFile() && O(c)) {
|
83
|
+
const T = await R(t, c, s), i = [];
|
84
|
+
Object.entries(T).forEach(([C, d]) => {
|
85
|
+
if (d.isKeyframes && d.css) {
|
86
|
+
const I = `${d.animationName}.css`, G = `css/${I}`, J = o(s, G);
|
87
|
+
e.push(I), F(J, d.css);
|
84
88
|
return;
|
85
89
|
}
|
86
|
-
if (!
|
87
|
-
const
|
88
|
-
name:
|
89
|
-
config:
|
90
|
-
}),
|
91
|
-
n[
|
92
|
-
const
|
93
|
-
|
90
|
+
if (!d.generator) return;
|
91
|
+
const h = d.generator._withBuildContext({
|
92
|
+
name: C,
|
93
|
+
config: f
|
94
|
+
}), k = `${h.hash}-${h.priority}.css`;
|
95
|
+
n[h.priority] || (n[h.priority] = []), n[h.priority].push(k), i.push(k);
|
96
|
+
const P = `css/${k}`, K = o(s, P);
|
97
|
+
F(K, h.css);
|
94
98
|
});
|
95
|
-
const
|
96
|
-
`),
|
97
|
-
|
99
|
+
const l = i.map((C) => `@import url('./${C}');`).join(`
|
100
|
+
`), m = v(c, 6), p = o(s, `css/${m}.css`);
|
101
|
+
F(p, l);
|
98
102
|
}
|
99
103
|
}
|
100
|
-
await
|
101
|
-
const
|
104
|
+
await y(t, s);
|
105
|
+
const r = e.map((c) => `@import url('./css/${c}');`).join(`
|
102
106
|
`);
|
103
|
-
let
|
107
|
+
let g = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
104
108
|
|
105
|
-
${["
|
109
|
+
${["variables.css", "global.css", "templates.css"].filter((c) => {
|
110
|
+
try {
|
111
|
+
return M(o(s, "css", c), "utf8").length > 0;
|
112
|
+
} catch {
|
113
|
+
return !1;
|
114
|
+
}
|
115
|
+
}).map((c) => `@import url('./css/${c}');`).join(`
|
106
116
|
`)}
|
107
|
-
${
|
108
|
-
if (
|
109
|
-
const
|
117
|
+
${r}`;
|
118
|
+
if (f.importStrategy !== "component") {
|
119
|
+
const c = n.flat().map((u) => `@import url('./css/${u}');`).join(`
|
110
120
|
`);
|
111
|
-
|
121
|
+
g += c;
|
112
122
|
}
|
113
|
-
|
123
|
+
F(a, g);
|
114
124
|
} catch (e) {
|
115
125
|
console.error(e);
|
116
126
|
}
|
117
|
-
},
|
127
|
+
}, ft = async (t, e) => {
|
118
128
|
try {
|
119
|
-
const n = [],
|
129
|
+
const n = [], s = o(t, "./saltygen"), a = o(s, "index.css");
|
120
130
|
if (O(e)) {
|
121
|
-
const
|
122
|
-
Object.entries(
|
123
|
-
if (!
|
124
|
-
const u =
|
125
|
-
name:
|
126
|
-
config:
|
127
|
-
}),
|
128
|
-
n.push(
|
131
|
+
const f = await B(t), y = await R(t, e, s);
|
132
|
+
Object.entries(y).forEach(([g, c]) => {
|
133
|
+
if (!c.generator) return;
|
134
|
+
const u = c.generator._withBuildContext({
|
135
|
+
name: g,
|
136
|
+
config: f
|
137
|
+
}), j = `${u.hash}-${u.priority}.css`, x = `css/${j}`, b = o(s, x);
|
138
|
+
n.push(j), F(b, u.css);
|
129
139
|
});
|
130
|
-
const
|
131
|
-
`),
|
140
|
+
const r = M(a, "utf8").split(`
|
141
|
+
`), S = n.map((g) => `@import url('../saltygen/css/${g}');`), D = [.../* @__PURE__ */ new Set([...r, ...S])].join(`
|
132
142
|
`);
|
133
|
-
|
143
|
+
F(a, D);
|
134
144
|
}
|
135
145
|
} catch (n) {
|
136
146
|
console.error(n);
|
137
147
|
}
|
138
|
-
},
|
148
|
+
}, ut = async (t, e) => {
|
139
149
|
try {
|
140
|
-
const n = o(
|
150
|
+
const n = o(t, "./saltygen");
|
141
151
|
if (O(e)) {
|
142
|
-
|
143
|
-
|
144
|
-
const
|
145
|
-
let
|
146
|
-
Object.entries(
|
147
|
-
var
|
148
|
-
if (
|
149
|
-
|
150
|
-
|
152
|
+
const a = M(e, "utf8");
|
153
|
+
a.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== a && await X(e, a);
|
154
|
+
const f = await B(t), y = await R(t, e, n);
|
155
|
+
let r = a;
|
156
|
+
Object.entries(y).forEach(([$, D]) => {
|
157
|
+
var k;
|
158
|
+
if (D.isKeyframes || !D.generator) return;
|
159
|
+
const g = D.generator._withBuildContext({
|
160
|
+
name: $,
|
161
|
+
config: f
|
162
|
+
}), c = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
|
163
|
+
if (!c) return console.error("Could not find the original declaration");
|
164
|
+
const u = (k = c.at(1)) == null ? void 0 : k.trim(), j = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(r);
|
165
|
+
if (!j) return console.error("Could not find the original declaration");
|
166
|
+
const { index: x } = j;
|
167
|
+
let b = !1;
|
168
|
+
const T = setTimeout(() => b = !0, 5e3);
|
169
|
+
let i = 0, l = !1, m = 0;
|
170
|
+
for (; !l && !b; ) {
|
171
|
+
const P = r[x + i];
|
172
|
+
P === "(" && m++, P === ")" && m--, m === 0 && P === ")" && (l = !0), i > r.length && (b = !0), i++;
|
151
173
|
}
|
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);
|
174
|
+
if (!b) clearTimeout(T);
|
175
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
176
|
+
const p = x + i, C = r.slice(x, p), d = r, h = ` ${$} = styled(${u}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`;
|
177
|
+
r = r.replace(C, h), d === r && console.error("Minimize file failed to change content", { name: $, tagName: u });
|
163
178
|
});
|
164
|
-
const
|
165
|
-
return
|
166
|
-
${
|
179
|
+
const S = v(e, 6);
|
180
|
+
return f.importStrategy === "component" && (r = `import '../../saltygen/css/${S}.css';
|
181
|
+
${r}`), r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
|
167
182
|
}
|
168
183
|
} catch (n) {
|
169
|
-
console.error(n);
|
184
|
+
console.error("Error in minimizeFile:", n);
|
170
185
|
}
|
171
186
|
};
|
172
187
|
export {
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
188
|
+
R as compileSaltyFile,
|
189
|
+
nt as generateConfigStyles,
|
190
|
+
pt as generateCss,
|
191
|
+
ft as generateFile,
|
177
192
|
O as isSaltyFile,
|
178
|
-
|
179
|
-
|
193
|
+
ut as minimizeFile,
|
194
|
+
tt as saltyFileExtensions,
|
195
|
+
st as saltyFileRegExp
|
180
196
|
};
|
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;
|
@@ -30,11 +32,11 @@ export interface SaltyConfig {
|
|
30
32
|
* - `root` will import the css file from the root of the project.
|
31
33
|
* - `component` will import the css file from the component's directory.
|
32
34
|
*/
|
33
|
-
importStrategy
|
35
|
+
importStrategy?: 'root' | 'component';
|
34
36
|
/**
|
35
37
|
* Base variables that can be used in all styles as they are applied globally to :root.
|
36
38
|
*/
|
37
|
-
variables
|
39
|
+
variables?: CssVariables;
|
38
40
|
/**
|
39
41
|
* Variables that are defined for different media queries.
|
40
42
|
*/
|
@@ -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.70",
|
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
|
}
|