@salty-css/vite 0.0.1-alpha.144 → 0.0.1-alpha.146
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/index.cjs +20 -21
- package/index.js +249 -241
- package/package.json +2 -2
package/index.cjs
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
2
|
-
${
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const yt=require("esbuild"),gt=require("child_process"),a=require("path"),f=require("fs"),L=require("fs/promises"),J=require("winston");var Z=typeof document<"u"?document.currentScript:null;function ht(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Y=ht(yt),G=t=>String.fromCharCode(t+(t>25?39:97)),mt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=G(n%52)+s;return s=G(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},$t=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},W=(t,e=5)=>{const s=$t(5381,JSON.stringify(t))>>>0;return mt(s,e)};function V(t){return t?typeof t!="string"?V(String(t)):t.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const St=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:i,transform:r}=n;t=t.replace(i,u=>{const{value:d,css:c}=r(u);return c&&s.push(c),d})}),{result:t,additionalCss:s}},Q=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:t},M=(t,e,s)=>{if(!t)return"";const n=[],i=Object.entries(t).reduce((u,[d,c])=>{const o=d.trim();if(typeof c=="function"&&(c=c()),typeof c=="object"){if(!c)return u;if(o==="variants")return Object.entries(c).forEach(([l,m])=>{m&&Object.entries(m).forEach(([N,w])=>{if(!w)return;const T=`${e}.${l}-${N}`,k=M(w,T);n.push(k)})}),u;if(o==="defaultVariants")return u;if(o==="compoundVariants")return c.forEach(l=>{const{css:m,...N}=l,w=Object.entries(N).reduce((k,[y,$])=>`${k}.${y}-${$}`,e),T=M(m,w);n.push(T)}),u;if(o.startsWith("@")){const l=M(c,e),m=`${o} {
|
2
|
+
${l.replace(`
|
3
3
|
`,`
|
4
4
|
`)}
|
5
|
-
}`;return n.push(m),
|
5
|
+
}`;return n.push(m),u}const p=d.includes("&")?o.replace("&",e):o.startsWith(":")?`${e}${o}`:`${e} ${o}`,j=M(c,p);return n.push(j),u}const g=o.startsWith("-")?o:V(o),h=(p,j=";")=>u=`${u}${p}${j}`,C=p=>h(`${g}:${p}`);if(typeof c=="number")return C(c);if(typeof c!="string")if("toString"in c)c=c.toString();else return u;const{modifiers:x}={},O=function*(){yield Q(c),yield St(c,x)}();for(const{result:p,additionalCss:j=[]}of O)c=p,j.forEach(l=>{const m=M(l,"");h(m,"")});return C(c)},"");return i?e?[`${e} { ${i} }`,...n].join(`
|
6
6
|
`):i:n.join(`
|
7
|
-
`)},v=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([i,
|
8
|
-
`)}
|
7
|
+
`)},v=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([i,r])=>{if(typeof r=="object"){if(!r)return;const u=i.trim(),d=v(r,[...e,u]);s.push(d)}else n[i]=r}),Object.keys(n).length){const i=e.map(V).join("-"),r=M(n,`.${i}`);s.push(r)}return s.join(`
|
8
|
+
`)},jt=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=tt(n).map(i=>`"${i}"`).join(" | ")),e),{}),tt=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,i])=>{const r=e?`${e}.${n}`:n;return typeof i=="object"?tt(i,r,s):s.add(e)}),[...s]):[],et=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=a.join(t,"package.json");return f.existsSync(e)?e:et(a.join(t,".."))},bt=async t=>{const e=et(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},wt=async t=>{const e=await bt(t);if(e)return e.type};let A;const st=async t=>{if(A)return A;const e=await wt(t);return e==="module"?A="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:Z&&Z.tagName.toUpperCase()==="SCRIPT"&&Z.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},H=J.createLogger({level:"debug",format:J.format.combine(J.format.colorize(),J.format.cli()),transports:[new J.transports.Console({})]});function nt(t){return t?typeof t!="string"?nt(String(t)):t.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?".":"")+e.toLowerCase()):""}const Ft={"*, *::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"}},q={externalModules:[]},ot=t=>{if(q.externalModules.length>0)return q.externalModules;const s=f.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return q.externalModules=n,n},I=t=>a.join(t,"./saltygen"),rt=["salty","css","styles","styled"],Ct=(t=[])=>new RegExp(`\\.(${[...rt,...t].join("|")})\\.`),z=(t,e=[])=>Ct(e).test(t),it=async t=>{if(t==="/")throw new Error("Could not find .saltyrc.json file");const e=a.join(t,".saltyrc.json"),s=await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{});return s||it(a.join(t,".."))},ct=async t=>{var n,i;const e=await it(t),s=(n=e.projects)==null?void 0:n.find(r=>t.endsWith(r.dir||""));return s||((i=e.projects)==null?void 0:i.find(r=>r.dir===e.defaultProject))},xt=async t=>{const e=await ct(t),s=I(t),n=a.join(t,(e==null?void 0:e.configDir)||"","salty.config.ts"),i=a.join(s,"salty.config.js"),r=await st(t),u=ot(n);await Y.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:r,external:u});const d=Date.now(),{config:c}=await import(`${i}?t=${d}`);return c},kt=async t=>{const e=await xt(t),s=new Set,n=(y,$=[])=>y?Object.entries(y).flatMap(([F,S])=>{if(!S)return;if(typeof S=="object")return n(S,[...$,F]);const D=nt(F),R=V(F),_=[...$,D].join(".");s.add(`"${_}"`);const P=[...$.map(V),R].join("-"),{result:E}=Q(S);return`--${P}: ${E};`}):[],i=y=>y?Object.entries(y).flatMap(([$,F])=>{const S=n(F);return $==="base"?S.join(""):`${$} { ${S.join("")} }`}):[],r=y=>y?Object.entries(y).flatMap(([$,F])=>Object.entries(F).flatMap(([S,D])=>{const R=n(D,[$]),_=`.${$}-${S}, [data-${$}="${S}"]`,P=R.join("");return`${_} { ${P} }`})):[],u=n(e.variables),d=i(e.responsiveVariables),c=r(e.conditionalVariables),o=I(t),g=a.join(o,"css/_variables.css"),h=`:root { ${u.join("")} ${d.join("")} } ${c.join("")}`;f.writeFileSync(g,h);const C=a.join(o,"css/_global.css"),x=M(e.global,"");f.writeFileSync(C,`@layer global { ${x} }`);const b=a.join(o,"css/_reset.css"),p=e.reset==="none"?{}:typeof e.reset=="object"?e.reset:Ft,j=M(p,"");f.writeFileSync(b,`@layer reset { ${j} }`);const l=a.join(o,"css/_templates.css"),m=v(e.templates),N=jt(e.templates);f.writeFileSync(l,m);const w=a.join(o,"types/css-tokens.d.ts"),k=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...s].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
12
|
|
13
13
|
// Template types
|
14
14
|
type TemplateTokens = {
|
15
|
-
${Object.entries(
|
15
|
+
${Object.entries(N).map(([y,$])=>`${y}?: ${$}`).join(`
|
16
16
|
`)}
|
17
17
|
}
|
18
|
-
`;
|
19
|
-
`),
|
20
|
-
`);let
|
18
|
+
`;f.writeFileSync(w,k)},X=t=>t.replace(/styled\(([^"'`{,]+),/g,(e,s)=>{if(/^['"`]/.test(s))return e;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(t))return e;const u=i.exec(t);if(u){const d=u.at(1);if(rt.some(o=>d==null?void 0:d.includes(o)))return e}return"styled('div',"}),B=async(t,e,s)=>{const n=W(e),i=a.join(s,"./temp");f.existsSync(i)||f.mkdirSync(i);const r=a.parse(e);let u=f.readFileSync(e,"utf8");u=X(u);const d=a.join(s,"js",n+".js"),c=await ct(t),o=a.join(t,(c==null?void 0:c.configDir)||"","salty.config.ts"),g=ot(o),h=await st(t);await Y.build({stdin:{contents:u,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:h,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:b=>{b.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},O=>{const p=f.readFileSync(O.path,"utf8");return{contents:X(p),loader:"ts"}})}}]});const C=Date.now();return await import(`${d}?t=${C}`)},K=async t=>{const e=I(t),s=a.join(e,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},at=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Pt=async(t,e=at())=>{try{const s=Date.now();e?H.info("Generating CSS in production mode! 🔥"):H.info("Generating CSS in development mode! 🚀");const n=[],i=[],r=I(t),u=a.join(r,"index.css");(()=>{f.existsSync(r)&>.execSync("rm -rf "+r),f.mkdirSync(r),f.mkdirSync(a.join(r,"css")),f.mkdirSync(a.join(r,"types"))})(),await kt(t);const c=await K(t);async function o(l,m){const N=["node_modules","saltygen"],w=f.statSync(l);if(w.isDirectory()){const T=f.readdirSync(l);if(N.some(y=>l.includes(y)))return;await Promise.all(T.map(y=>o(a.join(l,y),a.join(m,y))))}else if(w.isFile()&&z(l)){const k=await B(t,l,r),y=[];Object.entries(k).forEach(([_,P])=>{if(P.isKeyframes&&P.css){const U=`a_${P.animationName}.css`,dt=`css/${U}`,pt=a.join(r,dt);n.push(U),f.writeFileSync(pt,P.css);return}if(!P.generator)return;const E=P.generator._withBuildContext({name:_,config:c,prod:e});i[E.priority]||(i[E.priority]=[]),i[E.priority].push(E.cssFileName),y.push(E.cssFileName);const ft=`css/${E.cssFileName}`,ut=a.join(r,ft);f.writeFileSync(ut,E.css)});const $=y.map(_=>`@import url('./${_}');`).join(`
|
19
|
+
`),F=W(l,6),S=a.parse(l),D=V(S.name),R=a.join(r,`css/f_${D}-${F}.css`);f.writeFileSync(R,$)}}await o(t,r);const g=n.map(l=>`@import url('./css/${l}');`).join(`
|
20
|
+
`);let b=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
21
|
|
22
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(
|
22
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(l=>{try{return f.readFileSync(a.join(r,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
23
23
|
`)}
|
24
|
-
${
|
24
|
+
${g}`;if(c.importStrategy!=="component"){const l=i.reduce((m,N,w)=>{const T=N.reduce((F,S)=>{var P;const D=a.join(r,"css",S),R=f.readFileSync(D,"utf8"),_=((P=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:P.at(1))||W(D,6);return F.includes(_)?F:`${F}
|
25
25
|
/*start:${_}*/
|
26
26
|
${R}
|
27
27
|
/*end:${_}*/
|
28
|
-
`},""),
|
29
|
-
}`;return
|
30
|
-
@import url('./css/${
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
${C}
|
36
|
-
}`}
|
37
|
-
${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}},ct=t=>({name:"stylegen",buildStart:()=>xt(t),load:async e=>{if(z(e))return await Pt(t,e)},handleHotUpdate:async({file:e,server:s})=>{e.includes("salty.config")&&await s.restart()},watchChange:{handler:async e=>{z(e)&&await kt(t,e)}}});exports.default=ct;exports.saltyPlugin=ct;
|
28
|
+
`},""),k=`l_${w}.css`,y=a.join(r,"css",k),$=`@layer l${w} { ${T}
|
29
|
+
}`;return f.writeFileSync(y,$),`${m}
|
30
|
+
@import url('./css/${k}');`},"");b+=l}f.writeFileSync(u,b);const p=Date.now()-s,j=p<200?"🔥":p<500?"🚀":p<1e3?"🎉":p<2e3?"🚗":p<5e3?"🤔":"🥴";H.info(`Generated CSS in ${p}ms! ${j}`)}catch(s){console.error(s)}},Nt=async(t,e)=>{try{const s=a.join(t,"./saltygen");if(z(e)){const i=[],r=await K(t),u=await B(t,e,s);Object.entries(u).forEach(([d,c])=>{if(c.isKeyframes&&c.css){const x=`css/${`a_${c.animationName}.css`}`,b=a.join(s,x);f.writeFileSync(b,c.css);return}if(!c.generator)return;const o=c.generator._withBuildContext({name:d,config:r}),g=`css/${o.cssFileName}`,h=a.join(s,g);f.writeFileSync(h,o.css),i[o.priority]||(i[o.priority]=[]),i[o.priority].push(o.cssFileName)}),r.importStrategy!=="component"&&i.forEach((d,c)=>{const o=`l_${c}.css`,g=a.join(s,"css",o);let h=f.readFileSync(g,"utf8");d.forEach(C=>{var p;const x=a.join(s,"css",C),b=((p=/.*-([^-]+)-\d+.css/.exec(C))==null?void 0:p.at(1))||W(x,6);if(!h.includes(b)){const j=f.readFileSync(x,"utf8"),l=`/*start:${b}*/
|
31
|
+
${j}
|
32
|
+
/*end:${b}*/
|
33
|
+
`;h=`${h.replace(/\}$/,"")}
|
34
|
+
${l}
|
35
|
+
}`}}),f.writeFileSync(g,h)})}}catch(s){console.error(s)}},Tt=async(t,e,s=at())=>{try{const n=a.join(t,"./saltygen");if(z(e)){const r=f.readFileSync(e,"utf8");r.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==r&&await L.writeFile(e,r);const d=await K(t),c=await B(t,e,n);let o=r;if(Object.entries(c).forEach(([g,h])=>{var F;if(h.isKeyframes||!h.generator)return;const C=h.generator._withBuildContext({name:g,config:d,prod:s}),x=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!x)return console.error("Could not find the original declaration");const b=(F=x.at(1))==null?void 0:F.trim(),O=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(o);if(!O)return console.error("Could not find the original declaration");const{index:p}=O;let j=!1;const l=setTimeout(()=>j=!0,5e3);let m=0,N=!1,w=0;for(;!N&&!j;){const S=o[p+m];S==="("&&w++,S===")"&&w--,w===0&&S===")"&&(N=!0),m>o.length&&(j=!0),m++}if(!j)clearTimeout(l);else throw new Error("Failed to find the end of the styled call and timed out");const T=p+m,k=o.slice(p,T),y=o,$=` ${g} = styled(${b}, "${C.classNames}", ${JSON.stringify(C.props)});`;o=o.replace(k,$),y===o&&console.error("Minimize file failed to change content",{name:g,tagName:b})}),d.importStrategy==="component"){const g=W(e,6),h=a.parse(e);o=`import '../../saltygen/css/${`f_${V(h.name)}-${g}.css`}';
|
36
|
+
${o}`}return o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}},lt=t=>({name:"stylegen",buildStart:()=>Pt(t),load:async e=>{if(z(e))return await Tt(t,e)},handleHotUpdate:async({file:e,server:s})=>{e.includes("salty.config")&&await s.restart()},watchChange:{handler:async e=>{z(e)&&await Nt(t,e)}}});exports.default=lt;exports.saltyPlugin=lt;
|
package/index.js
CHANGED
@@ -1,131 +1,131 @@
|
|
1
1
|
import * as v from "esbuild";
|
2
|
-
import { execSync as
|
2
|
+
import { execSync as ht } from "child_process";
|
3
3
|
import { join as a, parse as K } from "path";
|
4
|
-
import { existsSync as G, mkdirSync as
|
5
|
-
import { readFile as
|
6
|
-
import { createLogger as
|
7
|
-
const Y = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)),
|
4
|
+
import { existsSync as G, mkdirSync as Z, statSync as mt, readdirSync as $t, writeFileSync as N, readFileSync as M } from "fs";
|
5
|
+
import { readFile as tt, writeFile as bt } from "fs/promises";
|
6
|
+
import { createLogger as St, format as I, transports as wt } from "winston";
|
7
|
+
const Y = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), jt = (t, e) => {
|
8
8
|
let s = "", n;
|
9
9
|
for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = Y(n % 52) + s;
|
10
10
|
return s = Y(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
-
},
|
11
|
+
}, Ct = (t, e) => {
|
12
12
|
let s = e.length;
|
13
13
|
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
14
|
return t;
|
15
15
|
}, W = (t, e = 5) => {
|
16
|
-
const s =
|
17
|
-
return
|
16
|
+
const s = Ct(5381, JSON.stringify(t)) >>> 0;
|
17
|
+
return jt(s, e);
|
18
18
|
};
|
19
|
-
function
|
20
|
-
return t ? typeof t != "string" ?
|
19
|
+
function R(t) {
|
20
|
+
return t ? typeof t != "string" ? R(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
|
21
21
|
}
|
22
|
-
const
|
22
|
+
const Ft = (t, e) => {
|
23
23
|
if (typeof t != "string") return { result: t };
|
24
24
|
if (!e) return { result: t };
|
25
25
|
const s = [];
|
26
26
|
return Object.values(e).forEach((n) => {
|
27
|
-
const { pattern: i, transform:
|
28
|
-
t = t.replace(i, (
|
29
|
-
const { value:
|
30
|
-
return c && s.push(c),
|
27
|
+
const { pattern: i, transform: r } = n;
|
28
|
+
t = t.replace(i, (f) => {
|
29
|
+
const { value: p, css: c } = r(f);
|
30
|
+
return c && s.push(c), p;
|
31
31
|
});
|
32
32
|
}), { result: t, additionalCss: s };
|
33
|
-
},
|
33
|
+
}, et = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${R(n[1].replaceAll(".", "-"))})`) } : { result: t }, _ = (t, e, s) => {
|
34
34
|
if (!t) return "";
|
35
|
-
const n = [], i = Object.entries(t).reduce((
|
36
|
-
const
|
35
|
+
const n = [], i = Object.entries(t).reduce((f, [p, c]) => {
|
36
|
+
const o = p.trim();
|
37
37
|
if (typeof c == "function" && (c = c()), typeof c == "object") {
|
38
|
-
if (!c) return
|
39
|
-
if (
|
40
|
-
return Object.entries(c).forEach(([
|
41
|
-
|
38
|
+
if (!c) return f;
|
39
|
+
if (o === "variants")
|
40
|
+
return Object.entries(c).forEach(([l, h]) => {
|
41
|
+
h && Object.entries(h).forEach(([P, w]) => {
|
42
42
|
if (!w) return;
|
43
|
-
const
|
44
|
-
n.push(
|
43
|
+
const E = `${e}.${l}-${P}`, x = _(w, E);
|
44
|
+
n.push(x);
|
45
45
|
});
|
46
|
-
}),
|
47
|
-
if (
|
48
|
-
return
|
49
|
-
if (
|
50
|
-
return c.forEach((
|
51
|
-
const { css:
|
52
|
-
n.push(
|
53
|
-
}),
|
54
|
-
if (
|
55
|
-
const
|
56
|
-
${
|
46
|
+
}), f;
|
47
|
+
if (o === "defaultVariants")
|
48
|
+
return f;
|
49
|
+
if (o === "compoundVariants")
|
50
|
+
return c.forEach((l) => {
|
51
|
+
const { css: h, ...P } = l, w = Object.entries(P).reduce((x, [d, m]) => `${x}.${d}-${m}`, e), E = _(h, w);
|
52
|
+
n.push(E);
|
53
|
+
}), f;
|
54
|
+
if (o.startsWith("@")) {
|
55
|
+
const l = _(c, e), h = `${o} {
|
56
|
+
${l.replace(`
|
57
57
|
`, `
|
58
58
|
`)}
|
59
59
|
}`;
|
60
|
-
return n.push(
|
60
|
+
return n.push(h), f;
|
61
61
|
}
|
62
|
-
const u =
|
63
|
-
return n.push(
|
62
|
+
const u = p.includes("&") ? o.replace("&", e) : o.startsWith(":") ? `${e}${o}` : `${e} ${o}`, b = _(c, u);
|
63
|
+
return n.push(b), f;
|
64
64
|
}
|
65
|
-
const
|
66
|
-
if (typeof c == "number") return
|
65
|
+
const g = o.startsWith("-") ? o : R(o), y = (u, b = ";") => f = `${f}${u}${b}`, C = (u) => y(`${g}:${u}`);
|
66
|
+
if (typeof c == "number") return C(c);
|
67
67
|
if (typeof c != "string")
|
68
68
|
if ("toString" in c) c = c.toString();
|
69
|
-
else return
|
70
|
-
const { modifiers:
|
71
|
-
yield
|
69
|
+
else return f;
|
70
|
+
const { modifiers: F } = {}, D = function* () {
|
71
|
+
yield et(c), yield Ft(c, F);
|
72
72
|
}();
|
73
|
-
for (const { result: u, additionalCss:
|
74
|
-
c = u,
|
75
|
-
const
|
76
|
-
|
73
|
+
for (const { result: u, additionalCss: b = [] } of D)
|
74
|
+
c = u, b.forEach((l) => {
|
75
|
+
const h = _(l, "");
|
76
|
+
y(h, "");
|
77
77
|
});
|
78
|
-
return
|
78
|
+
return C(c);
|
79
79
|
}, "");
|
80
80
|
return i ? e ? [`${e} { ${i} }`, ...n].join(`
|
81
81
|
`) : i : n.join(`
|
82
82
|
`);
|
83
|
-
},
|
83
|
+
}, st = (t, e = []) => {
|
84
84
|
if (!t) return "";
|
85
85
|
const s = [], n = {};
|
86
|
-
if (Object.entries(t).forEach(([i,
|
87
|
-
if (typeof
|
88
|
-
if (!
|
89
|
-
const
|
90
|
-
s.push(
|
86
|
+
if (Object.entries(t).forEach(([i, r]) => {
|
87
|
+
if (typeof r == "object") {
|
88
|
+
if (!r) return;
|
89
|
+
const f = i.trim(), p = st(r, [...e, f]);
|
90
|
+
s.push(p);
|
91
91
|
} else
|
92
|
-
n[i] =
|
92
|
+
n[i] = r;
|
93
93
|
}), Object.keys(n).length) {
|
94
|
-
const i = e.map(
|
95
|
-
s.push(
|
94
|
+
const i = e.map(R).join("-"), r = _(n, `.${i}`);
|
95
|
+
s.push(r);
|
96
96
|
}
|
97
97
|
return s.join(`
|
98
98
|
`);
|
99
|
-
},
|
100
|
-
const
|
101
|
-
return typeof i == "object" ?
|
102
|
-
}), [...s]) : [],
|
99
|
+
}, xt = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = nt(n).map((i) => `"${i}"`).join(" | ")), e), {}), nt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
|
100
|
+
const r = e ? `${e}.${n}` : n;
|
101
|
+
return typeof i == "object" ? nt(i, r, s) : s.add(e);
|
102
|
+
}), [...s]) : [], ot = (t) => {
|
103
103
|
if (!t || t === "/") throw new Error("Could not find package.json file");
|
104
104
|
const e = a(t, "package.json");
|
105
|
-
return G(e) ? e :
|
106
|
-
},
|
107
|
-
const e =
|
108
|
-
return await
|
105
|
+
return G(e) ? e : ot(a(t, ".."));
|
106
|
+
}, kt = async (t) => {
|
107
|
+
const e = ot(t);
|
108
|
+
return await tt(e, "utf-8").then(JSON.parse).catch(() => {
|
109
109
|
});
|
110
|
-
},
|
111
|
-
const e = await
|
110
|
+
}, Nt = async (t) => {
|
111
|
+
const e = await kt(t);
|
112
112
|
if (e)
|
113
113
|
return e.type;
|
114
114
|
};
|
115
115
|
let J;
|
116
|
-
const
|
116
|
+
const rt = async (t) => {
|
117
117
|
if (J) return J;
|
118
|
-
const e = await
|
118
|
+
const e = await Nt(t);
|
119
119
|
return e === "module" ? J = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (J = "cjs"), J || "esm";
|
120
|
-
}, L =
|
120
|
+
}, L = St({
|
121
121
|
level: "debug",
|
122
122
|
format: I.combine(I.colorize(), I.cli()),
|
123
|
-
transports: [new
|
123
|
+
transports: [new wt.Console({})]
|
124
124
|
});
|
125
|
-
function
|
126
|
-
return t ? typeof t != "string" ?
|
125
|
+
function it(t) {
|
126
|
+
return t ? typeof t != "string" ? it(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
127
127
|
}
|
128
|
-
const
|
128
|
+
const Pt = {
|
129
129
|
/** Set box model to border-box */
|
130
130
|
"*, *::before, *::after": {
|
131
131
|
boxSizing: "border-box"
|
@@ -173,287 +173,295 @@ const kt = {
|
|
173
173
|
}
|
174
174
|
}, B = {
|
175
175
|
externalModules: []
|
176
|
-
},
|
176
|
+
}, ct = (t) => {
|
177
177
|
if (B.externalModules.length > 0) return B.externalModules;
|
178
|
-
const
|
179
|
-
if (!
|
180
|
-
const
|
181
|
-
return B.externalModules =
|
182
|
-
},
|
183
|
-
|
178
|
+
const s = M(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
179
|
+
if (!s) return [];
|
180
|
+
const n = s[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
181
|
+
return B.externalModules = n, n;
|
182
|
+
}, H = (t) => a(t, "./saltygen"), at = ["salty", "css", "styles", "styled"], Et = (t = []) => new RegExp(`\\.(${[...at, ...t].join("|")})\\.`), z = (t, e = []) => Et(e).test(t), lt = async (t) => {
|
183
|
+
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
184
|
+
const e = a(t, ".saltyrc.json"), s = await tt(e, "utf-8").then(JSON.parse).catch(() => {
|
185
|
+
});
|
186
|
+
return s || lt(a(t, ".."));
|
187
|
+
}, ft = async (t) => {
|
188
|
+
var n, i;
|
189
|
+
const e = await lt(t), s = (n = e.projects) == null ? void 0 : n.find((r) => t.endsWith(r.dir || ""));
|
190
|
+
return s || ((i = e.projects) == null ? void 0 : i.find((r) => r.dir === e.defaultProject));
|
191
|
+
}, Tt = async (t) => {
|
192
|
+
const e = await ft(t), s = H(t), n = a(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), i = a(s, "salty.config.js"), r = await rt(t), f = ct(n);
|
184
193
|
await v.build({
|
185
|
-
entryPoints: [
|
194
|
+
entryPoints: [n],
|
186
195
|
minify: !0,
|
187
196
|
treeShaking: !0,
|
188
197
|
bundle: !0,
|
189
|
-
outfile:
|
190
|
-
format:
|
191
|
-
external:
|
198
|
+
outfile: i,
|
199
|
+
format: r,
|
200
|
+
external: f
|
192
201
|
});
|
193
|
-
const
|
194
|
-
return
|
195
|
-
},
|
196
|
-
const e = await
|
202
|
+
const p = Date.now(), { config: c } = await import(`${i}?t=${p}`);
|
203
|
+
return c;
|
204
|
+
}, Dt = async (t) => {
|
205
|
+
const e = await Tt(t), s = /* @__PURE__ */ new Set(), n = (d, m = []) => d ? Object.entries(d).flatMap(([j, $]) => {
|
197
206
|
if (!$) return;
|
198
|
-
if (typeof $ == "object") return n($, [...
|
199
|
-
const
|
200
|
-
s.add(`"${
|
201
|
-
const
|
202
|
-
return `--${
|
203
|
-
}) : [], i = (d) => d ? Object.entries(d).flatMap(([
|
204
|
-
const $ = n(
|
205
|
-
return
|
206
|
-
}) : [],
|
207
|
-
const
|
208
|
-
return `${
|
209
|
-
})) : [],
|
210
|
-
|
211
|
-
const
|
212
|
-
|
213
|
-
const
|
214
|
-
|
215
|
-
const
|
216
|
-
|
217
|
-
const w = a(
|
207
|
+
if (typeof $ == "object") return n($, [...m, j]);
|
208
|
+
const V = it(j), A = R(j), T = [...m, V].join(".");
|
209
|
+
s.add(`"${T}"`);
|
210
|
+
const k = [...m.map(R), A].join("-"), { result: O } = et($);
|
211
|
+
return `--${k}: ${O};`;
|
212
|
+
}) : [], i = (d) => d ? Object.entries(d).flatMap(([m, j]) => {
|
213
|
+
const $ = n(j);
|
214
|
+
return m === "base" ? $.join("") : `${m} { ${$.join("")} }`;
|
215
|
+
}) : [], r = (d) => d ? Object.entries(d).flatMap(([m, j]) => Object.entries(j).flatMap(([$, V]) => {
|
216
|
+
const A = n(V, [m]), T = `.${m}-${$}, [data-${m}="${$}"]`, k = A.join("");
|
217
|
+
return `${T} { ${k} }`;
|
218
|
+
})) : [], f = n(e.variables), p = i(e.responsiveVariables), c = r(e.conditionalVariables), o = H(t), g = a(o, "css/_variables.css"), y = `:root { ${f.join("")} ${p.join("")} } ${c.join("")}`;
|
219
|
+
N(g, y);
|
220
|
+
const C = a(o, "css/_global.css"), F = _(e.global, "");
|
221
|
+
N(C, `@layer global { ${F} }`);
|
222
|
+
const S = a(o, "css/_reset.css"), u = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : Pt, b = _(u, "");
|
223
|
+
N(S, `@layer reset { ${b} }`);
|
224
|
+
const l = a(o, "css/_templates.css"), h = st(e.templates), P = xt(e.templates);
|
225
|
+
N(l, h);
|
226
|
+
const w = a(o, "types/css-tokens.d.ts"), x = `
|
218
227
|
// Variable types
|
219
228
|
type VariableTokens = ${[...s].join("|")};
|
220
229
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
221
230
|
|
222
231
|
// Template types
|
223
232
|
type TemplateTokens = {
|
224
|
-
${Object.entries(
|
233
|
+
${Object.entries(P).map(([d, m]) => `${d}?: ${m}`).join(`
|
225
234
|
`)}
|
226
235
|
}
|
227
236
|
`;
|
228
|
-
|
237
|
+
N(w, x);
|
229
238
|
}, Q = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
230
239
|
if (/^['"`]/.test(s)) return e;
|
231
240
|
const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
232
241
|
if (!i.test(t)) return e;
|
233
|
-
const
|
234
|
-
if (
|
235
|
-
const
|
236
|
-
if (
|
242
|
+
const f = i.exec(t);
|
243
|
+
if (f) {
|
244
|
+
const p = f.at(1);
|
245
|
+
if (at.some((o) => p == null ? void 0 : p.includes(o))) return e;
|
237
246
|
}
|
238
247
|
return "styled('div',";
|
239
248
|
}), q = async (t, e, s) => {
|
240
249
|
const n = W(e), i = a(s, "./temp");
|
241
|
-
G(i) ||
|
242
|
-
const
|
243
|
-
let
|
244
|
-
|
245
|
-
const
|
250
|
+
G(i) || Z(i);
|
251
|
+
const r = K(e);
|
252
|
+
let f = M(e, "utf8");
|
253
|
+
f = Q(f);
|
254
|
+
const p = a(s, "js", n + ".js"), c = await ft(t), o = a(t, (c == null ? void 0 : c.configDir) || "", "salty.config.ts"), g = ct(o), y = await rt(t);
|
246
255
|
await v.build({
|
247
256
|
stdin: {
|
248
|
-
contents:
|
249
|
-
sourcefile:
|
250
|
-
resolveDir:
|
257
|
+
contents: f,
|
258
|
+
sourcefile: r.base,
|
259
|
+
resolveDir: r.dir,
|
251
260
|
loader: "tsx"
|
252
261
|
},
|
253
262
|
minify: !1,
|
254
263
|
treeShaking: !0,
|
255
264
|
bundle: !0,
|
256
|
-
outfile:
|
257
|
-
format:
|
265
|
+
outfile: p,
|
266
|
+
format: y,
|
258
267
|
target: ["node20"],
|
259
268
|
keepNames: !0,
|
260
|
-
external:
|
269
|
+
external: g,
|
261
270
|
packages: "external",
|
262
271
|
plugins: [
|
263
272
|
{
|
264
273
|
name: "test",
|
265
274
|
setup: (S) => {
|
266
|
-
S.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (
|
267
|
-
const
|
268
|
-
return { contents: Q(
|
275
|
+
S.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (D) => {
|
276
|
+
const u = M(D.path, "utf8");
|
277
|
+
return { contents: Q(u), loader: "ts" };
|
269
278
|
});
|
270
279
|
}
|
271
280
|
}
|
272
281
|
]
|
273
282
|
});
|
274
|
-
const
|
275
|
-
return await import(`${
|
283
|
+
const C = Date.now();
|
284
|
+
return await import(`${p}?t=${C}`);
|
276
285
|
}, U = async (t) => {
|
277
|
-
const e =
|
286
|
+
const e = H(t), s = a(e, "salty.config.js"), n = Date.now(), { config: i } = await import(`${s}?t=${n}`);
|
278
287
|
return i;
|
279
|
-
},
|
288
|
+
}, pt = () => {
|
280
289
|
try {
|
281
290
|
return process.env.NODE_ENV === "production";
|
282
291
|
} catch {
|
283
292
|
return !1;
|
284
293
|
}
|
285
|
-
},
|
294
|
+
}, Ot = async (t, e = pt()) => {
|
286
295
|
try {
|
287
296
|
const s = Date.now();
|
288
297
|
e ? L.info("Generating CSS in production mode! 🔥") : L.info("Generating CSS in development mode! 🚀");
|
289
|
-
const n = [], i = [],
|
298
|
+
const n = [], i = [], r = H(t), f = a(r, "index.css");
|
290
299
|
(() => {
|
291
|
-
G(
|
292
|
-
})(), await
|
300
|
+
G(r) && ht("rm -rf " + r), Z(r), Z(a(r, "css")), Z(a(r, "types"));
|
301
|
+
})(), await Dt(t);
|
293
302
|
const c = await U(t);
|
294
|
-
async function
|
295
|
-
const
|
303
|
+
async function o(l, h) {
|
304
|
+
const P = ["node_modules", "saltygen"], w = mt(l);
|
296
305
|
if (w.isDirectory()) {
|
297
|
-
const
|
298
|
-
if (
|
299
|
-
await Promise.all(
|
300
|
-
} else if (w.isFile() && z(
|
301
|
-
const
|
302
|
-
Object.entries(
|
303
|
-
if (
|
304
|
-
const X = `a_${
|
305
|
-
n.push(X),
|
306
|
+
const E = $t(l);
|
307
|
+
if (P.some((d) => l.includes(d))) return;
|
308
|
+
await Promise.all(E.map((d) => o(a(l, d), a(h, d))));
|
309
|
+
} else if (w.isFile() && z(l)) {
|
310
|
+
const x = await q(t, l, r), d = [];
|
311
|
+
Object.entries(x).forEach(([T, k]) => {
|
312
|
+
if (k.isKeyframes && k.css) {
|
313
|
+
const X = `a_${k.animationName}.css`, gt = `css/${X}`, yt = a(r, gt);
|
314
|
+
n.push(X), N(yt, k.css);
|
306
315
|
return;
|
307
316
|
}
|
308
|
-
if (!
|
309
|
-
const O =
|
310
|
-
name:
|
317
|
+
if (!k.generator) return;
|
318
|
+
const O = k.generator._withBuildContext({
|
319
|
+
name: T,
|
311
320
|
config: c,
|
312
321
|
prod: e
|
313
322
|
});
|
314
323
|
i[O.priority] || (i[O.priority] = []), i[O.priority].push(O.cssFileName), d.push(O.cssFileName);
|
315
|
-
const
|
316
|
-
|
324
|
+
const ut = `css/${O.cssFileName}`, dt = a(r, ut);
|
325
|
+
N(dt, O.css);
|
317
326
|
});
|
318
|
-
const
|
319
|
-
`),
|
320
|
-
|
327
|
+
const m = d.map((T) => `@import url('./${T}');`).join(`
|
328
|
+
`), j = W(l, 6), $ = K(l), V = R($.name), A = a(r, `css/f_${V}-${j}.css`);
|
329
|
+
N(A, m);
|
321
330
|
}
|
322
331
|
}
|
323
|
-
await
|
324
|
-
const
|
332
|
+
await o(t, r);
|
333
|
+
const g = n.map((l) => `@import url('./css/${l}');`).join(`
|
325
334
|
`);
|
326
|
-
let
|
335
|
+
let S = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
327
336
|
|
328
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((
|
337
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
329
338
|
try {
|
330
|
-
return
|
339
|
+
return M(a(r, "css", l), "utf8").length > 0;
|
331
340
|
} catch {
|
332
341
|
return !1;
|
333
342
|
}
|
334
|
-
}).map((
|
343
|
+
}).map((l) => `@import url('./css/${l}');`).join(`
|
335
344
|
`)}
|
336
|
-
${
|
345
|
+
${g}`;
|
337
346
|
if (c.importStrategy !== "component") {
|
338
|
-
const
|
339
|
-
const
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
347
|
+
const l = i.reduce((h, P, w) => {
|
348
|
+
const E = P.reduce((j, $) => {
|
349
|
+
var k;
|
350
|
+
const V = a(r, "css", $), A = M(V, "utf8"), T = ((k = /.*-([^-]+)-\d+.css/.exec($)) == null ? void 0 : k.at(1)) || W(V, 6);
|
351
|
+
return j.includes(T) ? j : `${j}
|
352
|
+
/*start:${T}*/
|
353
|
+
${A}
|
354
|
+
/*end:${T}*/
|
345
355
|
`;
|
346
|
-
}, ""),
|
356
|
+
}, ""), x = `l_${w}.css`, d = a(r, "css", x), m = `@layer l${w} { ${E}
|
347
357
|
}`;
|
348
|
-
return
|
349
|
-
@import url('./css/${
|
358
|
+
return N(d, m), `${h}
|
359
|
+
@import url('./css/${x}');`;
|
350
360
|
}, "");
|
351
|
-
|
361
|
+
S += l;
|
352
362
|
}
|
353
|
-
|
354
|
-
const u = Date.now() - s,
|
355
|
-
L.info(`Generated CSS in ${u}ms! ${
|
363
|
+
N(f, S);
|
364
|
+
const u = Date.now() - s, b = u < 200 ? "🔥" : u < 500 ? "🚀" : u < 1e3 ? "🎉" : u < 2e3 ? "🚗" : u < 5e3 ? "🤔" : "🥴";
|
365
|
+
L.info(`Generated CSS in ${u}ms! ${b}`);
|
356
366
|
} catch (s) {
|
357
367
|
console.error(s);
|
358
368
|
}
|
359
|
-
},
|
369
|
+
}, Vt = async (t, e) => {
|
360
370
|
try {
|
361
|
-
const s = a(t, "./saltygen")
|
371
|
+
const s = a(t, "./saltygen");
|
362
372
|
if (z(e)) {
|
363
|
-
const
|
364
|
-
Object.entries(
|
365
|
-
if (
|
366
|
-
const
|
367
|
-
|
373
|
+
const i = [], r = await U(t), f = await q(t, e, s);
|
374
|
+
Object.entries(f).forEach(([p, c]) => {
|
375
|
+
if (c.isKeyframes && c.css) {
|
376
|
+
const F = `css/${`a_${c.animationName}.css`}`, S = a(s, F);
|
377
|
+
N(S, c.css);
|
368
378
|
return;
|
369
379
|
}
|
370
|
-
if (!
|
371
|
-
const
|
372
|
-
name:
|
373
|
-
config:
|
374
|
-
}),
|
375
|
-
|
376
|
-
})
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
${f}
|
387
|
-
/*end:${y}*/
|
380
|
+
if (!c.generator) return;
|
381
|
+
const o = c.generator._withBuildContext({
|
382
|
+
name: p,
|
383
|
+
config: r
|
384
|
+
}), g = `css/${o.cssFileName}`, y = a(s, g);
|
385
|
+
N(y, o.css), i[o.priority] || (i[o.priority] = []), i[o.priority].push(o.cssFileName);
|
386
|
+
}), r.importStrategy !== "component" && i.forEach((p, c) => {
|
387
|
+
const o = `l_${c}.css`, g = a(s, "css", o);
|
388
|
+
let y = M(g, "utf8");
|
389
|
+
p.forEach((C) => {
|
390
|
+
var u;
|
391
|
+
const F = a(s, "css", C), S = ((u = /.*-([^-]+)-\d+.css/.exec(C)) == null ? void 0 : u.at(1)) || W(F, 6);
|
392
|
+
if (!y.includes(S)) {
|
393
|
+
const b = M(F, "utf8"), l = `/*start:${S}*/
|
394
|
+
${b}
|
395
|
+
/*end:${S}*/
|
388
396
|
`;
|
389
|
-
|
390
|
-
${
|
397
|
+
y = `${y.replace(/\}$/, "")}
|
398
|
+
${l}
|
391
399
|
}`;
|
392
400
|
}
|
393
|
-
}),
|
401
|
+
}), N(g, y);
|
394
402
|
});
|
395
403
|
}
|
396
404
|
} catch (s) {
|
397
405
|
console.error(s);
|
398
406
|
}
|
399
|
-
},
|
407
|
+
}, _t = async (t, e, s = pt()) => {
|
400
408
|
try {
|
401
409
|
const n = a(t, "./saltygen");
|
402
410
|
if (z(e)) {
|
403
|
-
const
|
404
|
-
|
405
|
-
const
|
406
|
-
let
|
407
|
-
if (Object.entries(c).forEach(([
|
408
|
-
var
|
409
|
-
if (
|
410
|
-
const
|
411
|
-
name:
|
412
|
-
config:
|
411
|
+
const r = M(e, "utf8");
|
412
|
+
r.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== r && await bt(e, r);
|
413
|
+
const p = await U(t), c = await q(t, e, n);
|
414
|
+
let o = r;
|
415
|
+
if (Object.entries(c).forEach(([g, y]) => {
|
416
|
+
var j;
|
417
|
+
if (y.isKeyframes || !y.generator) return;
|
418
|
+
const C = y.generator._withBuildContext({
|
419
|
+
name: g,
|
420
|
+
config: p,
|
413
421
|
prod: s
|
414
|
-
}),
|
415
|
-
if (!
|
416
|
-
const
|
417
|
-
if (!
|
418
|
-
const { index: u } =
|
419
|
-
let
|
420
|
-
const
|
421
|
-
let
|
422
|
-
for (; !
|
423
|
-
const $ =
|
424
|
-
$ === "(" && w++, $ === ")" && w--, w === 0 && $ === ")" && (
|
422
|
+
}), F = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(r);
|
423
|
+
if (!F) return console.error("Could not find the original declaration");
|
424
|
+
const S = (j = F.at(1)) == null ? void 0 : j.trim(), D = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(o);
|
425
|
+
if (!D) return console.error("Could not find the original declaration");
|
426
|
+
const { index: u } = D;
|
427
|
+
let b = !1;
|
428
|
+
const l = setTimeout(() => b = !0, 5e3);
|
429
|
+
let h = 0, P = !1, w = 0;
|
430
|
+
for (; !P && !b; ) {
|
431
|
+
const $ = o[u + h];
|
432
|
+
$ === "(" && w++, $ === ")" && w--, w === 0 && $ === ")" && (P = !0), h > o.length && (b = !0), h++;
|
425
433
|
}
|
426
|
-
if (!
|
434
|
+
if (!b) clearTimeout(l);
|
427
435
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
428
|
-
const
|
429
|
-
|
430
|
-
}),
|
431
|
-
const
|
432
|
-
|
433
|
-
${
|
436
|
+
const E = u + h, x = o.slice(u, E), d = o, m = ` ${g} = styled(${S}, "${C.classNames}", ${JSON.stringify(C.props)});`;
|
437
|
+
o = o.replace(x, m), d === o && console.error("Minimize file failed to change content", { name: g, tagName: S });
|
438
|
+
}), p.importStrategy === "component") {
|
439
|
+
const g = W(e, 6), y = K(e);
|
440
|
+
o = `import '../../saltygen/css/${`f_${R(y.name)}-${g}.css`}';
|
441
|
+
${o}`;
|
434
442
|
}
|
435
|
-
return
|
443
|
+
return o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
436
444
|
}
|
437
445
|
} catch (n) {
|
438
446
|
console.error("Error in minimizeFile:", n);
|
439
447
|
}
|
440
|
-
},
|
448
|
+
}, zt = (t) => ({
|
441
449
|
name: "stylegen",
|
442
|
-
buildStart: () =>
|
450
|
+
buildStart: () => Ot(t),
|
443
451
|
load: async (e) => {
|
444
452
|
if (z(e))
|
445
|
-
return await
|
453
|
+
return await _t(t, e);
|
446
454
|
},
|
447
455
|
handleHotUpdate: async ({ file: e, server: s }) => {
|
448
456
|
e.includes("salty.config") && await s.restart();
|
449
457
|
},
|
450
458
|
watchChange: {
|
451
459
|
handler: async (e) => {
|
452
|
-
z(e) && await
|
460
|
+
z(e) && await Vt(t, e);
|
453
461
|
}
|
454
462
|
}
|
455
463
|
});
|
456
464
|
export {
|
457
|
-
|
458
|
-
|
465
|
+
zt as default,
|
466
|
+
zt as saltyPlugin
|
459
467
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/vite",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.146",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -34,6 +34,6 @@
|
|
34
34
|
}
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@salty-css/core": "^0.0.1-alpha.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.146"
|
38
38
|
}
|
39
39
|
}
|