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