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