@salty-css/webpack 0.0.1-alpha.140 → 0.0.1-alpha.141

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.
@@ -5,7 +5,7 @@
5
5
  }`;return n.push(y),l}const g=d.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,w=O(c,g);return n.push(w),l}const h=r.startsWith("-")?r:E(r),F=(g,w=";")=>l=`${l}${g}${w}`,j=g=>F(`${h}:${g}`);if(typeof c=="number")return j(c);if(typeof c!="string")if("toString"in c)c=c.toString();else return l;const{modifiers:S}={},_=function*(){yield Q(c),yield he(c,S)}();for(const{result:g,additionalCss:w=[]}of _)c=g,w.forEach(f=>{const y=O(f,"");F(y,"")});return j(c)},"");return i?t?[`${t} { ${i} }`,...n].join(`
6
6
  `):i:n.join(`
7
7
  `)},v=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,o])=>{if(typeof o=="object"){if(!o)return;const l=i.trim(),d=v(o,[...t,l]);s.push(d)}else n[i]=o}),Object.keys(n).length){const i=t.map(E).join("-"),o=O(n,`.${i}`);s.push(o)}return s.join(`
8
- `)},Se=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ee(n).map(i=>`"${i}"`).join(" | ")),t),{}),ee=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?ee(i,o,s):s.add(t)}),[...s]):[],te=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:te(a.join(e,".."))},$e=async e=>{const t=te(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},be=async e=>{const t=await $e(e);if(t)return t.type};let R;const se=async e=>{if(R)return R;const t=await be(e);return t==="module"?R="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-D0sdFJc4.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},Z=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]});function ne(e){return e?typeof e!="string"?ne(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 je={"*, *::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"}},I={externalModules:[]},oe=e=>{if(I.externalModules.length>0)return I.externalModules;const t=a.join(e,"salty.config.ts"),n=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return I.externalModules=i,i},J=e=>a.join(e,"./saltygen"),re=["salty","css","styles","styled"],ie=(e=[])=>new RegExp(`\\.(${[...re,...e].join("|")})\\.`),L=(e,t=[])=>ie(t).test(e),we=async e=>{const t=J(e),s=a.join(e,"salty.config.ts"),n=a.join(t,"salty.config.js"),i=await se(e),o=oe(e);await Y.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const l=Date.now(),{config:d}=await import(`${n}?t=${l}`);return d},Fe=async e=>{const t=await we(e),s=new Set,n=(p,m=[])=>p?Object.entries(p).flatMap(([C,$])=>{if(!$)return;if(typeof $=="object")return n($,[...m,C]);const M=ne(C),A=E(C),V=[...m,M].join(".");s.add(`"${V}"`);const P=[...m.map(E),A].join("-"),{result:D}=Q($);return`--${P}: ${D};`}):[],i=p=>p?Object.entries(p).flatMap(([m,C])=>{const $=n(C);return m==="base"?$.join(""):`${m} { ${$.join("")} }`}):[],o=p=>p?Object.entries(p).flatMap(([m,C])=>Object.entries(C).flatMap(([$,M])=>{const A=n(M,[m]),V=`.${m}-${$}, [data-${m}="${$}"]`,P=A.join("");return`${V} { ${P} }`})):[],l=n(t.variables),d=i(t.responsiveVariables),c=o(t.conditionalVariables),r=J(e),h=a.join(r,"css/_variables.css"),F=`:root { ${l.join("")} ${d.join("")} } ${c.join("")}`;u.writeFileSync(h,F);const j=a.join(r,"css/_global.css"),S=O(t.global,"");u.writeFileSync(j,`@layer global { ${S} }`);const x=a.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:je,w=O(g,"");u.writeFileSync(x,`@layer reset { ${w} }`);const f=a.join(r,"css/_templates.css"),y=v(t.templates),N=Se(t.templates);u.writeFileSync(f,y);const b=a.join(r,"types/css-tokens.d.ts"),k=`
8
+ `)},Se=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ee(n).map(i=>`"${i}"`).join(" | ")),t),{}),ee=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?ee(i,o,s):s.add(t)}),[...s]):[],te=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:te(a.join(e,".."))},$e=async e=>{const t=te(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},be=async e=>{const t=await $e(e);if(t)return t.type};let R;const se=async e=>{if(R)return R;const t=await be(e);return t==="module"?R="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-BxheJE6C.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},Z=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]});function ne(e){return e?typeof e!="string"?ne(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 je={"*, *::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"}},I={externalModules:[]},oe=e=>{if(I.externalModules.length>0)return I.externalModules;const t=a.join(e,"salty.config.ts"),n=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return I.externalModules=i,i},J=e=>a.join(e,"./saltygen"),re=["salty","css","styles","styled"],ie=(e=[])=>new RegExp(`\\.(${[...re,...e].join("|")})\\.`),L=(e,t=[])=>ie(t).test(e),we=async e=>{const t=J(e),s=a.join(e,"salty.config.ts"),n=a.join(t,"salty.config.js"),i=await se(e),o=oe(e);await Y.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const l=Date.now(),{config:d}=await import(`${n}?t=${l}`);return d},Fe=async e=>{const t=await we(e),s=new Set,n=(p,m=[])=>p?Object.entries(p).flatMap(([C,$])=>{if(!$)return;if(typeof $=="object")return n($,[...m,C]);const M=ne(C),A=E(C),V=[...m,M].join(".");s.add(`"${V}"`);const P=[...m.map(E),A].join("-"),{result:D}=Q($);return`--${P}: ${D};`}):[],i=p=>p?Object.entries(p).flatMap(([m,C])=>{const $=n(C);return m==="base"?$.join(""):`${m} { ${$.join("")} }`}):[],o=p=>p?Object.entries(p).flatMap(([m,C])=>Object.entries(C).flatMap(([$,M])=>{const A=n(M,[m]),V=`.${m}-${$}, [data-${m}="${$}"]`,P=A.join("");return`${V} { ${P} }`})):[],l=n(t.variables),d=i(t.responsiveVariables),c=o(t.conditionalVariables),r=J(e),h=a.join(r,"css/_variables.css"),F=`:root { ${l.join("")} ${d.join("")} } ${c.join("")}`;u.writeFileSync(h,F);const j=a.join(r,"css/_global.css"),S=O(t.global,"");u.writeFileSync(j,`@layer global { ${S} }`);const x=a.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:je,w=O(g,"");u.writeFileSync(x,`@layer reset { ${w} }`);const f=a.join(r,"css/_templates.css"),y=v(t.templates),N=Se(t.templates);u.writeFileSync(f,y);const b=a.join(r,"types/css-tokens.d.ts"),k=`
9
9
  // Variable types
