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