@salty-css/core 0.0.1-alpha.183 → 0.0.1-alpha.186
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 +6 -6
- package/bin/main.js +125 -125
- package/compiler/index.cjs +1 -1
- package/compiler/index.d.ts +3 -0
- package/compiler/index.js +1 -1
- package/css/class-name.d.ts +16 -0
- package/css/index.cjs +1 -1
- package/css/index.d.ts +1 -0
- package/css/index.js +83 -54
- package/generator/index.cjs +1 -1
- package/generator/index.js +11 -11
- package/index-BmsXxgnE.cjs +30 -0
- package/index-DKkgPK-r.js +433 -0
- package/package.json +1 -1
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/types/index.d.ts +1 -1
- package/index-BjclEscx.js +0 -404
- package/index-zPXqhZf1.cjs +0 -29
package/css/index.js
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import { p
|
5
|
-
import { t as
|
6
|
-
import { m as
|
7
|
-
const
|
8
|
-
const
|
1
|
+
var S = Object.defineProperty;
|
2
|
+
var C = (r, t, s) => t in r ? S(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s;
|
3
|
+
var h = (r, t, s) => C(r, typeof t != "symbol" ? t + "" : t, s);
|
4
|
+
import { p } from "../parse-styles-DrLhKtqW.js";
|
5
|
+
import { t as g, d as _ } from "../dash-case-DBThphLm.js";
|
6
|
+
import { m as W } from "../merge-BVm9us1A.js";
|
7
|
+
const O = ({ animationName: r, params: t, appendInitialStyles: s, ...e }) => {
|
8
|
+
const n = r || g(e), i = (o = {}) => {
|
9
9
|
const {
|
10
|
-
duration:
|
11
|
-
easing:
|
12
|
-
delay:
|
13
|
-
iterationCount:
|
14
|
-
direction:
|
15
|
-
fillMode:
|
10
|
+
duration: a = "500ms",
|
11
|
+
easing: c = "ease-in-out",
|
12
|
+
delay: m = "0s",
|
13
|
+
iterationCount: l = "1",
|
14
|
+
direction: f = "normal",
|
15
|
+
fillMode: N = "forwards",
|
16
16
|
playState: v = "running"
|
17
|
-
} = { ...t, ...o },
|
18
|
-
if (!
|
19
|
-
const
|
20
|
-
if (!
|
21
|
-
const
|
22
|
-
return `${
|
23
|
-
},
|
24
|
-
if (!
|
25
|
-
const
|
26
|
-
return `${o}${
|
27
|
-
}, ""),
|
28
|
-
return Object.assign(
|
29
|
-
toString:
|
17
|
+
} = { ...t, ...o }, $ = `${n} ${a} ${c} ${m} ${l} ${f} ${N} ${v}`;
|
18
|
+
if (!s) return $;
|
19
|
+
const d = e.from || e["0%"];
|
20
|
+
if (!d) return $;
|
21
|
+
const y = p(d, "");
|
22
|
+
return `${$};${y}`;
|
23
|
+
}, b = Object.entries(e).reduce((o, [a, c]) => {
|
24
|
+
if (!c) return o;
|
25
|
+
const m = p(c, ""), l = typeof a == "number" ? `${a}%` : a;
|
26
|
+
return `${o}${l}{${m}}`;
|
27
|
+
}, ""), x = `@keyframes ${n} {${b}}`;
|
28
|
+
return Object.assign(i, {
|
29
|
+
toString: i,
|
30
30
|
isKeyframes: !0,
|
31
|
-
animationName:
|
32
|
-
css:
|
33
|
-
keyframes:
|
34
|
-
}),
|
31
|
+
animationName: n,
|
32
|
+
css: x,
|
33
|
+
keyframes: e
|
34
|
+
}), i;
|
35
35
|
};
|
36
|
-
class
|
36
|
+
class u {
|
37
37
|
constructor(t = "@media") {
|
38
|
-
|
39
|
-
const
|
40
|
-
return Object.assign(
|
38
|
+
h(this, "next", (t) => {
|
39
|
+
const s = new String(t);
|
40
|
+
return Object.assign(s, {
|
41
41
|
get isMedia() {
|
42
42
|
return !0;
|
43
43
|
},
|
44
44
|
get and() {
|
45
|
-
return new
|
45
|
+
return new u(`${t} and`);
|
46
46
|
},
|
47
47
|
get or() {
|
48
|
-
return new
|
48
|
+
return new u(`${t},`);
|
49
49
|
}
|
50
|
-
}),
|
50
|
+
}), s;
|
51
51
|
});
|
52
52
|
this.base = t;
|
53
53
|
}
|
@@ -55,20 +55,20 @@ class a {
|
|
55
55
|
return this.next(`${this.base} ${t}`);
|
56
56
|
}
|
57
57
|
minWidth(t) {
|
58
|
-
const
|
59
|
-
return this.next(
|
58
|
+
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (min-width: ${s})`;
|
59
|
+
return this.next(e);
|
60
60
|
}
|
61
61
|
maxWidth(t) {
|
62
|
-
const
|
63
|
-
return this.next(
|
62
|
+
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (max-width: ${s})`;
|
63
|
+
return this.next(e);
|
64
64
|
}
|
65
65
|
minHeight(t) {
|
66
|
-
const
|
67
|
-
return this.next(
|
66
|
+
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (min-height: ${s})`;
|
67
|
+
return this.next(e);
|
68
68
|
}
|
69
69
|
maxHeight(t) {
|
70
|
-
const
|
71
|
-
return this.next(
|
70
|
+
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (max-height: ${s})`;
|
71
|
+
return this.next(e);
|
72
72
|
}
|
73
73
|
get portrait() {
|
74
74
|
const t = `${this.base} (orientation: portrait)`;
|
@@ -79,8 +79,8 @@ class a {
|
|
79
79
|
return this.next(t);
|
80
80
|
}
|
81
81
|
prefersColorScheme(t) {
|
82
|
-
const
|
83
|
-
return this.next(
|
82
|
+
const s = `${this.base} (prefers-color-scheme: ${t})`;
|
83
|
+
return this.next(s);
|
84
84
|
}
|
85
85
|
get dark() {
|
86
86
|
return this.prefersColorScheme("dark");
|
@@ -113,11 +113,40 @@ class a {
|
|
113
113
|
return this.next(t);
|
114
114
|
}
|
115
115
|
}
|
116
|
-
const
|
116
|
+
const k = new u(), z = (r) => `{${r}}`;
|
117
|
+
class F {
|
118
|
+
constructor(t) {
|
119
|
+
h(this, "_isProd");
|
120
|
+
h(this, "_callerName");
|
121
|
+
this.params = t;
|
122
|
+
}
|
123
|
+
get hash() {
|
124
|
+
return g(this.params.base || this.params);
|
125
|
+
}
|
126
|
+
get cssClassName() {
|
127
|
+
return this.hash;
|
128
|
+
}
|
129
|
+
get classNames() {
|
130
|
+
const t = [this.hash], { className: s } = this.params;
|
131
|
+
return s && t.push(s), t.join(" ");
|
132
|
+
}
|
133
|
+
get cssFileName() {
|
134
|
+
return this._callerName ? `cl_${_(this._callerName)}-${this.hash}.css` : `${this.hash}.css`;
|
135
|
+
}
|
136
|
+
get css() {
|
137
|
+
const { base: t = {}, variants: s = {}, compoundVariants: e = [] } = this.params, n = { ...t, variants: s, compoundVariants: e };
|
138
|
+
return p(n, `.${this.cssClassName}`);
|
139
|
+
}
|
140
|
+
_withBuildContext(t) {
|
141
|
+
const { name: s, prod: e } = t;
|
142
|
+
return this._isProd = e, this._callerName = s, this;
|
143
|
+
}
|
144
|
+
}
|
117
145
|
export {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
146
|
+
F as ClassNameFactory,
|
147
|
+
u as MediaQueryFactory,
|
148
|
+
O as keyframes,
|
149
|
+
k as media,
|
150
|
+
W as mergeStyles,
|
151
|
+
z as token
|
123
152
|
};
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var f=Object.defineProperty;var y=(a,t,s)=>t in a?f(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>y(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-BJEkFEGQ.cjs"),g=require("../parse-templates-VIvmVb52.cjs"),N=require("../parse-styles-3zK35muR.cjs");class _{constructor(t,s){c(this,"_isProd");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 typeof s=="string"&&t.push(s),typeof s=="object"&&t.push(...s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get cssFileName(){return this._callerName?`c_${u.dashCase(this._callerName)}-${this.hash}-${this.priority}.css`:`${this.hash}-${this.priority}.css`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?g.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:s={},compoundVariants:i=[]}=this.params,r={...t,variants:s,compoundVariants:i};return N.parseStyles(r,`.${this.cssClassName}`,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:s={},compoundVariants:i=[],defaultVariants:r={},defaultProps:p={},passProps:n}=this.params,h=new Set([]),l=e=>{const o=r[e];o!==void 0?h.add(`${e}=${String(o)}`):h.add(e)};Object.keys(s).forEach(l),i.map(e=>Object.keys(e).forEach(l));const m=new Set([]);if(this.params.base){const e=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);e&&e.forEach(o=>{const d=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");d&&m.add(d)})}return{element:t,variantKeys:[...h],propValueKeys:[...m],passProps:n,defaultProps:p,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:i,prod:r}=t;return this._isProd=r,this._callerName=s,this}}exports.StyleComponentGenerator=_;
|
package/generator/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
var f = Object.defineProperty;
|
2
|
-
var
|
3
|
-
var c = (
|
4
|
-
import { t as
|
2
|
+
var u = (a, s, t) => s in a ? f(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
3
|
+
var c = (a, s, t) => u(a, typeof s != "symbol" ? s + "" : s, t);
|
4
|
+
import { t as g, d as y } from "../dash-case-DBThphLm.js";
|
5
5
|
import { g as N } from "../parse-templates-DRKlN-pP.js";
|
6
6
|
import { p as _ } from "../parse-styles-DrLhKtqW.js";
|
7
7
|
class K {
|
@@ -12,7 +12,7 @@ class K {
|
|
12
12
|
this.tagName = s, this.params = t;
|
13
13
|
}
|
14
14
|
get hash() {
|
15
|
-
return
|
15
|
+
return g(this.params.base || this.params);
|
16
16
|
}
|
17
17
|
get priority() {
|
18
18
|
var s;
|
@@ -20,7 +20,7 @@ class K {
|
|
20
20
|
}
|
21
21
|
get classNames() {
|
22
22
|
const s = [this.hash], { className: t } = this.params;
|
23
|
-
return t && s.push(t), s.join(" ");
|
23
|
+
return typeof t == "string" && s.push(t), typeof t == "object" && s.push(...t), s.join(" ");
|
24
24
|
}
|
25
25
|
get cssClassName() {
|
26
26
|
return this.hash;
|
@@ -41,15 +41,15 @@ class K {
|
|
41
41
|
return _(r, `.${this.cssClassName}`, (o = this._context) == null ? void 0 : o.config);
|
42
42
|
}
|
43
43
|
get props() {
|
44
|
-
const { element: s, variants: t = {}, compoundVariants: i = [], defaultVariants: r = {}, defaultProps: p = {}, passProps: o } = this.params, h = /* @__PURE__ */ new Set([]), m = (
|
45
|
-
const n = r[
|
46
|
-
n !== void 0 ? h.add(`${
|
44
|
+
const { element: s, variants: t = {}, compoundVariants: i = [], defaultVariants: r = {}, defaultProps: p = {}, passProps: o } = this.params, h = /* @__PURE__ */ new Set([]), m = (e) => {
|
45
|
+
const n = r[e];
|
46
|
+
n !== void 0 ? h.add(`${e}=${String(n)}`) : h.add(e);
|
47
47
|
};
|
48
|
-
Object.keys(t).forEach(m), i.map((
|
48
|
+
Object.keys(t).forEach(m), i.map((e) => Object.keys(e).forEach(m));
|
49
49
|
const l = /* @__PURE__ */ new Set([]);
|
50
50
|
if (this.params.base) {
|
51
|
-
const
|
52
|
-
|
51
|
+
const e = JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);
|
52
|
+
e && e.forEach((n) => {
|
53
53
|
const d = n.replace(/\{props\.([\w\d]+)\}/gi, "$1");
|
54
54
|
d && l.add(d);
|
55
55
|
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";const ue=require("esbuild"),ye=require("child_process"),T=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),Q=require("fs/promises"),A=require("./parse-styles-3zK35muR.cjs"),te=require("./parse-templates-VIvmVb52.cjs"),I=require("winston"),z=require("./merge-DxGoJDHv.cjs");var U=typeof document<"u"?document.currentScript:null;function me(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ne=me(ue),oe=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:oe(o.join(e,".."))},ge=async e=>{const t=oe(e);return await Q.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},he=async e=>{const t=await ge(e);if(t)return t.type};let J;const ie=async e=>{if(J)return J;const t=await he(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index-BmsXxgnE.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},W=I.createLogger({level:"debug",format:I.format.combine(I.format.colorize(),I.format.cli()),transports:[new I.transports.Console({})]}),Se=e=>{W.error(e)};function re(e){return e?typeof e!="string"?re(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const we={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},E={externalModules:[],rcFile:void 0,destDir:void 0},ce=e=>{if(E.externalModules.length>0)return E.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(f=>f.replace(/['"`]/g,"").trim());return E.externalModules=c,c},O=async e=>{if(E.destDir)return E.destDir;const t=await Y(e),s=o.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},X=["salty","css","styles","styled"],ae=(e=[])=>new RegExp(`\\.(${[...X,...e].join("|")})\\.`),B=(e,t=[])=>ae(t).test(e),le=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=o.join(e,".saltyrc.json"),s=await Q.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):le(o.join(e,".."))},Y=async e=>{var c,f;const t=await le(e),s=(c=t.projects)==null?void 0:c.find(a=>e.endsWith(a.dir||""));return s||((f=t.projects)==null?void 0:f.find(a=>a.dir===t.defaultProject))},Fe=async e=>{const t=await Y(e),s=await O(e),c=o.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),f=o.join(s,"salty.config.js"),a=await ie(e),d=ce(c);await ne.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:f,format:a,external:d});const h=Date.now(),{config:p}=await import(`${f}?t=${h}`);return p},fe=async(e,t)=>{const s=await Fe(e),c={...s},f=new Set,a=(x,b=[])=>x?Object.entries(x).flatMap(([_,N])=>{if(!N)return;if(typeof N=="object")return a(N,[...b,_]);const v=re(_),L=T.dashCase(_),K=[...b,v].join(".");f.add(`"${K}"`);const Z=[...b.map(T.dashCase),L].join("-"),{result:pe}=A.parseValueTokens(N);return`--${Z}: ${pe};`}):[],d=x=>x?Object.entries(x).flatMap(([b,_])=>{const N=a(_);return b==="base"?N.join(""):`${b} { ${N.join("")} }`}):[],h=x=>x?Object.entries(x).flatMap(([b,_])=>Object.entries(_).flatMap(([N,v])=>{const L=a(v,[b]),K=`.${b}-${N}, [data-${b}="${N}"]`,Z=L.join("");return`${K} { ${Z} }`})):[],p=x=>t.variables.map(b=>b._current[x]),n=a(z.mergeStyles(s.variables,p("variables"))),g=d(z.mergeStyles(s.responsiveVariables,p("responsiveVariables"))),m=h(z.mergeStyles(s.conditionalVariables,p("conditionalVariables"))),l=await O(e),C=o.join(l,"css/_variables.css"),$=`:root { ${n.join("")} ${g.join("")} } ${m.join("")}`;i.writeFileSync(C,$);const M=o.join(l,"css/_global.css"),P=z.mergeStyles(s.global,t.globalStyles),k=A.parseStyles(P,"");i.writeFileSync(M,`@layer global { ${k} }`);const V=o.join(l,"css/_reset.css"),R=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:we,r=A.parseStyles(R,"");i.writeFileSync(V,`@layer reset { ${r} }`);const j=o.join(l,"css/_templates.css"),S=z.mergeStyles(s.templates,t.templates),F=te.parseTemplates(S),u=te.getTemplateTypes(S);i.writeFileSync(j,F),c.templates=S;const w=o.join(l,"types/css-tokens.d.ts"),H=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...f].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(u).map(([x,b])=>`${x}?: ${b}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;i.writeFileSync(w,H);const q=o.join(l,"cache/config-cache.json");i.writeFileSync(q,JSON.stringify(c,null,2))},se=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const f=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!f.test(e))return t;const d=f.exec(e);if(d){const h=d.at(1);if(X.some(n=>h==null?void 0:h.includes(n)))return t}return"styled('div',"}),G=async(e,t,s)=>{const c=T.toHash(t),f=o.join(s,"./temp");i.existsSync(f)||i.mkdirSync(f);const a=o.parse(t);let d=i.readFileSync(t,"utf8");d=se(d);const h=o.join(s,"js",c+".js"),p=await Y(e),n=o.join(e,(p==null?void 0:p.configDir)||"","salty.config.ts"),g=ce(n),m=await ie(e);await ne.build({stdin:{contents:d,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:m,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:$=>{$.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},M=>{const P=i.readFileSync(M.path,"utf8");return{contents:se(P),loader:"ts"}})}}]});const l=Date.now();return await import(`${h}?t=${l}`)},je=async e=>{const t=await O(e),s=o.join(t,"cache/config-cache.json"),c=i.readFileSync(s,"utf8");if(!c)throw new Error("Could not find config cache file");return JSON.parse(c)},ee=async e=>{const t=await je(e),s=await O(e),c=o.join(s,"salty.config.js"),f=Date.now(),{config:a}=await import(`${c}?t=${f}`);return z.mergeStyles(a,t)},de=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},be=async(e,t=de(),s=!0)=>{try{const c=Date.now();t?W.info("Generating CSS in production mode! 🔥"):W.info("Generating CSS in development mode! 🚀");const f=[],a=[],d=await O(e),h=o.join(d,"index.css");s&&(()=>{i.existsSync(d)&&ye.execSync("rm -rf "+d),i.mkdirSync(d,{recursive:!0}),i.mkdirSync(o.join(d,"css")),i.mkdirSync(o.join(d,"types")),i.mkdirSync(o.join(d,"js")),i.mkdirSync(o.join(d,"cache"))})();const n={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function g(r){const j=["node_modules","saltygen"],S=i.statSync(r);if(S.isDirectory()){const F=i.readdirSync(r);if(j.some(w=>r.includes(w)))return;await Promise.all(F.map(w=>g(o.join(r,w))))}else if(S.isFile()&&B(r)){const u=await G(e,r,d);Object.entries(u).forEach(([w,y])=>{y.isKeyframes?n.keyframes.push({value:y,src:r,name:w}):y.isMedia?n.mediaQueries.push(y):y.isGlobalDefine?n.globalStyles.push(y):y.isDefineVariables?n.variables.push(y):y.isDefineTemplates?n.templates.push(y):y.isClassName?n.classNames.push({value:y.factory,src:r,name:w}):y.generator&&n.components.push({value:y.generator,src:r,name:w})})}}await g(e),await fe(e,n);const m=await ee(e);for(const r of n.keyframes){const{value:j}=r,S=`a_${j.animationName}.css`,F=`css/${S}`,u=o.join(d,F);f.push(S),i.writeFileSync(u,j.css)}const l={};for(const r of n.components){const{value:j,name:S,src:F}=r,u=j._withBuildContext({name:S,config:m,prod:t});a[u.priority]||(a[u.priority]=[]),a[u.priority].push(u.cssFileName);const w=`css/${u.cssFileName}`,y=o.join(d,w);i.writeFileSync(y,u.css),m.importStrategy==="component"&&(l[F]?l[F].push(u.cssFileName):l[F]=[u.cssFileName])}for(const r of n.classNames){const{value:j,src:S,name:F}=r,u=j._withBuildContext({name:F,prod:t});a[0].push(u.cssFileName);const w=`css/${u.cssFileName}`,y=o.join(d,w);i.writeFileSync(y,u.css),m.importStrategy==="component"&&(l[S]?l[S].push(u.cssFileName):l[S]=[u.cssFileName])}m.importStrategy==="component"&&Object.entries(l).forEach(([r,j])=>{const S=j.map(H=>`@import url('./${H}');`).join(`
|
12
|
+
`),F=T.toHash(r,6),u=o.parse(r),w=T.dashCase(u.name),y=o.join(d,`css/f_${w}-${F}.css`);i.writeFileSync(y,S)});const C=f.map(r=>`@import url('./css/${r}');`).join(`
|
13
|
+
`);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(r=>{try{return i.readFileSync(o.join(d,"css",r),"utf8").length>0}catch{return!1}}).map(r=>`@import url('./css/${r}');`).join(`
|
16
|
+
`)}
|
17
|
+
${C}`;if(m.importStrategy!=="component"){const r=a.reduce((j,S,F)=>{const u=S.reduce((q,x)=>{var v;const b=o.join(d,"css",x),_=i.readFileSync(b,"utf8"),N=((v=/.*-([^-]+)-\d+.css/.exec(x))==null?void 0:v.at(1))||T.toHash(b,6);return q.includes(N)?q:`${q}
|
18
|
+
/*start:${N}*/
|
19
|
+
${_}
|
20
|
+
/*end:${N}*/
|
21
|
+
`},""),w=`l_${F}.css`,y=o.join(d,"css",w),H=`@layer l${F} { ${u}
|
22
|
+
}`;return i.writeFileSync(y,H),`${j}
|
23
|
+
@import url('./css/${w}');`},"");k+=r}i.writeFileSync(h,k);const D=Date.now()-c,R=D<200?"🔥":D<500?"🚀":D<1e3?"🎉":D<2e3?"🚗":D<5e3?"🤔":"🥴";W.info(`Generated CSS in ${D}ms! ${R}`)}catch(c){console.error(c)}},$e=async(e,t)=>{try{const s=await O(e);if(B(t)){const f=[],a=await ee(e),d=await G(e,t,s);if(Object.entries(d).forEach(([h,p])=>{if(p.isKeyframes&&p.css){const C=`css/${`a_${p.animationName}.css`}`,$=o.join(s,C);i.writeFileSync($,p.css);return}if(p.isClassName){console.log("found className value",p);const l=p.factory._withBuildContext({name:h});f[0].push(l.cssFileName);const C=`css/${l.cssFileName}`,$=o.join(s,C);i.writeFileSync($,l.css),console.log($,l.css)}if(!p.generator)return;const n=p.generator._withBuildContext({name:h,config:a}),g=`css/${n.cssFileName}`,m=o.join(s,g);i.writeFileSync(m,n.css),f[n.priority]||(f[n.priority]=[]),f[n.priority].push(n.cssFileName)}),console.log(f),a.importStrategy!=="component")f.forEach((h,p)=>{const n=`l_${p}.css`,g=o.join(s,"css",n);let m=i.readFileSync(g,"utf8");h.forEach(l=>{var P;const C=o.join(s,"css",l),$=((P=/.*-([^-]+)-\d+.css/.exec(l))==null?void 0:P.at(1))||T.toHash(C,6);if(!m.includes($)){const k=i.readFileSync(C,"utf8"),V=`/*start:${$}*/
|
24
|
+
${k}
|
25
|
+
/*end:${$}*/
|
26
|
+
`;m=`${m.replace(/\}$/,"")}
|
27
|
+
${V}
|
28
|
+
}`}}),i.writeFileSync(g,m)});else{const h=f.flat().map(l=>`@import url('./${l}');`).join(`
|
29
|
+
`),p=T.toHash(t,6),n=o.parse(t),g=T.dashCase(n.name),m=o.join(s,`css/f_${g}-${p}.css`);i.writeFileSync(m,h)}}}catch(s){console.error(s)}},Ce=async(e,t,s=de())=>{try{const c=await O(e);if(B(t)){const a=i.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==a&&await Q.writeFile(t,a);const h=await ee(e),p=await G(e,t,c);let n=a;if(Object.entries(p).forEach(([g,m])=>{var w;if(m.isKeyframes||!m.generator)return;const l=m.generator._withBuildContext({name:g,config:h,prod:s}),C=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!C)return console.error("Could not find the original declaration");const $=(w=C.at(1))==null?void 0:w.trim(),M=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(n);if(!M)return console.error("Could not find the original declaration");const{index:P}=M;let k=!1;const V=setTimeout(()=>k=!0,5e3);let D=0,R=!1,r=0;for(;!R&&!k;){const y=n[P+D];y==="("&&r++,y===")"&&r--,r===0&&y===")"&&(R=!0),D>n.length&&(k=!0),D++}if(!k)clearTimeout(V);else throw new Error("Failed to find the end of the styled call and timed out");const j=P+D,S=n.slice(P,j),F=n,u=` ${g} = styled(${$}, "${l.classNames}", ${JSON.stringify(l.props)});`;n=n.replace(S,u),F===n&&console.error("Minimize file failed to change content",{name:g,tagName:$})}),h.importStrategy==="component"){const g=T.toHash(t,6),m=o.parse(t);n=`import '../../saltygen/css/${`f_${T.dashCase(m.name)}-${g}.css`}';
|
30
|
+
${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=G;exports.generateConfigStyles=fe;exports.generateCss=be;exports.generateFile=$e;exports.isSaltyFile=B;exports.logError=Se;exports.logger=W;exports.minimizeFile=Ce;exports.saltyFileExtensions=X;exports.saltyFileRegExp=ae;
|