10
10
  type VariableTokens = ${[...s].join("|")};
11
11
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -15,7 +15,7 @@
15
15
  ${Object.entries(N).map(([p,m])=>`${p}?: ${m}`).join(`
16
16
  `)}
17
17
  }
18
- `;u.writeFileSync(b,k)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{const n=/^['"`]/.test(s);if(n&&console.log("String tag",s),n)return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`),o=i.test(e);if(o||console.log("Not imported",s),!o)return t;const l=i.exec(e);if(l){const d=l.at(1),c=re.some(r=>d==null?void 0:d.includes(r));if(c&&console.log("Salty import for",s,`"${l.at(0)}"`),c)return t}return console.log("Replacing",s),"styled('div',"}),H=async(e,t,s)=>{console.log({sourceFilePath:t});const n=q(t),i=a.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=a.parse(t);let l=u.readFileSync(t,"utf8");l=U(l);const d=a.join(s,"js",n+".js"),c=oe(e),r=await se(e);await Y.build({stdin:{contents:l,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:r,target:["node20"],keepNames:!0,external:c,packages:"external",plugins:[{name:"test",setup:j=>{j.onLoad({filter:/.*.css.ts/},S=>{console.log("Loading",{sourceFilePath:t,args:S});const x=u.readFileSync(S.path,"utf8");return{contents:U(x)}})}}]});const h=Date.now();return await import(`${d}?t=${h}`)},B=async e=>{const t=J(e),s=a.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ce())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=J(e),l=a.join(o,"index.css");(()=>{u.existsSync(o)&&de.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(a.join(o,"css")),u.mkdirSync(a.join(o,"types"))})(),await Fe(e);const c=await B(e);async function r(f,y){const N=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const T=u.readdirSync(f);if(N.some(p=>f.includes(p)))return;await Promise.all(T.map(p=>r(a.join(f,p),a.join(y,p))))}else if(b.isFile()&&L(f)){const k=await H(e,f,o),p=[];Object.entries(k).forEach(([V,P])=>{if(P.isKeyframes&&P.css){const K=`a_${P.animationName}.css`,fe=`css/${K}`,ue=a.join(o,fe);n.push(K),u.writeFileSync(ue,P.css);return}if(!P.generator)return;const D=P.generator._withBuildContext({name:V,config:c,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),p.push(D.cssFileName);const ae=`css/${D.cssFileName}`,le=a.join(o,ae);u.writeFileSync(le,D.css)});const m=p.map(V=>`@import url('./${V}');`).join(`
18
+ `;u.writeFileSync(b,k)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{const n=/^['"`]/.test(s);if(n&&console.log("String tag",s),n)return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`),o=i.test(e);if(o||console.log("Not imported",s),!o)return t;const l=i.exec(e);if(l){const d=l.at(1),c=re.some(r=>d==null?void 0:d.includes(r));if(c&&console.log("Salty import for",s,`"${l.at(0)}"`),c)return t}return console.log("Replacing",s),"styled('div',"}),H=async(e,t,s)=>{console.log({sourceFilePath:t});const n=q(t),i=a.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=a.parse(t);let l=u.readFileSync(t,"utf8");l=U(l);const d=a.join(s,"js",n+".js"),c=oe(e),r=await se(e);await Y.build({stdin:{contents:l,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:r,target:["node20"],keepNames:!0,external:c,packages:"external",plugins:[{name:"test",setup:j=>{j.onLoad({filter:/.*.css.ts/},S=>{console.log("Loading",{sourceFilePath:t,args:S});const x=u.readFileSync(S.path,"utf8");return{contents:U(x),loader:"ts"}})}}]});const h=Date.now();return await import(`${d}?t=${h}`)},B=async e=>{const t=J(e),s=a.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ce())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=J(e),l=a.join(o,"index.css");(()=>{u.existsSync(o)&&de.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(a.join(o,"css")),u.mkdirSync(a.join(o,"types"))})(),await Fe(e);const c=await B(e);async function r(f,y){const N=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const T=u.readdirSync(f);if(N.some(p=>f.includes(p)))return;await Promise.all(T.map(p=>r(a.join(f,p),a.join(y,p))))}else if(b.isFile()&&L(f)){const k=await H(e,f,o),p=[];Object.entries(k).forEach(([V,P])=>{if(P.isKeyframes&&P.css){const K=`a_${P.animationName}.css`,fe=`css/${K}`,ue=a.join(o,fe);n.push(K),u.writeFileSync(ue,P.css);return}if(!P.generator)return;const D=P.generator._withBuildContext({name:V,config:c,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),p.push(D.cssFileName);const ae=`css/${D.cssFileName}`,le=a.join(o,ae);u.writeFileSync(le,D.css)});const m=p.map(V=>`@import url('./${V}');`).join(`
19
19
  `),C=q(f,6),$=a.parse(f),M=E($.name),A=a.join(o,`css/f_${M}-${C}.css`);u.writeFileSync(A,m)}}await r(e,o);const h=n.map(f=>`@import url('./css/${f}');`).join(`
20
20
  `);let x=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
21
 
@@ -271,7 +271,7 @@ const kt = {
271
271
  args: h
272
272
  });
273
273
  const x = A(h.path, "utf8");
274
- return { contents: Q(x) };
274
+ return { contents: Q(x), loader: "ts" };
275
275
  });
276
276
  }
277
277
  }
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-D0sdFJc4.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-BxheJE6C.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as n } from "path";
2
- import { s as u, g as i } from "./index-SUW5aXyU.js";
2
+ import { s as u, g as i } from "./index-BykKWc8Q.js";
3
3
  const g = (s, e, o = !1, r = !1) => {
4
4
  var a, l, t;
5
5
  (l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-D0sdFJc4.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
1
+ "use strict";const i=require("./index-BxheJE6C.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
package/loader.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, m as i } from "./index-SUW5aXyU.js";
1
+ import { a as e, m as i } from "./index-BykKWc8Q.js";
2
2
  async function s() {
3
3
  const { dir: t } = this.getOptions(), { resourcePath: a } = this;
4
4
  return await e(t, a), await i(t, a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
3
- "version": "0.0.1-alpha.140",
3
+ "version": "0.0.1-alpha.141",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.140",
37
+ "@salty-css/core": "^0.0.1-alpha.141",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }