@salty-css/core 0.0.1-alpha.29 → 0.0.1-alpha.292
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/.saltyrc.schema.json +48 -0
- package/README.md +469 -26
- package/bin/logger.d.ts +1 -0
- package/bin/main.cjs +8 -5
- package/bin/main.js +230 -106
- package/cache/resolve-dynamic-config-cache.cjs +1 -0
- package/cache/resolve-dynamic-config-cache.d.ts +1 -0
- package/cache/resolve-dynamic-config-cache.js +11 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/get-function-range.d.ts +1 -0
- package/compiler/helpers.d.ts +2 -0
- package/compiler/index.cjs +1 -11
- package/compiler/index.d.ts +19 -11
- package/compiler/index.js +20 -172
- package/config/define-config.d.ts +1 -1
- package/config/index.cjs +1 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +12 -2
- package/css/index.cjs +1 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +10 -2
- package/css/keyframes.cjs +1 -0
- package/css/keyframes.d.ts +22 -0
- package/css/keyframes.js +39 -0
- package/css/media.cjs +1 -0
- package/css/media.d.ts +87 -0
- package/css/media.js +88 -0
- package/css/merge.cjs +1 -0
- package/css/merge.d.ts +7 -0
- package/css/merge.js +5 -0
- package/css/token.cjs +1 -0
- package/css/token.d.ts +1 -0
- package/css/token.js +4 -0
- package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
- package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
- package/define-templates-4A2yHcMF.js +52 -0
- package/define-templates-Cunsb_Tr.cjs +1 -0
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-media-query.d.ts +8 -0
- package/factories/define-templates.d.ts +27 -0
- package/factories/define-variables.d.ts +12 -0
- package/factories/index.cjs +1 -0
- package/factories/index.d.ts +4 -0
- package/factories/index.js +30 -0
- package/generators/class-name-generator.d.ts +6 -0
- package/generators/index.cjs +1 -0
- package/generators/index.d.ts +2 -0
- package/generators/index.js +88 -0
- package/generators/styled-generator.d.ts +20 -0
- package/generators/styles-generator.d.ts +22 -0
- package/helpers/color.d.ts +18 -0
- package/helpers/index.cjs +1 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +1154 -0
- package/helpers/viewport-clamp.d.ts +8 -0
- package/helpers-CC5pFyba.cjs +1 -0
- package/helpers-nHqH4L9L.js +11 -0
- package/index-C8WlBhQE.js +524 -0
- package/index-CxAphBMJ.cjs +41 -0
- package/package.json +54 -6
- package/parse-styles-DLPgVsVQ.js +154 -0
- package/parse-styles-DZYIEhB4.cjs +5 -0
- package/parsers/index.cjs +2 -0
- package/parsers/index.d.ts +5 -0
- package/parsers/index.js +33 -0
- package/parsers/parse-modifiers.d.ts +3 -0
- package/parsers/parse-styles.d.ts +13 -0
- package/parsers/parse-templates.d.ts +4 -0
- package/parsers/parse-tokens.d.ts +3 -0
- package/parsers/parser-types.d.ts +8 -0
- package/parsers/property-name-check.d.ts +1 -0
- package/parsers/unit-check.d.ts +7 -0
- package/react-vanilla-file-CCXbsjIb.js +18 -0
- package/react-vanilla-file-CG_WJLam.cjs +15 -0
- package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
- package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
- package/server/index.cjs +1 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +4 -0
- package/server/should-restart.d.ts +1 -0
- package/should-restart-Cp2E_1Lh.cjs +1 -0
- package/should-restart-DaT4pHXq.js +12 -0
- package/templates/salty-reset.d.ts +2 -0
- package/types/cli-types.d.ts +10 -0
- package/types/config-types.d.ts +85 -0
- package/types/index.d.ts +53 -22
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
- package/util/module-type.d.ts +1 -0
- package/viewport-clamp-BOc-8Oph.js +7 -0
- package/viewport-clamp-kY8JqYzm.cjs +1 -0
- package/config/config-types.d.ts +0 -59
- package/generator/index.cjs +0 -1
- package/generator/index.d.ts +0 -1
- package/generator/index.js +0 -61
- package/generator/parse-modifiers.d.ts +0 -3
- package/generator/parse-styles.d.ts +0 -2
- package/generator/parse-templates.d.ts +0 -2
- package/generator/parse-tokens.d.ts +0 -2
- package/generator/parser-types.d.ts +0 -4
- package/generator/style-generator.d.ts +0 -28
- package/parse-templates-D4p3pgQR.js +0 -92
- package/parse-templates-W0YfTmOT.cjs +0 -8
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.292",
|
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
|
},
|
@@ -23,14 +28,21 @@
|
|
23
28
|
"name": "core"
|
24
29
|
},
|
25
30
|
"peerDependencies": {
|
31
|
+
"color": ">=5.x",
|
26
32
|
"commander": ">=12.x",
|
33
|
+
"csstype": "^3.1.x",
|
27
34
|
"ejs": ">=3.x",
|
28
|
-
"esbuild": ">=0.
|
35
|
+
"esbuild": ">=0.25.x",
|
29
36
|
"ora": ">=8.x",
|
30
37
|
"react": ">=18.x || >=19.x",
|
38
|
+
"typescript": ">=5.x",
|
31
39
|
"winston": ">=3.x"
|
32
40
|
},
|
33
41
|
"exports": {
|
42
|
+
"./bin": {
|
43
|
+
"import": "./bin/index.js",
|
44
|
+
"require": "./bin/index.cjs"
|
45
|
+
},
|
34
46
|
"./bin/main": {
|
35
47
|
"import": "./bin/main.js",
|
36
48
|
"require": "./bin/main.cjs"
|
@@ -39,13 +51,41 @@
|
|
39
51
|
"import": "./compiler/index.js",
|
40
52
|
"require": "./compiler/index.cjs"
|
41
53
|
},
|
54
|
+
"./factories": {
|
55
|
+
"import": "./factories/index.js",
|
56
|
+
"require": "./factories/index.cjs"
|
57
|
+
},
|
42
58
|
"./css": {
|
43
59
|
"import": "./css/index.js",
|
44
60
|
"require": "./css/index.cjs"
|
45
61
|
},
|
46
|
-
"./
|
47
|
-
"import": "./
|
48
|
-
"require": "./
|
62
|
+
"./css/keyframes": {
|
63
|
+
"import": "./css/keyframes.js",
|
64
|
+
"require": "./css/keyframes.cjs"
|
65
|
+
},
|
66
|
+
"./css/media": {
|
67
|
+
"import": "./css/media.js",
|
68
|
+
"require": "./css/media.cjs"
|
69
|
+
},
|
70
|
+
"./css/token": {
|
71
|
+
"import": "./css/token.js",
|
72
|
+
"require": "./css/token.cjs"
|
73
|
+
},
|
74
|
+
"./css/merge": {
|
75
|
+
"import": "./css/merge.js",
|
76
|
+
"require": "./css/merge.cjs"
|
77
|
+
},
|
78
|
+
"./helpers": {
|
79
|
+
"import": "./helpers/index.js",
|
80
|
+
"require": "./helpers/index.cjs"
|
81
|
+
},
|
82
|
+
"./generators": {
|
83
|
+
"import": "./generators/index.js",
|
84
|
+
"require": "./generators/index.cjs"
|
85
|
+
},
|
86
|
+
"./parsers": {
|
87
|
+
"import": "./parsers/index.js",
|
88
|
+
"require": "./parsers/index.cjs"
|
49
89
|
},
|
50
90
|
"./config": {
|
51
91
|
"import": "./config/index.js",
|
@@ -58,6 +98,14 @@
|
|
58
98
|
"./util": {
|
59
99
|
"import": "./util/index.js",
|
60
100
|
"require": "./util/index.cjs"
|
101
|
+
},
|
102
|
+
"./server": {
|
103
|
+
"import": "./server/index.js",
|
104
|
+
"require": "./server/index.cjs"
|
105
|
+
},
|
106
|
+
"./cache/resolve-dynamic-config-cache": {
|
107
|
+
"import": "./cache/resolve-dynamic-config-cache.js",
|
108
|
+
"require": "./cache/resolve-dynamic-config-cache.cjs"
|
61
109
|
}
|
62
110
|
},
|
63
111
|
"bin": {
|
@@ -0,0 +1,154 @@
|
|
1
|
+
import { d as O } from "./dash-case-DBThphLm.js";
|
2
|
+
import { d as N } from "./viewport-clamp-BOc-8Oph.js";
|
3
|
+
const U = (o) => (s) => {
|
4
|
+
if (typeof s != "string" || !o) return;
|
5
|
+
let t = s;
|
6
|
+
const m = [];
|
7
|
+
return Object.values(o).forEach((e) => {
|
8
|
+
const { pattern: p, transform: f } = e;
|
9
|
+
t = t.replace(p, (E) => {
|
10
|
+
const { value: x, css: v } = f(E);
|
11
|
+
return v && m.push(v), x;
|
12
|
+
});
|
13
|
+
}), { transformed: t, additionalCss: m };
|
14
|
+
}, A = (o) => (s) => typeof s != "string" || !/\{[^{}]+\}/g.test(s) ? void 0 : { transformed: s.replace(/\{([^{}]+)\}/g, (...e) => {
|
15
|
+
const p = O(e[1].replaceAll(".", "-"));
|
16
|
+
return o && !o.includes(p) && console.warn(`Token ${p} might not exist`), p.startsWith("-") ? `-${p}` : `var(--${p})`;
|
17
|
+
}) }, D = A(), M = [
|
18
|
+
"top",
|
19
|
+
"right",
|
20
|
+
"bottom",
|
21
|
+
"left",
|
22
|
+
"min-width",
|
23
|
+
/.*width.*/,
|
24
|
+
/^[^line]*height.*/,
|
25
|
+
// Exclude line-height
|
26
|
+
/padding.*/,
|
27
|
+
/margin.*/,
|
28
|
+
/border.*/,
|
29
|
+
/inset.*/,
|
30
|
+
/.*radius.*/,
|
31
|
+
/.*spacing.*/,
|
32
|
+
/.*gap.*/,
|
33
|
+
/.*indent.*/,
|
34
|
+
/.*offset.*/,
|
35
|
+
/.*size.*/,
|
36
|
+
/.*thickness.*/,
|
37
|
+
/.*font-size.*/
|
38
|
+
], Q = (o, s, t) => {
|
39
|
+
if (M.some((e) => typeof e == "string" ? e === o : e.test(o))) {
|
40
|
+
const e = (t == null ? void 0 : t.defaultUnit) || "px";
|
41
|
+
if (e.startsWith("viewport-clamp:"))
|
42
|
+
try {
|
43
|
+
const f = e.split(":")[1];
|
44
|
+
return N({
|
45
|
+
screenSize: parseInt(f)
|
46
|
+
})(Number(s));
|
47
|
+
} catch (f) {
|
48
|
+
throw console.error(f), new Error(`Invalid viewport-clamp value: ${e}`);
|
49
|
+
}
|
50
|
+
return `${s}${e}`;
|
51
|
+
}
|
52
|
+
return `${s}`;
|
53
|
+
}, _ = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : _.some((s) => o.startsWith(s)) ? `-${O(o)}` : O(o), y = async (o, s = "", t, m = !1) => {
|
54
|
+
if (!o) throw new Error("No styles provided to parseStyles function!");
|
55
|
+
const e = /* @__PURE__ */ new Set(), p = Object.entries(o), f = async ([u, r]) => {
|
56
|
+
var P;
|
57
|
+
const n = u.trim().replace(/^\?+/g, ""), b = q(n), h = (a, c = ";") => `${b}:${a}${c}`, C = { scope: s, config: t };
|
58
|
+
if (typeof r == "function") return f([u, r(C)]);
|
59
|
+
if (r instanceof Promise) return f([u, await r]);
|
60
|
+
if (t != null && t.templates && t.templatePaths[n])
|
61
|
+
try {
|
62
|
+
const [a, c] = t.templatePaths[n].split(";;"), i = await import(
|
63
|
+
/* webpackIgnore: true */
|
64
|
+
/* @vite-ignore */
|
65
|
+
c
|
66
|
+
), d = c.includes("salty.config"), l = d ? i[a].templates : i[a], $ = d ? l[n] : l.params[n];
|
67
|
+
if (l && typeof $ == "function") {
|
68
|
+
const j = await $(r), [w] = await y(j, "");
|
69
|
+
return w;
|
70
|
+
}
|
71
|
+
} catch (a) {
|
72
|
+
console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`, a);
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
if (t != null && t.templates && t.templates[n]) {
|
76
|
+
if (m) return;
|
77
|
+
const c = r.split(".").reduce((i, d) => i[d], t.templates[n]);
|
78
|
+
if (c) {
|
79
|
+
const [i] = await y(c, "");
|
80
|
+
return i;
|
81
|
+
}
|
82
|
+
console.warn(`Template "${n}" with path of "${r}" was not found in config!`);
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (typeof r == "object") {
|
86
|
+
if (!r) return;
|
87
|
+
if (r.isColor) return h(r.toString());
|
88
|
+
if (n === "defaultVariants") return;
|
89
|
+
if (n === "variants") {
|
90
|
+
const i = Object.entries(r);
|
91
|
+
for (const [d, l] of i) {
|
92
|
+
if (!l) continue;
|
93
|
+
const $ = Object.entries(l);
|
94
|
+
for (const [j, w] of $) {
|
95
|
+
if (!w) continue;
|
96
|
+
const W = `${s}.${d}-${j}`;
|
97
|
+
(await y(w, W, t)).forEach((I) => e.add(I));
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
if (n === "compoundVariants") {
|
103
|
+
for (const i of r) {
|
104
|
+
const { css: d, ...l } = i, $ = Object.entries(l).reduce((w, [W, V]) => `${w}.${W}-${V}`, s);
|
105
|
+
(await y(d, $, t)).forEach((w) => e.add(w));
|
106
|
+
}
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
if (n.startsWith("@")) {
|
110
|
+
const i = ((P = t == null ? void 0 : t.mediaQueries) == null ? void 0 : P[n]) || n, d = await z(r, s, t), l = `${i} { ${d} }`;
|
111
|
+
e.add(l);
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
const a = u.includes("&") ? n.replaceAll("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
|
115
|
+
(await y(r, a, t)).forEach((i) => e.add(i));
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
if (typeof r == "number") {
|
119
|
+
const a = Q(b, r, t);
|
120
|
+
return h(a);
|
121
|
+
}
|
122
|
+
if (typeof r != "string")
|
123
|
+
if ("toString" in r) r = r.toString();
|
124
|
+
else throw new Error(`Invalid value type for property ${b}`);
|
125
|
+
return h(r);
|
126
|
+
}, E = p.map(f), { modifiers: x } = t || {}, v = [A(), U(x)], S = (await Promise.all(E).then((u) => Promise.all(
|
127
|
+
u.map((r) => v.reduce(async (n, b) => {
|
128
|
+
const h = await n;
|
129
|
+
if (!h) return h;
|
130
|
+
const C = await b(h);
|
131
|
+
if (!C) return h;
|
132
|
+
const { transformed: P, additionalCss: a } = C;
|
133
|
+
let c = "";
|
134
|
+
if (a)
|
135
|
+
for (const i of a)
|
136
|
+
c += await z(i, "");
|
137
|
+
return `${c}${P}`;
|
138
|
+
}, Promise.resolve(r)))
|
139
|
+
))).filter((u) => u !== void 0).join(`
|
140
|
+
`);
|
141
|
+
if (!S.trim()) return Array.from(e);
|
142
|
+
const T = s ? `${s} {
|
143
|
+
${S}
|
144
|
+
}` : S;
|
145
|
+
return e.has(T) ? Array.from(e) : [T, ...e];
|
146
|
+
}, z = async (o, s, t, m = !1) => (await y(o, s, t, m)).join(`
|
147
|
+
`);
|
148
|
+
export {
|
149
|
+
D as a,
|
150
|
+
U as b,
|
151
|
+
y as c,
|
152
|
+
A as d,
|
153
|
+
z as p
|
154
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";const x=require("./dash-case-BJEkFEGQ.cjs"),M=require("./viewport-clamp-kY8JqYzm.cjs"),q=o=>s=>{if(typeof s!="string"||!o)return;let t=s;const u=[];return Object.values(o).forEach(e=>{const{pattern:p,transform:f}=e;t=t.replace(p,C=>{const{value:V,css:v}=f(C);return v&&u.push(v),V})}),{transformed:t,additionalCss:u}},A=o=>s=>typeof s!="string"||!/\{[^{}]+\}/g.test(s)?void 0:{transformed:s.replace(/\{([^{}]+)\}/g,(...e)=>{const p=x.dashCase(e[1].replaceAll(".","-"));return o&&!o.includes(p)&&console.warn(`Token ${p} might not exist`),p.startsWith("-")?`-${p}`:`var(--${p})`})},N=A(),U=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],k=(o,s,t)=>{if(U.some(e=>typeof e=="string"?e===o:e.test(o))){const e=(t==null?void 0:t.defaultUnit)||"px";if(e.startsWith("viewport-clamp:"))try{const f=e.split(":")[1];return M.defineViewportClamp({screenSize:parseInt(f)})(Number(s))}catch(f){throw console.error(f),new Error(`Invalid viewport-clamp value: ${e}`)}return`${s}${e}`}return`${s}`},J=["Webkit","Moz","ms","O"],Q=o=>o.startsWith("-")?o:J.some(s=>o.startsWith(s))?`-${x.dashCase(o)}`:x.dashCase(o),$=async(o,s="",t,u=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const e=new Set,p=Object.entries(o),f=async([m,r])=>{var P;const n=m.trim().replace(/^\?+/g,""),b=Q(n),h=(a,c=";")=>`${b}:${a}${c}`,E={scope:s,config:t};if(typeof r=="function")return f([m,r(E)]);if(r instanceof Promise)return f([m,await r]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[a,c]=t.templatePaths[n].split(";;"),i=await import(c),l=c.includes("salty.config"),d=l?i[a].templates:i[a],y=l?d[n]:d.params[n];if(d&&typeof y=="function"){const S=await y(r),[w]=await $(S,"");return w}}catch(a){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,a);return}if(t!=null&&t.templates&&t.templates[n]){if(u)return;const c=r.split(".").reduce((i,l)=>i[l],t.templates[n]);if(c){const[i]=await $(c,"");return i}console.warn(`Template "${n}" with path of "${r}" was not found in config!`);return}if(typeof r=="object"){if(!r)return;if(r.isColor)return h(r.toString());if(n==="defaultVariants")return;if(n==="variants"){const i=Object.entries(r);for(const[l,d]of i){if(!d)continue;const y=Object.entries(d);for(const[S,w]of y){if(!w)continue;const T=`${s}.${l}-${S}`;(await $(w,T,t)).forEach(I=>e.add(I))}}return}if(n==="compoundVariants"){for(const i of r){const{css:l,...d}=i,y=Object.entries(d).reduce((w,[T,z])=>`${w}.${T}-${z}`,s);(await $(l,y,t)).forEach(w=>e.add(w))}return}if(n.startsWith("@")){const i=((P=t==null?void 0:t.mediaQueries)==null?void 0:P[n])||n,l=await W(r,s,t),d=`${i} { ${l} }`;e.add(d);return}const a=m.includes("&")?n.replaceAll("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`;(await $(r,a,t)).forEach(i=>e.add(i));return}if(typeof r=="number"){const a=k(b,r,t);return h(a)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${b}`);return h(r)},C=p.map(f),{modifiers:V}=t||{},v=[A(),q(V)],j=(await Promise.all(C).then(m=>Promise.all(m.map(r=>v.reduce(async(n,b)=>{const h=await n;if(!h)return h;const E=await b(h);if(!E)return h;const{transformed:P,additionalCss:a}=E;let c="";if(a)for(const i of a)c+=await W(i,"");return`${c}${P}`},Promise.resolve(r)))))).filter(m=>m!==void 0).join(`
|
2
|
+
`);if(!j.trim())return Array.from(e);const O=s?`${s} {
|
3
|
+
${j}
|
4
|
+
}`:j;return e.has(O)?Array.from(e):[O,...e]},W=async(o,s,t,u=!1)=>(await $(o,s,t,u)).join(`
|
5
|
+
`);exports.parseAndJoinStyles=W;exports.parseStyles=$;exports.parseValueModifiers=q;exports.parseValueTokens=A;exports.parseVariableTokens=N;
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-DZYIEhB4.cjs"),c=require("../dash-case-BJEkFEGQ.cjs"),p=async(e,s=[])=>{if(!e)return"";const t=[],r={};for(const[n,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const i=n.trim(),u=await p(o,[...s,i]);t.push(u)}else r[n]=o;if(Object.keys(r).length){const n=s.map(c.dashCase).join("-"),o="t_"+c.toHash(n,4),i=await a.parseAndJoinStyles(r,`.${n}, .${o}`);t.push(i)}return t.join(`
|
2
|
+
`)},y=e=>Object.keys(e),f=e=>e?Object.entries(e).reduce((s,[t,r])=>(typeof r=="function"?s[t]="any":typeof r=="object"&&(s[t]=l(r).map(n=>`"${n}"`).join(" | ")),s),{}):{},l=(e,s="",t=new Set)=>e?(Object.entries(e).forEach(([r,n])=>{const o=s?`${s}.${r}`:r;return typeof n=="object"?l(n,o,t):t.add(s)}),[...t]):[];exports.parseAndJoinStyles=a.parseAndJoinStyles;exports.parseStyles=a.parseStyles;exports.parseValueModifiers=a.parseValueModifiers;exports.parseValueTokens=a.parseValueTokens;exports.parseVariableTokens=a.parseVariableTokens;exports.getTemplateKeys=y;exports.getTemplateTokens=l;exports.getTemplateTypes=f;exports.parseTemplates=p;
|
package/parsers/index.js
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
import { p as f } from "../parse-styles-DLPgVsVQ.js";
|
2
|
+
import { c as T, b as O, d as $, a as g } from "../parse-styles-DLPgVsVQ.js";
|
3
|
+
import { d as p, t as u } from "../dash-case-DBThphLm.js";
|
4
|
+
const l = async (e, s = []) => {
|
5
|
+
if (!e) return "";
|
6
|
+
const t = [], r = {};
|
7
|
+
for (const [n, o] of Object.entries(e))
|
8
|
+
if (typeof o != "function") if (o && typeof o == "object") {
|
9
|
+
const a = n.trim(), c = await l(o, [...s, a]);
|
10
|
+
t.push(c);
|
11
|
+
} else
|
12
|
+
r[n] = o;
|
13
|
+
if (Object.keys(r).length) {
|
14
|
+
const n = s.map(p).join("-"), o = "t_" + u(n, 4), a = await f(r, `.${n}, .${o}`);
|
15
|
+
t.push(a);
|
16
|
+
}
|
17
|
+
return t.join(`
|
18
|
+
`);
|
19
|
+
}, b = (e) => Object.keys(e), m = (e) => e ? Object.entries(e).reduce((s, [t, r]) => (typeof r == "function" ? s[t] = "any" : typeof r == "object" && (s[t] = i(r).map((n) => `"${n}"`).join(" | ")), s), {}) : {}, i = (e, s = "", t = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([r, n]) => {
|
20
|
+
const o = s ? `${s}.${r}` : r;
|
21
|
+
return typeof n == "object" ? i(n, o, t) : t.add(s);
|
22
|
+
}), [...t]) : [];
|
23
|
+
export {
|
24
|
+
b as getTemplateKeys,
|
25
|
+
i as getTemplateTokens,
|
26
|
+
m as getTemplateTypes,
|
27
|
+
f as parseAndJoinStyles,
|
28
|
+
T as parseStyles,
|
29
|
+
l as parseTemplates,
|
30
|
+
O as parseValueModifiers,
|
31
|
+
$ as parseValueTokens,
|
32
|
+
g as parseVariableTokens
|
33
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { CachedConfig, SaltyConfig } from '../types/config-types';
|
2
|
+
/**
|
3
|
+
* Transform styles object to css string with or without scope
|
4
|
+
* @param styles CSS as JS object
|
5
|
+
* @param currentScope Scope of the styles, for class names full path with dot separator is required
|
6
|
+
* @param config Salty config object to allow use of templates and media queries etc.
|
7
|
+
* @param omitTemplates If true, static templates will be ignored
|
8
|
+
* @returns CSS strings that can be injected to the .css file or used inside of styles tag
|
9
|
+
* - First item is the main class with all the styles
|
10
|
+
* - Rest of the items are child selectors or media queries etc.
|
11
|
+
*/
|
12
|
+
export declare const parseStyles: <T extends object>(styles?: T, currentScope?: string, config?: (SaltyConfig & CachedConfig) | CachedConfig | undefined, omitTemplates?: boolean) => Promise<string[]>;
|
13
|
+
export declare const parseAndJoinStyles: <T extends object>(styles: T, currentClass: string, config?: (SaltyConfig & CachedConfig) | undefined, omitTemplates?: boolean) => Promise<string>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export declare const parseTemplates: <T extends object>(obj: T, path?: PropertyKey[]) => Promise<string>;
|
2
|
+
export declare const getTemplateKeys: <T extends object>(templates: T) => string[];
|
3
|
+
export declare const getTemplateTypes: <T extends object>(templates: T) => Record<string, string>;
|
4
|
+
export declare const getTemplateTokens: <T extends object>(templates: T, parent?: string, templateTokens?: Set<string>) => string[];
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export interface ValueParserReturnValue {
|
2
|
+
transformed: string;
|
3
|
+
additionalCss?: object[];
|
4
|
+
}
|
5
|
+
type StyleValueModifierFunctionReturnValue = undefined | ValueParserReturnValue;
|
6
|
+
export type SyncronousStyleValueModifierFunction = (current: unknown) => StyleValueModifierFunctionReturnValue;
|
7
|
+
export type StyleValueModifierFunction = (current: string) => Promise<StyleValueModifierFunctionReturnValue> | StyleValueModifierFunctionReturnValue;
|
8
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const propertyNameCheck: (key: string) => string;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { SaltyConfig } from '../config';
|
2
|
+
/**
|
3
|
+
* Add unit to a number value based on property name
|
4
|
+
* @param key - The property name
|
5
|
+
* @param value - The value to add unit to
|
6
|
+
*/
|
7
|
+
export declare const addUnit: (key: string, value: string | number, config?: SaltyConfig) => string;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
const n = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
2
|
+
|
3
|
+
interface <%- componentName %>Props {
|
4
|
+
text?: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
8
|
+
return (
|
9
|
+
<<%- styledComponentName %>>
|
10
|
+
{text}
|
11
|
+
</<%- styledComponentName %>>
|
12
|
+
);
|
13
|
+
};
|
14
|
+
|
15
|
+
export default <%- componentName %>;`;
|
16
|
+
export {
|
17
|
+
n as default
|
18
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
2
|
+
|
3
|
+
interface <%- componentName %>Props {
|
4
|
+
text?: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
8
|
+
return (
|
9
|
+
<<%- styledComponentName %>>
|
10
|
+
{text}
|
11
|
+
</<%- styledComponentName %>>
|
12
|
+
);
|
13
|
+
};
|
14
|
+
|
15
|
+
export default <%- componentName %>;`;exports.default=e;
|
@@ -1,6 +1,7 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { defineConfig } from '@salty-css/core/config';
|
2
2
|
|
3
3
|
export const config = defineConfig({
|
4
4
|
// Add your custom config here
|
5
|
+
externalModules: ['react', 'react-dom']
|
5
6
|
});
|
6
|
-
`;exports.default=
|
7
|
+
`;exports.default=e;
|
package/server/index.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-Cp2E_1Lh.cjs");exports.checkShouldRestart=e.checkShouldRestart;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './should-restart';
|
package/server/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const checkShouldRestart: (filename: string) => Promise<boolean>;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const s=require("fs/promises"),r=require("./index-CxAphBMJ.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { readFile as r } from "fs/promises";
|
2
|
+
import { i as e } from "./index-C8WlBhQE.js";
|
3
|
+
const f = async (t) => {
|
4
|
+
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
|
+
if (t.includes("salty.config")) return !0;
|
6
|
+
if (!e(t)) return !1;
|
7
|
+
const s = await r(t, "utf-8");
|
8
|
+
return !!(/.+define[A-Z]\w+/.test(s) || /.+keyframes\(.+/.test(s));
|
9
|
+
};
|
10
|
+
export {
|
11
|
+
f as c
|
12
|
+
};
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { BaseStyles, CssStyles, MediaQueryStyles } from '../types';
|
2
|
+
import { OrString } from '../types/util-types';
|
3
|
+
export type GlobalStyles = Record<string, BaseStyles>;
|
4
|
+
export type CssVariableTokensObject = Record<string, unknown>;
|
5
|
+
export interface CssResponsiveVariables {
|
6
|
+
[key: string]: CssVariableTokensObject;
|
7
|
+
}
|
8
|
+
export interface CssConditionalVariables {
|
9
|
+
[key: PropertyKey]: {
|
10
|
+
[key: PropertyKey]: CssVariableTokensObject;
|
11
|
+
};
|
12
|
+
}
|
13
|
+
export interface SaltyVariables {
|
14
|
+
responsive?: CssResponsiveVariables;
|
15
|
+
conditional?: CssConditionalVariables;
|
16
|
+
[key: string]: undefined | string | number | CssVariableTokensObject;
|
17
|
+
}
|
18
|
+
type CssTemplate = MediaQueryStyles | CssStyles | {
|
19
|
+
[key: PropertyKey]: CssTemplate;
|
20
|
+
};
|
21
|
+
export interface CssTemplateObject {
|
22
|
+
[key: PropertyKey]: CssTemplate;
|
23
|
+
}
|
24
|
+
export interface CssTemplateFunction {
|
25
|
+
(value: any): CssTemplate;
|
26
|
+
}
|
27
|
+
export interface CssTemplates {
|
28
|
+
[key: PropertyKey]: CssTemplateObject | CssTemplateFunction;
|
29
|
+
}
|
30
|
+
export interface CssModifier {
|
31
|
+
pattern: RegExp;
|
32
|
+
transform: (regexMatch: string) => {
|
33
|
+
css?: CssStyles;
|
34
|
+
value: string;
|
35
|
+
};
|
36
|
+
}
|
37
|
+
export type CssModifiers = Record<string, CssModifier>;
|
38
|
+
export interface SaltyConfig {
|
39
|
+
/**
|
40
|
+
* The import strategy to use when importing css files.
|
41
|
+
* - `root` will import the css file from the root of the project.
|
42
|
+
* - `component` will import the css file from the component's directory.
|
43
|
+
*/
|
44
|
+
importStrategy?: 'root' | 'component';
|
45
|
+
/**
|
46
|
+
* Base level variables that can be used in all styles as they are applied globally to :root.
|
47
|
+
@param responsive Variables that are defined for different media queries.
|
48
|
+
@param conditional Variables that are defined for different parent selectors (classes or data attributes).
|
49
|
+
*/
|
50
|
+
variables?: SaltyVariables;
|
51
|
+
/**
|
52
|
+
* The global styles that are imported in the root of the project.
|
53
|
+
*/
|
54
|
+
reset?: 'default' | 'none' | GlobalStyles;
|
55
|
+
/**
|
56
|
+
* The global styles that are imported in the root of the project.
|
57
|
+
*/
|
58
|
+
global?: GlobalStyles;
|
59
|
+
/**
|
60
|
+
* The templates that can be used in styles to create reusable css.
|
61
|
+
*/
|
62
|
+
templates?: CssTemplates;
|
63
|
+
/**
|
64
|
+
* The modifiers that can transform css values.
|
65
|
+
*/
|
66
|
+
modifiers?: CssModifiers;
|
67
|
+
/**
|
68
|
+
* 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.
|
69
|
+
*/
|
70
|
+
externalModules?: ('react' | 'react-dom' | OrString)[];
|
71
|
+
/**
|
72
|
+
* default unit for px based properties when providing a number value. Default is 'px'.
|
73
|
+
*/
|
74
|
+
defaultUnit?: 'px' | 'rem' | 'em' | 'vh' | 'vw' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'ex' | 'fr' | 'percent' | `viewport-clamp:${number}` | OrString;
|
75
|
+
}
|
76
|
+
export interface CachedConfig {
|
77
|
+
templates: CssTemplates;
|
78
|
+
staticVariables: Record<string, any>;
|
79
|
+
mediaQueries: Record<string, string>;
|
80
|
+
modifiers?: CssModifiers;
|
81
|
+
templatePaths: {
|
82
|
+
[key: string]: string;
|
83
|
+
};
|
84
|
+
}
|
85
|
+
export {};
|