@salty-css/webpack 0.0.1-alpha.200 → 0.0.1-alpha.201
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-DL_E4ukB.js → index-2dgpGWxF.js} +1 -1
- package/{index-DDv7Jk6c.cjs → index-Dq_u-jmb.cjs} +2 -2
- 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(T),i}const j=p.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,D=z(r,j);return n.push(D),i}if(typeof r=="number"){const j=Te(y,r);return g(j)}if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:b}={},O=function*(){yield pe(r),yield _e(r,b)}();for(const{result:j,additionalCss:D=[]}of O)r=j,D.forEach(_=>{const x=z(_,"");m(x,"")});return g(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
|
6
6
|
`):o:n.join(`
|
7
7
|
`)},ge=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=ge(a,[...t,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=t.map(E).join("-"),a=z(n,`.${o}`);s.push(a)}return s.join(`
|
8
|
-
`)},Me=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ye(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},ye=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?ye(o,a,s):s.add(t)}),[...s]):[],me=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:me(l.join(e,".."))},Re=async e=>{const t=me(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ze=async e=>{const t=await Re(e);if(t)return t.type};let A;const he=async e=>{if(A)return A;const t=await ze(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.tagName.toUpperCase()==="SCRIPT"&&se.src||new URL("index-
|
8
|
+
`)},Me=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ye(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},ye=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?ye(o,a,s):s.add(t)}),[...s]):[],me=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:me(l.join(e,".."))},Re=async e=>{const t=me(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ze=async e=>{const t=await Re(e);if(t)return t.type};let A;const he=async e=>{if(A)return A;const t=await ze(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.tagName.toUpperCase()==="SCRIPT"&&se.src||new URL("index-Dq_u-jmb.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},ne=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.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 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=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),R={externalModules:[],rcFile:void 0,destDir:void 0},$e=e=>{if(R.externalModules.length>0)return R.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 R.externalModules=n,n},J=async e=>{if(R.destDir)return R.destDir;const t=await re(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},be=["salty","css","styles","styled"],je=(e=[])=>new RegExp(`\\.(${[...be,...e].join("|")})\\.`),U=(e,t=[])=>je(t).test(e),we=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):we(l.join(e,".."))},re=async e=>{var n,o;const t=await we(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},We=async e=>{const t=await re(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await he(e),i=$e(n);await de.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},Ae=async(e,t)=>{var ae,le;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const F=await X(e,w,s);Object.entries(F).forEach(([M,C])=>{C.isMedia?n.mediaQueries.push([M,C]):C.isGlobalDefine?n.globalStyles.push(C):C.isDefineVariables?n.variables.push(C):C.isDefineTemplates&&n.templates.push(C)})}));const o=await We(e),a={...o},i=new Set,p=(w,F=[])=>w?Object.entries(w).flatMap(([M,C])=>{if(!C)return;if(typeof C=="object")return p(C,[...F,M]);const Y=Se(M),v=E(M),ee=[...F,Y].join(".");i.add(`"${ee}"`);const te=[...F.map(E),v].join("-"),{result:Ce}=pe(C);return`--${te}: ${Ce};`}):[],r=w=>w?Object.entries(w).flatMap(([F,M])=>{const C=p(M);return F==="base"?C.join(""):`${F} { ${C.join("")} }`}):[],c=w=>w?Object.entries(w).flatMap(([F,M])=>Object.entries(M).flatMap(([C,Y])=>{const v=p(Y,[F]),ee=`.${F}-${C}, [data-${F}="${C}"]`,te=v.join("");return`${ee} { ${te} }`})):[],y=w=>({...w,responsive:void 0,conditional:void 0}),m=w=>n.variables.map(F=>w==="static"?y(F._current):F._current[w]),g=I(y(o.variables),m("static")),b=p(g),S=I((ae=o.variables)==null?void 0:ae.responsive,m("responsive")),O=r(S),j=I((le=o.variables)==null?void 0:le.conditional,m("conditional")),D=c(j),_=l.join(s,"css/_variables.css"),x=`:root { ${b.join("")} ${O.join("")} } ${D.join("")}`;u.writeFileSync(_,x),a.staticVariables=g;const T=l.join(s,"css/_global.css"),P=I(o.global,n.globalStyles),V=z(P,"");u.writeFileSync(T,`@layer global { ${V} }`);const f=l.join(s,"css/_reset.css"),$=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Je,d=z($,"");u.writeFileSync(f,`@layer reset { ${d} }`);const N=l.join(s,"css/_templates.css"),k=I(o.templates,n.templates),q=ge(k),H=Me(k);u.writeFileSync(N,q),a.templates=k;const{mediaQueries:W}=n;a.mediaQueries=Object.fromEntries(W.map(([w,F])=>[`@${w}`,F]));const G=W.map(([w])=>`'@${w}'`).join(" | "),K=l.join(s,"types/css-tokens.d.ts"),L=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...i].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -17,7 +17,7 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
// Media query types
|
20
|
-
type MediaQueryKeys = ${G};
|
20
|
+
type MediaQueryKeys = ${G||"''"};
|
21
21
|
`;u.writeFileSync(K,L);const Q=l.join(s,"cache/config-cache.json");u.writeFileSync(Q,JSON.stringify(a,null,2))},ue=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 i=o.exec(e);if(i){const p=i.at(1);if(be.some(c=>p==null?void 0:p.includes(c)))return t}return"styled('div',"}),Ie=(e,t)=>{try{const s=u.readFileSync(l.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
22
22
|
|
23
23
|
${e}`:`globalThis.saltyConfig = {};
|
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-Dq_u-jmb.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as d } from "path";
|
2
|
-
import { i as f, s as p, g as u, a as y } from "./index-
|
2
|
+
import { i as f, s as p, g as u, a as y } from "./index-2dgpGWxF.js";
|
3
3
|
import { readFile as g } from "fs/promises";
|
4
4
|
import { watch as m } from "fs";
|
5
5
|
const w = async (s) => {
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-Dq_u-jmb.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.201",
|
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.201",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|