@thi.ng/meta-css 0.19.2 → 0.19.4
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 +1 -1
- package/README.md +1 -1
- package/index.js +25 -26
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2758,7 +2758,7 @@ The toolchain itself is distributed as CLI bundle with **no runtime
|
|
|
2758
2758
|
dependencies**. The following dependencies are only shown for informational
|
|
2759
2759
|
purposes and are (partially) included in the bundle.
|
|
2760
2760
|
|
|
2761
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
2761
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 14.03 KB
|
|
2762
2762
|
|
|
2763
2763
|
## Dependencies
|
|
2764
2764
|
|
package/index.js
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var fo={default:95,command:92,hint:90,multi:90,param:96,required:33};var
|
|
3
|
-
`),this.parent?.logEntry(t)}}var Oo={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
|
|
4
|
-
`};var
|
|
5
|
-
`,start:()=>"",end:""};var
|
|
6
|
-
`)},Kt=(t)=>D(t)?{...fo,...t}:t?fo:{};var
|
|
7
|
-
`]:[],...r(
|
|
2
|
+
var fo={default:95,command:92,hint:90,multi:90,param:96,required:33};var Tt=(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 ot=R((t,o)=>t.repeat(o));var Xo=(t)=>/^[a-f0-9]+$/i.test(t);var Po=(t)=>/^[-+]?\d+$/.test(t),bo=(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 wr=U(()=>"illegal argument(s)"),_=(t)=>{throw new wr(t)};var Eo=(t)=>bo(t)?parseFloat(t):_(`not a numeric value: ${t}`),Zo=(t)=>t.map(Eo),Go=(t)=>Xo(t)?parseInt(t,16):_(`not a hex value: ${t}`),Ko=(t)=>t.map(Go),No=(t)=>Po(t)?parseInt(t):_(`not an integer: ${t}`),Vo=(t)=>t.map(No);var Rt=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),Ut=(t,o)=>(n)=>({hint:Sr(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Sr=(t,o)=>t+(o?`[${o}..]`:""),W=(t)=>({flag:!0,default:!1,group:"flags",...t}),Y=Rt(Tt,"STR"),Yt=Ut(Tt,"STR"),hf=Rt(Eo,"NUM"),Cf=Rt(Go,"HEX"),Dt=Rt(No,"INT"),Lf=Ut(Zo,"NUM"),_f=Ut(Ko,"HEX"),Bf=Ut(Vo,"INT");var e=((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})(e||{});var Hr=0;class et{constructor(t,o=e.FINE,n){this.parent=n,this.id=t||`logger-${Hr++}`,this.level=typeof o==="string"?e[o]:o}id;level;addChild(t){return t.parent=this,t}enabled(t){return this.level<=t}fine(...t){this.log(e.FINE,t)}debug(...t){this.log(e.DEBUG,t)}info(...t){this.log(e.INFO,t)}warn(...t){this.log(e.WARN,t)}severe(...t){this.log(e.SEVERE,t)}none(){}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var qo=(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 zt extends et{constructor(t,o,n,r){super(o,n,r);this.target=t}childLogger(t,o){return new zt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${e[t[0]]}] ${t[1]}: ${qo(t.slice(3))}
|
|
3
|
+
`),this.parent?.logEntry(t)}}var Oo={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 Ir=(t,o)=>(n)=>t.format(o,n),ho=(t)=>Object.keys(Oo).reduce((o,n)=>(o[n]=Ir(t,Oo[n]),o),{format:t});var po="\x1B[0m";var Mr=["","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(Mr[n]),"\x1B["+o.join(";")+"m"}),end:po,prefix:po,suffix:`
|
|
4
|
+
`};var Qo={format:(t,o)=>String(o),prefix:"",suffix:`
|
|
5
|
+
`,start:()=>"",end:""};var it=ho(Jt),Co=ho(Qo);var i=Array.isArray;var yr=(t)=>t.toUpperCase(),ko=(t)=>t.toLowerCase(),jt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,vo=(t,o="-")=>ko(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+o+m));var lo=(t,o="-")=>ko(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,r)=>yr(r));var go=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);var xo=Object.getPrototypeOf,D=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=xo(t))===null||xo(o)===null)};var Wr=/\x1b\[[0-9;]+m/g,Rr=(t)=>t.replace(Wr,"");var Xt=(t)=>Rr(t).length;function*nt(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 Lo{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},so={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}},ao=(t,o,n,r)=>{let m=t[t.length-1];m&&r-m.n>n?m.add(o,n):t.push(new Lo(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);ao(E,h,N,o),t=t.substring(O),N=o,G=m.length(t)}return ao(E,t,G,o),E},Dr=(t,o,n=[])=>{if(!t.length)return n.push(new Lo),n;let r={width:80,min:4,hard:!1,splitter:Ur,...o};for(let m of nt(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},co=(t,o)=>{let n=[];for(let r of nt(t,o.delimLine))n=n.concat(Dr(r,o));return n};var tn=R((t,o=" ")=>{let n=ot(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 Z=(t,o)=>o!=null?`\x1B[${o}m${t}\x1B[0m`:t,Pt=(t,o)=>tn(o)(t,Xt(t)),bt=(t,o)=>t?co(t,{width:o,splitter:so,hard:!1}):[],Zt=(t,o,n)=>{let r=ot(" ",o);return bt(t,n-o).map((m,f)=>f?r+m:m).join(`
|
|
6
|
+
`)},Kt=(t)=>D(t)?{...fo,...t}:t?fo:{};var ut=(t,o={})=>{o={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...o};let n=Kt(o.color),r=(E)=>E.map((G)=>zr(G,t[G],o,n,o.paramWidth)),m=Object.keys(t).sort(),f=o.groups?o.groups.map((E)=>[E,m.filter((G)=>t[G].group===E)]).filter((E)=>!!E[1].length):[["options",m]];return[...bt(o.prefix,o.lineWidth),...f.map(([E,G])=>[...o.showGroupNames?[`${jt(E)}:
|
|
7
|
+
`]:[],...r(G),""].join(`
|
|
8
8
|
`)),...bt(o.suffix,o.lineWidth)].join(`
|
|
9
|
-
`)},
|
|
9
|
+
`)},zr=(t,o,n,r,m)=>{let f=Jr(o,r),E=jr(o,r,f),G=Z(`--${vo(t)}`,r.param),N=`${E}${G}${f}`,O=o.optional===!1&&o.default===void 0,h=[];O&&h.push("required"),o.multi&&h.push("multiple");let L=Xr(h,r,O)+(o.desc||"")+Pr(o,n,r);return Pt(N,n.paramWidth)+Zt(L,m,n.lineWidth)},Jr=(t,o)=>t.hint?Z(" "+t.hint,o.hint):"",jr=(t,o,n)=>t.alias?`${Z("-"+t.alias,o.param)}${n}, `:"",Xr=(t,o,n)=>t.length?Z(`[${t.join(", ")}] `,n?o.required:o.multi):"",Pr=(t,o,n)=>o.showDefaults&&t.default!=null&&t.default!==!1?Z(` (default: ${go(!0)(t.defaultHint!=null?t.defaultHint:t.default)})`,n.default):"";var br=U(()=>"parse error"),on=(t,o,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return Zr(t,o,n)}catch(r){if(n.showUsage)console.log(r.message+`
|
|
10
10
|
|
|
11
|
-
`+
|
|
12
|
-
`),tn(t,r);let N=await t.ctx({logger:new Dt(process.stderr,t.name,"INFO"),format:n?Jt:po,opts:E.result,inputs:E.rest},f);if(await f.fn(N),t.post)await t.post(N,f)}catch(m){process.stderr.write(m.message+`
|
|
13
|
-
|
|
14
|
-
`),process.exit(1)}},tn=(t,o)=>{process.stderr.write(Tt(t.opts,o)),process.exit(1)},Qr=(t,{color:o,lineWidth:n=80}={})=>{let r=Object.keys(t),m=Math.max(...r.map((G)=>G.length)),f=Kt(o);return[`
|
|
11
|
+
`+ut(t,n.usageOpts));throw new br(r.message)}},Zr=(t,o,n)=>{let r=Kr(t),m={},f,E,G=n.start;for(;G<o.length;){let N=o[G];if(!f){if(n.help.includes(N)){console.log(ut(t,n.usageOpts));return}let O=Vr(t,r,m,N);if(f=O.id,E=O.spec,G=G+~~(O.state<2),O.state)break}else{if(qr(E,m,f,N))break;f=null,G++}}return f&&_(`missing value for: --${f}`),{result:pr(t,m),index:G,rest:o.slice(G),done:G>=o.length}},Kr=(t)=>Object.entries(t).reduce((o,[n,r])=>r.alias?(o[r.alias]=n,o):o,{}),Vr=(t,o,n,r)=>{if(r[0]==="-"){let m;if(r[1]==="-"){if(r==="--")return{state:1};m=lo(r.substring(2))}else m=o[r.substring(1)],!m&&_(`unknown option: ${r}`);let f=t[m];if(!f&&_(m),f.flag){if(n[m]=!0,m=void 0,f.fn&&!f.fn("true"))return{state:1,spec:f}}return{state:0,id:m,spec:f}}return{state:2}},qr=(t,o,n,r)=>{if(/^-[a-z]/i.test(r)&&_(`missing value for: --${n}`),t.multi)i(o[n])?o[n].push(r):o[n]=[r];else o[n]=r;return t.fn&&!t.fn(r)},pr=(t,o)=>{let n;for(let r in t)if(n=t[r],o[r]===void 0){if(n.default!==void 0)o[r]=n.default;else if(n.optional===!1)_(`missing arg: --${r}`)}else if(n.coerce)Qr(n,o,r);return o},Qr=(t,o,n)=>{try{if(t.multi&&t.delim)o[n]=o[n].reduce((r,m)=>(r.push(...m.split(t.delim)),r),[]);o[n]=t.coerce(o[n])}catch(r){throw new Error(`arg --${n}: ${r.message}`)}};var nn=async(t)=>{let o=t.argv||process.argv,n=!process.env.NO_COLOR,r=n?it:Co,m={prefix:"",color:n,...t.usage};try{let f,E,G=t.start??2;if(t.single){if(f=Object.keys(t.commands)[0],!f)_("no command provided");E=t.commands[f]}else{if(f=o[G],E=t.commands[f],!E)m.prefix+=kr(t.commands,m),_o(t,m);G++}let N;try{N=on({...t.opts,...E.opts},o,{showUsage:!1,usageOpts:m,start:G})}catch(h){Bo(h.message,r)}if(!N)_o(t,m),process.exit(1);if(E.inputs!==void 0&&E.inputs!==N.rest.length)Bo(`expected ${E.inputs||0} input(s)`,r),_o(t,m);let O=await t.ctx({logger:new zt(process.stderr,t.name,"INFO"),format:n?it:Co,opts:N.result,inputs:N.rest},E);if(await E.fn(O),t.post)await t.post(O,E)}catch(f){Bo(f.message,r),process.exit(1)}},_o=(t,o)=>{process.stderr.write(ut(t.opts,o)),process.exit(1)},kr=(t,{color:o,lineWidth:n=80}={})=>{let r=Object.keys(t),m=Math.max(...r.map((E)=>E.length)),f=Kt(o);return[`
|
|
15
12
|
Available commands:
|
|
16
|
-
`,...r.map((
|
|
13
|
+
`,...r.map((E)=>`${Pt(Z(E,f.command),m)} : ${Zt(t[E].desc,m+3,n)}`),`
|
|
17
14
|
`].join(`
|
|
18
|
-
`)}
|
|
15
|
+
`)},Bo=(t,o)=>process.stderr.write(o.red(t)+`
|
|
16
|
+
|
|
17
|
+
`);var rn=(t,o,n)=>`
|
|
19
18
|
\u2588 \u2588 \u2588 \u2502
|
|
20
19
|
\u2588\u2588 \u2588 \u2502
|
|
21
20
|
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${t} v${o}
|
|
22
21
|
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${n}
|
|
23
22
|
\u2588 \u2502
|
|
24
|
-
\u2588 \u2588 \u2502`;import{existsSync as
|
|
25
|
-
`):o,"utf-8",n,r);var P=(t,o)=>JSON.parse(
|
|
23
|
+
\u2588 \u2588 \u2502`;import{existsSync as vr,mkdirSync as lr,statSync as iE}from"fs";import{dirname as dr}from"path";var gr=(t)=>t.length>0&&!vr(t)?(lr(t,{recursive:!0}),!0):!1,mn=(t)=>gr(dr(t));var X=(t)=>typeof t==="function";var T=(t)=>typeof t==="string";import{readFileSync as ar}from"fs";import{writeFileSync as xr}from"fs";var fn=(t,o,n,r,m=!1)=>{if(r?.info(`${m?"[dryrun] ":""}writing file: ${t}`),m)return;mn(t),xr(t,o,!n&&T(o)?"utf-8":n)};var w=(t,o,n="utf-8")=>{return o?.debug("reading file:",t),ar(t,n)},$o=(t,o,n,r=!1)=>fn(t,i(o)?o.join(`
|
|
24
|
+
`):o,"utf-8",n,r);var P=(t,o)=>JSON.parse(w(t,o));var K=Symbol(),Ao=()=>{};var Ft=Object.freeze({level:e.NONE,addChild(t){return t},childLogger:()=>Ft,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},none(){},logEntry(){}});class To extends et{set(t){this.parent=t}childLogger(t,o){return new To(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var En=new To("root",e.FINE,Ft);import{join as qm}from"path";var eo=(t,o)=>{if(t===o)return 0;if(t==null)return o==null?0:-1;if(o==null)return t==null?0:1;if(typeof t.compare==="function")return t.compare(o);if(typeof o.compare==="function")return-o.compare(t);return t<o?-1:t>o?1:0};var sr=U(()=>"Assertion failed"),Vt=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(t,o)=>{if(typeof t==="function"&&!t()||!t)throw new sr(typeof o==="function"?o():o)}:()=>{};var qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var Gn=(t)=>{return(t==null||!t[Symbol.iterator])&&_(`value is not iterable: ${t}`),t};var Nn=(t)=>qt(t)?t:[...Gn(t)];var wt=(t)=>t[t.length-1];var pt=(t,o)=>typeof t?.[o]==="function";var u=(t)=>typeof t?.[Symbol.iterator]==="function";var Qt=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var cr=U(()=>"illegal arity"),rt=(t)=>{throw new cr(t)};var tm=U(()=>"illegal state"),mt=(t)=>{throw new tm(t)};var On=["-moz-","-ms-","-o-","-webkit-"],ft={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},kt={rules:`
|
|
26
25
|
`,ruleSep:", ",valSep:" ",decls:`
|
|
27
26
|
`,declStart:` {
|
|
28
27
|
`,declEnd:`}
|
|
29
|
-
`,indent:" ",comments:!0};function io(...t){let[o,n,r,m,f,G,
|
|
30
|
-
`).map((
|
|
31
|
-
`),m+"*/");return n};var gt=(t,o,n)=>(r,m)=>{let f=j(m);return r.push(`${f}${t} ${Nm(o)}${m.format.declStart}`),m.depth++,ht(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},Nm=(t)=>{if(A(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=An.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${An.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},An=new Set(["all","print","screen"]);var x=(t,o)=>{return o={format:ft,vendors:Nn,fns:{},depth:0,...o},T(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),D(t)?wt(t,o):X(t)?t([],o).join(o.format.rules):ht([],[],T(t)?t:Qt(t)?[...t]:L("invalid rules"),o).join(o.format.rules)};var en=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var _t=(t,o)=>gt("@media",t,o);function Tn(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var un=(t,o)=>gt("@supports",t,o);var xt={"@comment":$n,"@import":en,"@keyframes":Bn,"@media":_t,"@namespace":Tn,"@supports":un};var Fn=4,Sn=(t)=>Fn=t,M=(t)=>t===(t|0)?String(t):t.toFixed(Fn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var wn=(t)=>`${M(t)}em`,Hn=(t)=>`${M(t)}ex`;var In=(t)=>`${M(t)}rem`,uo=(t)=>`${M(t)}%`,Mn=(t)=>`${M(t)}px`,yn=(t)=>`${M(t)}vh`,Rn=(t)=>`${M(t)}vw`,Wn=(t)=>`${M(t)}vmin`,Un=(t)=>`${M(t)}vmax`,Yn=(t)=>`${t|0}ms`,Dn=(t)=>`${M(t)}s`;var zn=(t)=>`${M(t)}deg`,Jn=(t)=>`${M(t)}rad`,jn=(t)=>`${M(t)}turn`,Xn=(t)=>`url(${t})`;var F=((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})(F||{});var Om=0,hm=()=>Om++,a=(t,o)=>!o||!o.id?{...o,id:t+"-"+hm()}:o;var H=fn.childLogger("rstream");class p{constructor(t,o){this.wrapped=t,o=a("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(Nt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=K;state=F.IDLE;subs=[];deref(){return this.last!==K?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof p&&!o.xform)t.ensureState(),Vt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new p(t,{...o,parent:this});return this.subs.push(n),this.setState(F.ACTIVE),n.setState(F.ACTIVE),this.last!=K&&n.next(this.last),n}transform(...t){let o,n;if(D(Ft(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,a("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 H.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<F.UNSUBSCRIBED&&(this.state=F.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){H.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>=F.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(H.debug(this.id,"entering done()"),this.state>=F.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=F.DONE,this.dispatchTo("done"))this.state<F.UNSUBSCRIBED&&this.unsubscribe();H.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&H.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(H.parent!==ut?H:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=F.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){H.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))w(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<F.DONE;n++)this.dispatch(o[n]);return this.state<F.ERROR}ensureState(){if(this.state>=F.DONE)mt(`operation not allowed in state ${F[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Pn=(t,o)=>{let n=new bn(o);return n.next(t),n};class bn extends p{src;_cancel;_inited;constructor(t,o){let[n,r]=X(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,a("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){H.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var Zn=(t,o)=>t==="first"||t==="last"&&!o;function Fo(t){return t?Et(Fo(),t):Gt(()=>({}),(o,[n,r])=>(o[n]=r,o))}var Kn=()=>(t)=>{let o=t[2];return V(t,(n,r)=>{if(r){for(let m of J(r)||[])if(n=o(n,m),w(n))break}return w(r)?On(n):n})};function So(t,o){return u(o)?Ot(So(t),o):z(i(t),Kn())}function wo(t,o){return u(o)?g(wo(t),o):i(X(t)?(n)=>[t(n),n]:(n)=>[t,n])}function Ho(...t){let o=vt(Ho,t);if(o)return o;let n=t[0],r=t[1]!==!1;return i((m)=>{let f=r?{}:m;for(let G in m)f[G]=n(m[G]);return f})}var Vn=(t)=>t;function Io(...t){let o=vt(Io,t,Ot);if(o)return o;let{key:n=Vn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:G=0}=t[1],E=T(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},C=([_,B,y])=>{let v=!0;if(r||G<1)return[_,($)=>{if(m&&f&&N.size>0||!m&&v)$=y($,h),h={},N.clear(),v=!1;return B($)},($,l)=>{let I=n(l);if(E.has(I)){if(h[I]=l,N.add(I),r||pn(E,N))if($=y($,h),v=!1,m)h={},N.clear();else h={...h}}return $}];else return[_,($)=>{if(f&&N.size>0)$=y($,qn(O,N)),O.clear(),N.clear();return B($)},($,l)=>{let I=n(l);if(E.has(I)){let b=O.get(I);!b&&O.set(I,b=[]),b.length>=G&&mt(`max back pressure (${G}) exceeded for input: ${String(I)}`),b.push(l),N.add(I);while(pn(E,N))if($=y($,qn(O,N)),v=!1,w($))break}return $}]};return C.keys=()=>E,C.clear=()=>{O.clear(),E.clear(),N.clear(),h={}},C.add=(_)=>{E.add(_)},C.delete=(_,B=!0)=>{if(O.delete(_),E.delete(_),B)N.delete(_),delete h[_]},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},qn=(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 Qn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var at=(t)=>new kn(t);class kn extends p{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Io(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Ho((r)=>r[1]);super(void 0,a("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 p?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:wo(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 H.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 Qn(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){H.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),Zn(this.closeIn,this.sources.size)&&this.done()}}var Mo=W((t,o=" ")=>{let n=ot(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}}),xG=Mo(2,"0"),aG=Mo(3,"0"),vn=Mo(4,"0");var _m=/\{(\d+)\}/g;var yo=(t,...o)=>o.length>0?t.replace(_m,(n,r)=>String(o[parseInt(r,10)])):t;var ln=(t)=>({key:(o)=>o,group:Nt(),...t});function Ro(...t){let o=hn(Ro,t);if(o)return o;let n=ln(t[0]),[r,m,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=m(G[E]);return G},(G,E)=>{let N=n.key(E);return G[N]=G[N]?f(G[N],E):f(r(),E),G}]}function Wo(t,o){return u(o)?g(Wo(t),o):(n)=>{let r=n[2];return V(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as sn}from"fs";import{resolve as s}from"path";var dn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},st={bundle:R({alias:"b",desc:"Bundle inputs (see `out` option)"})},Ct={include:Ut({alias:"I",desc:"Include CSS files (prepend)"})},ct={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},to={force:Ut({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},gn={media:Ut({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},xn={onlyDecls:R({desc:"Only emit framework decls"})},q={out:Y({alias:"o",desc:"Output file (or stdout)"})},oo={prec:Yt({default:3,desc:"Number of fractional digits"})},Q={pretty:R({alias:"p",desc:"Pretty print output"})},Lt={noDecls:R({alias:"d",desc:"Don't emit framework decls"})},Bt={noHeader:R({desc:"Don't emit generated header comment"})},$t={scope:Y({desc:"Suffix for CSS class names"})},it={watch:R({alias:"w",desc:"Watch input files for changes"})};import{watch as Cm}from"fs";import{resolve as an}from"path";var k=(t,o,n)=>{o=A(o)?o:o.join(`
|
|
32
|
-
`),t
|
|
33
|
-
`)},no=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Ht=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=an(m);let G=Pn(S(m,o),{id:`in${vn(f)}`});return{input:G,watcher:Cm(m,{},(E)=>{if(E==="change")try{G.next(S(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),at({src:Fo(i(({input:m})=>[m.id,m],r))})},ro=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var tr={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...st,...ct,...to,...Ct,...Lt,...Bt,...q,...Q,...$t,...dn,...it,noWrite:R({desc:"Don't write files, use stdout only"})},fn:Uo};async function Uo(t){let o=P(s(t.opts.specs),t.logger),n=Am(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await Bm(t,n);else Mt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>S(s(r),t.logger)),t.opts.out);else if(t.opts.watch)await Lm(t,o,n);else if(t.opts.eval)try{Mt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=s(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;Mt(t,o,n,[S(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Lm=async(t,o,n)=>{let r=s(t.opts.specs),m,f={process:()=>{try{return o=P(r,t.logger),m.forEach((E)=>E.process()),!0}catch(E){return t.logger.warn(E.message+": "+r),!1}},watcher:sn(r,{},(E)=>{if(E==="change")f.process();else t.logger.warn("specs file removed:",r),G()})},G=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((E)=>E.watcher.close())};m=t.inputs.map((E)=>{E=s(E);let N=!t.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return Mt(t,o,n,[S(E,t.logger)],N),!0}catch(h){if(t.logger.warn(h.message+": "+E),m)G();return!1}};if(!O())process.exit(1);return{process:O,watcher:sn(E,{},(h)=>{if(h==="change")O();else t.logger.warn("input removed:",E),G()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Bm=async(t,o)=>{at({src:{styles:Ht(t.inputs,t.logger),specs:Ht([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{Mt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},Mt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},G,E,N,O)=>{let h={logger:t,specs:G,css:{format:m?kt:ft,fns:xt,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},C=o?o.map((_)=>S(s(_),t).trim()):[];if(!r)C.push(no(G));if(!n&&G.decls.length)C.push(x(G.decls,h.css));N.forEach((_)=>em(_,h)),im(C,h),$m(C,h),k(O,C,t)},$m=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let G=nr(r[f],m);n.debug("mediaquery rules",f,G),t.push(x(_t(Sm(m.media,f),G),o))}},im=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=nr(r,m);n.debug("plain rules",f),t.push(x(f,o))},Am=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},G={};if(o.length&&o[0][0]==="@")o=[...nt(S(s(o[0].substring(1)),n))];for(let E of o){if(!E||E.startsWith("//"))continue;let{token:N,query:O}=rr(E,r),h;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);h=[...Wo((_)=>C.test(_),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let C of h)n.debug("including class:",C),O?mr(f,O,`.${C}`,C):fr(G,`.${C}`,C)}return{mediaQueryRules:f,plainRules:G}},em=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=yt(),G=yt(f),E={root:f,curr:G,scopes:[G]};for(let N of nt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of Tm(N)){if(!O)continue;let h=E.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((C)=>C.replace(",","")),h.path=um(E.scopes);h.state="class"}else if(O==="}")cn(E);else{let C=Ft(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",E.scopes.push(E.curr=yt(h));else if(O==="}")cn(E);else{let{token:C,query:_}=rr(O,n);if(!o.classes[C]&&!(Er(C)||Nr(C)||Gr(C)))L(`unknown class ID: ${C}`);if(_)mr(r,_,h.path,C);else fr(m,h.path,C)}break;default:mt(h.state)}}}};function*Tm(t){let o=-1,n=t.length,r=0,m=0,f=!1;for(let G=0;G<n;G++){let E=t[G];if(E==='"'&&!(r||m))if(f)yield t.substring(o,G+1),o=-1,f=!1;else f=!0;else if(E===" "||E==="\t"){if(!(r||m||f)&&o>=0)yield t.substring(o,G),o=-1}else if(E==="{"||E==="}"){if(o>=0)yield t.substring(o,G);yield E,o=-1}else if(E==="(")r++;else if(E===")"){if(--r<0)L(`invalid nesting in line: '${t}'`)}else if(E==="["){if(o<0)o=G;m++}else if(E==="]"){if(--m<0)L(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=G}if(f)L("string literals must be fully on a single line");if(r)L("template calls must be fully on a single line");if(m)L("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var It=":",or="///",yt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),cn=(t)=>{let o=!t.curr.sel.length;if(Vt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=Ft(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=yt(t.curr))}else t.scopes.push(t.curr=yt(t.root))},um=(t)=>t.map((o)=>o.sel.join(",")).join(or),nr=(t,o)=>Object.entries(t).map(([n,r])=>Fm(n,r,o)),Fm=(t,o,n)=>{let r=[],m=r,f=t.split(or);for(let G=0;G<f.length;G++){let E=f[G].split(",");if(G==f.length-1){let N=Object.assign({},...i((O)=>Nr(O)?Im(O):Er(O)?wm(O):Gr(O)?Hm(n,O):ro(n.classes[O]),o));E.push(N)}m.push(E),m=E}return r[0]},rr=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(It);if(n<0)return{token:t};let r=t.indexOf("("),m=t.indexOf("[");if(r>0||m>0){let E=r>0?m>0?Math.min(r,m):r:m;if(E<n&&t.indexOf(It)>E)return{token:t};n=t.substring(0,E).lastIndexOf(It)}let f=t.substring(0,n);if(!f.split(It).every((E)=>o.has(E)))L(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:f}},Sm=(t,o)=>o.split(It).reduce((n,r)=>Object.assign(n,t[r]),{}),mr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},fr=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),wm=(t)=>{let o=t.indexOf("="),n=t.substring(0,o),r=t.substring(o+1);return{[`--${n}`]:r[0]==='"'?r.slice(1,-1):r}},Hm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=t.templates[r];if(!f)L(`unknown template: ${r}`);if(m.length!==f.__arity)L(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=yo(E,...m),A(N))N=yo(N,...m);G[E]=N}return G},{})},Im=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},Er=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),Gr=(t)=>t.includes("(")&&t.endsWith(")"),Nr=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var hr={deg:zn,em:wn,ex:Hn,ms:Yn,percent:uo,px:Mn,rad:Jn,rem:In,second:Dn,turn:jn,url:Xn,vh:yn,vmax:Un,vmin:Wn,vw:Rn,"%":uo},Mm={percent:"{0}%",second:"{0}s",url:"url({0})"},ym={"":[""],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:[""]},_r={desc:"Generate framework rules from specs",opts:{...q,...oo,...Q,...it},fn:Yo};async function Yo(t){if(t.opts.watch)await Rm(t);else await Cr(t.inputs.map((o)=>S(o,t.logger)),t.opts,t.logger)}var Rm=async(t)=>{Ht(t.inputs,t.logger).subscribe({next(o){try{Cr(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Cr=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Sn(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 G of f.specs)try{Lr(f,G,r.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)Wm(f,G,r.templates,n)}return k(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Lr=(t,o,n,r,m=!1)=>{let f=T(o.vars)?o.vars:[""],G=A(o.props)?{[o.props]:"<v>"}:o.props,E=Um(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||ym[O];if(!h)L(`unknown variation ID: ${O}`);for(let[C,_]of lt(h,Object.keys(E))){let B=c(o.name,O,C,_,E[_]),y=o.unit?c(o.unit,O,C,_,E[_]):void 0,v=m?Dm(y):Ym(E[_],y);if(!n[B]){if(n[B]={},o.user!=null)n[B].__user=o.user;if(o.doc!=null)n[B].__doc=zm(o.doc,O,C,_,v)}else if(!N.has(B))L(`duplicate class ID: ${B}`);N.add(B);let $=-1;for(let[l,I]of Object.entries(G)){let b=c(l,O,C,_,E[_]),mo=c(!y||A(I)?String(I):hr[y](I),O,C,_,v);if(n[B][b]=mo,r.debug(B,b,mo),m)$=Or(mo,Or(b,$))}if(m)n[B].__arity=$+1}}return n},Wm=(t,o,n,r)=>Lr(t,{...o,values:[""]},n,r,!0),Or=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},Um=(t,o)=>{let n=A(t.values)?o.tables?.[t.values]||L(`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):L(`invalid key type: ${t.key}`);return n.reduce((m,f,G)=>{return m[r(f,G)]=f,m},{})},Ym=(t,o)=>{if(!o||A(t))return t;let n=hr[o];if(!n)L(`invalid unit: ${o}`);return n(t)},Dm=(t)=>t?Mm[t]||"{0}"+t:"{0}",c=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),zm=({group:t,desc:o,args:n},r,m,f,G)=>({group:t?c(t,r,m,f,G):"TODO",desc:o?c(o,r,m,f,G):void 0,args:n?n.map((E)=>c(E,r,m,f,G)):void 0});var Br={desc:"Combination of the generate & convert commands",opts:{...st,...ct,...to,...Ct,...Lt,...Bt,...oo,...Q,...$t,...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((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},G={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Yo(f),await Uo(G)}};import{resolve as Jm}from"path";var Ar={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=P(Jm(r[0]),o),f=jm(m,n);k(n.out,f,o)}},jm=(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}):`,"",`${tt(o+1)} Classes by category`,"",...ir(t.classes,Pm,o+2),`${tt(o+1)} Templates by category`,"",...ir(t.templates,bm,o+2),`${tt(o+1)} Media queries`,"",...Object.entries(t.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${tt(o)} ${n??t.info.name}
|
|
34
|
-
`);return f}
|
|
35
|
-
<details><summary>${
|
|
28
|
+
`,indent:" ",comments:!0};function io(...t){let[o,n,r,m,f,E,G,N,O,h]=t;switch(t.length){case 0:rt(0);case 1:return o;case 2:return(...C)=>o(n(...C));case 3:return(...C)=>o(n(r(...C)));case 4:return(...C)=>o(n(r(m(...C))));case 5:return(...C)=>o(n(r(m(f(...C)))));case 6:return(...C)=>o(n(r(m(f(E(...C))))));case 7:return(...C)=>o(n(r(m(f(E(G(...C)))))));case 8:return(...C)=>o(n(r(m(f(E(G(N(...C))))))));case 9:return(...C)=>o(n(r(m(f(E(G(N(O(...C)))))))));case 10:default:let L=(...C)=>o(n(r(m(f(E(G(N(O(h(...C))))))))));return t.length===10?L:io(L,...t.slice(10))}}var d=(t)=>pt(t,"xform")?t.xform():t;function z(...t){return t=t.map(d),io.apply(null,t)}var V=(t,o)=>[t[0],t[1],o];class St{value;constructor(t){this.value=t}deref(){return this.value}}var S=(t)=>t instanceof St,hn=(t)=>t instanceof St?t:new St(t),J=(t)=>t instanceof St?t.deref():t;var om=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:rt(t.length);function Et(...t){let o=t[0],n=o[0],r=o[1],m=o[2];t=om(t);let f=t[0]==null?n():t[0],E=t[1];return J(r(pt(E,"$reduce")?E.$reduce(m,f):qt(E)?nm(m,f,E):rm(m,f,E)))}var nm=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),S(o)){o=o.deref();break}return o},rm=(t,o,n)=>{for(let r of n)if(o=t(o,r),S(o)){o=o.deref();break}return o},Gt=(t,o)=>[t,Tt,o],Cn=(t,o)=>{let n=o.length-1;return u(o[n])?o.length>1?Et(t.apply(null,o.slice(0,n)),o[n]):Et(t(),o[0]):void 0};function Nt(t){return t?[...t]:Gt(()=>[],(o,n)=>(o.push(n),o))}function*Ot(t,o){let n=d(t)(Nt()),r=n[1],m=n[2];for(let f of o){let E=m([],f);if(S(E)){yield*J(r(E.deref()));return}if(E.length)yield*E}yield*J(r([]))}function*g(t,o){let n=d(t)([Ao,Ao,(r,m)=>m])[2];for(let r of o){let m=n(K,r);if(S(m)){if(m=J(m.deref()),m!==K)yield m;return}if(m!==K)yield m}}var vt=(t,o,n=g)=>{let r=o.length-1;return u(o[r])?o.length>1?n(t.apply(null,o.slice(0,r)),o[r]):n(t(),o[0]):void 0};function uo(t,o){return u(o)?Ot(uo(t),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),S(f))break;return f}return r(f,E)};return V(n,m)}}function Ln(t){return uo((o)=>Qt(o)?o:void 0,t)}function A(t,o){return u(o)?g(A(t),o):(n)=>{let r=n[2];return V(n,(m,f)=>r(m,t(f)))}}function*lt(...t){let o=t.length-1;if(o<0)return;let n=new Array(o+1).fill(0),r=t.map(Nn),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*_n(t,o=1/0){while(o-- >0)yield t}function Fo(t,o){t=t||"";let n=!0;return o?[...o].join(t):Gt(()=>"",(r,m)=>(r=n?r+m:r+t+m,n=!1,r))}function dt(...t){return mm(dt,Et,t)}var mm=(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 A((f)=>t(n[0],n[1],f));default:rt(n.length)}return o(d(n[0])(n[1]),r,m)};var fm=new Set,Em=":[",Bn=z(Ln(),A((t)=>t[0]==="&"?t.substring(1):Em.includes(t[0])?t:" "+t)),Gm=(t,o)=>z(t,A((n)=>T(n)&&n.startsWith(" .")?n+o:n)),ht=(t,o,n,r)=>{let m=n.length,f=[],E,G,N=(O,h)=>{let L=null;if(i(h))ht(t,wo(o,f),h,r);else if(u(h)&&!T(h))ht(t,wo(o,f),[...h],r);else if((G=X(h))||(L=r.fns[h]))if(!o.length){if(L)return L.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(Nm(o,f,E,r)),t},wo=(t,o)=>t.length?[...lt(t,o)]:o,Nm=(t,o,n,r)=>{let m=r.format,f=j(r),E=r.scope?Gm(Bn,r.scope):Bn;return[f,dt(A((G)=>dt(E,Fo(),i(G)?G:[G]).trim()),Fo(m.ruleSep),wo(t,o)),m.declStart,Ht(n,r),f,m.declEnd].join("")},Ht=(t,o)=>{let n=o.format,r=o.autoprefix||fm,m=j(o,o.depth+1),f=[];for(let E in t)if(t.hasOwnProperty(E)){let G=t[E];if(X(G))G=G(t);if(i(G))G=G.map((N)=>i(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?[..._n(t.format.indent,o)].join(""):o>0?t.format.indent:"";function $n(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 An=(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(`
|
|
29
|
+
`).map((E)=>f+E).join(`
|
|
30
|
+
`),m+"*/");return n};var gt=(t,o,n)=>(r,m)=>{let f=j(m);return r.push(`${f}${t} ${Om(o)}${m.format.declStart}`),m.depth++,ht(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},Om=(t)=>{if(T(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=Tn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Tn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},Tn=new Set(["all","print","screen"]);var x=(t,o)=>{return o={format:ft,vendors:On,fns:{},depth:0,...o},i(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),D(t)?Ht(t,o):X(t)?t([],o).join(o.format.rules):ht([],[],i(t)?t:Qt(t)?[...t]:_("invalid rules"),o).join(o.format.rules)};var en=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var Ct=(t,o)=>gt("@media",t,o);function un(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var Fn=(t,o)=>gt("@supports",t,o);var xt={"@comment":An,"@import":en,"@keyframes":$n,"@media":Ct,"@namespace":un,"@supports":Fn};var wn=4,Sn=(t)=>wn=t,M=(t)=>t===(t|0)?String(t):t.toFixed(wn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Hn=(t)=>`${M(t)}em`,In=(t)=>`${M(t)}ex`;var Mn=(t)=>`${M(t)}rem`,So=(t)=>`${M(t)}%`,yn=(t)=>`${M(t)}px`,Wn=(t)=>`${M(t)}vh`,Rn=(t)=>`${M(t)}vw`,Un=(t)=>`${M(t)}vmin`,Yn=(t)=>`${M(t)}vmax`,Dn=(t)=>`${t|0}ms`,zn=(t)=>`${M(t)}s`;var Jn=(t)=>`${M(t)}deg`,jn=(t)=>`${M(t)}rad`,Xn=(t)=>`${M(t)}turn`,Pn=(t)=>`url(${t})`;var F=((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})(F||{});var hm=0,Cm=()=>hm++,a=(t,o)=>!o||!o.id?{...o,id:t+"-"+Cm()}:o;var H=En.childLogger("rstream");class q{constructor(t,o){this.wrapped=t,o=a("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(Nt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=K;state=F.IDLE;subs=[];deref(){return this.last!==K?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof q&&!o.xform)t.ensureState(),Vt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new q(t,{...o,parent:this});return this.subs.push(n),this.setState(F.ACTIVE),n.setState(F.ACTIVE),this.last!=K&&n.next(this.last),n}transform(...t){let o,n;if(D(wt(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,a("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform(A(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return H.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<F.UNSUBSCRIBED&&(this.state=F.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){H.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>=F.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(H.debug(this.id,"entering done()"),this.state>=F.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=F.DONE,this.dispatchTo("done"))this.state<F.UNSUBSCRIBED&&this.unsubscribe();H.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&H.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(H.parent!==Ft?H:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=F.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){H.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))S(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<F.DONE;n++)this.dispatch(o[n]);return this.state<F.ERROR}ensureState(){if(this.state>=F.DONE)mt(`operation not allowed in state ${F[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var bn=(t,o)=>{let n=new Zn(o);return n.next(t),n};class Zn extends q{src;_cancel;_inited;constructor(t,o){let[n,r]=X(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,a("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){H.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var Kn=(t,o)=>t==="first"||t==="last"&&!o;function Ho(t){return t?Et(Ho(),t):Gt(()=>({}),(o,[n,r])=>(o[n]=r,o))}var Vn=()=>(t)=>{let o=t[2];return V(t,(n,r)=>{if(r){for(let m of J(r)||[])if(n=o(n,m),S(n))break}return S(r)?hn(n):n})};function Io(t,o){return u(o)?Ot(Io(t),o):z(A(t),Vn())}function Mo(t,o){return u(o)?g(Mo(t),o):A(X(t)?(n)=>[t(n),n]:(n)=>[t,n])}function yo(...t){let o=vt(yo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return A((m)=>{let f=r?{}:m;for(let E in m)f[E]=n(m[E]);return f})}var qn=(t)=>t;function Wo(...t){let o=vt(Wo,t,Ot);if(o)return o;let{key:n=qn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:E=0}=t[1],G=i(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},L=([C,B,y])=>{let v=!0;if(r||E<1)return[C,($)=>{if(m&&f&&N.size>0||!m&&v)$=y($,h),h={},N.clear(),v=!1;return B($)},($,l)=>{let I=n(l);if(G.has(I)){if(h[I]=l,N.add(I),r||pn(G,N))if($=y($,h),v=!1,m)h={},N.clear();else h={...h}}return $}];else return[C,($)=>{if(f&&N.size>0)$=y($,Qn(O,N)),O.clear(),N.clear();return B($)},($,l)=>{let I=n(l);if(G.has(I)){let b=O.get(I);!b&&O.set(I,b=[]),b.length>=E&&mt(`max back pressure (${E}) exceeded for input: ${String(I)}`),b.push(l),N.add(I);while(pn(G,N))if($=y($,Qn(O,N)),v=!1,S($))break}return $}]};return L.keys=()=>G,L.clear=()=>{O.clear(),G.clear(),N.clear(),h={}},L.add=(C)=>{G.add(C)},L.delete=(C,B=!0)=>{if(O.delete(C),G.delete(C),B)N.delete(C),delete h[C]},L}var pn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Qn=(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 at=(t)=>new vn(t);class vn extends q{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Wo(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=yo((r)=>r[1]);super(void 0,a("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 q?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:Mo(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 H.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){H.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),Kn(this.closeIn,this.sources.size)&&this.done()}}var Ro=R((t,o=" ")=>{let n=ot(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}}),aG=Ro(2,"0"),sG=Ro(3,"0"),ln=Ro(4,"0");var Lm=/\{(\d+)\}/g;var Uo=(t,...o)=>o.length>0?t.replace(Lm,(n,r)=>String(o[parseInt(r,10)])):t;var dn=(t)=>({key:(o)=>o,group:Nt(),...t});function Yo(...t){let o=Cn(Yo,t);if(o)return o;let n=dn(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 Do(t,o){return u(o)?g(Do(t),o):(n)=>{let r=n[2];return V(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as cn}from"fs";import{resolve as s}from"path";var gn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},st={bundle:W({alias:"b",desc:"Bundle inputs (see `out` option)"})},Lt={include:Yt({alias:"I",desc:"Include CSS files (prepend)"})},ct={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},to={force:Yt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},xn={media:Yt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},an={onlyDecls:W({desc:"Only emit framework decls"})},p={out:Y({alias:"o",desc:"Output file (or stdout)"})},oo={prec:Dt({default:3,desc:"Number of fractional digits"})},Q={pretty:W({alias:"p",desc:"Pretty print output"})},_t={noDecls:W({alias:"d",desc:"Don't emit framework decls"})},Bt={noHeader:W({desc:"Don't emit generated header comment"})},$t={scope:Y({desc:"Suffix for CSS class names"})},At={watch:W({alias:"w",desc:"Watch input files for changes"})};import{watch as _m}from"fs";import{resolve as sn}from"path";var k=(t,o,n)=>{o=T(o)?o:o.join(`
|
|
31
|
+
`),t?$o(sn(t),o,n):process.stdout.write(o+`
|
|
32
|
+
`)},no=({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=sn(m);let E=bn(w(m,o),{id:`in${ln(f)}`});return{input:E,watcher:_m(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),at({src:Ho(A(({input:m})=>[m.id,m],r))})},ro=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var or={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...st,...ct,...to,...Lt,..._t,...Bt,...p,...Q,...$t,...gn,...At,noWrite:W({desc:"Don't write files, use stdout only"})},fn:zo};async function zo(t){let o=P(s(t.opts.specs),t.logger),n=em(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await $m(t,n);else yt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>w(s(r),t.logger)),t.opts.out);else if(t.opts.watch)await Bm(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=s(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 Bm=async(t,o,n)=>{let r=s(t.opts.specs),m,f={process:()=>{try{return o=P(r,t.logger),m.forEach((G)=>G.process()),!0}catch(G){return t.logger.warn(G.message+": "+r),!1}},watcher:cn(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=s(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:cn(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)},$m=async(t,o)=>{at({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?kt:ft,fns:xt,scope:f},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},L=o?o.map((C)=>w(s(C),t).trim()):[];if(!r)L.push(no(E));if(!n&&E.decls.length)L.push(x(E.decls,h.css));N.forEach((C)=>im(C,h)),Tm(L,h),Am(L,h),k(O,L,t)},Am=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let E=rr(r[f],m);n.debug("mediaquery rules",f,E),t.push(x(Ct(Sm(m.media,f),E),o))}},Tm=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=rr(r,m);n.debug("plain rules",f),t.push(x(f,o))},em=(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=[...nt(w(s(o[0].substring(1)),n))];for(let G of o){if(!G||G.startsWith("//"))continue;let{token:N,query:O}=mr(G,r),h;if(N.includes("*")){let L=new RegExp(`^${N.replace("*",".*")}$`);h=[...Do((C)=>L.test(C),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let L of h)n.debug("including class:",L),O?fr(f,O,`.${L}`,L):Er(E,`.${L}`,L)}return{mediaQueryRules:f,plainRules:E}},im=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Wt(),E=Wt(f),G={root:f,curr:E,scopes:[E]};for(let N of nt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of um(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((L)=>L.replace(",","")),h.path=Fm(G.scopes);h.state="class"}else if(O==="}")tr(G);else{let L=wt(h.sel);if(!L||L.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=Wt(h));else if(O==="}")tr(G);else{let{token:L,query:C}=mr(O,n);if(!o.classes[L]&&!(Gr(L)||Or(L)||Nr(L)))_(`unknown class ID: ${L}`);if(C)fr(r,C,h.path,L);else Er(m,h.path,L)}break;default:mt(h.state)}}}};function*um(t){let o=-1,n=t.length,r=0,m=0,f=!1;for(let E=0;E<n;E++){let G=t[E];if(G==='"'&&!(r||m))if(f)yield t.substring(o,E+1),o=-1,f=!1;else f=!0;else if(G===" "||G==="\t"){if(!(r||m||f)&&o>=0)yield t.substring(o,E),o=-1}else if(G==="{"||G==="}"){if(o>=0)yield t.substring(o,E);yield G,o=-1}else if(G==="(")r++;else if(G===")"){if(--r<0)_(`invalid nesting in line: '${t}'`)}else if(G==="["){if(o<0)o=E;m++}else if(G==="]"){if(--m<0)_(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=E}if(f)_("string literals must be fully on a single line");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 Mt=":",nr="///",Wt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),tr=(t)=>{let o=!t.curr.sel.length;if(Vt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=wt(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Wt(t.curr))}else t.scopes.push(t.curr=Wt(t.root))},Fm=(t)=>t.map((o)=>o.sel.join(",")).join(nr),rr=(t,o)=>Object.entries(t).map(([n,r])=>wm(n,r,o)),wm=(t,o,n)=>{let r=[],m=r,f=t.split(nr);for(let E=0;E<f.length;E++){let G=f[E].split(",");if(E==f.length-1){let N=Object.assign({},...A((O)=>Or(O)?Mm(O):Gr(O)?Hm(O):Nr(O)?Im(n,O):ro(n.classes[O]),o));G.push(N)}m.push(G),m=G}return r[0]},mr=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(Mt);if(n<0)return{token:t};let r=t.indexOf("("),m=t.indexOf("[");if(r>0||m>0){let G=r>0?m>0?Math.min(r,m):r:m;if(G<n&&t.indexOf(Mt)>G)return{token:t};n=t.substring(0,G).lastIndexOf(Mt)}let f=t.substring(0,n);if(!f.split(Mt).every((G)=>o.has(G)))_(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:f}},Sm=(t,o)=>o.split(Mt).reduce((n,r)=>Object.assign(n,t[r]),{}),fr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},Er=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Hm=(t)=>{let o=t.indexOf("="),n=t.substring(0,o),r=t.substring(o+1);return{[`--${n}`]:r[0]==='"'?r.slice(1,-1):r}},Im=(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),T(N))N=Uo(N,...m);E[G]=N}return E},{})},Mm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},Gr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),Nr=(t)=>t.includes("(")&&t.endsWith(")"),Or=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Cr={deg:Jn,em:Hn,ex:In,ms:Dn,percent:So,px:yn,rad:jn,rem:Mn,second:zn,turn:Xn,url:Pn,vh:Wn,vmax:Yn,vmin:Un,vw:Rn,"%":So},ym={percent:"{0}%",second:"{0}s",url:"url({0})"},Wm={"":[""],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:[""]},Lr={desc:"Generate framework rules from specs",opts:{...p,...oo,...Q,...At},fn:Jo};async function Jo(t){if(t.opts.watch)await Rm(t);else await _r(t.inputs.map((o)=>w(o,t.logger)),t.opts,t.logger)}var Rm=async(t)=>{It(t.inputs,t.logger).subscribe({next(o){try{_r(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},_r=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Sn(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{Br(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 k(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Br=(t,o,n,r,m=!1)=>{let f=i(o.vars)?o.vars:[""],E=T(o.props)?{[o.props]:"<v>"}:o.props,G=Ym(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||Wm[O];if(!h)_(`unknown variation ID: ${O}`);for(let[L,C]of lt(h,Object.keys(G))){let B=c(o.name,O,L,C,G[C]),y=o.unit?c(o.unit,O,L,C,G[C]):void 0,v=m?zm(y):Dm(G[C],y);if(!n[B]){if(n[B]={},o.user!=null)n[B].__user=o.user;if(o.doc!=null)n[B].__doc=Jm(o.doc,O,L,C,v)}else if(!N.has(B))_(`duplicate class ID: ${B}`);N.add(B);let $=-1;for(let[l,I]of Object.entries(E)){let b=c(l,O,L,C,G[C]),mo=c(!y||T(I)?String(I):Cr[y](I),O,L,C,v);if(n[B][b]=mo,r.debug(B,b,mo),m)$=hr(mo,hr(b,$))}if(m)n[B].__arity=$+1}}return n},Um=(t,o,n,r)=>Br(t,{...o,values:[""]},n,r,!0),hr=(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(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},{})},Dm=(t,o)=>{if(!o||T(t))return t;let n=Cr[o];if(!n)_(`invalid unit: ${o}`);return n(t)},zm=(t)=>t?ym[t]||"{0}"+t:"{0}",c=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Jm=({group:t,desc:o,args:n},r,m,f,E)=>({group:t?c(t,r,m,f,E):"TODO",desc:o?c(o,r,m,f,E):void 0,args:n?n.map((G)=>c(G,r,m,f,E)):void 0});var $r={desc:"Combination of the generate & convert commands",opts:{...st,...ct,...to,...Lt,..._t,...Bt,...oo,...Q,...$t,...At,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 Jo(f),await zo(E)}};import{resolve as jm}from"path";var er={desc:"Generate Markdown documentation for framework specs",opts:{...p,level:Dt({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=P(jm(r[0]),o),f=Xm(m,n);k(n.out,f,o)}},Xm=(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}):`,"",`${tt(o+1)} Classes by category`,"",...Tr(t.classes,bm,o+2),`${tt(o+1)} Templates by category`,"",...Tr(t.templates,Zm,o+2),`${tt(o+1)} Media queries`,"",...Object.entries(t.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")f.unshift(`${tt(o)} ${n??t.info.name}
|
|
33
|
+
`);return f},Ar=(t)=>t.split(/(\d+)/).map((o)=>{let n=parseInt(o);return isNaN(n)?o:n}),Pm=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){let n=Ar(t),r=Ar(o),m=n.length;if(m===r.length){for(let f=0;f<m;f++)if(n[f]!==r[f])return eo(n[f],r[f]);return 0}return n.length-r.length}return eo(t,o)},Tr=(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 Io((m)=>{let f=r[m].sort(Pm).map((G)=>o(G,t[G].__doc,n+1)),E=f.length;return[`${tt(n)} ${jt(m)}`,E>3?`
|
|
34
|
+
<details><summary>${E} items:</summary>
|
|
36
35
|
`:"",f.join(`
|
|
37
|
-
`),
|
|
38
|
-
`:""]},Object.keys(r).sort())},
|
|
36
|
+
`),E>3?`</details>
|
|
37
|
+
`:""]},Object.keys(r).sort())},bm=(t,o)=>{if(!o?.desc)return`- \`${t}\``;let n=o.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${t}\` (${n})`},Zm=(t,o,n)=>{if(!o?.args)return`${tt(n)} ${t}(...)
|
|
39
38
|
|
|
40
|
-
TODO`;let r=o.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${tt(n)} \`${t}(${r})\``,"",...o.args.map(
|
|
39
|
+
TODO`;let r=o.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${tt(n)} \`${t}(${r})\``,"",...o.args.map(Km),o.desc?`
|
|
41
40
|
${o.desc}
|
|
42
41
|
`:""].join(`
|
|
43
|
-
`)},
|
|
42
|
+
`)},Km=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,tt=R((t)=>"#".repeat(t));import{resolve as ir}from"path";var Fr={desc:"Export entire generated framework as CSS",opts:{...Lt,..._t,...an,...p,...Q,...Bt,...xn,...$t},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,L={format:N?kt:ft,fns:xt,scope:O},C=P(ir(h[0]),o),B=n?n.map((y)=>w(ir(y),o).trim()):[];if(!f)B.push(no(C));if(!m&&C.decls.length)B.push(x(C.decls,L));if(!E)B.push(Vm(C,r,L,o));k(G,B,o)}},Vm=(t,o,n,r)=>{let m=ur("",t);if(o){let f=o[0]==="ALL"?Object.keys(t.media):o;for(let E of f)if(t.media[E])m.push(Ct(t.media[E],ur("-"+E,t)));else r.warn(`invalid media query ID: ${E}, skipping...`)}return x(m,n)},ur=(t,o)=>Object.entries(o.classes).map(([n,r])=>[`.${n}${t}`,ro(r)]);var jo=P(qm(process.argv[2],"package.json"));nn({name:"metacss",start:3,opts:{verbose:W({alias:"v",desc:"Display extra process information"})},commands:{convert:or,develop:$r,doc:er,export:Fr,generate:Lr},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=e.DEBUG;return{...t,format:it}},usage:{prefix:`${rn(jo.name,jo.version,jo.description)}
|
|
44
43
|
|
|
45
44
|
Usage: metacss <cmd> [opts] input [...]
|
|
46
45
|
metacss <cmd> --help
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/meta-css",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@thi.ng/api": "^8.11.29",
|
|
48
|
-
"@thi.ng/args": "^2.
|
|
48
|
+
"@thi.ng/args": "^2.6.1",
|
|
49
49
|
"@thi.ng/arrays": "^2.13.1",
|
|
50
50
|
"@thi.ng/checks": "^3.7.9",
|
|
51
51
|
"@thi.ng/compare": "^2.4.21",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@thi.ng/hiccup-css": "^2.7.52",
|
|
55
55
|
"@thi.ng/logger": "^3.1.10",
|
|
56
56
|
"@thi.ng/memoize": "^4.0.19",
|
|
57
|
-
"@thi.ng/rstream": "^9.2.
|
|
57
|
+
"@thi.ng/rstream": "^9.2.25",
|
|
58
58
|
"@thi.ng/strings": "^3.9.15",
|
|
59
59
|
"@thi.ng/text-format": "^2.2.34",
|
|
60
60
|
"@thi.ng/transducers": "^9.4.3"
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"status": "alpha",
|
|
114
114
|
"year": 2023
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "eb3ac07d044559d88b4871fed080929556de1b7c\n"
|
|
117
117
|
}
|