@thi.ng/meta-css 0.17.14 → 0.18.0
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/CHANGELOG.md +10 -1
- package/README.md +5 -5
- package/bin/metacss +10 -2
- package/index.js +5 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-
|
|
3
|
+
- **Last updated**: 2025-02-11T10:30:07Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -11,6 +11,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [0.18.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.18.0) (2025-02-11)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- update CLI wrapper, make `bun` optional ([a694c9d](https://github.com/thi-ng/umbrella/commit/a694c9d))
|
|
19
|
+
- check if `bun` is available, otherwise fallback to `node`
|
|
20
|
+
- update CLI args (add metacss pkg dir)
|
|
21
|
+
- update readme
|
|
22
|
+
|
|
14
23
|
### [0.17.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.17.8) (2025-01-14)
|
|
15
24
|
|
|
16
25
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -2762,12 +2762,12 @@ Sets padding to custom size
|
|
|
2762
2762
|
npx @thi.ng/meta-css --help
|
|
2763
2763
|
```
|
|
2764
2764
|
|
|
2765
|
-
[Bun](https://bun.sh) is
|
|
2766
|
-
distributed as CLI bundle with **no runtime
|
|
2767
|
-
dependencies are only shown for informational
|
|
2768
|
-
included in the bundle.
|
|
2765
|
+
If [Bun](https://bun.sh) is installed, MetaCSS will use it instead of Node JS.
|
|
2766
|
+
The toolchain itself is distributed as CLI bundle with **no runtime
|
|
2767
|
+
dependencies**. The following dependencies are only shown for informational
|
|
2768
|
+
purposes and are (partially) included in the bundle.
|
|
2769
2769
|
|
|
2770
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 13.
|
|
2770
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 13.86 KB
|
|
2771
2771
|
|
|
2772
2772
|
## Dependencies
|
|
2773
2773
|
|
package/bin/metacss
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
# https://stackoverflow.com/a/246128/294515
|
|
4
4
|
SOURCE="${BASH_SOURCE[0]}"
|
|
5
|
-
while [ -
|
|
5
|
+
while [ -L "$SOURCE" ]; do
|
|
6
6
|
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
7
7
|
SOURCE="$(readlink "$SOURCE")"
|
|
8
8
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
9
9
|
done
|
|
10
10
|
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
11
|
+
DIR="$(dirname $DIR)"
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
# prefer using bun
|
|
14
|
+
if [ -x "$(command -v bun)" ]; then
|
|
15
|
+
CMD=bun
|
|
16
|
+
else
|
|
17
|
+
CMD=node
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
/usr/bin/env $CMD "$DIR/index.js" "$DIR" "$@"
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var no={default:95,hint:90,multi:90,param:96,required:33};var
|
|
2
|
+
var no={default:95,hint:90,multi:90,param:96,required:33};var it=(t)=>t;function R(t,o=Object.create(null)){return(...n)=>{let r=n.join("-");return r in o?o[r]:o[r]=t(...n)}}var tt=R((t,o)=>t.repeat(o));var Yo=(t)=>/^[a-f0-9]+$/i.test(t);var Do=(t)=>/^[-+]?\d+$/.test(t),zo=(t)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(t);var U=(t,o=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(t(n)+o(n));this.origMessage=n!==void 0?String(n):""}};var $r=U(()=>"illegal argument(s)"),_=(t)=>{throw new $r(t)};var ro=(t)=>zo(t)?parseFloat(t):_(`not a numeric value: ${t}`),jo=(t)=>t.map(ro),mo=(t)=>Yo(t)?parseInt(t,16):_(`not a hex value: ${t}`),Jo=(t)=>t.map(mo),fo=(t)=>Do(t)?parseInt(t):_(`not an integer: ${t}`),bo=(t)=>t.map(fo);var Wt=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),Rt=(t,o)=>(n)=>({hint:Ar(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Ar=(t,o)=>t+(o?`[${o}..]`:""),W=(t)=>({flag:!0,default:!1,group:"flags",...t}),Y=Wt(it,"STR"),Ut=Rt(it,"STR"),ff=Wt(ro,"NUM"),Ef=Wt(mo,"HEX"),Yt=Wt(fo,"INT"),Gf=Rt(jo,"NUM"),Nf=Rt(Jo,"HEX"),Of=Rt(bo,"INT");var A=((t)=>{return t[t.FINE=0]="FINE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.SEVERE=4]="SEVERE",t[t.NONE=5]="NONE",t})(A||{});var Tr=0;class $t{constructor(t,o=A.FINE,n){this.parent=n,this.id=t||`logger-${Tr++}`,this.level=typeof o==="string"?A[o]:o}id;level;addChild(t){return t.parent=this,t}enabled(t){return this.level<=t}fine(...t){this.log(A.FINE,t)}debug(...t){this.log(A.DEBUG,t)}info(...t){this.log(A.INFO,t)}warn(...t){this.log(A.WARN,t)}severe(...t){this.log(A.SEVERE,t)}none(){}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var Xo=(t)=>t.map((o)=>{if(typeof o==="function")o=o();if(!(typeof o==="string"||typeof o==="number"))o=JSON.stringify(o);return o}).join(" ");class Dt extends $t{constructor(t,o,n,r){super(o,n,r);this.target=t}childLogger(t,o){return new Dt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${A[t[0]]}] ${t[1]}: ${Xo(t.slice(3))}
|
|
3
3
|
`),this.parent?.logEntry(t)}}var zt=R((t,o=" ")=>{let n=tt(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?r+n.substring(m):r}});var Eo={black:1,blue:5,cyan:7,gray:17,green:3,magenta:6,red:2,white:24,yellow:4,lightBlue:21,lightCyan:23,lightGray:8,lightGreen:19,lightMagenta:22,lightRed:18,lightYellow:20,bgBlack:32,bgBlue:160,bgCyan:224,bgGray:544,bgGreen:96,bgMagenta:192,bgRed:64,bgWhite:768,bgYellow:128,bgLightBlue:672,bgLightCyan:736,bgLightGray:256,bgLightGreen:608,bgLightMagenta:704,bgLightRed:576,bgLightYellow:640};var Fr=(t,o)=>(n)=>t.format(o,n),Go=(t)=>Object.keys(Eo).reduce((o,n)=>(o[n]=Fr(t,Eo[n]),o),{format:t});var Po="\x1B[0m";var Sr=["","1","2","1;2","4","1;4","2;4","1;2;4"],jt={format:(t,o)=>jt.start(t)+o+jt.end,start:R((t)=>{let o=[],n=t&15;return n&&o.push(29+(t>>4&1)*60+n),n=t>>5&15,n&&o.push(39+(t>>9&1)*60+n),n=t>>10,n&&o.push(Sr[n]),"\x1B["+o.join(";")+"m"}),end:Po,prefix:Po,suffix:`
|
|
4
4
|
`};var Zo={format:(t,o)=>String(o),prefix:"",suffix:`
|
|
5
5
|
`,start:()=>"",end:""};var Jt=Go(jt),Ko=Go(Zo);var T=Array.isArray;var wr=(t)=>t.toUpperCase(),Vo=(t)=>t.toLowerCase(),bt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,qo=(t,o="-")=>Vo(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+o+m));var po=(t,o="-")=>Vo(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,r)=>wr(r));var Qo=Object.getPrototypeOf,D=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=Qo(t))===null||Qo(o)===null)};var Hr=/\x1b\[[0-9;]+m/g,Ir=(t)=>t.replace(Hr,"");var Xt=(t)=>Ir(t).length;var ko=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);function*ot(t,o=/\r?\n/g,n=!1){let r=0,m=t.length,f=~~n,E;if(typeof o==="string")E=new RegExp(o,"g");else if(!o.flags.includes("g"))E=new RegExp(o,o.flags+"g");else E=o;for(;r<m;){let G=E.exec(t);if(!G){yield t.substring(r);return}let N=G[0].length;yield t.substring(r,G.index+f*N),r=G.index+N}}class No{n=0;w=[];constructor(t,o){t!=null&&this.add(t,o)}add(t,o=t.length){return this.w.push(t),this.n+=o+~~(this.n>0),this}toString(){return this.w.join(" ")}}var ur={length:(t)=>t.length,split:(t,o)=>o},lo={length:Xt,split:(t,o)=>{let n=/\x1b\[[0-9;]+m/g,r=o,m;while(m=n.exec(t)){if(m.index>=o)break;let f=m[0].length;r+=f,o+=f}return r}},vo=(t,o,n,r)=>{let m=t[t.length-1];m&&r-m.n>n?m.add(o,n):t.push(new No(o,n))},yr=(t,{width:o,min:n,hard:r,splitter:m},f=0,E=[])=>{let G=m.length(t),N=o-f;if(N<n&&N<G)N=o;while(r&&G>N){let O=m.split(t,N),h=t.substring(0,O);vo(E,h,N,o),t=t.substring(O),N=o,G=m.length(t)}return vo(E,t,G,o),E},Mr=(t,o,n=[])=>{if(!t.length)return n.push(new No),n;let r={width:80,min:4,hard:!1,splitter:ur,...o};for(let m of ot(t,o.delimWord||/\s/g)){let f=n[n.length-1];yr(m,r,f&&f.n>0?f.n+1:0,n)}return n},go=(t,o)=>{let n=[];for(let r of ot(t,o.delimLine))n=n.concat(Mr(r,o));return n};var At=(t,o={})=>{o={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...o};let n=D(o.color)?{...no,...o.color}:o.color?no:{},r=tt(" ",o.paramWidth),m=(G)=>G.map((N)=>Wr(N,t[N],o,n,r)),f=Object.keys(t).sort(),E=o.groups?o.groups.map((G)=>[G,f.filter((N)=>t[N].group===G)]).filter((G)=>!!G[1].length):[["options",f]];return[...Oo(o.prefix,o.lineWidth),...E.map(([G,N])=>[...o.showGroupNames?[`${bt(G)}:
|
|
@@ -20,11 +20,11 @@ Available commands:
|
|
|
20
20
|
`,ruleSep:", ",valSep:" ",decls:`
|
|
21
21
|
`,declStart:` {
|
|
22
22
|
`,declEnd:`}
|
|
23
|
-
`,indent:" ",comments:!0};function eo(...t){let[o,n,r,m,f,E,G,N,O,h]=t;switch(t.length){case 0:nt(0);case 1:return o;case 2:return(...L)=>o(n(...L));case 3:return(...L)=>o(n(r(...L)));case 4:return(...L)=>o(n(r(m(...L))));case 5:return(...L)=>o(n(r(m(f(...L)))));case 6:return(...L)=>o(n(r(m(f(E(...L))))));case 7:return(...L)=>o(n(r(m(f(E(G(...L)))))));case 8:return(...L)=>o(n(r(m(f(E(G(N(...L))))))));case 9:return(...L)=>o(n(r(m(f(E(G(N(O(...L)))))))));case 10:default:let C=(...L)=>o(n(r(m(f(E(G(N(O(h(...L))))))))));return t.length===10?C:eo(C,...t.slice(10))}}var l=(t)=>Kt(t,"xform")?t.xform():t;function z(...t){return t=t.map(l),eo.apply(null,t)}var K=(t,o)=>[t[0],t[1],o];class wt{value;constructor(t){this.value=t}deref(){return this.value}}var H=(t)=>t instanceof wt,fn=(t)=>t instanceof wt?t:new wt(t),j=(t)=>t instanceof wt?t.deref():t;var xr=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:nt(t.length);function ft(...t){let o=t[0],n=o[0],r=o[1],m=o[2];t=xr(t);let f=t[0]==null?n():t[0],E=t[1];return j(r(Kt(E,"$reduce")?E.$reduce(m,f):Zt(E)?ar(m,f,E):sr(m,f,E)))}var ar=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),H(o)){o=o.deref();break}return o},sr=(t,o,n)=>{for(let r of n)if(o=t(o,r),H(o)){o=o.deref();break}return o},Et=(t,o)=>[t,
|
|
23
|
+
`,indent:" ",comments:!0};function eo(...t){let[o,n,r,m,f,E,G,N,O,h]=t;switch(t.length){case 0:nt(0);case 1:return o;case 2:return(...L)=>o(n(...L));case 3:return(...L)=>o(n(r(...L)));case 4:return(...L)=>o(n(r(m(...L))));case 5:return(...L)=>o(n(r(m(f(...L)))));case 6:return(...L)=>o(n(r(m(f(E(...L))))));case 7:return(...L)=>o(n(r(m(f(E(G(...L)))))));case 8:return(...L)=>o(n(r(m(f(E(G(N(...L))))))));case 9:return(...L)=>o(n(r(m(f(E(G(N(O(...L)))))))));case 10:default:let C=(...L)=>o(n(r(m(f(E(G(N(O(h(...L))))))))));return t.length===10?C:eo(C,...t.slice(10))}}var l=(t)=>Kt(t,"xform")?t.xform():t;function z(...t){return t=t.map(l),eo.apply(null,t)}var K=(t,o)=>[t[0],t[1],o];class wt{value;constructor(t){this.value=t}deref(){return this.value}}var H=(t)=>t instanceof wt,fn=(t)=>t instanceof wt?t:new wt(t),j=(t)=>t instanceof wt?t.deref():t;var xr=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:nt(t.length);function ft(...t){let o=t[0],n=o[0],r=o[1],m=o[2];t=xr(t);let f=t[0]==null?n():t[0],E=t[1];return j(r(Kt(E,"$reduce")?E.$reduce(m,f):Zt(E)?ar(m,f,E):sr(m,f,E)))}var ar=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),H(o)){o=o.deref();break}return o},sr=(t,o,n)=>{for(let r of n)if(o=t(o,r),H(o)){o=o.deref();break}return o},Et=(t,o)=>[t,it,o],En=(t,o)=>{let n=o.length-1;return F(o[n])?o.length>1?ft(t.apply(null,o.slice(0,n)),o[n]):ft(t(),o[0]):void 0};function Gt(t){return t?[...t]:Et(()=>[],(o,n)=>(o.push(n),o))}function*Nt(t,o){let n=l(t)(Gt()),r=n[1],m=n[2];for(let f of o){let E=m([],f);if(H(E)){yield*j(r(E.deref()));return}if(E.length)yield*E}yield*j(r([]))}function*d(t,o){let n=l(t)([Lo,Lo,(r,m)=>m])[2];for(let r of o){let m=n(Z,r);if(H(m)){if(m=j(m.deref()),m!==Z)yield m;return}if(m!==Z)yield m}}var pt=(t,o,n=d)=>{let r=o.length-1;return F(o[r])?o.length>1?n(t.apply(null,o.slice(0,r)),o[r]):n(t(),o[0]):void 0};function Bo(t,o){return F(o)?Nt(Bo(t),$(o)?[o]:o):(n)=>{let r=n[2],m=(f,E)=>{let G=t(E);if(G){for(let N of G)if(f=m(f,N),H(f))break;return f}return r(f,E)};return K(n,m)}}function Gn(t){return Bo((o)=>Vt(o)?o:void 0,t)}function i(t,o){return F(o)?d(i(t),o):(n)=>{let r=n[2];return K(n,(m,f)=>r(m,t(f)))}}function*Qt(...t){let o=t.length-1;if(o<0)return;let n=new Array(o+1).fill(0),r=t.map(rn),m=r.reduce((f,E)=>f*E.length,1);for(let f=0;f<m;f++){let E=[];for(let G=o;G>=0;G--){let N=r[G],O=n[G];if(O===N.length)n[G]=O=0,G>0&&n[G-1]++;E[G]=N[O]}n[o]++,yield E}}function*Nn(t,o=1/0){while(o-- >0)yield t}function io(t,o){t=t||"";let n=!0;return o?[...o].join(t):Et(()=>"",(r,m)=>(r=n?r+m:r+t+m,n=!1,r))}function kt(...t){return cr(kt,ft,t)}var cr=(t,o,n)=>{let r,m;switch(n.length){case 4:m=n[3],r=n[2];break;case 3:m=n[2];break;case 2:return i((f)=>t(n[0],n[1],f));default:nt(n.length)}return o(l(n[0])(n[1]),r,m)};var tm=new Set,om=":[",On=z(Gn(),i((t)=>t[0]==="&"?t.substring(1):om.includes(t[0])?t:" "+t)),nm=(t,o)=>z(t,i((n)=>$(n)&&n.startsWith(" .")?n+o:n)),Ot=(t,o,n,r)=>{let m=n.length,f=[],E,G,N=(O,h)=>{let C=null;if(T(h))Ot(t,$o(o,f),h,r);else if(F(h)&&!$(h))Ot(t,$o(o,f),[...h],r);else if((G=b(h))||(C=r.fns[h]))if(!o.length){if(C)return C.apply(null,n.slice(O+1))(t,r),!0;h(t,r)}else if(G)N(O,h());else _(`quoted fn ('${h}') only allowed at head position`);else if(D(h))E=Object.assign(E||{},h);else if(h!=null)f.push(h)};for(let O=0;O<m;O++)if(N(O,n[O]))return t;return E&&t.push(rm(o,f,E,r)),t},$o=(t,o)=>t.length?[...Qt(t,o)]:o,rm=(t,o,n,r)=>{let m=r.format,f=J(r),E=r.scope?nm(On,r.scope):On;return[f,kt(i((G)=>kt(E,io(),T(G)?G:[G]).trim()),io(m.ruleSep),$o(t,o)),m.declStart,Ht(n,r),f,m.declEnd].join("")},Ht=(t,o)=>{let n=o.format,r=o.autoprefix||tm,m=J(o,o.depth+1),f=[];for(let E in t)if(t.hasOwnProperty(E)){let G=t[E];if(b(G))G=G(t);if(T(G))G=G.map((N)=>T(N)?N.join(" "):N).join(n.ruleSep);if(r.has(E))for(let N of o.vendors)f.push(`${m}${N}${E}:${n.valSep}${G};`);f.push(`${m}${E}:${n.valSep}${G};`)}return f.join(n.decls)+n.decls},J=(t,o=t.depth)=>o>1?[...Nn(t.format.indent,o)].join(""):o>0?t.format.indent:"";function hn(t,...o){let n=o.length===1?o[0]:o.reduce((r,m,f)=>{return r[f/(o.length-1)*100|0]=m,r},{});return(r,m)=>{let f=J(m);m.depth++;let E=J(m);r.push(`${f}@keyframes ${t}${m.format.declStart}`);for(let G in n)if(n.hasOwnProperty(G))r.push([E,G+"%",m.format.declStart,Ht(n[G],m),E,m.format.declEnd].join(""));return m.depth--,r.push(f+m.format.declEnd),r}}var Ln=(t,o=!1)=>(n,r)=>{let m=J(r),f=J(r,r.depth+1);if(r.format.comments||o)n.push(m+"/*",t.split(`
|
|
24
24
|
`).map((E)=>f+E).join(`
|
|
25
|
-
`),m+"*/");return n};var vt=(t,o,n)=>(r,m)=>{let f=J(m);return r.push(`${f}${t} ${mm(o)}${m.format.declStart}`),m.depth++,Ot(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},mm=(t)=>{if($(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=Cn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Cn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:mt,vendors:mn,fns:{},depth:0,...o},T(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),D(t)?Ht(t,o):b(t)?t([],o).join(o.format.rules):Ot([],[],T(t)?t:Vt(t)?[...t]:_("invalid rules"),o).join(o.format.rules)};var _n=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var ht=(t,o)=>vt("@media",t,o);function en(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var Bn=(t,o)=>vt("@supports",t,o);var lt={"@comment":Ln,"@import":_n,"@keyframes":hn,"@media":ht,"@namespace":en,"@supports":Bn};var $n=4,An=(t)=>$n=t,y=(t)=>t===(t|0)?String(t):t.toFixed($n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Tn=(t)=>`${y(t)}em`,Fn=(t)=>`${y(t)}ex`;var Sn=(t)=>`${y(t)}rem`,Ao=(t)=>`${y(t)}%`,wn=(t)=>`${y(t)}px`,Hn=(t)=>`${y(t)}vh`,In=(t)=>`${y(t)}vw`,un=(t)=>`${y(t)}vmin`,yn=(t)=>`${y(t)}vmax`,Mn=(t)=>`${t|0}ms`,Wn=(t)=>`${y(t)}s`;var Rn=(t)=>`${y(t)}deg`,Un=(t)=>`${y(t)}rad`,Yn=(t)=>`${y(t)}turn`,Dn=(t)=>`url(${t})`;var S=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(S||{});var fm=0,Em=()=>fm++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Em()}:o;var I=on.childLogger("rstream");class V{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(Gt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Z;state=S.IDLE;subs=[];deref(){return this.last!==Z?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof V&&!o.xform)t.ensureState(),Pt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new V(t,{...o,parent:this});return this.subs.push(n),this.setState(S.ACTIVE),n.setState(S.ACTIVE),this.last!=Z&&n.next(this.last),n}transform(...t){let o,n;if(D(St(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform(B(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return I.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<S.UNSUBSCRIBED&&(this.state=S.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){I.debug(this.id,"unsub child",t.id);let o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(t){if(this.state>=S.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(I.debug(this.id,"entering done()"),this.state>=S.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=S.DONE,this.dispatchTo("done"))this.state<S.UNSUBSCRIBED&&this.unsubscribe();I.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&I.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(I.parent!==Ft?I:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=S.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(m){if(!this.error(m))return!1}let r=t==="next"?this.subs:[...this.subs];for(let m=r.length;m-- >0;){n=r[m];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){I.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))H(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){let o=j(t);for(let n=0,r=o.length;n<r&&this.state<S.DONE;n++)this.dispatch(o[n]);return this.state<S.ERROR}ensureState(){if(this.state>=S.DONE)rt(`operation not allowed in state ${S[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var zn=(t,o)=>{let n=new jn(o);return n.next(t),n};class jn extends V{src;_cancel;_inited;constructor(t,o){let[n,r]=b(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,x("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){let n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(r){let m=this.wrapped;if(!m||!m.error||!m.error(r))this.unhandledError(r)}this._inited=!0}return n}unsubscribe(t){let o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){I.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var Jn=(t,o)=>t==="first"||t==="last"&&!o;function To(t){return t?ft(To(),t):Et(()=>({}),(o,[n,r])=>(o[n]=r,o))}var bn=()=>(t)=>{let o=t[2];return K(t,(n,r)=>{if(r){for(let m of j(r)||[])if(n=o(n,m),H(n))break}return H(r)?fn(n):n})};function Fo(t,o){return F(o)?Nt(Fo(t),o):z(B(t),bn())}function So(t,o){return F(o)?d(So(t),o):B(b(t)?(n)=>[t(n),n]:(n)=>[t,n])}function wo(...t){let o=pt(wo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return B((m)=>{let f=r?{}:m;for(let E in m)f[E]=n(m[E]);return f})}var Xn=(t)=>t;function Ho(...t){let o=pt(Ho,t,Nt);if(o)return o;let{key:n=Xn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:E=0}=t[1],G=T(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},C=([L,e,M])=>{let k=!0;if(r||E<1)return[L,(i)=>{if(m&&f&&N.size>0||!m&&k)i=M(i,h),h={},N.clear(),k=!1;return e(i)},(i,v)=>{let u=n(v);if(G.has(u)){if(h[u]=v,N.add(u),r||Pn(G,N))if(i=M(i,h),k=!1,m)h={},N.clear();else h={...h}}return i}];else return[L,(i)=>{if(f&&N.size>0)i=M(i,Zn(O,N)),O.clear(),N.clear();return e(i)},(i,v)=>{let u=n(v);if(G.has(u)){let P=O.get(u);!P&&O.set(u,P=[]),P.length>=E&&rt(`max back pressure (${E}) exceeded for input: ${String(u)}`),P.push(v),N.add(u);while(Pn(G,N))if(i=M(i,Zn(O,N)),k=!1,H(i))break}return i}]};return C.keys=()=>G,C.clear=()=>{O.clear(),G.clear(),N.clear(),h={}},C.add=(L)=>{G.add(L)},C.delete=(L,e=!0)=>{if(O.delete(L),G.delete(L),e)N.delete(L),delete h[L]},C}var Pn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Zn=(t,o)=>{let n={};for(let r of o){let m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var Kn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var dt=(t)=>new Vn(t);class Vn extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Ho(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=wo((r)=>r[1]);super(void 0,x("streamsync",{...t,xform:t.xform?z(o,n,t.xform):z(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof V?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:So(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){let o=this.sources.get(t);if(o){let n=this.invRealSourceIDs.get(t.id);return I.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){let o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return Kn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){let t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){I.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Jn(this.closeIn,this.sources.size)&&this.done()}}var Io=R((t,o=" ")=>{let n=tt(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?n.substring(m)+r:r}}),p1=Io(2,"0"),Q1=Io(3,"0"),qn=Io(4,"0");var Gm=/\{(\d+)\}/g;var uo=(t,...o)=>o.length>0?t.replace(Gm,(n,r)=>String(o[parseInt(r,10)])):t;var pn=(t)=>({key:(o)=>o,group:Gt(),...t});function yo(...t){let o=En(yo,t);if(o)return o;let n=pn(t[0]),[r,m,f]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=m(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?f(E[N],G):f(r(),G),E}]}function Mo(t,o){return F(o)?d(Mo(t),o):(n)=>{let r=n[2];return K(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as dn}from"fs";import{resolve as a}from"path";var Qn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},gt={bundle:W({alias:"b",desc:"Bundle inputs (see `out` option)"})},Lt={include:Ut({alias:"I",desc:"Include CSS files (prepend)"})},xt={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},at={force:Ut({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},kn={media:Ut({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},vn={onlyDecls:W({desc:"Only emit framework decls"})},q={out:Y({alias:"o",desc:"Output file (or stdout)"})},st={prec:Yt({default:3,desc:"Number of fractional digits"})},p={pretty:W({alias:"p",desc:"Pretty print output"})},Ct={noDecls:W({alias:"d",desc:"Don't emit framework decls"})},_t={noHeader:W({desc:"Don't emit generated header comment"})},et={scope:Y({desc:"Suffix for CSS class names"})},it={watch:W({alias:"w",desc:"Watch input files for changes"})};import{watch as Nm}from"fs";import{resolve as ln}from"path";var Q=(t,o,n)=>{o=$(o)?o:o.join(`
|
|
25
|
+
`),m+"*/");return n};var vt=(t,o,n)=>(r,m)=>{let f=J(m);return r.push(`${f}${t} ${mm(o)}${m.format.declStart}`),m.depth++,Ot(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},mm=(t)=>{if($(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=Cn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Cn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:mt,vendors:mn,fns:{},depth:0,...o},T(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),D(t)?Ht(t,o):b(t)?t([],o).join(o.format.rules):Ot([],[],T(t)?t:Vt(t)?[...t]:_("invalid rules"),o).join(o.format.rules)};var _n=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var ht=(t,o)=>vt("@media",t,o);function en(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var Bn=(t,o)=>vt("@supports",t,o);var lt={"@comment":Ln,"@import":_n,"@keyframes":hn,"@media":ht,"@namespace":en,"@supports":Bn};var $n=4,An=(t)=>$n=t,y=(t)=>t===(t|0)?String(t):t.toFixed($n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Tn=(t)=>`${y(t)}em`,Fn=(t)=>`${y(t)}ex`;var Sn=(t)=>`${y(t)}rem`,Ao=(t)=>`${y(t)}%`,wn=(t)=>`${y(t)}px`,Hn=(t)=>`${y(t)}vh`,In=(t)=>`${y(t)}vw`,un=(t)=>`${y(t)}vmin`,yn=(t)=>`${y(t)}vmax`,Mn=(t)=>`${t|0}ms`,Wn=(t)=>`${y(t)}s`;var Rn=(t)=>`${y(t)}deg`,Un=(t)=>`${y(t)}rad`,Yn=(t)=>`${y(t)}turn`,Dn=(t)=>`url(${t})`;var S=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(S||{});var fm=0,Em=()=>fm++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Em()}:o;var I=on.childLogger("rstream");class V{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(Gt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Z;state=S.IDLE;subs=[];deref(){return this.last!==Z?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof V&&!o.xform)t.ensureState(),Pt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new V(t,{...o,parent:this});return this.subs.push(n),this.setState(S.ACTIVE),n.setState(S.ACTIVE),this.last!=Z&&n.next(this.last),n}transform(...t){let o,n;if(D(St(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform(i(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return I.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<S.UNSUBSCRIBED&&(this.state=S.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){I.debug(this.id,"unsub child",t.id);let o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(t){if(this.state>=S.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(I.debug(this.id,"entering done()"),this.state>=S.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=S.DONE,this.dispatchTo("done"))this.state<S.UNSUBSCRIBED&&this.unsubscribe();I.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&I.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(I.parent!==Ft?I:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=S.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(m){if(!this.error(m))return!1}let r=t==="next"?this.subs:[...this.subs];for(let m=r.length;m-- >0;){n=r[m];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){I.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))H(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){let o=j(t);for(let n=0,r=o.length;n<r&&this.state<S.DONE;n++)this.dispatch(o[n]);return this.state<S.ERROR}ensureState(){if(this.state>=S.DONE)rt(`operation not allowed in state ${S[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var zn=(t,o)=>{let n=new jn(o);return n.next(t),n};class jn extends V{src;_cancel;_inited;constructor(t,o){let[n,r]=b(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,x("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){let n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(r){let m=this.wrapped;if(!m||!m.error||!m.error(r))this.unhandledError(r)}this._inited=!0}return n}unsubscribe(t){let o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){I.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var Jn=(t,o)=>t==="first"||t==="last"&&!o;function To(t){return t?ft(To(),t):Et(()=>({}),(o,[n,r])=>(o[n]=r,o))}var bn=()=>(t)=>{let o=t[2];return K(t,(n,r)=>{if(r){for(let m of j(r)||[])if(n=o(n,m),H(n))break}return H(r)?fn(n):n})};function Fo(t,o){return F(o)?Nt(Fo(t),o):z(i(t),bn())}function So(t,o){return F(o)?d(So(t),o):i(b(t)?(n)=>[t(n),n]:(n)=>[t,n])}function wo(...t){let o=pt(wo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return i((m)=>{let f=r?{}:m;for(let E in m)f[E]=n(m[E]);return f})}var Xn=(t)=>t;function Ho(...t){let o=pt(Ho,t,Nt);if(o)return o;let{key:n=Xn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:E=0}=t[1],G=T(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},C=([L,e,M])=>{let k=!0;if(r||E<1)return[L,(B)=>{if(m&&f&&N.size>0||!m&&k)B=M(B,h),h={},N.clear(),k=!1;return e(B)},(B,v)=>{let u=n(v);if(G.has(u)){if(h[u]=v,N.add(u),r||Pn(G,N))if(B=M(B,h),k=!1,m)h={},N.clear();else h={...h}}return B}];else return[L,(B)=>{if(f&&N.size>0)B=M(B,Zn(O,N)),O.clear(),N.clear();return e(B)},(B,v)=>{let u=n(v);if(G.has(u)){let P=O.get(u);!P&&O.set(u,P=[]),P.length>=E&&rt(`max back pressure (${E}) exceeded for input: ${String(u)}`),P.push(v),N.add(u);while(Pn(G,N))if(B=M(B,Zn(O,N)),k=!1,H(B))break}return B}]};return C.keys=()=>G,C.clear=()=>{O.clear(),G.clear(),N.clear(),h={}},C.add=(L)=>{G.add(L)},C.delete=(L,e=!0)=>{if(O.delete(L),G.delete(L),e)N.delete(L),delete h[L]},C}var Pn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Zn=(t,o)=>{let n={};for(let r of o){let m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var Kn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var dt=(t)=>new Vn(t);class Vn extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Ho(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=wo((r)=>r[1]);super(void 0,x("streamsync",{...t,xform:t.xform?z(o,n,t.xform):z(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof V?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:So(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){let o=this.sources.get(t);if(o){let n=this.invRealSourceIDs.get(t.id);return I.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){let o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return Kn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){let t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){I.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Jn(this.closeIn,this.sources.size)&&this.done()}}var Io=R((t,o=" ")=>{let n=tt(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?n.substring(m)+r:r}}),p1=Io(2,"0"),Q1=Io(3,"0"),qn=Io(4,"0");var Gm=/\{(\d+)\}/g;var uo=(t,...o)=>o.length>0?t.replace(Gm,(n,r)=>String(o[parseInt(r,10)])):t;var pn=(t)=>({key:(o)=>o,group:Gt(),...t});function yo(...t){let o=En(yo,t);if(o)return o;let n=pn(t[0]),[r,m,f]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=m(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?f(E[N],G):f(r(),G),E}]}function Mo(t,o){return F(o)?d(Mo(t),o):(n)=>{let r=n[2];return K(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as dn}from"fs";import{resolve as a}from"path";var Qn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},gt={bundle:W({alias:"b",desc:"Bundle inputs (see `out` option)"})},Lt={include:Ut({alias:"I",desc:"Include CSS files (prepend)"})},xt={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},at={force:Ut({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},kn={media:Ut({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},vn={onlyDecls:W({desc:"Only emit framework decls"})},q={out:Y({alias:"o",desc:"Output file (or stdout)"})},st={prec:Yt({default:3,desc:"Number of fractional digits"})},p={pretty:W({alias:"p",desc:"Pretty print output"})},Ct={noDecls:W({alias:"d",desc:"Don't emit framework decls"})},_t={noHeader:W({desc:"Don't emit generated header comment"})},et={scope:Y({desc:"Suffix for CSS class names"})},Bt={watch:W({alias:"w",desc:"Watch input files for changes"})};import{watch as Nm}from"fs";import{resolve as ln}from"path";var Q=(t,o,n)=>{o=$(o)?o:o.join(`
|
|
26
26
|
`),t?ho(ln(t),o,n):process.stdout.write(o+`
|
|
27
|
-
`)},ct=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,It=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=ln(m);let E=zn(w(m,o),{id:`in${qn(f)}`});return{input:E,watcher:Nm(m,{},(G)=>{if(G==="change")try{E.next(w(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),dt({src:To(B(({input:m})=>[m.id,m],r))})},to=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...q,...p,...et,...Qn,...it,noWrite:W({desc:"Don't write files, use stdout only"})},fn:Wo};async function Wo(t){let o=X(a(t.opts.specs),t.logger),n=_m(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await hm(t,n);else yt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>w(a(r),t.logger)),t.opts.out);else if(t.opts.watch)await Om(t,o,n);else if(t.opts.eval)try{yt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=a(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;yt(t,o,n,[w(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Om=async(t,o,n)=>{let r=a(t.opts.specs),m,f={process:()=>{try{return o=X(r,t.logger),m.forEach((G)=>G.process()),!0}catch(G){return t.logger.warn(G.message+": "+r),!1}},watcher:dn(r,{},(G)=>{if(G==="change")f.process();else t.logger.warn("specs file removed:",r),E()})},E=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((G)=>G.watcher.close())};m=t.inputs.map((G)=>{G=a(G);let N=!t.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return yt(t,o,n,[w(G,t.logger)],N),!0}catch(h){if(t.logger.warn(h.message+": "+G),m)E();return!1}};if(!O())process.exit(1);return{process:O,watcher:dn(G,{},(h)=>{if(h==="change")O();else t.logger.warn("input removed:",G),E()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},hm=async(t,o)=>{dt({src:{styles:It(t.inputs,t.logger),specs:It([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{yt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},yt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},E,G,N,O)=>{let h={logger:t,specs:E,css:{format:m?qt:mt,fns:lt,scope:f},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},C=o?o.map((L)=>w(a(L),t).trim()):[];if(!r)C.push(ct(E));if(!n&&E.decls.length)C.push(g(E.decls,h.css));N.forEach((L)=>em(L,h)),Cm(C,h),Lm(C,h),Q(O,C,t)},Lm=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let E=sn(r[f],m);n.debug("mediaquery rules",f,E),t.push(g(ht(Am(m.media,f),E),o))}},Cm=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=sn(r,m);n.debug("plain rules",f),t.push(g(f,o))},_m=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},E={};if(o.length&&o[0][0]==="@")o=[...ot(w(a(o[0].substring(1)),n))];for(let G of o){if(!G||G.startsWith("//"))continue;let{token:N,query:O}=cn(G,r),h;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);h=[...Mo((L)=>C.test(L),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let C of h)n.debug("including class:",C),O?tr(f,O,`.${C}`,C):or(E,`.${C}`,C)}return{mediaQueryRules:f,plainRules:E}},em=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Mt(),E=Mt(f),G={root:f,curr:E,scopes:[E]};for(let N of ot(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of im(N)){if(!O)continue;let h=G.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((C)=>C.replace(",","")),h.path=Bm(G.scopes);h.state="class"}else if(O==="}")gn(G);else{let C=St(h.sel);if(!C||C.endsWith(","))h.sel.push(O);else h.sel[h.sel.length-1]+=" "+O}break;case"class":if(O==="{")h.state="nest",G.scopes.push(G.curr=Mt(h));else if(O==="}")gn(G);else{let{token:C,query:L}=cn(O,n);if(!o.classes[C]&&!(nr(C)||mr(C)||rr(C)))_(`unknown class ID: ${C}`);if(L)tr(r,L,h.path,C);else or(m,h.path,C)}break;default:rt(h.state)}}}};function*im(t){let o=-1,n=t.length,r=0,m=0;for(let f=0;f<n;f++){let E=t[f];if(E===" "||E==="\t"){if(!(r||m)&&o>=0)yield t.substring(o,f),o=-1}else if(E==="{"||E==="}"){if(o>=0)yield t.substring(o,f);yield E,o=-1}else if(E==="(")r++;else if(E===")"){if(--r<0)_(`invalid nesting in line: '${t}'`)}else if(E==="["){if(o<0)o=f;m++}else if(E==="]"){if(--m<0)_(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=f}if(r)_("template calls must be fully on a single line");if(m)_("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var ut=":",an="///",Mt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),gn=(t)=>{let o=!t.curr.sel.length;if(Pt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=St(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Mt(t.curr))}else t.scopes.push(t.curr=Mt(t.root))},Bm=(t)=>t.map((o)=>o.sel.join(",")).join(an),sn=(t,o)=>Object.entries(t).map(([n,r])=>$m(n,r,o)),$m=(t,o,n)=>{let r=[],m=r,f=t.split(an);for(let E=0;E<f.length;E++){let G=f[E].split(",");if(E==f.length-1){let N=Object.assign({},...B((O)=>mr(O)?Sm(O):nr(O)?Tm(O):rr(O)?Fm(n,O):to(n.classes[O]),o));G.push(N)}m.push(G),m=G}return r[0]},cn=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(ut);if(n<0)return{token:t};let r=t.indexOf("(");if(r>0){if(r<n&&t.indexOf(ut)>r)return{token:t};n=t.substring(0,r).lastIndexOf(ut)}let m=t.substring(0,n);if(!m.split(ut).every((E)=>o.has(E)))_(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:m}},Am=(t,o)=>o.split(ut).reduce((n,r)=>Object.assign(n,t[r]),{}),tr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},or=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Tm=(t)=>{let o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Fm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),f=t.templates[r];if(!f)_(`unknown template: ${r}`);if(m.length!==f.__arity)_(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=uo(G,...m),$(N))N=uo(N,...m);E[G]=N}return E},{})},Sm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},nr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),rr=(t)=>t.includes("(")&&t.endsWith(")"),mr=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Er={deg:Rn,em:Tn,ex:Fn,ms:Mn,percent:Ao,px:wn,rad:Un,rem:Sn,second:Wn,turn:Yn,url:Dn,vh:Hn,vmax:yn,vmin:un,vw:In,"%":Ao},wm={percent:"{0}%",second:"{0}s",url:"url({0})"},Hm={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Gr={desc:"Generate framework rules from specs",opts:{...q,...st,...p,...it},fn:Ro};async function Ro(t){if(t.opts.watch)await Im(t);else await Nr(t.inputs.map((o)=>w(o,t.logger)),t.opts,t.logger)}var Im=async(t)=>{It(t.inputs,t.logger).subscribe({next(o){try{Nr(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Nr=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};An(o.prec);for(let m of t){let f=JSON.parse(m);if(Object.assign(r.info,f.info),Object.assign(r.media,f.media),f.decls)r.decls.push(...f.decls);if(f.specs)for(let E of f.specs)try{Or(f,E,r.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(f.templates)for(let E of f.templates)um(f,E,r.templates,n)}return Q(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Or=(t,o,n,r,m=!1)=>{let f=T(o.vars)?o.vars:[""],E=$(o.props)?{[o.props]:"<v>"}:o.props,G=ym(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||Hm[O];if(!h)_(`unknown variation ID: ${O}`);for(let[C,L]of Qt(h,Object.keys(G))){let e=s(o.name,O,C,L,G[L]),M=o.unit?s(o.unit,O,C,L,G[L]):void 0,k=m?Wm(M):Mm(G[L],M);if(!n[e]){if(n[e]={},o.user!=null)n[e].__user=o.user;if(o.doc!=null)n[e].__doc=Rm(o.doc,O,C,L,k)}else if(!N.has(e))_(`duplicate class ID: ${e}`);N.add(e);let i=-1;for(let[v,u]of Object.entries(E)){let P=s(v,O,C,L,G[L]),oo=s(!M||$(u)?String(u):Er[M](u),O,C,L,k);if(n[e][P]=oo,r.debug(e,P,oo),m)i=fr(oo,fr(P,i))}if(m)n[e].__arity=i+1}}return n},um=(t,o,n,r)=>Or(t,{...o,values:[""]},n,r,!0),fr=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},ym=(t,o)=>{let n=$(t.values)?o.tables?.[t.values]||_(`invalid table ID: ${t.values}`):t.values;if(D(n))return n;let r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key==="i"||t.key===void 0?(m,f)=>String(f):_(`invalid key type: ${t.key}`);return n.reduce((m,f,E)=>{return m[r(f,E)]=f,m},{})},Mm=(t,o)=>{if(!o||$(t))return t;let n=Er[o];if(!n)_(`invalid unit: ${o}`);return n(t)},Wm=(t)=>t?wm[t]||"{0}"+t:"{0}",s=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Rm=({group:t,desc:o,args:n},r,m,f,E)=>({group:t?s(t,r,m,f,E):"TODO",desc:o?s(o,r,m,f,E):void 0,args:n?n.map((G)=>s(G,r,m,f,E)):void 0});var hr={desc:"Combination of the generate & convert commands",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...st,...p,...et,...it,outCss:Y({desc:"Output file for CSS bundle",optional:!1}),outSpecs:Y({desc:"Output file for framework",optional:!1})},fn:async(t)=>{let{opts:o,inputs:n}=t,[r,m]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},E={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Ro(f),await Wo(E)}};import{resolve as Um}from"path";var _r={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Yt({alias:"l",desc:"Initial heading level",default:1}),title:Y({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{let{logger:o,opts:n,inputs:r}=t,m=X(Um(r[0]),o),f=Ym(m,n);Q(n.out,f,o)}},Ym=(t,{level:o,title:n})=>{let r=Object.keys(t.classes).length,m=Object.keys(t.templates).length,f=[`Currently, there are ${r+m} CSS utility classes (incl. ${m} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${c(o+1)} Classes by category`,"",...Cr(t.classes,zm,o+2),`${c(o+1)} Templates by category`,"",...Cr(t.templates,jm,o+2),`${c(o+1)} Media queries`,"",...Object.entries(t.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")f.unshift(`${c(o)} ${n??t.info.name}
|
|
27
|
+
`)},ct=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,It=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=ln(m);let E=zn(w(m,o),{id:`in${qn(f)}`});return{input:E,watcher:Nm(m,{},(G)=>{if(G==="change")try{E.next(w(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),dt({src:To(i(({input:m})=>[m.id,m],r))})},to=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...q,...p,...et,...Qn,...Bt,noWrite:W({desc:"Don't write files, use stdout only"})},fn:Wo};async function Wo(t){let o=X(a(t.opts.specs),t.logger),n=_m(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await hm(t,n);else yt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>w(a(r),t.logger)),t.opts.out);else if(t.opts.watch)await Om(t,o,n);else if(t.opts.eval)try{yt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=a(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;yt(t,o,n,[w(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Om=async(t,o,n)=>{let r=a(t.opts.specs),m,f={process:()=>{try{return o=X(r,t.logger),m.forEach((G)=>G.process()),!0}catch(G){return t.logger.warn(G.message+": "+r),!1}},watcher:dn(r,{},(G)=>{if(G==="change")f.process();else t.logger.warn("specs file removed:",r),E()})},E=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((G)=>G.watcher.close())};m=t.inputs.map((G)=>{G=a(G);let N=!t.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return yt(t,o,n,[w(G,t.logger)],N),!0}catch(h){if(t.logger.warn(h.message+": "+G),m)E();return!1}};if(!O())process.exit(1);return{process:O,watcher:dn(G,{},(h)=>{if(h==="change")O();else t.logger.warn("input removed:",G),E()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},hm=async(t,o)=>{dt({src:{styles:It(t.inputs,t.logger),specs:It([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{yt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},yt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},E,G,N,O)=>{let h={logger:t,specs:E,css:{format:m?qt:mt,fns:lt,scope:f},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},C=o?o.map((L)=>w(a(L),t).trim()):[];if(!r)C.push(ct(E));if(!n&&E.decls.length)C.push(g(E.decls,h.css));N.forEach((L)=>em(L,h)),Cm(C,h),Lm(C,h),Q(O,C,t)},Lm=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let E=sn(r[f],m);n.debug("mediaquery rules",f,E),t.push(g(ht(Am(m.media,f),E),o))}},Cm=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=sn(r,m);n.debug("plain rules",f),t.push(g(f,o))},_m=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},E={};if(o.length&&o[0][0]==="@")o=[...ot(w(a(o[0].substring(1)),n))];for(let G of o){if(!G||G.startsWith("//"))continue;let{token:N,query:O}=cn(G,r),h;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);h=[...Mo((L)=>C.test(L),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let C of h)n.debug("including class:",C),O?tr(f,O,`.${C}`,C):or(E,`.${C}`,C)}return{mediaQueryRules:f,plainRules:E}},em=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Mt(),E=Mt(f),G={root:f,curr:E,scopes:[E]};for(let N of ot(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of Bm(N)){if(!O)continue;let h=G.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((C)=>C.replace(",","")),h.path=im(G.scopes);h.state="class"}else if(O==="}")gn(G);else{let C=St(h.sel);if(!C||C.endsWith(","))h.sel.push(O);else h.sel[h.sel.length-1]+=" "+O}break;case"class":if(O==="{")h.state="nest",G.scopes.push(G.curr=Mt(h));else if(O==="}")gn(G);else{let{token:C,query:L}=cn(O,n);if(!o.classes[C]&&!(nr(C)||mr(C)||rr(C)))_(`unknown class ID: ${C}`);if(L)tr(r,L,h.path,C);else or(m,h.path,C)}break;default:rt(h.state)}}}};function*Bm(t){let o=-1,n=t.length,r=0,m=0;for(let f=0;f<n;f++){let E=t[f];if(E===" "||E==="\t"){if(!(r||m)&&o>=0)yield t.substring(o,f),o=-1}else if(E==="{"||E==="}"){if(o>=0)yield t.substring(o,f);yield E,o=-1}else if(E==="(")r++;else if(E===")"){if(--r<0)_(`invalid nesting in line: '${t}'`)}else if(E==="["){if(o<0)o=f;m++}else if(E==="]"){if(--m<0)_(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=f}if(r)_("template calls must be fully on a single line");if(m)_("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var ut=":",an="///",Mt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),gn=(t)=>{let o=!t.curr.sel.length;if(Pt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=St(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Mt(t.curr))}else t.scopes.push(t.curr=Mt(t.root))},im=(t)=>t.map((o)=>o.sel.join(",")).join(an),sn=(t,o)=>Object.entries(t).map(([n,r])=>$m(n,r,o)),$m=(t,o,n)=>{let r=[],m=r,f=t.split(an);for(let E=0;E<f.length;E++){let G=f[E].split(",");if(E==f.length-1){let N=Object.assign({},...i((O)=>mr(O)?Sm(O):nr(O)?Tm(O):rr(O)?Fm(n,O):to(n.classes[O]),o));G.push(N)}m.push(G),m=G}return r[0]},cn=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(ut);if(n<0)return{token:t};let r=t.indexOf("(");if(r>0){if(r<n&&t.indexOf(ut)>r)return{token:t};n=t.substring(0,r).lastIndexOf(ut)}let m=t.substring(0,n);if(!m.split(ut).every((E)=>o.has(E)))_(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:m}},Am=(t,o)=>o.split(ut).reduce((n,r)=>Object.assign(n,t[r]),{}),tr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},or=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Tm=(t)=>{let o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Fm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),f=t.templates[r];if(!f)_(`unknown template: ${r}`);if(m.length!==f.__arity)_(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=uo(G,...m),$(N))N=uo(N,...m);E[G]=N}return E},{})},Sm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},nr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),rr=(t)=>t.includes("(")&&t.endsWith(")"),mr=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Er={deg:Rn,em:Tn,ex:Fn,ms:Mn,percent:Ao,px:wn,rad:Un,rem:Sn,second:Wn,turn:Yn,url:Dn,vh:Hn,vmax:yn,vmin:un,vw:In,"%":Ao},wm={percent:"{0}%",second:"{0}s",url:"url({0})"},Hm={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Gr={desc:"Generate framework rules from specs",opts:{...q,...st,...p,...Bt},fn:Ro};async function Ro(t){if(t.opts.watch)await Im(t);else await Nr(t.inputs.map((o)=>w(o,t.logger)),t.opts,t.logger)}var Im=async(t)=>{It(t.inputs,t.logger).subscribe({next(o){try{Nr(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Nr=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};An(o.prec);for(let m of t){let f=JSON.parse(m);if(Object.assign(r.info,f.info),Object.assign(r.media,f.media),f.decls)r.decls.push(...f.decls);if(f.specs)for(let E of f.specs)try{Or(f,E,r.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(f.templates)for(let E of f.templates)um(f,E,r.templates,n)}return Q(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Or=(t,o,n,r,m=!1)=>{let f=T(o.vars)?o.vars:[""],E=$(o.props)?{[o.props]:"<v>"}:o.props,G=ym(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||Hm[O];if(!h)_(`unknown variation ID: ${O}`);for(let[C,L]of Qt(h,Object.keys(G))){let e=s(o.name,O,C,L,G[L]),M=o.unit?s(o.unit,O,C,L,G[L]):void 0,k=m?Wm(M):Mm(G[L],M);if(!n[e]){if(n[e]={},o.user!=null)n[e].__user=o.user;if(o.doc!=null)n[e].__doc=Rm(o.doc,O,C,L,k)}else if(!N.has(e))_(`duplicate class ID: ${e}`);N.add(e);let B=-1;for(let[v,u]of Object.entries(E)){let P=s(v,O,C,L,G[L]),oo=s(!M||$(u)?String(u):Er[M](u),O,C,L,k);if(n[e][P]=oo,r.debug(e,P,oo),m)B=fr(oo,fr(P,B))}if(m)n[e].__arity=B+1}}return n},um=(t,o,n,r)=>Or(t,{...o,values:[""]},n,r,!0),fr=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},ym=(t,o)=>{let n=$(t.values)?o.tables?.[t.values]||_(`invalid table ID: ${t.values}`):t.values;if(D(n))return n;let r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key==="i"||t.key===void 0?(m,f)=>String(f):_(`invalid key type: ${t.key}`);return n.reduce((m,f,E)=>{return m[r(f,E)]=f,m},{})},Mm=(t,o)=>{if(!o||$(t))return t;let n=Er[o];if(!n)_(`invalid unit: ${o}`);return n(t)},Wm=(t)=>t?wm[t]||"{0}"+t:"{0}",s=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Rm=({group:t,desc:o,args:n},r,m,f,E)=>({group:t?s(t,r,m,f,E):"TODO",desc:o?s(o,r,m,f,E):void 0,args:n?n.map((G)=>s(G,r,m,f,E)):void 0});var hr={desc:"Combination of the generate & convert commands",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...st,...p,...et,...Bt,outCss:Y({desc:"Output file for CSS bundle",optional:!1}),outSpecs:Y({desc:"Output file for framework",optional:!1})},fn:async(t)=>{let{opts:o,inputs:n}=t,[r,m]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},E={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Ro(f),await Wo(E)}};import{resolve as Um}from"path";var _r={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Yt({alias:"l",desc:"Initial heading level",default:1}),title:Y({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{let{logger:o,opts:n,inputs:r}=t,m=X(Um(r[0]),o),f=Ym(m,n);Q(n.out,f,o)}},Ym=(t,{level:o,title:n})=>{let r=Object.keys(t.classes).length,m=Object.keys(t.templates).length,f=[`Currently, there are ${r+m} CSS utility classes (incl. ${m} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${c(o+1)} Classes by category`,"",...Cr(t.classes,zm,o+2),`${c(o+1)} Templates by category`,"",...Cr(t.templates,jm,o+2),`${c(o+1)} Media queries`,"",...Object.entries(t.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")f.unshift(`${c(o)} ${n??t.info.name}
|
|
28
28
|
`);return f},Lr=(t)=>t.split(/(\d+)/).map((o)=>{let n=parseInt(o);return isNaN(n)?o:n}),Dm=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){let n=Lr(t),r=Lr(o),m=n.length;if(m===r.length){for(let f=0;f<m;f++)if(n[f]!==r[f])return _o(n[f],r[f]);return 0}return n.length-r.length}return _o(t,o)},Cr=(t,o,n)=>{let r=yo({key:([m,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(m)=>m.sort(),(m,f)=>(m.push(f[0]),m)]},Object.entries(t));return Fo((m)=>{let f=r[m].sort(Dm).map((G)=>o(G,t[G].__doc,n+1)),E=f.length;return[`${c(n)} ${bt(m)}`,E>3?`
|
|
29
29
|
<details><summary>${E} items:</summary>
|
|
30
30
|
`:"",f.join(`
|
|
@@ -34,7 +34,7 @@ Available commands:
|
|
|
34
34
|
TODO`;let r=o.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${c(n)} \`${t}(${r})\``,"",...o.args.map(Jm),o.desc?`
|
|
35
35
|
${o.desc}
|
|
36
36
|
`:""].join(`
|
|
37
|
-
`)},Jm=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,c=R((t)=>"#".repeat(t));import{resolve as er}from"path";var
|
|
37
|
+
`)},Jm=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,c=R((t)=>"#".repeat(t));import{resolve as er}from"path";var ir={desc:"Export entire generated framework as CSS",opts:{...Lt,...Ct,...vn,...q,...p,..._t,...kn,...et},inputs:1,fn:async(t)=>{let{logger:o,opts:{include:n,media:r,noDecls:m,noHeader:f,onlyDecls:E,out:G,pretty:N,scope:O},inputs:h}=t,C={format:N?qt:mt,fns:lt,scope:O},L=X(er(h[0]),o),e=n?n.map((M)=>w(er(M),o).trim()):[];if(!f)e.push(ct(L));if(!m&&L.decls.length)e.push(g(L.decls,C));if(!E)e.push(bm(L,r,C,o));Q(G,e,o)}},bm=(t,o,n,r)=>{let m=Br("",t);if(o){let f=o[0]==="ALL"?Object.keys(t.media):o;for(let E of f)if(t.media[E])m.push(ht(t.media[E],Br("-"+E,t)));else r.warn(`invalid media query ID: ${E}, skipping...`)}return g(m,n)},Br=(t,o)=>Object.entries(o.classes).map(([n,r])=>[`.${n}${t}`,to(r)]);var Uo=X(Xm(process.argv[2],"package.json"));so({name:"metacss",opts:{verbose:W({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:hr,doc:_r,export:ir,generate:Gr},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=A.DEBUG;return{...t,format:Jt}},start:3,usage:{prefix:`
|
|
38
38
|
\u2588 \u2588 \u2588 \u2502
|
|
39
39
|
\u2588\u2588 \u2588 \u2502
|
|
40
40
|
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${Uo.name} ${Uo.version}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/meta-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"status": "alpha",
|
|
113
113
|
"year": 2023
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "035e34d5cbc5d1a7658ad9be0a1db160cee9ba52\n"
|
|
116
116
|
}
|