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