@salty-css/webpack 0.0.1-alpha.205 → 0.0.1-alpha.207
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-C2eoLLSc.cjs +40 -0
- package/index-CSE05P-J.js +599 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/loader.cjs +1 -1
- package/loader.js +1 -1
- package/package.json +2 -2
- package/index-Bap_89L2.js +0 -591
- package/index-DJ94M3fE.cjs +0 -40
package/index-DJ94M3fE.cjs
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
"use strict";const Pe=require("esbuild"),ke=require("child_process"),a=require("path"),u=require("fs"),ie=require("fs/promises"),L=require("winston");var oe=typeof document<"u"?document.currentScript:null;function _e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const me=_e(Pe),ue=e=>String.fromCharCode(e+(e>25?39:97)),De=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ue(n%52)+s;return s=ue(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Oe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},v=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(s,t)};function V(e){return e?typeof e!="string"?V(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const Te=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:l}=o;s=s.replace(i,m=>{const{value:w,css:c}=l(m);return c&&n.push(c),w})}),{transformed:s,additionalCss:n}},ye=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${V(o[1].replaceAll(".","-"))})`)},Ee=ye(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Re=["Webkit","Moz","ms","O"],ze=e=>e.startsWith("-")?e:Re.some(t=>e.startsWith(t))?`-${V(e)}`:V(e),X=async(e,t="",s)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const n=new Set,i=Object.entries(e).map(async([g,r])=>{const p=g.trim(),h=ze(p),N=(P,T=";")=>`${h}:${P}${T}`;if(typeof r=="function"&&(r=r({scope:t,config:s})),r instanceof Promise&&(r=await r),typeof r=="object"){if(!r)return;if(r.isColor)return N(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const F=Object.entries(r);for(const[D,x]of F){if(!x)return;const M=Object.entries(x);for(const[f,y]of M){if(!y)return;const b=`${t}.${D}-${f}`;(await X(y,b,s)).forEach(C=>n.add(C))}}return}if(p==="compoundVariants"){for(const F of r){const{css:D,...x}=F,M=Object.entries(x).reduce((y,[b,d])=>`${y}.${b}-${d}`,t);(await X(D,M,s)).forEach(y=>n.add(y))}return}if(p.startsWith("@")){const F=p,D=await B(r,t,s),x=`${F} { ${D} }`;n.add(x);return}const P=g.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,P,s)).forEach(F=>n.add(F));return}if(typeof r=="number"){const P=Me(h,r);return N(P)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${h}`);return N(r)}),{modifiers:l}={},m=[ye(),Te(l)],c=(await Promise.all(i).then(g=>Promise.all(g.map(r=>m.reduce(async(p,h)=>{const N=await p;if(!N)return N;const _=await h(N);if(!_)return N;const{transformed:P,additionalCss:T}=_;let F="";if(T)for(const D of T)F+=await B(D,"");return`${F}${P}`},Promise.resolve(r)))))).join(`
|
2
|
-
`);if(!c.trim())return n;const $=t?`${t} { ${c} }`:c;return n.add($),n},B=async(e,t,s)=>[...await X(e,t,s)].join(`
|
3
|
-
`),ge=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const l=o.trim(),m=await ge(i,[...t,l]);s.push(m)}else n[o]=i;if(Object.keys(n).length){const o=t.map(V).join("-"),i=await B(n,`.${o}`);s.push(i)}return s.join(`
|
4
|
-
`)},Je=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=he(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},he=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?he(o,i,s):s.add(t)}),[...s]):[],we=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return u.existsSync(t)?t:we(a.join(e,".."))},We=async e=>{const t=we(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ae=async e=>{const t=await We(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await Ae(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-DJ94M3fE.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function be(e){return e?typeof e!="string"?be(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const ve={"*, *::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"}},A=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ie=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),z={externalModules:[],rcFile:void 0,destDir:void 0},Se=e=>{if(z.externalModules.length>0)return z.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return z.externalModules=n,n},J=async e=>{if(z.destDir)return z.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},je=["salty","css","styles","styled"],Fe=(e=[])=>new RegExp(`\\.(${[...je,...e].join("|")})\\.`),Y=(e,t=[])=>Fe(t).test(e),Ce=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Ce(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ce(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Ze=async e=>{const t=await ce(e),s=await J(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await $e(e),l=Se(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:l});const m=Date.now(),{config:w}=await import(`${o}?t=${m}`);return w},qe=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:j,outputFilePath:R}=await ee(e,S,s);Object.entries(j).forEach(([O,E])=>{E.isMedia?n.mediaQueries.push([O,E]):E.isGlobalDefine?n.globalStyles.push(E):E.isDefineVariables?n.variables.push(E):E.isDefineTemplates&&n.templates.push(E._setPath(R))})}));const o=await Ze(e),i={...o},l=new Set,m=(S,j=[])=>S?Object.entries(S).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return m(O,[...j,R]);const E=be(R),se=V(R),ne=[...j,E].join(".");l.add(`"${ne}"`);const U=[...j.map(V),se].join("-"),de=Ee(O);return de?`--${U}: ${de.transformed};`:`--${U}: ${O};`}):[],w=S=>S?Object.entries(S).flatMap(([j,R])=>{const O=m(R);return j==="base"?O.join(""):`${j} { ${O.join("")} }`}):[],c=S=>S?Object.entries(S).flatMap(([j,R])=>Object.entries(R).flatMap(([O,E])=>{const se=m(E,[j]),ne=`.${j}-${O}, [data-${j}="${O}"]`,U=se.join("");return`${ne} { ${U} }`})):[],$=S=>({...S,responsive:void 0,conditional:void 0}),g=S=>n.variables.map(j=>S==="static"?$(j._current):j._current[S]),r=A($(o.variables),g("static")),p=m(r),h=A((le=o.variables)==null?void 0:le.responsive,g("responsive")),N=w(h),_=A((fe=o.variables)==null?void 0:fe.conditional,g("conditional")),P=c(_),T=a.join(s,"css/_variables.css"),F=`:root { ${p.join("")} ${N.join("")} } ${P.join("")}`;u.writeFileSync(T,F),i.staticVariables=r;const D=a.join(s,"css/_global.css"),x=A(o.global,n.globalStyles),M=await B(x,"");u.writeFileSync(D,`@layer global { ${M} }`);const f=a.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ve,d=await B(b,"");u.writeFileSync(f,`@layer reset { ${d} }`);const C=a.join(s,"css/_templates.css"),k=A(o.templates,n.templates),I=await ge(k),Z=Je(k);u.writeFileSync(C,I),i.templates=k;const q=Ie(n.templates);i.templatePaths=Object.fromEntries(Object.entries(q).map(([S,j])=>[S,j._path||"nope"]));const{mediaQueries:H}=n;i.mediaQueries=Object.fromEntries(H.map(([S,j])=>[`@${S}`,j]));const G=H.map(([S])=>`'@${S}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
|
5
|
-
// Variable types
|
6
|
-
type VariableTokens = ${[...l].join("|")};
|
7
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
8
|
-
|
9
|
-
// Template types
|
10
|
-
type TemplateTokens = {
|
11
|
-
${Object.entries(Z).map(([S,j])=>`${S}?: ${j}`).join(`
|
12
|
-
`)}
|
13
|
-
}
|
14
|
-
|
15
|
-
// Media query types
|
16
|
-
type MediaQueryKeys = ${G||"''"};
|
17
|
-
`;u.writeFileSync(te,Q);const Ne=a.join(s,"cache/config-cache.json");u.writeFileSync(Ne,JSON.stringify(i,null,2))},pe=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const l=o.exec(e);if(l){const m=l.at(1);if(je.some(c=>m==null?void 0:m.includes(c)))return t}return"styled('div',"}),He=(e,t)=>{try{const s=u.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
18
|
-
|
19
|
-
${e}`:`globalThis.saltyConfig = {};
|
20
|
-
|
21
|
-
${e}`}catch{return e}},ee=async(e,t,s)=>{const n=v(t),o=a.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=a.parse(t);let l=u.readFileSync(t,"utf8");l=pe(l),l=He(l,e);const m=a.join(s,"js",n+".js"),w=await ce(e),c=a.join(e,(w==null?void 0:w.configDir)||"","salty.config.ts"),$=Se(c),g=await $e(e);await me.build({stdin:{contents:l,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:$,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},N=>{const _=u.readFileSync(N.path,"utf8");return{contents:pe(_),loader:"ts"}})}}]});const r=Date.now();return{contents:await import(`${m}?t=${r}`),outputFilePath:m}},Le=async e=>{const t=await J(e),s=a.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Le(e),s=await J(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return A(i,t)},xe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=xe(),s=!0)=>{try{const n=Date.now();t?re.info("Generating CSS in production mode! 🔥"):re.info("Generating CSS in development mode! 🚀");const o=[],i=[],l=await J(e),m=a.join(l,"index.css");s&&(()=>{u.existsSync(l)&&ke.execSync("rm -rf "+l),u.mkdirSync(l,{recursive:!0}),u.mkdirSync(a.join(l,"css")),u.mkdirSync(a.join(l,"types")),u.mkdirSync(a.join(l,"js")),u.mkdirSync(a.join(l,"cache"))})();const c=new Set,$=new Set;async function g(f){const y=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(y.some(k=>f.includes(k)))return;await Promise.all(d.map(k=>g(a.join(f,k))))}else if(b.isFile()&&Y(f)){c.add(f);const C=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&$.add(f)}}await g(e),await qe(e,$);const r={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const{contents:y}=await ee(e,f,l);Object.entries(y).forEach(([b,d])=>{d.isKeyframes?r.keyframes.push({value:d,src:f,name:b}):d.isClassName?r.classNames.push({...d,src:f,name:b}):d.generator&&r.components.push({...d,src:f,name:b})})}));const p=await ae(e);for(const f of r.keyframes){const{value:y}=f,b=`a_${y.animationName}.css`,d=`css/${b}`,C=a.join(l,d);o.push(b),u.writeFileSync(C,y.css)}const h={};for(const f of r.components){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}for(const f of r.classNames){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[0].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}p.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const b=y.map(Z=>`@import url('./${Z}');`).join(`
|
22
|
-
`),d=v(f,6),C=a.parse(f),k=V(C.name),I=a.join(l,`css/f_${k}-${d}.css`);u.writeFileSync(I,b)});const N=o.map(f=>`@import url('./css/${f}');`).join(`
|
23
|
-
`);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
24
|
-
|
25
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(a.join(l,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
26
|
-
`)}
|
27
|
-
${N}`;if(p.importStrategy!=="component"){const f=i.reduce((y,b,d)=>{const C=b.reduce((q,H)=>{var Q;const G=a.join(l,"css",H),te=u.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:Q.at(1))||v(G,6);return q.includes(K)?q:`${q}
|
28
|
-
/*start:${K}*/
|
29
|
-
${te}
|
30
|
-
/*end:${K}*/
|
31
|
-
`},""),k=`l_${d}.css`,I=a.join(l,"css",k),Z=`@layer l${d} { ${C}
|
32
|
-
}`;return u.writeFileSync(I,Z),`${y}
|
33
|
-
@import url('./css/${k}');`},"");F+=f}u.writeFileSync(m,F);const x=Date.now()-n,M=x<200?"🔥":x<500?"🚀":x<1e3?"🎉":x<2e3?"🚗":x<5e3?"🤔":"🥴";re.info(`Generated CSS in ${x}ms! ${M}`)}catch(n){console.error(n)}},Ge=async(e,t)=>{try{const s=await J(e);if(Y(t)){const o=[],i=await ae(e),{contents:l}=await ee(e,t,s);for(const[m,w]of Object.entries(l)){if(w.isKeyframes&&w.css){const p=`css/${`a_${w.animationName}.css`}`,h=a.join(s,p);u.writeFileSync(h,await w.css);return}if(w.isClassName){const r=w.factory._withBuildContext({name:m});o[0].push(r.cssFileName);const p=`css/${r.cssFileName}`,h=a.join(s,p);u.writeFileSync(h,await r.css)}if(!w.generator)return;const c=w.generator._withBuildContext({name:m,config:i}),$=`css/${c.cssFileName}`,g=a.join(s,$);u.writeFileSync(g,await c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}if(i.importStrategy!=="component")o.forEach((m,w)=>{const c=`l_${w}.css`,$=a.join(s,"css",c);let g=u.readFileSync($,"utf8");m.forEach(r=>{var _;const p=a.join(s,"css",r),h=((_=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:_.at(1))||v(p,6);if(!g.includes(h)){const P=u.readFileSync(p,"utf8"),T=`/*start:${h}*/
|
34
|
-
${P}
|
35
|
-
/*end:${h}*/
|
36
|
-
`;g=`${g.replace(/\}$/,"")}
|
37
|
-
${T}
|
38
|
-
}`}}),u.writeFileSync($,g)});else{const m=o.flat().map(r=>`@import url('./${r}');`).join(`
|
39
|
-
`),w=v(t,6),c=a.parse(t),$=V(c.name),g=a.join(s,`css/f_${$}-${w}.css`);u.writeFileSync(g,m)}}}catch(s){console.error(s)}},Ke=async(e,t,s=xe())=>{try{const n=await J(e);if(Y(t)){const i=u.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,$=>`export ${$}`)!==i&&await ie.writeFile(t,i);const m=await ae(e),{contents:w}=await ee(e,t,n);let c=i;if(Object.entries(w).forEach(([$,g])=>{var d;if(g.isKeyframes||!g.generator)return;const r=g.generator._withBuildContext({name:$,config:m,prod:s}),p=new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!p)return console.error("Could not find the original declaration");const h=(d=p.at(1))==null?void 0:d.trim(),N=new RegExp(`\\s${$}[=\\s]+styled\\(`,"g").exec(c);if(!N)return console.error("Could not find the original declaration");const{index:_}=N;let P=!1;const T=setTimeout(()=>P=!0,5e3);let F=0,D=!1,x=0;for(;!D&&!P;){const C=c[_+F];C==="("&&x++,C===")"&&x--,x===0&&C===")"&&(D=!0),F>c.length&&(P=!0),F++}if(!P)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const M=_+F,f=c.slice(_,M),y=c,b=` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;c=c.replace(f,b),y===c&&console.error("Minimize file failed to change content",{name:$,tagName:h})}),m.importStrategy==="component"){const $=v(t,6),g=a.parse(t);c=`import '../../saltygen/css/${`f_${V(g.name)}-${$}.css`}';
|
40
|
-
${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)}};exports.generateCss=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Fe;
|