@salty-css/webpack 0.0.1-alpha.137 → 0.0.1-alpha.138
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-B3d_60Gq.cjs → index-DyEDMxfI.cjs} +2 -2
- package/{index-Bsx1QEJo.js → index-esCBzNKC.js} +1 -1
- 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
@@ -5,7 +5,7 @@
|
|
5
5
|
}`;return n.push(y),f}const d=m.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,S=O(a,d);return n.push(S),f}const h=r.startsWith("-")?r:E(r),F=(d,S=";")=>f=`${f}${d}${S}`,j=d=>F(`${h}:${d}`);if(typeof a=="number")return j(a);if(typeof a!="string")if("toString"in a)a=a.toString();else return f;const{modifiers:$}={},N=function*(){yield Y(a),yield me(a,$)}();for(const{result:d,additionalCss:S=[]}of N)a=d,S.forEach(c=>{const y=O(c,"");F(y,"")});return j(a)},"");return i?t?[`${t} { ${i} }`,...n].join(`
|
6
6
|
`):i:n.join(`
|
7
7
|
`)},Q=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,o])=>{if(typeof o=="object"){if(!o)return;const f=i.trim(),m=Q(o,[...t,f]);s.push(m)}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
|
-
`)},he=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=v(n).map(i=>`"${i}"`).join(" | ")),t),{}),v=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?v(i,o,s):s.add(t)}),[...s]):[],ee=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ee(l.join(e,".."))},$e=async e=>{const t=ee(e);return await U.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Se=async e=>{const t=await $e(e);if(t)return t.type};let R;const te=async e=>{if(R)return R;const t=await Se(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-
|
8
|
+
`)},he=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=v(n).map(i=>`"${i}"`).join(" | ")),t),{}),v=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?v(i,o,s):s.add(t)}),[...s]):[],ee=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ee(l.join(e,".."))},$e=async e=>{const t=ee(e);return await U.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Se=async e=>{const t=await $e(e);if(t)return t.type};let R;const te=async e=>{if(R)return R;const t=await Se(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-DyEDMxfI.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},I=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]});function se(e){return e?typeof e!="string"?se(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 be={"*, *::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={externalModules:[]},ne=e=>{if(Z.externalModules.length>0)return Z.externalModules;const t=l.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 Z.externalModules=i,i},J=e=>l.join(e,"./saltygen"),oe=["salty","css","styles","styled"],re=(e=[])=>new RegExp(`\\.(${[...oe,...e].join("|")})\\.`),H=(e,t=[])=>re(t).test(e),je=async e=>{const t=J(e),s=l.join(e,"salty.config.ts"),n=l.join(t,"salty.config.js"),i=await te(e),o=ne(e);await X.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const f=Date.now(),{config:m}=await import(`${n}?t=${f}`);return m},we=async e=>{const t=await je(e),s=new Set,n=(p,g=[])=>p?Object.entries(p).flatMap(([C,b])=>{if(!b)return;if(typeof b=="object")return n(b,[...g,C]);const M=se(C),A=E(C),V=[...g,M].join(".");s.add(`"${V}"`);const _=[...g.map(E),A].join("-"),{result:D}=Y(b);return`--${_}: ${D};`}):[],i=p=>p?Object.entries(p).flatMap(([g,C])=>{const b=n(C);return g==="base"?b.join(""):`${g} { ${b.join("")} }`}):[],o=p=>p?Object.entries(p).flatMap(([g,C])=>Object.entries(C).flatMap(([b,M])=>{const A=n(M,[g]),V=`.${g}-${b}, [data-${g}="${b}"]`,_=A.join("");return`${V} { ${_} }`})):[],f=n(t.variables),m=i(t.responsiveVariables),a=o(t.conditionalVariables),r=J(e),h=l.join(r,"css/_variables.css"),F=`:root { ${f.join("")} ${m.join("")} } ${a.join("")}`;u.writeFileSync(h,F);const j=l.join(r,"css/_global.css"),$=O(t.global,"");u.writeFileSync(j,`@layer global { ${$} }`);const k=l.join(r,"css/_reset.css"),d=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:be,S=O(d,"");u.writeFileSync(k,`@layer reset { ${S} }`);const c=l.join(r,"css/_templates.css"),y=Q(t.templates),x=he(t.templates);u.writeFileSync(c,y);const w=l.join(r,"types/css-tokens.d.ts"),P=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...s].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -15,7 +15,7 @@
|
|
15
15
|
${Object.entries(x).map(([p,g])=>`${p}?: ${g}`).join(`
|
16
16
|
`)}
|
17
17
|
}
|
18
|
-
`;u.writeFileSync(w,P)},L=async(e,t,s)=>{const n=q(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=l.parse(t);let f=u.readFileSync(t,"utf8");f=f.replace(/styled\(([^"'`{,]+),/g,(j,$)=>{if(/^['"`]/.test($))return j;const N=new RegExp(`import
|
18
|
+
`;u.writeFileSync(w,P)},L=async(e,t,s)=>{const n=q(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const o=l.parse(t);let f=u.readFileSync(t,"utf8");f=f.replace(/styled\(([^"'`{,]+),/g,(j,$)=>{if(/^['"`]/.test($))return j;const N=new RegExp(`import[^;]*${$}[,\\s{][^;]*from\\s?([^{};]+);`);if(!N.test(f))return j;const S=N.exec(f);if(S){const c=S.at(1);if(oe.some(x=>c==null?void 0:c.includes(x)))return j}return"styled('div',"});const m=l.join(s,"js",n+".js"),a=ne(e),r=await te(e);await X.build({stdin:{contents:f,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:r,target:["node20"],keepNames:!0,external:a,packages:"external"});const h=Date.now();return await import(`${m}?t=${h}`)},B=async e=>{const t=J(e),s=l.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ie=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Fe=async(e,t=ie())=>{try{const s=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=J(e),f=l.join(o,"index.css");(()=>{u.existsSync(o)&&pe.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(l.join(o,"css")),u.mkdirSync(l.join(o,"types"))})(),await we(e);const a=await B(e);async function r(c,y){const x=["node_modules","saltygen"],w=u.statSync(c);if(w.isDirectory()){const T=u.readdirSync(c);if(x.some(p=>c.includes(p)))return;await Promise.all(T.map(p=>r(l.join(c,p),l.join(y,p))))}else if(w.isFile()&&H(c)){const P=await L(e,c,o),p=[];Object.entries(P).forEach(([V,_])=>{if(_.isKeyframes&&_.css){const K=`a_${_.animationName}.css`,le=`css/${K}`,fe=l.join(o,le);n.push(K),u.writeFileSync(fe,_.css);return}if(!_.generator)return;const D=_.generator._withBuildContext({name:V,config:a,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),p.push(D.cssFileName);const ce=`css/${D.cssFileName}`,ae=l.join(o,ce);u.writeFileSync(ae,D.css)});const g=p.map(V=>`@import url('./${V}');`).join(`
|
19
19
|
`),C=q(c,6),b=l.parse(c),M=E(b.name),A=l.join(o,`css/f_${M}-${C}.css`);u.writeFileSync(A,g)}}await r(e,o);const h=n.map(c=>`@import url('./css/${c}');`).join(`
|
20
20
|
`);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
21
|
|
@@ -233,7 +233,7 @@ const Ct = {
|
|
233
233
|
let f = R(e, "utf8");
|
234
234
|
f = f.replace(/styled\(([^"'`{,]+),/g, (S, h) => {
|
235
235
|
if (/^['"`]/.test(h)) return S;
|
236
|
-
const P = new RegExp(`import
|
236
|
+
const P = new RegExp(`import[^;]*${h}[,\\s{][^;]*from\\s?([^{};]+);`);
|
237
237
|
if (!P.test(f)) return S;
|
238
238
|
const $ = P.exec(f);
|
239
239
|
if ($) {
|
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-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-DyEDMxfI.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-
|
2
|
+
import { s as u, g as i } from "./index-esCBzNKC.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-
|
1
|
+
"use strict";const i=require("./index-DyEDMxfI.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
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/webpack",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.138",
|
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.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.138",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|