@salty-css/core 0.0.1-alpha.276 → 0.0.1-alpha.278
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/bin/main.cjs +4 -4
- package/bin/main.js +125 -125
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +13 -13
- package/{index-DV-sarjD.cjs → index-B5Z3hZJn.cjs} +11 -11
- package/{index-CqTDidoK.js → index-WkN_0Aq0.js} +46 -46
- package/package.json +1 -1
- package/parse-styles-Bdgw_4ME.cjs +5 -0
- package/parse-styles-Xjjg0H2Z.js +153 -0
- package/parsers/index.cjs +1 -1
- package/parsers/index.js +2 -2
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-BE-pvAhK.js → should-restart-BCGjmlNw.js} +1 -1
- package/{should-restart-B6uSbFR6.cjs → should-restart-CapzIWDV.cjs} +1 -1
- package/parse-styles-Cq_H5JGg.js +0 -153
- package/parse-styles-DZYIEhB4.cjs +0 -5
package/parse-styles-Cq_H5JGg.js
DELETED
@@ -1,153 +0,0 @@
|
|
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
|
-
c
|
65
|
-
), d = c.includes("salty.config"), l = d ? i[a].templates : i[a], $ = d ? l[n] : l.params[n];
|
66
|
-
if (l && typeof $ == "function") {
|
67
|
-
const j = await $(r), [w] = await y(j, "");
|
68
|
-
return w;
|
69
|
-
}
|
70
|
-
} catch (a) {
|
71
|
-
console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`, a);
|
72
|
-
return;
|
73
|
-
}
|
74
|
-
if (t != null && t.templates && t.templates[n]) {
|
75
|
-
if (m) return;
|
76
|
-
const c = r.split(".").reduce((i, d) => i[d], t.templates[n]);
|
77
|
-
if (c) {
|
78
|
-
const [i] = await y(c, "");
|
79
|
-
return i;
|
80
|
-
}
|
81
|
-
console.warn(`Template "${n}" with path of "${r}" was not found in config!`);
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
if (typeof r == "object") {
|
85
|
-
if (!r) return;
|
86
|
-
if (r.isColor) return h(r.toString());
|
87
|
-
if (n === "defaultVariants") return;
|
88
|
-
if (n === "variants") {
|
89
|
-
const i = Object.entries(r);
|
90
|
-
for (const [d, l] of i) {
|
91
|
-
if (!l) continue;
|
92
|
-
const $ = Object.entries(l);
|
93
|
-
for (const [j, w] of $) {
|
94
|
-
if (!w) continue;
|
95
|
-
const W = `${s}.${d}-${j}`;
|
96
|
-
(await y(w, W, t)).forEach((I) => e.add(I));
|
97
|
-
}
|
98
|
-
}
|
99
|
-
return;
|
100
|
-
}
|
101
|
-
if (n === "compoundVariants") {
|
102
|
-
for (const i of r) {
|
103
|
-
const { css: d, ...l } = i, $ = Object.entries(l).reduce((w, [W, V]) => `${w}.${W}-${V}`, s);
|
104
|
-
(await y(d, $, t)).forEach((w) => e.add(w));
|
105
|
-
}
|
106
|
-
return;
|
107
|
-
}
|
108
|
-
if (n.startsWith("@")) {
|
109
|
-
const i = ((P = t == null ? void 0 : t.mediaQueries) == null ? void 0 : P[n]) || n, d = await z(r, s, t), l = `${i} { ${d} }`;
|
110
|
-
e.add(l);
|
111
|
-
return;
|
112
|
-
}
|
113
|
-
const a = u.includes("&") ? n.replaceAll("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
|
114
|
-
(await y(r, a, t)).forEach((i) => e.add(i));
|
115
|
-
return;
|
116
|
-
}
|
117
|
-
if (typeof r == "number") {
|
118
|
-
const a = Q(b, r, t);
|
119
|
-
return h(a);
|
120
|
-
}
|
121
|
-
if (typeof r != "string")
|
122
|
-
if ("toString" in r) r = r.toString();
|
123
|
-
else throw new Error(`Invalid value type for property ${b}`);
|
124
|
-
return h(r);
|
125
|
-
}, E = p.map(f), { modifiers: x } = t || {}, v = [A(), U(x)], S = (await Promise.all(E).then((u) => Promise.all(
|
126
|
-
u.map((r) => v.reduce(async (n, b) => {
|
127
|
-
const h = await n;
|
128
|
-
if (!h) return h;
|
129
|
-
const C = await b(h);
|
130
|
-
if (!C) return h;
|
131
|
-
const { transformed: P, additionalCss: a } = C;
|
132
|
-
let c = "";
|
133
|
-
if (a)
|
134
|
-
for (const i of a)
|
135
|
-
c += await z(i, "");
|
136
|
-
return `${c}${P}`;
|
137
|
-
}, Promise.resolve(r)))
|
138
|
-
))).filter((u) => u !== void 0).join(`
|
139
|
-
`);
|
140
|
-
if (!S.trim()) return Array.from(e);
|
141
|
-
const T = s ? `${s} {
|
142
|
-
${S}
|
143
|
-
}` : S;
|
144
|
-
return e.has(T) ? Array.from(e) : [T, ...e];
|
145
|
-
}, z = async (o, s, t, m = !1) => (await y(o, s, t, m)).join(`
|
146
|
-
`);
|
147
|
-
export {
|
148
|
-
D as a,
|
149
|
-
U as b,
|
150
|
-
y as c,
|
151
|
-
A as d,
|
152
|
-
z as p
|
153
|
-
};
|
@@ -1,5 +0,0 @@
|
|
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;
|