@salty-css/vite 0.0.1-alpha.198 → 0.0.1-alpha.199
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 +15 -15
- package/index.js +73 -73
- package/package.json +2 -2
package/index.cjs
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Ct=require("esbuild"),xt=require("child_process"),l=require("path"),u=require("fs"),Q=require("fs/promises"),U=require("winston");var ot=typeof document<"u"?document.currentScript:null;function Nt(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 ut=Nt(Ct),at=t=>String.fromCharCode(t+(t>25?39:97)),
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Ct=require("esbuild"),xt=require("child_process"),l=require("path"),u=require("fs"),Q=require("fs/promises"),U=require("winston");var ot=typeof document<"u"?document.currentScript:null;function Nt(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 ut=Nt(Ct),at=t=>String.fromCharCode(t+(t>25?39:97)),Pt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=at(n%52)+s;return s=at(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},kt=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},I=(t,e=5)=>{const s=kt(5381,JSON.stringify(t))>>>0;return Pt(s,e)};function E(t){return t?typeof t!="string"?E(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 _t=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:a}=n;t=t.replace(o,i=>{const{value:p,css:r}=a(i);return r&&s.push(r),p})}),{result:t,additionalCss:s}},dt=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${E(n[1].replaceAll(".","-"))})`)}:{result:t},Dt=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Tt=(t,e,s)=>Dt.some(o=>typeof o=="string"?o===t:o.test(t))?`${e}px`:`${e}`,Ot=["Webkit","Moz","ms","O"],Et=t=>t.startsWith("-")?t:Ot.some(e=>t.startsWith(e))?`-${E(t)}`:E(t),z=(t,e,s)=>{if(!t)return"";const n=[],o=Object.entries(t).reduce((i,[p,r])=>{const c=p.trim(),y=Et(c),h=(w,k=";")=>i=`${i}${w}${k}`,g=w=>h(`${y}:${w}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(r.isColor)return g(r.toString()),i;if(c==="variants")return Object.entries(r).forEach(([D,j])=>{j&&Object.entries(j).forEach(([R,C])=>{if(!C)return;const V=`${e}.${D}-${R}`,f=z(C,V);n.push(f)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(D=>{const{css:j,...R}=D,C=Object.entries(R).reduce((f,[m,b])=>`${f}.${m}-${b}`,e),V=z(j,C);n.push(V)}),i;if(c.startsWith("@")){const D=z(r,e),j=`${c} {
|
2
2
|
${D.replace(`
|
3
3
|
`,`
|
4
4
|
`)}
|
5
|
-
}`;return n.push(j),i}const w=p.includes("&")?c.replace("&",e):c.startsWith(":")?`${e}${c}`:`${e} ${c}`,
|
5
|
+
}`;return n.push(j),i}const w=p.includes("&")?c.replace("&",e):c.startsWith(":")?`${e}${c}`:`${e} ${c}`,k=z(r,w);return n.push(k),i}if(typeof r=="number"){const w=Tt(y,r);return g(w)}if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:$}={},T=function*(){yield dt(r),yield _t(r,$)}();for(const{result:w,additionalCss:k=[]}of T)r=w,k.forEach(D=>{const j=z(D,"");h(j,"")});return g(r)},"");return o?e?[`${e} { ${o} }`,...n].join(`
|
6
6
|
`):o:n.join(`
|
7
|
-
`)},pt=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=pt(a,[...e,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=e.map(
|
8
|
-
`)},
|
7
|
+
`)},pt=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=pt(a,[...e,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=e.map(E).join("-"),a=z(n,`.${o}`);s.push(a)}return s.join(`
|
8
|
+
`)},Rt=t=>t?Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=gt(n).map(o=>`"${o}"`).join(" | ")),e),{}):{},gt=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const a=e?`${e}.${n}`:n;return typeof o=="object"?gt(o,a,s):s.add(e)}),[...s]):[],yt=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=l.join(t,"package.json");return u.existsSync(e)?e:yt(l.join(t,".."))},Vt=async t=>{const e=yt(t);return await Q.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},Mt=async t=>{const e=await Vt(t);if(e)return e.type};let A;const ht=async t=>{if(A)return A;const e=await Mt(t);return e==="module"?A="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.tagName.toUpperCase()==="SCRIPT"&&ot.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},rt=U.createLogger({level:"debug",format:U.format.combine(U.format.colorize(),U.format.cli()),transports:[new U.transports.Console({})]});function mt(t){return t?typeof t!="string"?mt(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 zt={"*, *::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"}},Z=(...t)=>t.flat().reduce((e,s)=>s!=null&&s._current?{...e,...s._current}:{...e,...s},{}),M={externalModules:[],rcFile:void 0,destDir:void 0},St=t=>{if(M.externalModules.length>0)return M.externalModules;const s=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return M.externalModules=n,n},J=async t=>{if(M.destDir)return M.destDir;const e=await it(t),s=l.join(t,(e==null?void 0:e.saltygenDir)||"saltygen");return M.destDir=s,s},bt=["salty","css","styles","styled"],Jt=(t=[])=>new RegExp(`\\.(${[...bt,...t].join("|")})\\.`),H=(t,e=[])=>Jt(e).test(t),$t=async t=>{if(M.rcFile)return M.rcFile;if(t==="/")throw new Error("Could not find .saltyrc.json file");const e=l.join(t,".saltyrc.json"),s=await Q.readFile(e,"utf-8").then(JSON.parse).catch(()=>{});return s?(M.rcFile=s,s):$t(l.join(t,".."))},it=async t=>{var n,o;const e=await $t(t),s=(n=e.projects)==null?void 0:n.find(a=>t.endsWith(a.dir||""));return s||((o=e.projects)==null?void 0:o.find(a=>a.dir===e.defaultProject))},Wt=async t=>{const e=await it(t),s=await J(t),n=l.join(t,(e==null?void 0:e.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await ht(t),i=St(n);await ut.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const p=Date.now(),{config:r}=await import(`${o}?t=${p}`);return r},At=async(t,e)=>{var W,G;const s=await J(t),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...e].map(async N=>{const P=await X(t,N,s);Object.values(P).forEach(_=>{_.isMedia?n.mediaQueries.push(_):_.isGlobalDefine?n.globalStyles.push(_):_.isDefineVariables?n.variables.push(_):_.isDefineTemplates&&n.templates.push(_)})}));const o=await Wt(t),a={...o},i=new Set,p=(N,P=[])=>N?Object.entries(N).flatMap(([_,O])=>{if(!O)return;if(typeof O=="object")return p(O,[...P,_]);const tt=mt(_),et=E(_),st=[...P,tt].join(".");i.add(`"${st}"`);const nt=[...P.map(E),et].join("-"),{result:Ft}=dt(O);return`--${nt}: ${Ft};`}):[],r=N=>N?Object.entries(N).flatMap(([P,_])=>{const O=p(_);return P==="base"?O.join(""):`${P} { ${O.join("")} }`}):[],c=N=>N?Object.entries(N).flatMap(([P,_])=>Object.entries(_).flatMap(([O,tt])=>{const et=p(tt,[P]),st=`.${P}-${O}, [data-${P}="${O}"]`,nt=et.join("");return`${st} { ${nt} }`})):[],y=N=>({...N,responsive:void 0,conditional:void 0}),h=N=>n.variables.map(P=>N==="static"?y(P._current):P._current[N]),g=Z(y(o.variables),h("static")),$=p(g),S=Z((W=o.variables)==null?void 0:W.responsive,h("responsive")),T=r(S),w=Z((G=o.variables)==null?void 0:G.conditional,h("conditional")),k=c(w),D=l.join(s,"css/_variables.css"),j=`:root { ${$.join("")} ${T.join("")} } ${k.join("")}`;u.writeFileSync(D,j),a.staticVariables=g;const R=l.join(s,"css/_global.css"),C=Z(o.global,n.globalStyles),V=z(C,"");u.writeFileSync(R,`@layer global { ${V} }`);const f=l.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:zt,d=z(b,"");u.writeFileSync(f,`@layer reset { ${d} }`);const F=l.join(s,"css/_templates.css"),x=Z(o.templates,n.templates),q=pt(x),L=Rt(x);u.writeFileSync(F,q),a.templates=x;const B=l.join(s,"types/css-tokens.d.ts"),K=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...i].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
12
|
|
13
13
|
// Template types
|
14
14
|
type TemplateTokens = {
|
15
|
-
${Object.entries(L).map(([N,
|
15
|
+
${Object.entries(L).map(([N,P])=>`${N}?: ${P}`).join(`
|
16
16
|
`)}
|
17
17
|
}
|
18
|
-
`;u.writeFileSync(B,K);const v=l.join(s,"cache/config-cache.json");u.writeFileSync(v,JSON.stringify(a,null,2))},lt=t=>t.replace(/styled\(([^"'`{,]+),/g,(e,s)=>{if(/^['"`]/.test(s))return e;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(t))return e;const i=o.exec(t);if(i){const p=i.at(1);if(bt.some(c=>p==null?void 0:p.includes(c)))return e}return"styled('div',"}),
|
18
|
+
`;u.writeFileSync(B,K);const v=l.join(s,"cache/config-cache.json");u.writeFileSync(v,JSON.stringify(a,null,2))},lt=t=>t.replace(/styled\(([^"'`{,]+),/g,(e,s)=>{if(/^['"`]/.test(s))return e;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(t))return e;const i=o.exec(t);if(i){const p=i.at(1);if(bt.some(c=>p==null?void 0:p.includes(c)))return e}return"styled('div',"}),Zt=(t,e)=>{try{const s=u.readFileSync(l.join(e,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
19
19
|
|
20
20
|
${t}`:`globalThis.saltyConfig = {};
|
21
21
|
|
22
|
-
${t}`}catch{return t}},X=async(t,e,s)=>{const n=I(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(e);let i=u.readFileSync(e,"utf8");i=lt(i),i=
|
23
|
-
`),d=I(f,6),F=l.parse(f),x=
|
22
|
+
${t}`}catch{return t}},X=async(t,e,s)=>{const n=I(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(e);let i=u.readFileSync(e,"utf8");i=lt(i),i=Zt(i,t);const p=l.join(s,"js",n+".js"),r=await it(t),c=l.join(t,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=St(c),h=await ht(t);await ut.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:h,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:S=>{S.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const w=u.readFileSync(T.path,"utf8");return{contents:lt(w),loader:"ts"}})}}]});const g=Date.now();return await import(`${p}?t=${g}`)},It=async t=>{const e=await J(t),s=l.join(e,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ct=async t=>{const e=await It(t),s=await J(t),n=l.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return Z(a,e)},wt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ht=async(t,e=wt(),s=!0)=>{try{const n=Date.now();e?rt.info("Generating CSS in production mode! 🔥"):rt.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await J(t),p=l.join(i,"index.css");s&&(()=>{u.existsSync(i)&&xt.execSync("rm -rf "+i),u.mkdirSync(i,{recursive:!0}),u.mkdirSync(l.join(i,"css")),u.mkdirSync(l.join(i,"types")),u.mkdirSync(l.join(i,"js")),u.mkdirSync(l.join(i,"cache"))})();const c=new Set,y=new Set;async function h(f){const m=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(m.some(x=>f.includes(x)))return;await Promise.all(d.map(x=>h(l.join(f,x))))}else if(b.isFile()&&H(f)){c.add(f);const F=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&y.add(f)}}await h(t),await At(t,y);const g={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const m=await X(t,f,i);Object.entries(m).forEach(([b,d])=>{d.isKeyframes?g.keyframes.push({value:d,src:f,name:b}):d.isClassName?g.classNames.push({...d,src:f,name:b}):d.generator&&g.components.push({...d,src:f,name:b})})}));const $=await ct(t);for(const f of g.keyframes){const{value:m}=f,b=`a_${m.animationName}.css`,d=`css/${b}`,F=l.join(i,d);o.push(b),u.writeFileSync(F,m.css)}const S={};for(const f of g.components){const{src:m,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:e,config:$});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),$.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}for(const f of g.classNames){const{src:m,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:e,config:$});a[0].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),$.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}$.importStrategy==="component"&&Object.entries(S).forEach(([f,m])=>{const b=m.map(L=>`@import url('./${L}');`).join(`
|
23
|
+
`),d=I(f,6),F=l.parse(f),x=E(F.name),q=l.join(i,`css/f_${x}-${d}.css`);u.writeFileSync(q,b)});const T=o.map(f=>`@import url('./css/${f}');`).join(`
|
24
24
|
`);let j=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
25
25
|
|
26
26
|
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(i,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
27
27
|
`)}
|
28
|
-
${T}`;if($.importStrategy!=="component"){const f=a.reduce((m,b,d)=>{const F=b.reduce((B,Y)=>{var G;const K=l.join(i,"css",Y),v=u.readFileSync(K,"utf8"),
|
29
|
-
/*start:${
|
28
|
+
${T}`;if($.importStrategy!=="component"){const f=a.reduce((m,b,d)=>{const F=b.reduce((B,Y)=>{var G;const K=l.join(i,"css",Y),v=u.readFileSync(K,"utf8"),W=((G=/.*-([^-]+)-\d+.css/.exec(Y))==null?void 0:G.at(1))||I(K,6);return B.includes(W)?B:`${B}
|
29
|
+
/*start:${W}*/
|
30
30
|
${v}
|
31
|
-
/*end:${
|
31
|
+
/*end:${W}*/
|
32
32
|
`},""),x=`l_${d}.css`,q=l.join(i,"css",x),L=`@layer l${d} { ${F}
|
33
33
|
}`;return u.writeFileSync(q,L),`${m}
|
34
|
-
@import url('./css/${x}');`},"");j+=f}u.writeFileSync(p,j);const C=Date.now()-n,
|
35
|
-
${
|
34
|
+
@import url('./css/${x}');`},"");j+=f}u.writeFileSync(p,j);const C=Date.now()-n,V=C<200?"🔥":C<500?"🚀":C<1e3?"🎉":C<2e3?"🚗":C<5e3?"🤔":"🥴";rt.info(`Generated CSS in ${C}ms! ${V}`)}catch(n){console.error(n)}},qt=async(t,e)=>{try{const s=await J(t);if(H(e)){const o=[],a=await ct(t),i=await X(t,e,s);if(Object.entries(i).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const $=`css/${`a_${r.animationName}.css`}`,S=l.join(s,$);u.writeFileSync(S,r.css);return}if(r.isClassName){const g=r.factory._withBuildContext({name:p});o[0].push(g.cssFileName);const $=`css/${g.cssFileName}`,S=l.join(s,$);u.writeFileSync(S,g.css)}if(!r.generator)return;const c=r.generator._withBuildContext({name:p,config:a}),y=`css/${c.cssFileName}`,h=l.join(s,y);u.writeFileSync(h,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),a.importStrategy!=="component")o.forEach((p,r)=>{const c=`l_${r}.css`,y=l.join(s,"css",c);let h=u.readFileSync(y,"utf8");p.forEach(g=>{var w;const $=l.join(s,"css",g),S=((w=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:w.at(1))||I($,6);if(!h.includes(S)){const k=u.readFileSync($,"utf8"),D=`/*start:${S}*/
|
35
|
+
${k}
|
36
36
|
/*end:${S}*/
|
37
37
|
`;h=`${h.replace(/\}$/,"")}
|
38
38
|
${D}
|
39
39
|
}`}}),u.writeFileSync(y,h)});else{const p=o.flat().map(g=>`@import url('./${g}');`).join(`
|
40
|
-
`),r=I(e,6),c=l.parse(e),y=
|
41
|
-
${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}},ft=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!H(t))return!1;const n=await Q.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},jt=t=>({name:"stylegen",buildStart:()=>
|
40
|
+
`),r=I(e,6),c=l.parse(e),y=E(c.name),h=l.join(s,`css/f_${y}-${r}.css`);u.writeFileSync(h,p)}}}catch(s){console.error(s)}},Lt=async(t,e,s=wt())=>{try{const n=await J(t);if(H(e)){const a=u.readFileSync(e,"utf8");a.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==a&&await Q.writeFile(e,a);const p=await ct(t),r=await X(t,e,n);let c=a;if(Object.entries(r).forEach(([y,h])=>{var d;if(h.isKeyframes||!h.generator)return;const g=h.generator._withBuildContext({name:y,config:p,prod:s}),$=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const S=(d=$.at(1))==null?void 0:d.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:w}=T;let k=!1;const D=setTimeout(()=>k=!0,5e3);let j=0,R=!1,C=0;for(;!R&&!k;){const F=c[w+j];F==="("&&C++,F===")"&&C--,C===0&&F===")"&&(R=!0),j>c.length&&(k=!0),j++}if(!k)clearTimeout(D);else throw new Error("Failed to find the end of the styled call and timed out");const V=w+j,f=c.slice(w,V),m=c,b=` ${y} = styled(${S}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;c=c.replace(f,b),m===c&&console.error("Minimize file failed to change content",{name:y,tagName:S})}),p.importStrategy==="component"){const y=I(e,6),h=l.parse(e);c=`import '../../saltygen/css/${`f_${E(h.name)}-${y}.css`}';
|
41
|
+
${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}},ft=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!H(t))return!1;const n=await Q.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},jt=t=>({name:"stylegen",buildStart:()=>Ht(t),load:async e=>{if(H(e))return await Lt(t,e)},handleHotUpdate:async({file:e,server:s})=>{await ft(e)&&await s.restart()},watchChange:{handler:async e=>{H(e)&&(await ft(e)||await qt(t,e))}}});exports.default=jt;exports.saltyPlugin=jt;
|
package/index.js
CHANGED
@@ -8,18 +8,18 @@ const ut = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Tt = (t, e) => {
|
|
8
8
|
let s = "", n;
|
9
9
|
for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = ut(n % 52) + s;
|
10
10
|
return s = ut(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
-
},
|
11
|
+
}, Ot = (t, e) => {
|
12
12
|
let s = e.length;
|
13
13
|
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
14
|
return t;
|
15
15
|
}, B = (t, e = 5) => {
|
16
|
-
const s =
|
16
|
+
const s = Ot(5381, JSON.stringify(t)) >>> 0;
|
17
17
|
return Tt(s, e);
|
18
18
|
};
|
19
|
-
function
|
20
|
-
return t ? typeof t != "string" ?
|
19
|
+
function V(t) {
|
20
|
+
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()) : "";
|
21
21
|
}
|
22
|
-
const
|
22
|
+
const Vt = (t, e) => {
|
23
23
|
if (typeof t != "string") return { result: t };
|
24
24
|
if (!e) return { result: t };
|
25
25
|
const s = [];
|
@@ -30,7 +30,7 @@ const Ot = (t, e) => {
|
|
30
30
|
return r && s.push(r), d;
|
31
31
|
});
|
32
32
|
}), { result: t, additionalCss: s };
|
33
|
-
}, ht = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${
|
33
|
+
}, ht = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, Rt = [
|
34
34
|
"top",
|
35
35
|
"right",
|
36
36
|
"bottom",
|
@@ -51,19 +51,19 @@ const Ot = (t, e) => {
|
|
51
51
|
/.*size.*/,
|
52
52
|
/.*thickness.*/,
|
53
53
|
/.*font-size.*/
|
54
|
-
], Mt = (t, e, s) => Rt.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`,
|
54
|
+
], Mt = (t, e, s) => Rt.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, Jt = ["Webkit", "Moz", "ms", "O"], Wt = (t) => t.startsWith("-") ? t : Jt.some((e) => t.startsWith(e)) ? `-${V(t)}` : V(t), W = (t, e, s) => {
|
55
55
|
if (!t) return "";
|
56
56
|
const n = [], o = Object.entries(t).reduce((i, [d, r]) => {
|
57
|
-
const c = d.trim(), g =
|
57
|
+
const c = d.trim(), g = Wt(c), h = (w, k = ";") => i = `${i}${w}${k}`, p = (w) => h(`${g}:${w}`);
|
58
58
|
if (typeof r == "function" && (r = r()), typeof r == "object") {
|
59
59
|
if (!r) return i;
|
60
60
|
if (r.isColor)
|
61
61
|
return p(r.toString()), i;
|
62
62
|
if (c === "variants")
|
63
63
|
return Object.entries(r).forEach(([_, S]) => {
|
64
|
-
S && Object.entries(S).forEach(([
|
64
|
+
S && Object.entries(S).forEach(([R, j]) => {
|
65
65
|
if (!j) return;
|
66
|
-
const
|
66
|
+
const M = `${e}.${_}-${R}`, l = W(j, M);
|
67
67
|
n.push(l);
|
68
68
|
});
|
69
69
|
}), i;
|
@@ -71,18 +71,18 @@ const Ot = (t, e) => {
|
|
71
71
|
return i;
|
72
72
|
if (c === "compoundVariants")
|
73
73
|
return r.forEach((_) => {
|
74
|
-
const { css: S, ...
|
75
|
-
n.push(
|
74
|
+
const { css: S, ...R } = _, j = Object.entries(R).reduce((l, [m, $]) => `${l}.${m}-${$}`, e), M = W(S, j);
|
75
|
+
n.push(M);
|
76
76
|
}), i;
|
77
77
|
if (c.startsWith("@")) {
|
78
|
-
const _ =
|
78
|
+
const _ = W(r, e), S = `${c} {
|
79
79
|
${_.replace(`
|
80
80
|
`, `
|
81
81
|
`)}
|
82
82
|
}`;
|
83
83
|
return n.push(S), i;
|
84
84
|
}
|
85
|
-
const w = d.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k =
|
85
|
+
const w = d.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k = W(r, w);
|
86
86
|
return n.push(k), i;
|
87
87
|
}
|
88
88
|
if (typeof r == "number") {
|
@@ -93,11 +93,11 @@ const Ot = (t, e) => {
|
|
93
93
|
if ("toString" in r) r = r.toString();
|
94
94
|
else return i;
|
95
95
|
const { modifiers: b } = {}, E = function* () {
|
96
|
-
yield ht(r), yield
|
96
|
+
yield ht(r), yield Vt(r, b);
|
97
97
|
}();
|
98
98
|
for (const { result: w, additionalCss: k = [] } of E)
|
99
99
|
r = w, k.forEach((_) => {
|
100
|
-
const S =
|
100
|
+
const S = W(_, "");
|
101
101
|
h(S, "");
|
102
102
|
});
|
103
103
|
return p(r);
|
@@ -116,12 +116,12 @@ const Ot = (t, e) => {
|
|
116
116
|
} else
|
117
117
|
n[o] = a;
|
118
118
|
}), Object.keys(n).length) {
|
119
|
-
const o = e.map(
|
119
|
+
const o = e.map(V).join("-"), a = W(n, `.${o}`);
|
120
120
|
s.push(a);
|
121
121
|
}
|
122
122
|
return s.join(`
|
123
123
|
`);
|
124
|
-
},
|
124
|
+
}, zt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = yt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, yt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
125
125
|
const a = e ? `${e}.${n}` : n;
|
126
126
|
return typeof o == "object" ? yt(o, a, s) : s.add(e);
|
127
127
|
}), [...s]) : [], $t = (t) => {
|
@@ -132,7 +132,7 @@ const Ot = (t, e) => {
|
|
132
132
|
const e = $t(t);
|
133
133
|
return await at(e, "utf-8").then(JSON.parse).catch(() => {
|
134
134
|
});
|
135
|
-
},
|
135
|
+
}, Zt = async (t) => {
|
136
136
|
const e = await At(t);
|
137
137
|
if (e)
|
138
138
|
return e.type;
|
@@ -140,7 +140,7 @@ const Ot = (t, e) => {
|
|
140
140
|
let Z;
|
141
141
|
const bt = async (t) => {
|
142
142
|
if (Z) return Z;
|
143
|
-
const e = await
|
143
|
+
const e = await Zt(t);
|
144
144
|
return e === "module" ? Z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (Z = "cjs"), Z || "esm";
|
145
145
|
}, it = _t({
|
146
146
|
level: "debug",
|
@@ -150,7 +150,7 @@ const bt = async (t) => {
|
|
150
150
|
function wt(t) {
|
151
151
|
return t ? typeof t != "string" ? wt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
152
152
|
}
|
153
|
-
const
|
153
|
+
const Ht = {
|
154
154
|
/** Set box model to border-box */
|
155
155
|
"*, *::before, *::after": {
|
156
156
|
boxSizing: "border-box"
|
@@ -196,31 +196,31 @@ const Wt = {
|
|
196
196
|
fontSize: "100%",
|
197
197
|
lineHeight: "1.15em"
|
198
198
|
}
|
199
|
-
}, I = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}),
|
199
|
+
}, I = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), J = {
|
200
200
|
externalModules: [],
|
201
201
|
rcFile: void 0,
|
202
202
|
destDir: void 0
|
203
203
|
}, St = (t) => {
|
204
|
-
if (
|
204
|
+
if (J.externalModules.length > 0) return J.externalModules;
|
205
205
|
const s = T(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
206
206
|
if (!s) return [];
|
207
207
|
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
208
|
-
return
|
208
|
+
return J.externalModules = n, n;
|
209
209
|
}, z = async (t) => {
|
210
|
-
if (
|
210
|
+
if (J.destDir) return J.destDir;
|
211
211
|
const e = await lt(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
212
|
-
return
|
213
|
-
}, Ct = ["salty", "css", "styles", "styled"],
|
214
|
-
if (
|
212
|
+
return J.destDir = s, s;
|
213
|
+
}, Ct = ["salty", "css", "styles", "styled"], It = (t = []) => new RegExp(`\\.(${[...Ct, ...t].join("|")})\\.`), G = (t, e = []) => It(e).test(t), jt = async (t) => {
|
214
|
+
if (J.rcFile) return J.rcFile;
|
215
215
|
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
216
216
|
const e = f(t, ".saltyrc.json"), s = await at(e, "utf-8").then(JSON.parse).catch(() => {
|
217
217
|
});
|
218
|
-
return s ? (
|
218
|
+
return s ? (J.rcFile = s, s) : jt(f(t, ".."));
|
219
219
|
}, lt = async (t) => {
|
220
220
|
var n, o;
|
221
221
|
const e = await jt(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
|
222
222
|
return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
|
223
|
-
},
|
223
|
+
}, Bt = async (t) => {
|
224
224
|
const e = await lt(t), s = await z(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = f(s, "salty.config.js"), a = await bt(t), i = St(n);
|
225
225
|
await gt.build({
|
226
226
|
entryPoints: [n],
|
@@ -233,8 +233,8 @@ const Wt = {
|
|
233
233
|
});
|
234
234
|
const d = Date.now(), { config: r } = await import(`${o}?t=${d}`);
|
235
235
|
return r;
|
236
|
-
},
|
237
|
-
var
|
236
|
+
}, Gt = async (t, e) => {
|
237
|
+
var A, q;
|
238
238
|
const s = await z(t), n = {
|
239
239
|
mediaQueries: [],
|
240
240
|
globalStyles: [],
|
@@ -249,26 +249,26 @@ const Wt = {
|
|
249
249
|
});
|
250
250
|
})
|
251
251
|
);
|
252
|
-
const o = await
|
253
|
-
if (!
|
254
|
-
if (typeof
|
255
|
-
const et = wt(D), st =
|
252
|
+
const o = await Bt(t), a = { ...o }, i = /* @__PURE__ */ new Set(), d = (x, N = []) => x ? Object.entries(x).flatMap(([D, O]) => {
|
253
|
+
if (!O) return;
|
254
|
+
if (typeof O == "object") return d(O, [...N, D]);
|
255
|
+
const et = wt(D), st = V(D), nt = [...N, et].join(".");
|
256
256
|
i.add(`"${nt}"`);
|
257
|
-
const ot = [...N.map(
|
257
|
+
const ot = [...N.map(V), st].join("-"), { result: xt } = ht(O);
|
258
258
|
return `--${ot}: ${xt};`;
|
259
259
|
}) : [], r = (x) => x ? Object.entries(x).flatMap(([N, D]) => {
|
260
|
-
const
|
261
|
-
return N === "base" ?
|
262
|
-
}) : [], c = (x) => x ? Object.entries(x).flatMap(([N, D]) => Object.entries(D).flatMap(([
|
263
|
-
const st = d(et, [N]), nt = `.${N}-${
|
260
|
+
const O = d(D);
|
261
|
+
return N === "base" ? O.join("") : `${N} { ${O.join("")} }`;
|
262
|
+
}) : [], c = (x) => x ? Object.entries(x).flatMap(([N, D]) => Object.entries(D).flatMap(([O, et]) => {
|
263
|
+
const st = d(et, [N]), nt = `.${N}-${O}, [data-${N}="${O}"]`, ot = st.join("");
|
264
264
|
return `${nt} { ${ot} }`;
|
265
|
-
})) : [], g = (x) => ({ ...x, responsive: void 0, conditional: void 0 }), h = (x) => n.variables.map((N) => x === "static" ? g(N._current) : N._current[x]), p = I(g(o.variables), h("static")), b = d(p), y = I((
|
265
|
+
})) : [], g = (x) => ({ ...x, responsive: void 0, conditional: void 0 }), h = (x) => n.variables.map((N) => x === "static" ? g(N._current) : N._current[x]), p = I(g(o.variables), h("static")), b = d(p), y = I((A = o.variables) == null ? void 0 : A.responsive, h("responsive")), E = r(y), w = I((q = o.variables) == null ? void 0 : q.conditional, h("conditional")), k = c(w), _ = f(s, "css/_variables.css"), S = `:root { ${b.join("")} ${E.join("")} } ${k.join("")}`;
|
266
266
|
P(_, S), a.staticVariables = p;
|
267
|
-
const
|
268
|
-
P(
|
269
|
-
const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset :
|
267
|
+
const R = f(s, "css/_global.css"), j = I(o.global, n.globalStyles), M = W(j, "");
|
268
|
+
P(R, `@layer global { ${M} }`);
|
269
|
+
const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Ht, u = W($, "");
|
270
270
|
P(l, `@layer reset { ${u} }`);
|
271
|
-
const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), L = mt(F), K =
|
271
|
+
const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), L = mt(F), K = zt(F);
|
272
272
|
P(C, L), a.templates = F;
|
273
273
|
const U = f(s, "types/css-tokens.d.ts"), Q = `
|
274
274
|
// Variable types
|
@@ -294,7 +294,7 @@ const Wt = {
|
|
294
294
|
if (Ct.some((c) => d == null ? void 0 : d.includes(c))) return e;
|
295
295
|
}
|
296
296
|
return "styled('div',";
|
297
|
-
}),
|
297
|
+
}), Lt = (t, e) => {
|
298
298
|
try {
|
299
299
|
const s = T(f(e, "saltygen/cache/config-cache.json"), "utf8");
|
300
300
|
return s ? `globalThis.saltyConfig = ${s};
|
@@ -310,7 +310,7 @@ ${t}`;
|
|
310
310
|
ct(o) || H(o);
|
311
311
|
const a = X(e);
|
312
312
|
let i = T(e, "utf8");
|
313
|
-
i = dt(i), i =
|
313
|
+
i = dt(i), i = Lt(i, t);
|
314
314
|
const d = f(s, "js", n + ".js"), r = await lt(t), c = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), g = St(c), h = await bt(t);
|
315
315
|
await gt.build({
|
316
316
|
stdin: {
|
@@ -342,12 +342,12 @@ ${t}`;
|
|
342
342
|
});
|
343
343
|
const p = Date.now();
|
344
344
|
return await import(`${d}?t=${p}`);
|
345
|
-
},
|
345
|
+
}, Kt = async (t) => {
|
346
346
|
const e = await z(t), s = f(e, "cache/config-cache.json"), n = T(s, "utf8");
|
347
347
|
if (!n) throw new Error("Could not find config cache file");
|
348
348
|
return JSON.parse(n);
|
349
349
|
}, ft = async (t) => {
|
350
|
-
const e = await
|
350
|
+
const e = await Kt(t), s = await z(t), n = f(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
|
351
351
|
return I(a, e);
|
352
352
|
}, Ft = () => {
|
353
353
|
try {
|
@@ -355,7 +355,7 @@ ${t}`;
|
|
355
355
|
} catch {
|
356
356
|
return !1;
|
357
357
|
}
|
358
|
-
},
|
358
|
+
}, Ut = async (t, e = Ft(), s = !0) => {
|
359
359
|
try {
|
360
360
|
const n = Date.now();
|
361
361
|
e ? it.info("Generating CSS in production mode! 🔥") : it.info("Generating CSS in development mode! 🚀");
|
@@ -376,7 +376,7 @@ ${t}`;
|
|
376
376
|
/define[\w\d]+\(/.test(C) && g.add(l);
|
377
377
|
}
|
378
378
|
}
|
379
|
-
await h(t), await
|
379
|
+
await h(t), await Gt(t, g);
|
380
380
|
const p = {
|
381
381
|
keyframes: [],
|
382
382
|
components: [],
|
@@ -430,7 +430,7 @@ ${t}`;
|
|
430
430
|
}
|
431
431
|
b.importStrategy === "component" && Object.entries(y).forEach(([l, m]) => {
|
432
432
|
const $ = m.map((K) => `@import url('./${K}');`).join(`
|
433
|
-
`), u = B(l, 6), C = X(l), F =
|
433
|
+
`), u = B(l, 6), C = X(l), F = V(C.name), L = f(i, `css/f_${F}-${u}.css`);
|
434
434
|
P(L, $);
|
435
435
|
});
|
436
436
|
const E = o.map((l) => `@import url('./css/${l}');`).join(`
|
@@ -450,11 +450,11 @@ ${E}`;
|
|
450
450
|
const l = a.reduce((m, $, u) => {
|
451
451
|
const C = $.reduce((U, v) => {
|
452
452
|
var q;
|
453
|
-
const Q = f(i, "css", v), tt = T(Q, "utf8"),
|
454
|
-
return U.includes(
|
455
|
-
/*start:${
|
453
|
+
const Q = f(i, "css", v), tt = T(Q, "utf8"), A = ((q = /.*-([^-]+)-\d+.css/.exec(v)) == null ? void 0 : q.at(1)) || B(Q, 6);
|
454
|
+
return U.includes(A) ? U : `${U}
|
455
|
+
/*start:${A}*/
|
456
456
|
${tt}
|
457
|
-
/*end:${
|
457
|
+
/*end:${A}*/
|
458
458
|
`;
|
459
459
|
}, ""), F = `l_${u}.css`, L = f(i, "css", F), K = `@layer l${u} { ${C}
|
460
460
|
}`;
|
@@ -464,12 +464,12 @@ ${tt}
|
|
464
464
|
S += l;
|
465
465
|
}
|
466
466
|
P(d, S);
|
467
|
-
const j = Date.now() - n,
|
468
|
-
it.info(`Generated CSS in ${j}ms! ${
|
467
|
+
const j = Date.now() - n, M = j < 200 ? "🔥" : j < 500 ? "🚀" : j < 1e3 ? "🎉" : j < 2e3 ? "🚗" : j < 5e3 ? "🤔" : "🥴";
|
468
|
+
it.info(`Generated CSS in ${j}ms! ${M}`);
|
469
469
|
} catch (n) {
|
470
470
|
console.error(n);
|
471
471
|
}
|
472
|
-
},
|
472
|
+
}, qt = async (t, e) => {
|
473
473
|
try {
|
474
474
|
const s = await z(t);
|
475
475
|
if (G(e)) {
|
@@ -514,14 +514,14 @@ ${_}
|
|
514
514
|
});
|
515
515
|
else {
|
516
516
|
const d = o.flat().map((p) => `@import url('./${p}');`).join(`
|
517
|
-
`), r = B(e, 6), c = X(e), g =
|
517
|
+
`), r = B(e, 6), c = X(e), g = V(c.name), h = f(s, `css/f_${g}-${r}.css`);
|
518
518
|
P(h, d);
|
519
519
|
}
|
520
520
|
}
|
521
521
|
} catch (s) {
|
522
522
|
console.error(s);
|
523
523
|
}
|
524
|
-
},
|
524
|
+
}, Qt = async (t, e, s = Ft()) => {
|
525
525
|
try {
|
526
526
|
const n = await z(t);
|
527
527
|
if (G(e)) {
|
@@ -543,18 +543,18 @@ ${_}
|
|
543
543
|
const { index: w } = E;
|
544
544
|
let k = !1;
|
545
545
|
const _ = setTimeout(() => k = !0, 5e3);
|
546
|
-
let S = 0,
|
547
|
-
for (; !
|
546
|
+
let S = 0, R = !1, j = 0;
|
547
|
+
for (; !R && !k; ) {
|
548
548
|
const C = c[w + S];
|
549
|
-
C === "(" && j++, C === ")" && j--, j === 0 && C === ")" && (
|
549
|
+
C === "(" && j++, C === ")" && j--, j === 0 && C === ")" && (R = !0), S > c.length && (k = !0), S++;
|
550
550
|
}
|
551
551
|
if (!k) clearTimeout(_);
|
552
552
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
553
|
-
const
|
553
|
+
const M = w + S, l = c.slice(w, M), m = c, $ = ` ${g} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;
|
554
554
|
c = c.replace(l, $), m === c && console.error("Minimize file failed to change content", { name: g, tagName: y });
|
555
555
|
}), d.importStrategy === "component") {
|
556
556
|
const g = B(e, 6), h = X(e);
|
557
|
-
c = `import '../../saltygen/css/${`f_${
|
557
|
+
c = `import '../../saltygen/css/${`f_${V(h.name)}-${g}.css`}';
|
558
558
|
${c}`;
|
559
559
|
}
|
560
560
|
return c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
@@ -568,23 +568,23 @@ ${c}`;
|
|
568
568
|
if (!G(t)) return !1;
|
569
569
|
const n = await at(t, "utf-8");
|
570
570
|
return !!/.+define[A-Z]\w+/.test(n);
|
571
|
-
},
|
571
|
+
}, se = (t) => ({
|
572
572
|
name: "stylegen",
|
573
|
-
buildStart: () =>
|
573
|
+
buildStart: () => Ut(t),
|
574
574
|
load: async (e) => {
|
575
575
|
if (G(e))
|
576
|
-
return await
|
576
|
+
return await Qt(t, e);
|
577
577
|
},
|
578
578
|
handleHotUpdate: async ({ file: e, server: s }) => {
|
579
579
|
await pt(e) && await s.restart();
|
580
580
|
},
|
581
581
|
watchChange: {
|
582
582
|
handler: async (e) => {
|
583
|
-
G(e) && (await pt(e) || await
|
583
|
+
G(e) && (await pt(e) || await qt(t, e));
|
584
584
|
}
|
585
585
|
}
|
586
586
|
});
|
587
587
|
export {
|
588
|
-
|
589
|
-
|
588
|
+
se as default,
|
589
|
+
se as saltyPlugin
|
590
590
|
};
|
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.199",
|
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.199"
|
38
38
|
}
|
39
39
|
}
|